本文整理汇总了Java中org.apache.harmony.javax.security.sasl.SaslException类的典型用法代码示例。如果您正苦于以下问题:Java SaslException类的具体用法?Java SaslException怎么用?Java SaslException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SaslException类属于org.apache.harmony.javax.security.sasl包,在下文中一共展示了SaslException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createSaslClient
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
@Override
public SaslClient createSaslClient(String[] mechanisms,
String authorizationId, String protocol, String serverName,
Map<String, ?> props, CallbackHandler cbh) throws SaslException {
for (String mech: mechanisms) {
if ("PLAIN".equals(mech)) {
return new PlainSaslClient(authorizationId, cbh);
} else
if ("DIGEST-MD5".equals(mech)) {
return DigestMD5SaslClient.getClient(
authorizationId,
protocol,
serverName,
props,
cbh
);
}
}
return null;
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:21,代码来源:SaslClientFactory.java
示例2: createSaslClient
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
public SaslClient createSaslClient(String[] mechanisms, String authorizationId, String protocol,
String serverName, Map<String, ?> props, CallbackHandler cbh)
throws SaslException
{
for (int i = 0; i < mechanisms.length; i++)
{
if (mechanisms[i].equals(MECHANISM))
{
if (cbh == null)
{
throw new SaslException("CallbackHandler must not be null");
}
String[] mechs = {"CRAM-MD5"};
return Sasl.createSaslClient(mechs, authorizationId, protocol, serverName, props, cbh);
}
}
return null;
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:20,代码来源:CRAMMD5HashedSaslClientFactory.java
示例3: DigestChallenge
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
DigestChallenge(
byte[] challenge)
throws SaslException
{
m_realms = new ArrayList(5);
m_nonce = null;
m_qop = 0;
m_staleFlag = false;
m_maxBuf = -1;
m_characterSet = null;
m_algorithm = null;
m_cipherOptions = 0;
DirectiveList dirList = new DirectiveList(challenge);
try
{
dirList.parseDirectives();
checkSemantics(dirList);
}
catch (SaslException e)
{
}
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:24,代码来源:DigestChallenge.java
示例4: handleQop
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
/**
* This function implements the semenatics of the qop (quality of protection)
* directive. The value of the qop directive is as defined below:
* qop-options = "qop" "=" <"> qop-list <">
* qop-list = 1#qop-value
* qop-value = "auth" | "auth-int" | "auth-conf" | token
*
* @param pd ParsedDirective
*
* @exception SaslException If an error occurs due to too many qop
* directives
*/
void handleQop(
ParsedDirective pd) throws SaslException
{
String token;
TokenParser parser;
if (m_qop != 0)
throw new SaslException("Too many qop directives.");
parser = new TokenParser(pd.getValue());
for (token = parser.parseToken();
token != null;
token = parser.parseToken())
{
if (token.equals("auth"))
m_qop |= QOP_AUTH;
else if (token.equals("auth-int"))
m_qop |= QOP_AUTH_INT;
else if (token.equals("auth-conf"))
m_qop |= QOP_AUTH_CONF;
else
m_qop |= QOP_UNRECOGNIZED;
}
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:37,代码来源:DigestChallenge.java
示例5: checkServerResponseAuth
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
/**
* This function validates the server response. This step performs a
* modicum of mutual authentication by verifying that the server knows
* the user's password
*
* @param serverResponse Response recived form Server
*
* @return true if the mutual authentication succeeds;
* else return false
*
* @exception SaslException If an error occurs
*/
boolean checkServerResponseAuth(
byte[] serverResponse) throws SaslException
{
char[] response;
ResponseAuth responseAuth = null;
String responseStr;
responseAuth = new ResponseAuth(serverResponse);
response = DigestCalcResponse(m_HA1,
m_dc.getNonce(),
"00000001",
m_clientNonce,
m_qopValue,
DIGEST_METHOD,
m_digestURI,
false);
responseStr = new String(response);
return responseStr.equals(responseAuth.getResponseValue());
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:35,代码来源:DigestMD5SaslClient.java
示例6: ResponseAuth
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
ResponseAuth(
byte[] responseAuth)
throws SaslException
{
m_responseValue = null;
DirectiveList dirList = new DirectiveList(responseAuth);
try
{
dirList.parseDirectives();
checkSemantics(dirList);
}
catch (SaslException e)
{
}
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:17,代码来源:ResponseAuth.java
示例7: checkSemantics
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
/**
* Checks the semantics of the directives in the directive list as parsed
* from the digest challenge byte array.
*
* @param dirList the list of directives parsed from the digest challenge
*
* @exception SaslException If a semantic error occurs
*/
void checkSemantics(
DirectiveList dirList) throws SaslException
{
Iterator directives = dirList.getIterator();
ParsedDirective directive;
String name;
while (directives.hasNext())
{
directive = (ParsedDirective)directives.next();
name = directive.getName();
if (name.equals("rspauth"))
m_responseValue = directive.getValue();
}
/* post semantic check */
if (m_responseValue == null)
throw new SaslException("Missing response-auth directive.");
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:28,代码来源:ResponseAuth.java
示例8: createSaslClient
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
public static SaslClient createSaslClient(String[] mechanisms,
String authanticationID, String protocol, String serverName,
Map<String, ?> prop, CallbackHandler cbh) throws SaslException {
if (mechanisms == null) {
throw new NullPointerException("auth.33"); //$NON-NLS-1$
}
SaslClientFactory fact = getSaslClientFactories().nextElement();
String[] mech = fact.getMechanismNames(null);
boolean is = false;
if (mech != null) {
for (int j = 0; j < mech.length; j++) {
for (int n = 0; n < mechanisms.length; n++) {
if (mech[j].equals(mechanisms[n])) {
is = true;
break;
}
}
}
}
if (is) {
return fact.createSaslClient(mechanisms, authanticationID,
protocol, serverName, prop, cbh);
}
return null;
}
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:26,代码来源:Sasl.java
示例9: createSaslClient
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
public SaslClient createSaslClient(String[] mechanisms,
String authorizationId, String protocol, String serverName,
Map<String, ?> props, CallbackHandler cbh) throws SaslException {
for (int i = 0; i < mechanisms.length; i++) {
if (mechanisms[i].equals(MECHANISM)) {
if (cbh == null) {
throw new SaslException("CallbackHandler must not be null");
}
String[] mechs = { "CRAM-MD5" };
return Sasl.createSaslClient(mechs, authorizationId, protocol,
serverName, props, cbh);
}
}
return null;
}
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:17,代码来源:CRAMMD5HashedSaslClientFactory.java
示例10: getClientNonce
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
/**
* Calculates the Nonce value of the Client.
*
* @return Nonce value of the client
*
* @exception SaslException If an error Occurs
*/
private String getClientNonce() throws SaslException {
byte[] nonceBytes = new byte[NONCE_BYTE_COUNT];
SecureRandom prng;
char[] hexNonce = new char[NONCE_HEX_COUNT];
try {
prng = SecureRandom.getInstance("SHA1PRNG");
prng.nextBytes(nonceBytes);
for (int i = 0; i < NONCE_BYTE_COUNT; i++) {
final int val = nonceBytes[i] & 0xff;
//low nibble
hexNonce[i * 2] = hexChars[val / 0x10];
//high nibble
hexNonce[(i * 2) + 1] = hexChars[val % 0x10];
}
return new String(hexNonce);
} catch (NoSuchAlgorithmException e) {
throw new SaslException("No random number generator available", e);
}
}
开发者ID:BoogieMAN2K,项目名称:Beem,代码行数:28,代码来源:ScramSaslClient.java
示例11: createSaslClient
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
public static SaslClient createSaslClient(String[] mechanisms, String authanticationID,
String protocol, String serverName, Map<String, ?> prop, CallbackHandler cbh)
throws SaslException {
if (mechanisms == null) {
throw new NullPointerException("auth.33"); //$NON-NLS-1$
}
SaslClientFactory fact = getSaslClientFactories().nextElement();
String[] mech = fact.getMechanismNames(null);
boolean is = false;
if (mech != null) {
for (int j = 0; j < mech.length; j++) {
for (int n = 0; n < mechanisms.length; n++) {
if (mech[j].equals(mechanisms[n])) {
is = true;
break;
}
}
}
}
if (is) {
return fact.createSaslClient(
mechanisms,
authanticationID,
protocol,
serverName,
prop,
cbh
);
}
return null;
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:32,代码来源:Sasl.java
示例12: authenticate
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
protected void authenticate() throws IOException, XMPPException {
String authenticationText = null;
try {
if(sc.hasInitialResponse()) {
byte[] response = sc.evaluateChallenge(new byte[0]);
authenticationText = Base64.encodeBytes(response,Base64.DONT_BREAK_LINES);
}
} catch (SaslException e) {
throw new XMPPException("SASL authentication failed", e);
}
// Send the authentication to the server
getSASLAuthentication().send(new AuthMechanism(getName(), authenticationText));
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:15,代码来源:SASLMechanism.java
示例13: PlainSaslClient
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
public PlainSaslClient(String authorizationID, CallbackHandler cbh) throws SaslException
{
completed = false;
this.cbh = cbh;
Object[] userInfo = getUserInfo();
this.authorizationID = authorizationID;
this.authenticationID = (String) userInfo[0];
this.password = (byte[]) userInfo[1];
if (authenticationID == null || password == null)
{
throw new SaslException("PLAIN: authenticationID and password must be specified");
}
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:14,代码来源:PlainSaslClient.java
示例14: evaluateChallenge
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
public byte[] evaluateChallenge(byte[] challenge) throws SaslException
{
if (completed)
{
throw new IllegalStateException("PLAIN: authentication already " +
"completed");
}
completed = true;
try
{
byte authzid[] =
authorizationID == null ? null : authorizationID.getBytes("UTF8");
byte authnid[] = authenticationID.getBytes("UTF8");
byte response[] =
new byte[
password.length +
authnid.length +
2 + // SEPARATOR
(authzid != null ? authzid.length : 0)
];
int size = 0;
if (authzid != null) {
System.arraycopy(authzid, 0, response, 0, authzid.length);
size = authzid.length;
}
response[size++] = SEPARATOR;
System.arraycopy(authnid, 0, response, size, authnid.length);
size += authnid.length;
response[size++] = SEPARATOR;
System.arraycopy(password, 0, response, size, password.length);
clearPassword();
return response;
} catch (UnsupportedEncodingException e) {
throw new SaslException("PLAIN: Cannot get UTF-8 encoding of ids",
e);
}
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:38,代码来源:PlainSaslClient.java
示例15: unwrap
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
public byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException
{
if (completed) {
throw new IllegalStateException("PLAIN: this mechanism supports " +
"neither integrity nor privacy");
} else {
throw new IllegalStateException("PLAIN: authentication not " +
"completed");
}
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:11,代码来源:PlainSaslClient.java
示例16: wrap
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
public byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException
{
if (completed)
{
throw new IllegalStateException("PLAIN: this mechanism supports " +
"neither integrity nor privacy");
}
else
{
throw new IllegalStateException("PLAIN: authentication not " +
"completed");
}
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:14,代码来源:PlainSaslClient.java
示例17: createSaslClient
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
public SaslClient createSaslClient(String[] mechs, String authorizationId, String protocol,
String serverName, Map props, CallbackHandler cbh)
throws SaslException
{
for (int i = 0; i < mechs.length; i++)
{
if (mechs[i].equals("PLAIN"))
{
return new PlainSaslClient(authorizationId, cbh);
}
}
return null;
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:14,代码来源:ClientSaslFactory.java
示例18: handleNonce
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
/**
* This function implements the semenatics of the nonce directive.
*
* @param pd ParsedDirective
*
* @exception SaslException If an error occurs due to too many nonce
* values
*/
void handleNonce(
ParsedDirective pd) throws SaslException
{
if (null != m_nonce)
throw new SaslException("Too many nonce values.");
m_nonce = pd.getValue();
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:17,代码来源:DigestChallenge.java
示例19: handleMaxbuf
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
/**
* This function implements the semenatics of the Maxbuf directive.
* the value is defined as: 1*DIGIT
*
* @param pd ParsedDirective
*
* @exception SaslException If an error occur
*/
void handleMaxbuf(
ParsedDirective pd) throws SaslException
{
if (-1 != m_maxBuf) /*it's initialized to -1 */
throw new SaslException("Too many maxBuf directives.");
m_maxBuf = Integer.parseInt(pd.getValue());
if (0 == m_maxBuf)
throw new SaslException("Max buf value must be greater than zero.");
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:20,代码来源:DigestChallenge.java
示例20: handleCharset
import org.apache.harmony.javax.security.sasl.SaslException; //导入依赖的package包/类
/**
* This function implements the semenatics of the charset directive.
* the value is defined as: 1*DIGIT
*
* @param pd ParsedDirective
*
* @exception SaslException If an error occurs dur to too many charset
* directives or Invalid character encoding
* directive
*/
void handleCharset(
ParsedDirective pd) throws SaslException
{
if (null != m_characterSet)
throw new SaslException("Too many charset directives.");
m_characterSet = pd.getValue();
if (!m_characterSet.equals("utf-8"))
throw new SaslException("Invalid character encoding directive");
}
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:22,代码来源:DigestChallenge.java
注:本文中的org.apache.harmony.javax.security.sasl.SaslException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论