public final class ScramClient extends Object implements SaslClient
| Modifier and Type | Field and Description |
|---|---|
protected CallbackHandler |
callbackHandler |
protected String |
channelBinding |
protected String |
clientFirstMessageBare |
protected boolean |
isComplete |
protected String |
nonce |
protected String |
serverFirstMessage |
| Constructor and Description |
|---|
ScramClient(String hashAlgorithm,
String authorizationId,
CallbackHandler callbackHandler) |
| Modifier and Type | Method and Description |
|---|---|
String |
computeAuthMessage()
Computes the auth message.
|
byte[] |
computeClientKey(byte[] saltedPassword)
Computes the client key.
|
byte[] |
computeClientSignature(byte[] clientKey,
String authMessage)
Computes the client signature.
|
byte[] |
computeSaltedPassword(char[] password,
byte[] salt,
int iterationCount)
Computes the salted password.
|
byte[] |
computeStoredKey(byte[] clientKey)
Computes the stored key.
|
static String |
createClientFirstMessageBare(String username,
String nonce)
Creates the client-first-message-bare.
|
void |
dispose() |
byte[] |
evaluateChallenge(byte[] challenge) |
static String |
generateNonce()
Generates a nonce.
|
static Map<Character,String> |
getAttributes(String str)
Gets the attributes from a SCRAM string.
|
String |
getMechanismName()
Gets the mechanism name, i.e "SCRAM-" + the hash algorithm name.
|
Object |
getNegotiatedProperty(String propName) |
byte[] |
h(byte[] str)
Apply the cryptographic hash function to the octet string
"str", producing an octet string as a result.
|
boolean |
hasInitialResponse() |
byte[] |
hi(byte[] str,
byte[] salt,
int i)
Calculates the salted password.
|
byte[] |
hmac(byte[] key,
byte[] str)
Apply the HMAC keyed hash algorithm (defined in
[RFC2104]) using the octet string represented by "key" as the key
and the octet string "str" as the input string.
|
boolean |
isComplete() |
byte[] |
unwrap(byte[] incoming,
int offset,
int len) |
byte[] |
wrap(byte[] outgoing,
int offset,
int len) |
static byte[] |
xor(byte[] a,
byte[] b)
Apply the exclusive-or operation to combine the octet string
on the left of this operator with the octet string on the right of
this operator.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetMechanismNameprotected final CallbackHandler callbackHandler
protected boolean isComplete
protected String clientFirstMessageBare
protected String serverFirstMessage
protected String nonce
protected String channelBinding
public ScramClient(String hashAlgorithm, String authorizationId, CallbackHandler callbackHandler) throws SaslException
SaslExceptionpublic boolean hasInitialResponse()
hasInitialResponse in interface SaslClientpublic byte[] evaluateChallenge(byte[] challenge)
throws SaslException
evaluateChallenge in interface SaslClientSaslExceptionpublic boolean isComplete()
isComplete in interface SaslClientpublic byte[] unwrap(byte[] incoming,
int offset,
int len)
throws SaslException
unwrap in interface SaslClientSaslExceptionpublic byte[] wrap(byte[] outgoing,
int offset,
int len)
throws SaslException
wrap in interface SaslClientSaslExceptionpublic Object getNegotiatedProperty(String propName)
getNegotiatedProperty in interface SaslClientpublic void dispose()
throws SaslException
dispose in interface SaslClientSaslExceptionpublic static byte[] xor(byte[] a,
byte[] b)
a - The first byte array.b - The second byte array.public static String generateNonce() throws NoSuchAlgorithmException
NoSuchAlgorithmException - If the generation algorithm does not exist.public static Map<Character,String> getAttributes(String str)
str - The string.public static String createClientFirstMessageBare(String username, String nonce)
username - The user name.nonce - The nonce.public byte[] computeClientSignature(byte[] clientKey,
String authMessage)
throws InvalidKeyException,
NoSuchAlgorithmException
clientKey - The client key.authMessage - The auth message.InvalidKeyException - If the key is invalid.NoSuchAlgorithmException - If the mac algorithm does not exist.public String computeAuthMessage()
public byte[] computeSaltedPassword(char[] password,
byte[] salt,
int iterationCount)
throws InvalidKeyException,
NoSuchAlgorithmException
password - The password.salt - The salt.iterationCount - The iteration count.InvalidKeyException - If the key is invalid.NoSuchAlgorithmException - If the hash algorithm does not exist.public byte[] computeClientKey(byte[] saltedPassword)
throws InvalidKeyException,
NoSuchAlgorithmException
saltedPassword - The salted password.InvalidKeyException - If the key is invalid.NoSuchAlgorithmException - If the mac algorithm does not exist.public byte[] computeStoredKey(byte[] clientKey)
throws NoSuchAlgorithmException
clientKey - The client key.NoSuchAlgorithmException - If the hash algorithm does not exist.public byte[] h(byte[] str)
throws NoSuchAlgorithmException
str - The byte array.NoSuchAlgorithmException - If the hash algorithm does not exist.public byte[] hmac(byte[] key,
byte[] str)
throws NoSuchAlgorithmException,
InvalidKeyException
key - The key.str - The input.NoSuchAlgorithmException - If the MAC algorithm does not exist.InvalidKeyException - If the key does not exist.public byte[] hi(byte[] str,
byte[] salt,
int i)
throws NoSuchAlgorithmException,
InvalidKeyException
str - The input.salt - The salt.i - The iteration count.InvalidKeyException - If the key is invalid.NoSuchAlgorithmException - If the mac algorithm does not exist.public String getMechanismName()
Copyright © 2014 XMPP.rocks. All rights reserved.