com.esri.core.io
Class UserCredentials

java.lang.Object
  extended by com.esri.core.io.UserCredentials
All Implemented Interfaces:
Serializable

public class UserCredentials
extends Object
implements Serializable

This class represents user credential for accessing secure ArcGIS Services and Tasks. A user's credential is either composed of a user account (username,password) or a secure token.

Since:
1.0
See Also:
Serialized Form

Nested Class Summary
static class UserCredentials.AuthenticationType
          The supported authentication type.
 
Constructor Summary
UserCredentials()
          Constructs an instance of UserCredentials.
UserCredentials(UserCredentials other)
          Instantiates a copy of the given credential.
 
Method Summary
 boolean equals(Object obj)
           
 UserCredentials.AuthenticationType getAuthenticationType()
          Gets the type of the UserCredentials.
 UserCredentials getCopy()
          Returns a copy of the instance.
 String getPassword()
          Returns the password that this instance was initialized with.
 String getReferer()
          Returns the referer that was supplied with the token string.
 String getToken()
          Returns the token that this instance was initialized with.
 long getTokenExpiry()
           
 String getTokenServiceUrl()
          Returns the remote token service url that this instance was initialized with.
static KeyStore getTrustStore()
          Deprecated.  
 String getUserName()
          Returns the user name that this instance was initialized with.
 int hashCode()
           
 boolean isEmpty()
          Returns true if the credentials is empty or lack of enough information.
 boolean isSSLRequired()
          Returns whether or not the service should only be connected to with SSL encryption (usually https).
 void setAuthenticationType(UserCredentials.AuthenticationType type)
          Sets the type of the UserCredentials.
 void setSSLRequired(boolean required)
          Sets whether or not the service should only be connected to with SSL encryption (usually https).
 void setTokenServiceUrl(String tokenServiceUrl)
          Sets the URL to a remote token service if it is different from the default ArcGIS token service.
static void setTrustStore(KeyStore keyStore)
          Sets a KeyStore that contains trusted self-signed certificates for accessing HTTPS GIS service endpoints in an application.
static void setTrustStore(KeyStore clientCA, String password, KeyStore trustCA)
          Sets KeyStores which contain server and client certificates for accessing HTTPS GIS service endpoints in an application.
 void setUserAccount(String userName, String password)
          Sets the user account for accessing a secure Service or Task in an application.
 void setUserToken(String token, long tokenExpiry, String referer)
          Sets the user token for accessing a secure Service or Task in an application.
 void setUserToken(String token, String referer)
          Sets the user token for accessing a secure Service or Task in an application.
 UserCredentials.AuthenticationType verifyAuthenticationType()
          Looks up the authentication type based on the information available.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserCredentials

public UserCredentials()
Constructs an instance of UserCredentials.

Since:
1.0

UserCredentials

public UserCredentials(UserCredentials other)
Instantiates a copy of the given credential.

Parameters:
other - the instance to copy.
Since:
1.0
Method Detail

getCopy

public UserCredentials getCopy()
Returns a copy of the instance.

Returns:
a copy.
Since:
1.0

setTrustStore

public static void setTrustStore(KeyStore keyStore)
                          throws EsriSecurityException
Sets a KeyStore that contains trusted self-signed certificates for accessing HTTPS GIS service endpoints in an application.

Parameters:
keyStore - the KeyStore of CAs to trust.
Throws:
EsriSecurityException - the esri security exception KeyStore.
Since:
1.0

setTrustStore

public static void setTrustStore(KeyStore clientCA,
                                 String password,
                                 KeyStore trustCA)
                          throws EsriSecurityException
Sets KeyStores which contain server and client certificates for accessing HTTPS GIS service endpoints in an application.

Parameters:
trustCA - the KeyStore of server CAs to trust.
clientCA - the KeyStore of the client certificates.
password - the password to access the client certificates.
Throws:
EsriSecurityException - the ESRI security exception KeyStore.
Since:
1.0

getTrustStore

@Deprecated
public static KeyStore getTrustStore()
Deprecated. 

Returns the KeyStore that contains trusted self-signed certificates for accesing HTTPS GIS service and Task service endpoints in an application.

Returns:
the KeyStore
Since:
1.0

setUserAccount

public void setUserAccount(String userName,
                           String password)
Sets the user account for accessing a secure Service or Task in an application.

