Package com.esri.arcgisruntime.security
Class UserCredential
- java.lang.Object
-
- com.esri.arcgisruntime.security.Credential
-
- com.esri.arcgisruntime.security.UserCredential
-
- All Implemented Interfaces:
TokenCredential
public final class UserCredential extends Credential implements TokenCredential
Represents a named user credential. User credentials will be used to authenticate against HTTP-secured services, and to generate tokens for authenticating token-secured services.- Since:
- 100.0.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.esri.arcgisruntime.security.Credential
Credential.CredentialChangedEvent, Credential.CredentialChangedListener
-
-
Constructor Summary
Constructors Constructor Description UserCredential(String username, String password)
Constructs a UserCredential with the specified username and password.UserCredential(String username, String password, String referer)
Constructs a UserCredential with the specified username, password, and referer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description UserCredential
copy()
Creates a deep copy of this UserCredential instance.static UserCredential
createFromToken(String token, String referer)
Creates a UserCredential with the specified token and referer.boolean
equals(Object o)
Compares this instance with the specified object and indicates if they are equal.String
getPassword()
Gets the password to use for authenticating with this credential.String
getReferer()
Gets the referer of this credential, that is the entity that is using the credential to authenticate.int
hashCode()
Returns an integer hash code for this object.void
setPassword(String password)
Sets the password to use for authenticating with this credential.void
setReferer(String referer)
Sets the referer of this credential, that is the entity that is using the credential to authenticate.void
setUsername(String username)
Sets the username of the credential.-
Methods inherited from class com.esri.arcgisruntime.security.Credential
addCredentialChangedListener, fromJson, getUsername, removeCredentialChangedListener, toJson
-
-
-
-
Constructor Detail
-
UserCredential
public UserCredential(String username, String password)
Constructs a UserCredential with the specified username and password. The username and password will be used for authenticating against services.- Parameters:
username
- the user name of the userpassword
- the password of the user- Throws:
IllegalArgumentException
- if the username or password is null or empty- Since:
- 100.0.0
-
UserCredential
public UserCredential(String username, String password, String referer)
Constructs a UserCredential with the specified username, password, and referer. The username and password will be used for authenticating against services, while the referer indicates the entity on behalf of which authentication is requested.- Parameters:
username
- the user name of the userpassword
- the password of the userreferer
- the referer- Throws:
IllegalArgumentException
- if the username or password is null or empty- Since:
- 100.0.0
-
-
Method Detail
-
createFromToken
public static UserCredential createFromToken(String token, String referer)
Creates a UserCredential with the specified token and referer. The token will be used for authenticating against services, while the referer indicates the entity on behalf of which authentication is requested.- Parameters:
token
- the token with which to authenticatereferer
- the referer- Throws:
IllegalArgumentException
- if the token is null or emptyIllegalArgumentException
- if the referer is null or empty- Since:
- 100.1.0
-
setUsername
public void setUsername(String username)
Sets the username of the credential.- Parameters:
username
- the username to set- Throws:
IllegalArgumentException
- if username is null or empty- Since:
- 100.0.0
-
getPassword
public String getPassword()
Gets the password to use for authenticating with this credential.- Returns:
- the password
- Since:
- 100.0.0
-
setPassword
public void setPassword(String password)
Sets the password to use for authenticating with this credential.- Parameters:
password
- the password to set- Throws:
IllegalArgumentException
- if password is null or empty- Since:
- 100.0.0
-
getReferer
public String getReferer()
Gets the referer of this credential, that is the entity that is using the credential to authenticate.- Returns:
- the referer
- Since:
- 100.0.0
-
setReferer
public void setReferer(String referer)
Sets the referer of this credential, that is the entity that is using the credential to authenticate.- Parameters:
referer
- the referer to set- Since:
- 100.0.0
-
equals
public boolean equals(Object o)
Compares this instance with the specified object and indicates if they are equal. In order to be equal,o
must represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.- Overrides:
equals
in classObject
- Parameters:
o
- the object to compare this instance with.- Returns:
true
if the specified object is equal to thisObject
;false
otherwise.- See Also:
hashCode()
-
hashCode
public int hashCode()
Returns an integer hash code for this object.- Overrides:
hashCode
in classObject
- Returns:
- this object's hash code.
- See Also:
equals(java.lang.Object)
-
copy
public UserCredential copy()
Creates a deep copy of this UserCredential instance.- Specified by:
copy
in classCredential
- Returns:
- a deep copy of this UserCredential instance
- Since:
- 100.1.0
-
-