Class CredentialMap
- java.lang.Object
-
- nl.esciencecenter.xenon.credentials.CredentialMap
-
- All Implemented Interfaces:
Credential
public class CredentialMap extends java.lang.Object implements Credential
ACredentialconsisting 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 bygetif a key is not found.
-
-
Constructor Summary
Constructors Constructor Description CredentialMap()Create a new CredentialMap usingnullas the default credential.CredentialMap(UserCredential defaultCredential)Creates a newCredentialMapand set the default credential todefaultCredential.
-
Method Summary
Modifier and Type Method Description booleancontainsCredential(java.lang.String key)Check if thekeyis stored in this CredentialMap.booleanequals(java.lang.Object obj)UserCredentialget(java.lang.String key)Retrieve theUserCredentialstored using thekey.UserCredentialgetDefault()Returns the defaultUserCredential.inthashCode()java.util.Set<java.lang.String>keySet()Returns aSetview of the keys contained in this map.UserCredentialput(java.lang.String key, UserCredential credential)Add aCredentialto the CredentialMap usingkeyas a unique key.
-
-
-
Constructor Detail
-
CredentialMap
public CredentialMap()
Create a new CredentialMap usingnullas the default credential.
-
CredentialMap
public CredentialMap(UserCredential defaultCredential)
Creates a newCredentialMapand set the default credential todefaultCredential.- Parameters:
defaultCredential- the default credential to return bygetif a key is not found.
-
-
Method Detail
-
put
public UserCredential put(java.lang.String key, UserCredential credential)
Add aCredentialto the CredentialMap usingkeyas a unique key. If thekeyalready exists in the CredentialMap, the storedUserCredentialwill be replaced bycredential.- Parameters:
key- the unique key used to store the credential.credential- the UserCredential to store.- Returns:
- the
UserCredentialpreviously stored using thekeyornullif the key was not used before.
-
containsCredential
public boolean containsCredential(java.lang.String key)
Check if thekeyis stored in this CredentialMap.- Parameters:
key- the key to check.- Returns:
- if
keyis stored in this CredentialMap
-
get
public UserCredential get(java.lang.String key)
Retrieve theUserCredentialstored using thekey. If the key is not found in the map, the default credential is returned (if provided when the CredentialMap was created) ornullif no default is set.- Parameters:
key- the key of theUserCredentialto retrieve.- Returns:
- the
UserCredentialstored usingkeyor the default credential if the key is not found.
-
keySet
public java.util.Set<java.lang.String> keySet()
Returns aSetview of the keys contained in this map.- Returns:
- a set view of the keys contained in this map
-
getDefault
public UserCredential getDefault()
Returns the defaultUserCredential.- Returns:
- the default credential to return by
getif a key is not found.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-