Parameters:
userName - the username
password - the password
Since:
1.0

setUserToken

public void setUserToken(String token,
                         String referer)
Sets the user token for accessing a secure Service or Task in an application. The token is a secure token generated by an ArcGIS Token service or a Remote token service. Tokens are generated either by sending an HTTP URL request to a Token service end-point or through an HTML page. Regardless of which option is chosen, it is always necessary for a clientid paramter to be specified as a parameter for generating a secure token. The clientid is typically the identity of the client application consuming the secure service. For Android/Java applications, the clientid would be the referer string that is either the name of the application consuming the secure service or any other client identification string that is appropriate for the application. It is required that the referer string that was used to generate the token be supplied to this method. For documentation on how to generate tokens please refer to the following resource:
Tokens and token services

Parameters:
token - the secure token string
referer - the referer string
Since:
1.0

setUserToken

public void setUserToken(String token,
                         long tokenExpiry,
                         String referer)
Sets the user token for accessing a secure Service or Task in an application. The token is a secure token generated by an ArcGIS Token service or a Remote token service. Tokens are generated either by sending an HTTP URL request to a Token service end-point or through an HTML page. Regardless of which option is chosen, it is always necessary for a clientid paramter to be specified as a parameter for generating a secure token. The clientid is typically the identity of the client application consuming the secure service. For Android/Java applications, the clientid would be the referer string that is either the name of the application consuming the secure service or any other client identification string that is appropriate for the application. It is required that the referer string that was used to generate the token be supplied to this method. For documentation on how to generate tokens please refer to the following resource:
Tokens and token services

Parameters:
token - the secure token string
tokenExpiry - expiry date of token
referer - the referer string
Since:
1.0

setTokenServiceUrl

public void setTokenServiceUrl(String tokenServiceUrl)
Sets the URL to a remote token service if it is different from the default ArcGIS token service. If the application invoking this API is an Android application which along with the token service is part of the same LAN, then the hostname in the URL must be fully qualified to avoid DNS name resolution problems in Android.

Parameters:
tokenServiceUrl - a URL to a remote token service
Since:
1.0

getToken

public String getToken()
Returns the token that this instance was initialized with.

Returns:
the token
Since:
1.0

getTokenExpiry

public long getTokenExpiry()
Returns:
the token expiration.
Since:
10.1.1

getReferer

public String getReferer()
Returns the referer that was supplied with the token string.

Returns:
the referer
Since:
1.0

getTokenServiceUrl

public String getTokenServiceUrl()
Returns the remote token service url that this instance was initialized with.

Returns:
the remote token service url
Since:
1.0

getUserName

public String getUserName()
Returns the user name that this instance was initialized with.

Returns:
the user name
Since:
1.0

getPassword

public String getPassword()
Returns the password that this instance was initialized with.

Returns:
the password
Since:
1.0

isSSLRequired

public boolean isSSLRequired()
Returns whether or not the service should only be connected to with SSL encryption (usually https).

Returns:
Returns returns true if using SSL.
Since:
1.0

setSSLRequired

public void setSSLRequired(boolean required)
Sets whether or not the service should only be connected to with SSL encryption (usually https).

Parameters:
required - set to ture to use SSL.
Since:
1.0

getAuthenticationType

public UserCredentials.AuthenticationType getAuthenticationType()
Gets the type of the UserCredentials.

Returns:
Returns the _type.
Since:
1.0
See Also:
verifyAuthenticationType()

setAuthenticationType

public void setAuthenticationType(UserCredentials.AuthenticationType type)
Sets the type of the UserCredentials.

Parameters:
type - The type to set.
Since:
1.0

verifyAuthenticationType

public UserCredentials.AuthenticationType verifyAuthenticationType()
Looks up the authentication type based on the information available. If the credentials contains either the token or the token service URL, the Credentials will be treated as Token based credentials, otherwise it is a http based credentials if the Username and password are available. The AuthenticationType.None will be set if none information is available;

Returns:
the authentication type
Since:
1.0

isEmpty

public boolean isEmpty()
Returns true if the credentials is empty or lack of enough information.

Returns:
true if the credentials is empty or lack of enough information.
Since:
1.0

hashCode

public int hashCode()
Overrides:
hashCode in class Object
Since:
1.0

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
Since:
1.0


Copyright © 2012. All Rights Reserved.