Class ScramSha256SaslServer

java.lang.Object
org.jivesoftware.openfire.sasl.ScramSaslServer
org.jivesoftware.openfire.sasl.ScramSha256SaslServer
All Implemented Interfaces:
SaslServer

public class ScramSha256SaslServer extends ScramSaslServer
Implements the SCRAM-SHA-256 (and its channel binding -PLUS variant) server-side mechanism. The SCRAM exchange itself is implemented by the hash-agnostic ScramSaslServer superclass. This class binds that exchange to the SHA-256 hash function. As described in ScramSaslServer, instances are session-specific and must not be reused across sessions or users. In particular, the instance must retain the mechanism availability for its session when processing GS2 channel-binding negotiation.
Author:
Guus der Kinderen
  • Field Details

    • MECHANISM_NAME

      public static final String MECHANISM_NAME
      The IANA-registered name of the base (non-PLUS) mechanism implemented by this server.
      See Also:
    • HMAC_ALGORITHM_NAME

      public static final String HMAC_ALGORITHM_NAME
      The JCA name of the HMAC algorithm that corresponds to this mechanism's hash function
      See Also:
    • DIGEST_ALGORITHM_NAME

      public static final String DIGEST_ALGORITHM_NAME
      The JCA name of the message digest that corresponds to this mechanism's hash function.
      See Also:
    • ITERATION_COUNT

      public static final SystemProperty<Integer> ITERATION_COUNT
  • Constructor Details

    • ScramSha256SaslServer

      public ScramSha256SaslServer(boolean isPlusMechanism, Map<String,?> props, @Nonnull Set<String> availableMechanismsForSession)
      Creates a new, client-specific, instance.
      Parameters:
      isPlusMechanism - Denotes if this instance supports channel-binding (true) or not (false).
      props - The possibly null set of properties used to select the SASL mechanism and to configure the authentication exchange of the selected mechanism.
      availableMechanismsForSession - The names of SASL mechanisms that are available to this particular session (as opposed to the set of globally available mechanism names).
  • Method Details

    • getServerSecretForNonExistentUsers

      public static String getServerSecretForNonExistentUsers()
      Retrieves a server-side secret used when handling authentication attempts for non-existing users in SCRAM-SHA-256 (-PLUS). This method ensures that the one-time initialization that is required for usage will occur. Instead of failing immediately, the server derives deterministic, fake SCRAM credentials (such as stored keys, server keys, and where applicable salt values) based on this secret. This ensures that authentication processing for non-existing users is indistinguishable from that of existing users. This mechanism helps protect against user enumeration attacks by preventing observable differences in behavior between existing and non-existing accounts. Changing (rotating) this value will cause different derived values to be generated for non-existing users. This does not affect authentication of existing users but can invalidate consistency of ongoing or repeated authentication attempts for non-existing users.
      See Also:
    • getMechanismBaseName

      protected String getMechanismBaseName()
      Description copied from class: ScramSaslServer
      The IANA-registered name of the base (non-PLUS) mechanism implemented by this server, for example SCRAM-SHA-1. This value is also the key under which SCRAM credentials for this mechanism are stored: the -PLUS variant shares the credential of the base mechanism.
      Specified by:
      getMechanismBaseName in class ScramSaslServer
      Returns:
      A non-null string representing the IANA-registered (base) mechanism name.
    • getHmacAlgorithmName

      protected String getHmacAlgorithmName()
      Description copied from class: ScramSaslServer
      The JCA name of the HMAC algorithm that corresponds to this mechanism's hash function, for example HmacSHA1.
      Specified by:
      getHmacAlgorithmName in class ScramSaslServer
      Returns:
      the HMAC algorithm name.
    • getDigestAlgorithmName

      protected String getDigestAlgorithmName()
      Description copied from class: ScramSaslServer
      The JCA name of the message digest that corresponds to this mechanism's hash function, for example SHA-1. Used to compute H(ClientKey) when verifying the client proof.
      Specified by:
      getDigestAlgorithmName in class ScramSaslServer
      Returns:
      the message digest algorithm name.
    • getDefaultIterationCount

      protected int getDefaultIterationCount()
      Description copied from class: ScramSaslServer
      The iteration count to advertise when no per-user value is available.
      Specified by:
      getDefaultIterationCount in class ScramSaslServer
      Returns:
      the default iteration count for this mechanism.
    • getNonExistentUserSecret

      protected String getNonExistentUserSecret()
      Description copied from class: ScramSaslServer
      A server-side secret from which deterministic fake credentials are derived for non-existent users, so that authentication processing for non-existing users is indistinguishable from that of existing users.
      Specified by:
      getNonExistentUserSecret in class ScramSaslServer
      Returns:
      the server secret for this mechanism.
      See Also: