Class SecretAuthentication

  • All Implemented Interfaces:
    Authentication

    final class SecretAuthentication
    extends java.lang.Object
    implements Authentication
    Authentication block that manages a single authentication key and its secret string value (password, passphrase). Unlike StringAuthentication, the string value is kept in an encrypted buffer and only decrypted when needed to reduce the potential of leaking the secret in a heap dump.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String key  
      private static java.lang.Object[] KEYS  
      private int secretHash  
      private char[] value  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private SecretAuthentication​(char[] value, java.lang.String key)  
      (package private) SecretAuthentication​(java.lang.String key, char[] value)  
      (package private) SecretAuthentication​(java.lang.String key, java.lang.String value)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static void clear​(char[] chars)  
      private static char[] copy​(char[] chars)  
      void digest​(AuthenticationDigest digest)
      Updates the given digest with data from this authentication callback.
      boolean equals​(java.lang.Object obj)  
      void fill​(AuthenticationContext context, java.lang.String key, java.util.Map<java.lang.String,​java.lang.String> data)
      Fills the given authentication context with the data from this authentication callback.
      int hashCode()  
      java.lang.String toString()  
      private char[] xor​(char[] chars)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • KEYS

        private static final java.lang.Object[] KEYS
      • key

        private final java.lang.String key
      • value

        private final char[] value
      • secretHash

        private final int secretHash
    • Constructor Detail

      • SecretAuthentication

        SecretAuthentication​(java.lang.String key,
                             java.lang.String value)
      • SecretAuthentication

        SecretAuthentication​(java.lang.String key,
                             char[] value)
      • SecretAuthentication

        private SecretAuthentication​(char[] value,
                                     java.lang.String key)
    • Method Detail

      • copy

        private static char[] copy​(char[] chars)
      • xor

        private char[] xor​(char[] chars)
      • clear

        private static void clear​(char[] chars)
      • fill

        public void fill​(AuthenticationContext context,
                         java.lang.String key,
                         java.util.Map<java.lang.String,​java.lang.String> data)
        Description copied from interface: Authentication
        Fills the given authentication context with the data from this authentication callback. To do so, implementors have to call AuthenticationContext.put(String, Object).

        The key parameter supplied to this method acts merely as a hint for interactive callbacks that want to prompt the user for only that authentication data which is required. Implementations are free to ignore this parameter and put all the data they have into the authentication context at once.
        Specified by:
        fill in interface Authentication
        Parameters:
        context - The authentication context to populate, must not be null.
        key - The key denoting a specific piece of authentication data that is being requested for a network operation, may be null.
        data - Any (read-only) extra data in form of key value pairs that might be useful when getting the authentication data, may be null.
      • digest

        public void digest​(AuthenticationDigest digest)
        Description copied from interface: Authentication
        Updates the given digest with data from this authentication callback. To do so, implementors have to call the update() methods in AuthenticationDigest.
        Specified by:
        digest in interface Authentication
        Parameters:
        digest - The digest to update, must not be null.
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object