Class CredentialMap
- java.lang.Object
-
- nl.esciencecenter.xenon.credentials.CredentialMap
-
- All Implemented Interfaces:
Credential
public class CredentialMap extends java.lang.Object implements Credential
ACredential
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 byget
if a key is not found.
-
-
Constructor Summary
Constructors Constructor Description CredentialMap()
Create a new CredentialMap usingnull
as the default credential.CredentialMap(UserCredential defaultCredential)
Creates a newCredentialMap
and set the default credential todefaultCredential
.
-
Method Summary
Modifier and Type Method Description boolean
containsCredential(java.lang.String key)
Check if thekey
is stored in this CredentialMap.boolean
equals(java.lang.Object obj)
UserCredential
get(java.lang.String key)
Retrieve theUserCredential
stored using thekey
.UserCredential
getDefault()
Returns the defaultUserCredential
.int
hashCode()
java.util.Set<java.lang.String>
keySet()
Returns aSet
view of the keys contained in this map.UserCredential
put(java.lang.String key, UserCredential credential)
Add aCredential
to the CredentialMap usingkey
as a unique key.
-
-
-
Constructor Detail
-
CredentialMap
public CredentialMap()
Create a new CredentialMap usingnull
as the default credential.
-
CredentialMap
public CredentialMap(UserCredential defaultCredential)
Creates a newCredentialMap
and set the default credential todefaultCredential
.- Parameters:
defaultCredential
- the default credential to return byget
if a key is not found.
-
-
Method Detail
-
put
public UserCredential put(java.lang.String key, UserCredential credential)
Add aCredential
to the CredentialMap usingkey
as a unique key. If thekey
already exists in the CredentialMap, the storedUserCredential
will be replaced bycredential
.- Parameters:
key
- the unique key used to store the credential.credential
- the UserCredential to store.- Returns:
- the
UserCredential
previously stored using thekey
ornull
if the key was not used before.
-
containsCredential
public boolean containsCredential(java.lang.String key)
Check if thekey
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 theUserCredential
stored using thekey
. If the key is not found in the map, the default credential is returned (if provided when the CredentialMap was created) ornull
if no default is set.- Parameters:
key
- the key of theUserCredential
to retrieve.- Returns:
- the
UserCredential
stored usingkey
or the default credential if the key is not found.
-
keySet
public java.util.Set<java.lang.String> keySet()
Returns aSet
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 defaultUserCredential
.- Returns:
- the default credential to return by
get
if a key is not found.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-