Class CredentialMap

  • All Implemented Interfaces:
    Credential

    public class CredentialMap
    extends java.lang.Object
    implements Credential
    A Credential consisting of a collection of Credentials each uniquely identified by a String (typically a host name or host alias). A default Credential can be set that will be returned if by get if a key is not found.
    • Constructor Detail

      • CredentialMap

        public CredentialMap()
        Create a new CredentialMap using null as the default credential.
      • CredentialMap

        public CredentialMap​(UserCredential defaultCredential)
        Creates a new CredentialMap and set the default credential to defaultCredential.
        Parameters:
        defaultCredential - the default credential to return by get if a key is not found.
    • Method Detail

      • put

        public UserCredential put​(java.lang.String key,
                                  UserCredential credential)
        Add a Credential to the CredentialMap using key as a unique key. If the key already exists in the CredentialMap, the stored UserCredential will be replaced by credential.
        Parameters:
        key - the unique key used to store the credential.
        credential - the UserCredential to store.
        Returns:
        the UserCredential previously stored using the key or null if the key was not used before.
      • containsCredential

        public boolean containsCredential​(java.lang.String key)
        Check if the key is stored in this CredentialMap.
        Parameters:
        key - the key to check.
        Returns:
        if key is stored in this CredentialMap
      • get

        public UserCredential get​(java.lang.String key)
        Retrieve the UserCredential stored using the key. If the key is not found in the map, the default credential is returned (if provided when the CredentialMap was created) or null if no default is set.
        Parameters:
        key - the key of the UserCredential to retrieve.
        Returns:
        the UserCredential stored using key or the default credential if the key is not found.
      • keySet

        public java.util.Set<java.lang.String> keySet()
        Returns a Set view of the keys contained in this map.
        Returns:
        a set view of the keys contained in this map
      • getDefault

        public UserCredential getDefault()
        Returns the default UserCredential.
        Returns:
        the default credential to return by get if a key is not found.
      • hashCode

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

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