Class NonceManager


  • public class NonceManager
    extends Object
    A utility responsible for managing nonces.
    Author:
    Darran Lofthouse
    • Constructor Detail

      • NonceManager

        @Deprecated
        NonceManager​(long validityPeriod,
                     long nonceSessionTime,
                     boolean singleUse,
                     int keySize,
                     String algorithm)
        Deprecated.
        Parameters:
        validityPeriod - the time in ms that nonces are valid for in ms.
        nonceSessionTime - the time in ms a nonce is usable for after it's last use where nonce counts are in use.
        singleUse - are nonces single use?
        keySize - the number of bytes to use in the private key of this node.
        algorithm - the message digest algorithm to use when creating the digest portion of the nonce.
      • NonceManager

        NonceManager​(long validityPeriod,
                     long nonceSessionTime,
                     boolean singleUse,
                     int keySize,
                     String algorithm,
                     ElytronMessages log)
        Parameters:
        validityPeriod - the time in ms that nonces are valid for in ms.
        nonceSessionTime - the time in ms a nonce is usable for after it's last use where nonce counts are in use.
        singleUse - are nonces single use?
        keySize - the number of bytes to use in the private key of this node.
        algorithm - the message digest algorithm to use when creating the digest portion of the nonce.
        log - mechanism specific logger.
      • NonceManager

        NonceManager​(long validityPeriod,
                     long nonceSessionTime,
                     boolean singleUse,
                     int keySize,
                     String algorithm,
                     ElytronMessages log,
                     ScheduledExecutorService customExecutor)
        Parameters:
        validityPeriod - the time in ms that nonces are valid for in ms.
        nonceSessionTime - the time in ms a nonce is usable for after it's last use where nonce counts are in use.
        singleUse - are nonces single use?
        keySize - the number of bytes to use in the private key of this node.
        algorithm - the message digest algorithm to use when creating the digest portion of the nonce.
        log - mechanism specific logger.
        customExecutor - a custom ScheduledExecutorService to be used
    • Method Detail

      • generateNonce

        String generateNonce()
        Generate a new encoded nonce to send to the client.
        Returns:
        a new encoded nonce to send to the client.
      • generateNonce

        String generateNonce​(byte[] salt)
        Generate a new encoded nonce to send to the client.
        Parameters:
        salt - additional data to use when creating the overall signature for the nonce.
        Returns:
        a new encoded nonce to send to the client.
      • useNonce

        boolean useNonce​(String nonce,
                         int nonceCount)
                  throws AuthenticationMechanismException
        Attempt to use the supplied nonce. A nonce might not be usable for a couple of different reasons: -
        • It was created too far in the past.
        • Validation of the signature fails.
        • The nonce has been used previously and re-use is disabled.
        Parameters:
        nonce - the nonce supplied by the client.
        nonceCount - the nonce count, or -1 if not present
        Returns:
        true if the nonce can be used, false otherwise.
        Throws:
        AuthenticationMechanismException
      • useNonce

        boolean useNonce​(String nonce,
                         byte[] salt,
                         int nonceCount)
                  throws AuthenticationMechanismException
        Attempt to use the supplied nonce. A nonce might not be usable for a couple of different reasons: -
        • It was created too far in the past.
        • Validation of the signature fails.
        • The nonce has been used previously and re-use is disabled.
        Parameters:
        nonce - the nonce supplied by the client.
        salt - additional data to use when creating the overall signature for the nonce.
        Returns:
        true if the nonce can be used, false otherwise.
        Throws:
        AuthenticationMechanismException
      • shutdown

        public void shutdown()