Package rocks.xmpp.core.sasl.scram
Class ScramBase
- java.lang.Object
-
- rocks.xmpp.core.sasl.scram.ScramBase
-
- Direct Known Subclasses:
ScramClient
public abstract class ScramBase extends Object
A base SCRAM implementation.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]computeClientKey(byte[] saltedPassword)Computes the client key.byte[]computeSaltedPassword(char[] password, byte[] salt, int iterationCount)Computes the salted password.byte[]computeServerKey(byte[] saltedPassword)Computes the server key.byte[]computeStoredKey(byte[] clientKey)Computes the stored key.voiddispose()StringgetMechanismName()Gets the mechanism name, i.e "SCRAM-" + the hash algorithm name.ObjectgetNegotiatedProperty(String propName)booleanisComplete()StringtoString()byte[]unwrap(byte[] incoming, int offset, int len)byte[]wrap(byte[] outgoing, int offset, int len)
-
-
-
Method Detail
-
computeSaltedPassword
public final byte[] computeSaltedPassword(char[] password, byte[] salt, int iterationCount) throws InvalidKeyException, NoSuchAlgorithmExceptionComputes the salted password.- Parameters:
password- The password.salt- The salt.iterationCount- The iteration count.- Returns:
- The salted password.
- Throws:
InvalidKeyException- If the key is invalid.NoSuchAlgorithmException- If the hash algorithm does not exist.
-
computeClientKey
public final byte[] computeClientKey(byte[] saltedPassword) throws InvalidKeyException, NoSuchAlgorithmExceptionComputes the client key.- Parameters:
saltedPassword- The salted password.- Returns:
- The client key.
- Throws:
InvalidKeyException- If the key is invalid.NoSuchAlgorithmException- If the mac algorithm does not exist.
-
computeStoredKey
public final byte[] computeStoredKey(byte[] clientKey) throws NoSuchAlgorithmExceptionComputes the stored key.- Parameters:
clientKey- The client key.- Returns:
- The stored key.
- Throws:
NoSuchAlgorithmException- If the hash algorithm does not exist.
-
computeServerKey
public final byte[] computeServerKey(byte[] saltedPassword) throws InvalidKeyException, NoSuchAlgorithmExceptionComputes the server key.- Parameters:
saltedPassword- The salted password.- Returns:
- The stored key.
- Throws:
InvalidKeyException- If the provided password is invalid.NoSuchAlgorithmException- If the hash algorithm does not exist.
-
getMechanismName
public final String getMechanismName()
Gets the mechanism name, i.e "SCRAM-" + the hash algorithm name.- Returns:
- The mechanism name.
-
isComplete
public final boolean isComplete()
-
unwrap
public final byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException- Throws:
SaslException
-
wrap
public final byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException- Throws:
SaslException
-
dispose
public final void dispose()
-
-