Package org.wildfly.security.sasl.otp
Class OTPSaslClient
- java.lang.Object
- 
- org.wildfly.security.sasl.util.AbstractSaslParticipant
- 
- org.wildfly.security.sasl.util.AbstractSaslClient
- 
- org.wildfly.security.sasl.otp.OTPSaslClient
 
 
 
- 
- All Implemented Interfaces:
- SaslClient,- SaslWrapper
 
 final class OTPSaslClient extends AbstractSaslClient SaslClient for the OTP SASL mechanism as defined by RFC 2444.- Author:
- Farah Juma
 
- 
- 
Field SummaryFields Modifier and Type Field Description private String[]alternateDictionaryprivate NameCallbacknameCallbackprivate Supplier<Provider[]>providersprivate SecureRandomsecureRandomprivate static intST_CHALLENGE_RESPONSEprivate static intST_NEWprivate StringuserName- 
Fields inherited from class org.wildfly.security.sasl.util.AbstractSaslParticipantCOMPLETE_STATE, FAILED_STATE, NO_BYTES
 - 
Fields inherited from interface org.wildfly.security.sasl.util.SaslWrapperIDENTITY
 
- 
 - 
Constructor SummaryConstructors Constructor Description OTPSaslClient(String mechanismName, SecureRandom secureRandom, String[] alternateDictionary, String protocol, String serverName, CallbackHandler callbackHandler, String authorizationId, Supplier<Provider[]> providers)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description private org.wildfly.common.bytes.ByteStringBuildercreateInitResponse(String newAlgorithm, String newSeed, int newSequenceNumber, String newOTP)Create an init response, excluding the response type specifier and current OTP, where: init-hex response = init-hex:<current-OTP>:<new-params>:<new-OTP> init-word response = init-word:<current-OTP>:<new-params>:<new-OTP> new-params = <algorithm identifier> <sequence integer>private byte[]createOTPResponse(String algorithm, String seed, String otp, String responseType)Create an OTP response using the extended response syntax, where: hex response = hex:word response = word: init-hex response = init-hex:<current-OTP><new-params>:<new-OTP> init-word response = init-word:<current-OTP><new-params>:<new-OTP> new-params = <algorithm identifier> <sequence integer> <seed> voiddispose()Dispose of this participant.protected byte[]evaluateMessage(int state, byte[] challenge)private byte[]generateOtpHash(String algorithm, String passPhrase, String seed, int newSequenceNumber)private StringgetOTP(PasswordCallback passwordCallback)private StringgetPasswordFromPasswordChars(char[] passwordChars)voidinit()- 
Methods inherited from class org.wildfly.security.sasl.util.AbstractSaslClientevaluateChallenge, getAuthorizationId, hasInitialResponse
 - 
Methods inherited from class org.wildfly.security.sasl.util.AbstractSaslParticipantassertComplete, evaluateMessage, getCallbackHandler, getIntProperty, getMechanismName, getNegotiatedProperty, getProtocol, getServerName, getStringProperty, getWrapper, handleCallbacks, isComplete, negotiationComplete, setNegotiationState, setWrapper, tryHandleCallbacks, unwrap, wrap
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface javax.security.sasl.SaslClientgetMechanismName, getNegotiatedProperty, isComplete, unwrap, wrap
 
- 
 
- 
- 
- 
Field Detail- 
ST_NEWprivate static final int ST_NEW - See Also:
- Constant Field Values
 
 - 
ST_CHALLENGE_RESPONSEprivate static final int ST_CHALLENGE_RESPONSE - See Also:
- Constant Field Values
 
 - 
secureRandomprivate final SecureRandom secureRandom 
 - 
alternateDictionaryprivate final String[] alternateDictionary 
 - 
nameCallbackprivate NameCallback nameCallback 
 - 
userNameprivate String userName 
 
- 
 - 
Constructor Detail- 
OTPSaslClientOTPSaslClient(String mechanismName, SecureRandom secureRandom, String[] alternateDictionary, String protocol, String serverName, CallbackHandler callbackHandler, String authorizationId, Supplier<Provider[]> providers) 
 
- 
 - 
Method Detail- 
initpublic void init() - Overrides:
- initin class- AbstractSaslParticipant
 
 - 
evaluateMessageprotected byte[] evaluateMessage(int state, byte[] challenge) throws SaslException- Specified by:
- evaluateMessagein class- AbstractSaslParticipant
- Throws:
- SaslException
 
 - 
disposepublic void dispose() throws SaslExceptionDescription copied from class:AbstractSaslParticipantDispose of this participant.- Specified by:
- disposein interface- SaslClient
- Overrides:
- disposein class- AbstractSaslParticipant
- Throws:
- SaslException- if disposal failed
 
 - 
createOTPResponseprivate byte[] createOTPResponse(String algorithm, String seed, String otp, String responseType) throws SaslException Create an OTP response using the extended response syntax, where: hex response = hex:word response = word: init-hex response = init-hex:<current-OTP><new-params>:<new-OTP> init-word response = init-word:<current-OTP><new-params>:<new-OTP> new-params = <algorithm identifier> <sequence integer> <seed> - Parameters:
- algorithm- the OTP algorithm, must be either "otp-md5" or "otp-sha1"
- seed- the seed
- otp- the OTP as a string in either hex or multi-word format
- responseType- the response type, must be "hex", "word", "init-hex", or "init-word"
- Returns:
- the OTP response
- Throws:
- SaslException- if the given response type is invalid or if an error occurs while creating the response
 
 - 
createInitResponseprivate org.wildfly.common.bytes.ByteStringBuilder createInitResponse(String newAlgorithm, String newSeed, int newSequenceNumber, String newOTP) throws SaslException Create an init response, excluding the response type specifier and current OTP, where: init-hex response = init-hex:<current-OTP>:<new-params>:<new-OTP> init-word response = init-word:<current-OTP>:<new-params>:<new-OTP> new-params = <algorithm identifier> <sequence integer>- Parameters:
- newAlgorithm- the new OTP algorithm, must be either "otp-md5" or "otp-sha1"
- newSeed- the new seed
- newSequenceNumber- the new sequence number
- newOTP- the new OTP as a string in either hex or multi-word format
- Returns:
- the init response, excluding the response type specifier and current OTP
- Throws:
- SaslException- if the given OTP algorithm is invalid
 
 - 
getOTPprivate String getOTP(PasswordCallback passwordCallback) throws SaslException - Throws:
- SaslException
 
 - 
getPasswordFromPasswordCharsprivate String getPasswordFromPasswordChars(char[] passwordChars) 
 - 
generateOtpHashprivate byte[] generateOtpHash(String algorithm, String passPhrase, String seed, int newSequenceNumber) throws NoSuchAlgorithmException, InvalidKeySpecException 
 
- 
 
-