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 class
AbstractDigestMechanism.DigestWrapper
static class
AbstractDigestMechanism.FORMAT
-
Field Summary
Fields Modifier and Type Field Description protected String
authorizationId
protected Charset
charset
protected String
cipher
static String[]
CIPHER_OPTS
private static String
CLIENT_MAGIC_CONFIDENTIALITY
private static String
CLIENT_MAGIC_INTEGRITY
protected byte[]
cnonce
static int
DEFAULT_MAXBUF
static char
DELIMITER
protected MessageDigest
digest
protected String
digestURI
private AbstractDigestMechanism.FORMAT
format
protected byte[]
hA1
protected Mac
hmacMD5
protected MessageDigest
messageDigest
protected byte[]
nonce
private static int
NONCE_SIZE
private Supplier<Provider[]>
providers
protected String
qop
protected String
realm
protected SecureRandom
secureRandomGenerator
private static String
SERVER_MAGIC_CONFIDENTIALITY
private static String
SERVER_MAGIC_INTEGRITY
protected Cipher
unwrapCipher
protected byte[]
unwrapHmacKeyIntegrity
protected int
unwrapSeqNum
protected String
username
protected Cipher
wrapCipher
protected byte[]
wrapHmacKeyIntegrity
protected int
wrapSeqNum
-
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 boolean
arrayContains(String[] array, String searched)
protected Cipher
createCipher(boolean wrap)
protected void
createCiphersAndKeys()
protected byte[]
createIntegrityKey(boolean wrap)
(package private) static byte[]
generateNonce()
Charset
getCharset()
private int
gethA1PrefixLength(String cipher)
private Mac
getHmac()
(package private) static String
getSupportedCiphers(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
-
-