Package org.wildfly.security.sasl.digest
Class AbstractDigestMechanism
- java.lang.Object
-
- org.wildfly.security.sasl.util.AbstractSaslParticipant
-
- org.wildfly.security.sasl.digest.AbstractDigestMechanism
-
- All Implemented Interfaces:
SaslWrapper
- Direct Known Subclasses:
DigestSaslClient,DigestSaslServer
abstract class AbstractDigestMechanism extends AbstractSaslParticipant
- Author:
- Peter Skopek
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractDigestMechanism.DigestWrapperstatic classAbstractDigestMechanism.FORMAT
-
Field Summary
Fields Modifier and Type Field Description protected StringauthorizationIdprotected Charsetcharsetprotected Stringcipherstatic String[]CIPHER_OPTSprivate static StringCLIENT_MAGIC_CONFIDENTIALITYprivate static StringCLIENT_MAGIC_INTEGRITYprotected byte[]cnoncestatic intDEFAULT_MAXBUFstatic charDELIMITERprotected MessageDigestdigestprotected StringdigestURIprivate AbstractDigestMechanism.FORMATformatprotected byte[]hA1protected MachmacMD5protected MessageDigestmessageDigestprotected byte[]nonceprivate static intNONCE_SIZEprivate Supplier<Provider[]>providersprotected Stringqopprotected Stringrealmprotected SecureRandomsecureRandomGeneratorprivate static StringSERVER_MAGIC_CONFIDENTIALITYprivate static StringSERVER_MAGIC_INTEGRITYprotected CipherunwrapCipherprotected byte[]unwrapHmacKeyIntegrityprotected intunwrapSeqNumprotected Stringusernameprotected CipherwrapCipherprotected byte[]wrapHmacKeyIntegrityprotected intwrapSeqNum-
Fields inherited from class org.wildfly.security.sasl.util.AbstractSaslParticipant
COMPLETE_STATE, FAILED_STATE, NO_BYTES
-
Fields inherited from interface org.wildfly.security.sasl.util.SaslWrapper
IDENTITY
-
-
Constructor Summary
Constructors Constructor Description AbstractDigestMechanism(String mechanismName, String protocol, String serverName, CallbackHandler callbackHandler, AbstractDigestMechanism.FORMAT format, Charset charset, String[] ciphers, Supplier<Provider[]> providers)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanarrayContains(String[] array, String searched)protected CiphercreateCipher(boolean wrap)protected voidcreateCiphersAndKeys()protected byte[]createIntegrityKey(boolean wrap)(package private) static byte[]generateNonce()CharsetgetCharset()private intgethA1PrefixLength(String cipher)private MacgetHmac()(package private) static StringgetSupportedCiphers(String[] demandedCiphers)Get supported ciphers as comma separated list of cipher-opts by Digest MD5 spec.(package private) byte[]handleUserRealmPasswordCallbacks(String[] realms, boolean readOnlyRealmUsername, boolean skipRealmCallbacks)private byte[]unwrapConfidentialityProtectedMessage(byte[] message, int offset, int len)private byte[]unwrapIntegrityProtectedMessage(byte[] message, int offset, int len)private byte[]wrapConfidentialityProtectedMessage(byte[] message, int offset, int len)private byte[]wrapIntegrityProtectedMessage(byte[] message, int offset, int len)-
Methods inherited from class org.wildfly.security.sasl.util.AbstractSaslParticipant
assertComplete, dispose, evaluateMessage, evaluateMessage, getCallbackHandler, getIntProperty, getMechanismName, getNegotiatedProperty, getProtocol, getServerName, getStringProperty, getWrapper, handleCallbacks, init, isComplete, negotiationComplete, setNegotiationState, setWrapper, tryHandleCallbacks, unwrap, wrap
-
-
-
-
Field Detail
-
NONCE_SIZE
private static int NONCE_SIZE
-
DEFAULT_MAXBUF
public static final int DEFAULT_MAXBUF
- See Also:
- Constant Field Values
-
DELIMITER
public static final char DELIMITER
- See Also:
- Constant Field Values
-
CIPHER_OPTS
public static final String[] CIPHER_OPTS
-
format
private AbstractDigestMechanism.FORMAT format
-
digestURI
protected final String digestURI
-
charset
protected Charset charset
-
digest
protected MessageDigest digest
-
cipher
protected String cipher
-
qop
protected String qop
-
wrapSeqNum
protected int wrapSeqNum
-
unwrapSeqNum
protected int unwrapSeqNum
-
nonce
protected byte[] nonce
-
cnonce
protected byte[] cnonce
-
username
protected String username
-
realm
protected String realm
-
authorizationId
protected String authorizationId
-
hA1
protected byte[] hA1
-
secureRandomGenerator
protected SecureRandom secureRandomGenerator
-
hmacMD5
protected Mac hmacMD5
-
wrapCipher
protected Cipher wrapCipher
-
unwrapCipher
protected Cipher unwrapCipher
-
wrapHmacKeyIntegrity
protected byte[] wrapHmacKeyIntegrity
-
unwrapHmacKeyIntegrity
protected byte[] unwrapHmacKeyIntegrity
-
messageDigest
protected final MessageDigest messageDigest
-
CLIENT_MAGIC_INTEGRITY
private static final String CLIENT_MAGIC_INTEGRITY
- See Also:
- Constant Field Values
-
SERVER_MAGIC_INTEGRITY
private static final String SERVER_MAGIC_INTEGRITY
- See Also:
- Constant Field Values
-
CLIENT_MAGIC_CONFIDENTIALITY
private static final String CLIENT_MAGIC_CONFIDENTIALITY
- See Also:
- Constant Field Values
-
SERVER_MAGIC_CONFIDENTIALITY
private static final String SERVER_MAGIC_CONFIDENTIALITY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractDigestMechanism
public AbstractDigestMechanism(String mechanismName, String protocol, String serverName, CallbackHandler callbackHandler, AbstractDigestMechanism.FORMAT format, Charset charset, String[] ciphers, Supplier<Provider[]> providers) throws SaslException
- Parameters:
mechanismName-protocol-serverName-callbackHandler-- Throws:
SaslException
-
-
Method Detail
-
getSupportedCiphers
static String getSupportedCiphers(String[] demandedCiphers)
Get supported ciphers as comma separated list of cipher-opts by Digest MD5 spec.- Returns:
- comma separated list of ciphers
-
generateNonce
static byte[] generateNonce()
-
getCharset
public Charset getCharset()
-
handleUserRealmPasswordCallbacks
byte[] handleUserRealmPasswordCallbacks(String[] realms, boolean readOnlyRealmUsername, boolean skipRealmCallbacks) throws SaslException
- Throws:
SaslException
-
wrapIntegrityProtectedMessage
private byte[] wrapIntegrityProtectedMessage(byte[] message, int offset, int len) throws SaslException- Throws:
SaslException
-
unwrapIntegrityProtectedMessage
private byte[] unwrapIntegrityProtectedMessage(byte[] message, int offset, int len) throws SaslException- Throws:
SaslException
-
wrapConfidentialityProtectedMessage
private byte[] wrapConfidentialityProtectedMessage(byte[] message, int offset, int len) throws SaslException- Throws:
SaslException
-
unwrapConfidentialityProtectedMessage
private byte[] unwrapConfidentialityProtectedMessage(byte[] message, int offset, int len) throws SaslException- Throws:
SaslException
-
createCiphersAndKeys
protected void createCiphersAndKeys() throws SaslException- Throws:
SaslException
-
createIntegrityKey
protected byte[] createIntegrityKey(boolean wrap)
-
createCipher
protected Cipher createCipher(boolean wrap) throws SaslException
- Throws:
SaslException
-
gethA1PrefixLength
private int gethA1PrefixLength(String cipher)
-
getHmac
private Mac getHmac() throws SaslException
- Throws:
SaslException
-
-