com.sas.services.user
Class UserContext

com.sas.services.user.UserContext
All Implemented Interfaces:
com.sas.metadata.remote.CredentialResolver, UserContextInterface, java.io.Serializable, java.rmi.Remote

public class UserContext
implements UserContextInterface, java.io.Serializable

The UserContext provides handles to the user identities and profile services. It is basically a clearinghouse for any information that applies to a user but is not session oriented. It has a name, a set of identities (credential sets), a handle to the UserProfile, and a list of repositories the user is connected to. It also has a JAAS LoginContext and a callback handler that is used for any authentication operations requested by or for this user.

Since:
1.0
See Also:
Serialized Form

Field Summary
static java.lang.String MIDTIERINTERNAL_DOMAIN
           
 
Fields inherited from interface com.sas.services.user.UserContextInterface
IDPROPAGATION_SSPI, IDPROPAGATION_TRUSTED_PEER, INTERNAL_AUTH_DOMAIN, SHAREDRESOURCEKEY_CLIENT_TOKEN, SHAREDRESOURCEKEY_ENVIRONMENT, SHAREDRESOURCEKEY_SERVICEID
 
Constructor Summary
UserContext()
          Constructs a user context which will be exported as a remote object to the RMI system using the specified client and server socket factories.
UserContext(java.lang.String name)
          Construct a new user context with the user name.
UserContext(javax.security.auth.Subject subject)
          Constructs a user context for the specified subject.
 
Method Summary
 void addException(java.lang.Exception exception)
          Adds an exception.
 void addIdentity(UserIdentityInterface identity)
          Adds a new authentication identity to this user context.
 void addLogChangeListener(LogChangeListener listener)
          Receive a notification when the UserContext's logger is changed.
 void addRepository(java.lang.Object repository)
          Add a repository to this user context.
 void addRepositoryGroup(RepositoryGroup group)
          Add a repository group to this UserContext.
 void addServer(ServerInterface server)
          Add a server to the list that this user is connected to.
 boolean authenticate()
          Authenticate a user based on their current OS identity.
 boolean authenticate(UserIdentityInterface ident, java.util.Map options)
          Authenticates a user identity.
 void clearExceptions()
          Clears the exceptions.
 void destroy()
          Destroy the user context.
 void enableLocalAdminMode(java.lang.String authDomain)
          This sets up a special case where an administrative user with an internal account is used to authenticate a user.
 boolean equals(java.lang.Object o)
          Test against another object for equality.
 java.util.List getActions(java.lang.String appName)
          Get a List of actions associated with an application that this user can perform.
 java.util.List getActions(java.lang.String appName, boolean onlyGrantedActions)
          Get a List of actions associated with an application.
 java.lang.String getAppSource()
          Get the name of the application that initiated the login request for this UserContext.
 RepositoryInterface getAuthRepository()
          Get a handle to the repository the user authenticated against.
 java.lang.String getAuthRepositoryName()
          Get the Information Service configured name of the repository that was used for authentication.
 ServerInterface getAuthServer()
          Get a handle to the metadata server the user authenticated against.
 java.lang.String getAuthServerName()
          Get the definition name of the server the user authenticated against.
 RemoteCallbackHandler getChallengeCallbackHandler()
          Get the object that will handle credential challenge callbacks.
 java.lang.String getClientSource()
          Get the client location idetifier where the login request originated.
 java.lang.String getDescription()
          Get the common description for this user.
 java.lang.Exception[] getExceptions()
          Gets the exceptions.
 java.util.List getGroups()
          Get a List of the groups this user is a member of.
 java.util.List getIdentities()
          Get an Iterator of the identities which exist for this user context.
 java.util.List getIdentitiesByDomain(java.lang.String domain, boolean issueChallenge, java.lang.String challengePrompt)
          This method returns a list of all the credential sets that are available for the requested domain.
 UserIdentityInterface getIdentityByDomain(java.lang.String domain)
          Get an identity by domain.
 UserIdentityInterface getIdentityByDomain(java.lang.String domain, boolean issueChallenge)
          Get an identity by domain.
 UserIdentityInterface getIdentityByDomain(java.lang.String domain, boolean issueChallenge, java.lang.String prompt)
          Gets a user identify by domain.
 java.lang.String getIDPropagation()
          If the UserContext was authenticated using an ID propagation mechanism such as SSPI, the name of the ID propagation mechanism is returned.
static InformationServiceInterface getInformationService()
          Gets a foundation Information Service.
 java.lang.String getKey()
          Get the user key.
 java.util.Locale getLocale()
          Get the locale for this user.
 LoggerInterface getLogger()
          Deprecated. The Logging Service classes have been deprecated. use Log4J directly.
 LoginCallbackHandler getLoginCallback()
          Get the callback handler.
protected  java.lang.String getLoginConfigAppName()
           
 long getLoginTime()
          Get the timestamp when the user was authenticated.
 java.lang.String getName()
          Get the user name.
 IdentityInterface getPerson()
          Return the IdentityInterface object that represents this user.
 java.lang.String getPersonFQID()
          Get the FQID of the authenticated Identity.
 java.util.Set getPrincipals()
          Gets the set of principals.
 java.util.Set getPrivateCredentials()
          Gets the set of private credentials.
 ProfileInterface getProfile()
          Get the User's profile context.
 java.util.Set getPublicCredentials()
          Gets the set of public credentials.
 java.util.List getRepositories()
          Get an iterator of the repositories this user is connected to.
 RepositoryInterface getRepository(java.lang.String name)
          Gets the repository for the specified name.
 RepositoryGroup getRepositoryGroup(java.lang.String name)
          Get a repository group from this UserContext.
 java.lang.String getResolvedUserId()
          Return the metadata server resolved user id.
 java.util.List getRoles()
          Get a List of the roles this user is a member of.
 ServerInterface getServer(java.lang.String name)
          Get a specific named Information Service server from this user.
 java.util.List getServers()
          Get a List of the servers this user is connected to.
 SessionContextInterface getSessionContext()
          Get the session context for this user.
 java.lang.Object getSharedResource(java.lang.String key)
          Get an object from the shared resource map.
 java.lang.String getUniqueId()
          Gets the unique ID associated with this user context.
static UserServiceInterface getUserService()
          Gets a foundation User Service.
static UserServiceInterface getUserService(java.lang.String serviceId)
           
 boolean hasCapability(java.lang.String appName, java.lang.String action)
          Check whether this user has the capability to perform a specific action for a particular application.
 boolean isDestroyed()
          Determines whether or not this user context has been destroyed.
 boolean isInAnyGroup(java.util.List groupList)
          Check whether the user is a member of any of the groups in the list.
 boolean isInAnyRole(java.util.List roleList)
          Check whether the user is a member of any of the roles in the list.
 boolean isInGroup(java.lang.String group)
          Check whether the user is a member of a given group.
 boolean isInRole(java.lang.String role)
          Check whether the user is a member of a given role.
 boolean isInternalUser()
          Return a boolean indicating if this user was created using an internal userid.
 java.lang.Object putSharedResource(java.lang.String key, java.lang.Object value)
          Put an object into the shared resource map.
 void refreshRepositoryData()
          Refresh all of the data that's been retrieved using the Information Service during the life of this UserContext.
 void removeIdentity(UserIdentityInterface identity)
          Remove an identity from the context.
 void removeRepository(java.lang.Object repository)
          Remove a repository from this context.
 void removeRepositoryGroup(RepositoryGroup group)
          Remove a repository group from this UserContext.
 void removeServer(ServerInterface server)
          Remove a server from the list that this user is currently connected to.
 java.util.List requestCredentialList(java.lang.String authDomain, boolean issueChallenge, java.lang.String prompt)
           
 com.sas.metadata.remote.MdCredential requestCredentials(java.lang.String authDomain, boolean issueChallenge, java.lang.String prompt)
           
 void setAppSource(java.lang.String source)
          Set the application source identifier that initiated the logon request for this UserContext.
 void setChallengeCallbackHandler(RemoteCallbackHandler handler)
          Set the object that will be used to handle credential challenge callbacks.
 void setClientSource(java.lang.String source)
          Set the source location identifier for this UserContext.
 void setKey(java.lang.String key)
          Set the user key.
 void setLocale(java.util.Locale locale)
          Set the locale to use for this user session.
 void setName(java.lang.String name)
          Set the user name.
 void setPerson(IdentityInterface identity)
          This method gets called by UserService as part of the UserContext initialization.
 void setSessionContext(SessionContextInterface session)
          Set the session context that this user context will use for logging, etc.
 byte[] toByteArray()
           
 java.lang.String toString()
           
 

Field Detail

MIDTIERINTERNAL_DOMAIN

public static final java.lang.String MIDTIERINTERNAL_DOMAIN
See Also:
Constant Field Values
Constructor Detail

UserContext

public UserContext(javax.security.auth.Subject subject)
            throws java.rmi.RemoteException
Constructs a user context for the specified subject.

Parameters:
subject - User context's subject.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

UserContext

public UserContext()
            throws java.rmi.RemoteException
Constructs a user context which will be exported as a remote object to the RMI system using the specified client and server socket factories.

Throws:
java.rmi.RemoteException - if unable to export a remote object to the RMI system.

UserContext

public UserContext(java.lang.String name)
            throws java.rmi.RemoteException
Construct a new user context with the user name.

Parameters:
name - The name identitfying the user.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.
Method Detail

getInformationService

public static InformationServiceInterface getInformationService()
                                                         throws ServiceException
Gets a foundation Information Service.

Returns:
Information Service.
Throws:
ServiceException - if unable to obtain an information service.

getUserService

public static UserServiceInterface getUserService()
                                           throws ServiceException
Gets a foundation User Service.

Returns:
User Service.
Throws:
ServiceException - if unable to obtain a user service.

getUserService

public static UserServiceInterface getUserService(java.lang.String serviceId)
                                           throws ServiceException
Throws:
ServiceException

destroy

public void destroy()
             throws java.rmi.RemoteException
Destroy the user context. Release all resources in use.

Specified by:
destroy in interface UserContextInterface
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

getName

public java.lang.String getName()
                         throws java.rmi.RemoteException
Get the user name. The name may be set by an application or by a login module, if it can determine it during the authentication process. This should be the name the user is commonly known by.

Specified by:
getName in interface UserContextInterface
Returns:
The user name.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

getPersonFQID

public java.lang.String getPersonFQID()
                               throws java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get the FQID of the authenticated Identity. This may actually be a Person or an IdentityGroup, if group logins are enabled.

Specified by:
getPersonFQID in interface UserContextInterface
Returns:
The FQID of the authenticated user.
Throws:
java.rmi.RemoteException - In the event of remote object failure.

getDescription

public java.lang.String getDescription()
                                throws java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get the common description for this user. This should come from the repository that the user's global profile is defined in. As a fallback, it will get the description from the primary authentication repository (in case they're different).

Specified by:
getDescription in interface UserContextInterface
Returns:
A String with a description of the user.
Throws:
java.rmi.RemoteException - in the event of remote object failure.

getAppSource

public final java.lang.String getAppSource()
                                    throws java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get the name of the application that initiated the login request for this UserContext.

Specified by:
getAppSource in interface UserContextInterface
Returns:
The application source identifier.
Throws:
java.rmi.RemoteException - In the event of remote object failure.

getClientSource

public final java.lang.String getClientSource()
                                       throws java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get the client location idetifier where the login request originated.

Specified by:
getClientSource in interface UserContextInterface
Returns:
The client identifier (usually a TCP/IP address) where the login request originated for this UserContext.
Throws:
java.rmi.RemoteException - In the event of remote object failure.

setAppSource

public void setAppSource(java.lang.String source)
                  throws java.rmi.RemoteException
Description copied from interface: UserContextInterface
Set the application source identifier that initiated the logon request for this UserContext.

Specified by:
setAppSource in interface UserContextInterface
Parameters:
source - The application source that requested the creation of the UserContext. This is usualy either the main Java class name, or an identifiable application name.
Throws:
java.rmi.RemoteException - In the event of remote object failure.

setClientSource

public void setClientSource(java.lang.String source)
                     throws java.rmi.RemoteException
Description copied from interface: UserContextInterface
Set the source location identifier for this UserContext.

Specified by:
setClientSource in interface UserContextInterface
Parameters:
source - The source location identifier (usually a TCP/IP address).
Throws:
java.rmi.RemoteException - In the event of remote object failure.

setSessionContext

public void setSessionContext(SessionContextInterface session)
                       throws java.rmi.RemoteException
Set the session context that this user context will use for logging, etc.

Specified by:
setSessionContext in interface UserContextInterface
Parameters:
session - The session context.
Throws:
java.rmi.RemoteException - in the event of network failure.

getSessionContext

public SessionContextInterface getSessionContext()
                                          throws java.rmi.RemoteException
Get the session context for this user.

Specified by:
getSessionContext in interface UserContextInterface
Returns:
The session context.
Throws:
java.rmi.RemoteException - in the event of network failure.

setName

public void setName(java.lang.String name)
             throws java.rmi.RemoteException
Set the user name.

Specified by:
setName in interface UserContextInterface
Parameters:
name - The new name.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

getLogger

public LoggerInterface getLogger()
                          throws java.rmi.RemoteException
Deprecated. The Logging Service classes have been deprecated. use Log4J directly.

Get the LoggerInterface for this user. This method is used by some of the classes contained by the UserContext.

Specified by:
getLogger in interface UserContextInterface
Returns:
The LoggerInterface
Throws:
java.rmi.RemoteException - in the event of network problems.

getKey

public java.lang.String getKey()
                        throws java.rmi.RemoteException
Get the user key. This is probably a repository ID, a UUID, or some other unique identitfier for this user. Since names aren't always unique, this is necessary to uniquely locate a user context from the user service.

Specified by:
getKey in interface UserContextInterface
Returns:
A unique identifier for this user.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

setKey

public void setKey(java.lang.String key)
            throws java.rmi.RemoteException
Set the user key. This should be unique within the context of the user service. The key can only be set once. After it's set, the method will return without changing the key.

Specified by:
setKey in interface UserContextInterface
Parameters:
key - The key that identifies this user.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

getIDPropagation

public java.lang.String getIDPropagation()
                                  throws ServiceException,
                                         java.rmi.RemoteException
Description copied from interface: UserContextInterface
If the UserContext was authenticated using an ID propagation mechanism such as SSPI, the name of the ID propagation mechanism is returned. Otherwise, null is returned

Specified by:
getIDPropagation in interface UserContextInterface
Returns:
the name of the ID propagation mechanism used to authenticate this UserContext, if any.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.
See Also:
UserContextInterface.IDPROPAGATION_SSPI, UserContextInterface.IDPROPAGATION_TRUSTED_PEER

addIdentity

public void addIdentity(UserIdentityInterface identity)
                 throws java.rmi.RemoteException
Adds a new authentication identity to this user context.

Specified by:
addIdentity in interface UserContextInterface
Parameters:
identity - The new identity to add to this context.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

removeIdentity

public void removeIdentity(UserIdentityInterface identity)
Remove an identity from the context.

Specified by:
removeIdentity in interface UserContextInterface
Parameters:
identity - The identity to remove.

getIdentities

public java.util.List getIdentities()
                             throws java.rmi.RemoteException
Get an Iterator of the identities which exist for this user context. If the current user context (set by a Subject.doAs() call) is not the same as the Subject in the LoginContext, the user has to have a CredentialPermission granted.

Specified by:
getIdentities in interface UserContextInterface
Returns:
An Iterator of UserIdentityInterface objects.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

getIdentityByDomain

public UserIdentityInterface getIdentityByDomain(java.lang.String domain)
                                          throws java.rmi.RemoteException
Get an identity by domain.

Specified by:
getIdentityByDomain in interface UserContextInterface
Parameters:
domain - The domain to search for in the identities.
Returns:
An identity matching the domain requested.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

getIdentityByDomain

public UserIdentityInterface getIdentityByDomain(java.lang.String domain,
                                                 boolean issueChallenge)
                                          throws java.rmi.RemoteException,
                                                 ServiceException
Get an identity by domain.

Specified by:
getIdentityByDomain in interface UserContextInterface
Parameters:
domain - The domain to search for in the identities.
issueChallenge - If true, the callback handler set in the User Service will be used to challenge the user to provide the requested credentials.
Returns:
An identity matching the domain requested.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.
ServiceException - if unable to obtain the identity by domain.

getIdentityByDomain

public UserIdentityInterface getIdentityByDomain(java.lang.String domain,
                                                 boolean issueChallenge,
                                                 java.lang.String prompt)
                                          throws java.rmi.RemoteException,
                                                 ServiceException
Gets a user identify by domain.

Specified by:
getIdentityByDomain in interface UserContextInterface
Parameters:
domain - Authentication domain
issueChallenge - true if a challenge should be issued.
prompt - Challenge prompt
Returns:
User identity or null if an idenity was not found.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.
ServiceException - if unable to obtain the identity by domain.

getIdentitiesByDomain

public java.util.List getIdentitiesByDomain(java.lang.String domain,
                                            boolean issueChallenge,
                                            java.lang.String challengePrompt)
                                     throws java.rmi.RemoteException,
                                            ServiceException
This method returns a list of all the credential sets that are available for the requested domain.

Specified by:
getIdentitiesByDomain in interface UserContextInterface
Parameters:
domain - The Authentication Domain to get credentials for.
issueChallenge - If true, if the user currently doesn't have credentials for the requested authentication domain, a challenge is issued back to the user for them.
challengePrompt - A string to present to the user with the challenge.
Returns:
A List of UserIdentityInterface objects with the credential sets for the requested domain. If no credentials for the domain exist, and none are returned from the challenge, an empty list is returned.
Throws:
java.rmi.RemoteException - In the event of remote object failure.
ServiceException - If a service error occurs.

addRepositoryGroup

public void addRepositoryGroup(RepositoryGroup group)
                        throws ServiceException,
                               java.rmi.RemoteException
Description copied from interface: UserContextInterface
Add a repository group to this UserContext. A repository group is a list of names of repositories to use for a search. They need not all be the same type of repository. That is, you may have OMR repositories and DAV repositories in the same group, if it makes sense to search both for some types of data. The group must have a name (non-null, and one or more characters), and must be unique for the groups managed by this UserContext. To perform a search using a group, call InformationServiceInterface.searchGroupName(UserContextInterface, String, com.sas.services.information.FilterInterface), or InformationServiceInterface.searchGroupNameWithFilterArray(UserContextInterface, String, com.sas.services.information.FilterInterface[]).

Specified by:
addRepositoryGroup in interface UserContextInterface
Parameters:
group - The repository group to add.
Throws:
ServiceException - If the group name is null, or if a group with the same name already exists in the UserContext.
java.rmi.RemoteException - In the event of remote object failure.

removeRepositoryGroup

public void removeRepositoryGroup(RepositoryGroup group)
                           throws ServiceException,
                                  java.rmi.RemoteException
Description copied from interface: UserContextInterface
Remove a repository group from this UserContext.

Specified by:
removeRepositoryGroup in interface UserContextInterface
Parameters:
group - The Group to remove.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

getRepositoryGroup

public RepositoryGroup getRepositoryGroup(java.lang.String name)
                                   throws ServiceException,
                                          java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get a repository group from this UserContext. To perform a search using the returned group, call InformationServiceInterface.searchGroup(UserContextInterface, com.sas.services.information.RepositoryGroup, com.sas.services.information.FilterInterface), or InformationServiceInterface.searchGroupWithFilterArray(UserContextInterface, com.sas.services.information.RepositoryGroup, com.sas.services.information.FilterInterface[]).

Specified by:
getRepositoryGroup in interface UserContextInterface
Parameters:
name - The name of the group to return.
Returns:
The repository group specfied by name, or null if one by that name doesn't exist.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

getProfile

public ProfileInterface getProfile()
                            throws java.rmi.RemoteException
Get the User's profile context.

Specified by:
getProfile in interface UserContextInterface
Returns:
The profile context for the user.
Throws:
java.rmi.RemoteException - in a networking issue is encountered.

addServer

public void addServer(ServerInterface server)
               throws ServiceException,
                      java.rmi.RemoteException
Description copied from interface: UserContextInterface
Add a server to the list that this user is connected to.

Specified by:
addServer in interface UserContextInterface
Parameters:
server - A server to which this user has an active connection.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

removeServer

public void removeServer(ServerInterface server)
                  throws ServiceException,
                         java.rmi.RemoteException
Description copied from interface: UserContextInterface
Remove a server from the list that this user is currently connected to.

Specified by:
removeServer in interface UserContextInterface
Parameters:
server - The server to remove from the active list.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

getServer

public ServerInterface getServer(java.lang.String name)
                          throws ServiceException,
                                 java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get a specific named Information Service server from this user.

Specified by:
getServer in interface UserContextInterface
Parameters:
name - The configured name of the server to get from the connected list.
Returns:
The ServerInterface with the requested name, or null if it's not connected.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

getServers

public java.util.List getServers()
                          throws java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get a List of the servers this user is connected to.

Specified by:
getServers in interface UserContextInterface
Returns:
A List of ServerInterface objects this user has connections to.
Throws:
java.rmi.RemoteException - In the event of remote object failure.

addRepository

public void addRepository(java.lang.Object repository)
                   throws java.rmi.RemoteException
Add a repository to this user context.

Specified by:
addRepository in interface UserContextInterface
Parameters:
repository - A connected repository that uses an identity for this user
Throws:
java.rmi.RemoteException - in a networking issue is encountered.

removeRepository

public void removeRepository(java.lang.Object repository)
                      throws java.rmi.RemoteException
Remove a repository from this context.

Specified by:
removeRepository in interface UserContextInterface
Parameters:
repository - The repository to remove from this context.
Throws:
java.rmi.RemoteException - in a networking issue is encountered.

getRepository

public RepositoryInterface getRepository(java.lang.String name)
                                  throws ServiceException,
                                         java.rmi.RemoteException
Gets the repository for the specified name.

Specified by:
getRepository in interface UserContextInterface
Parameters:
name - Repository's name.
Returns:
Repository or null if a repository could not be located for the specified name.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.
ServiceException - if unable to obtain a repository.

getAuthRepositoryName

public java.lang.String getAuthRepositoryName()
                                       throws ServiceException,
                                              java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get the Information Service configured name of the repository that was used for authentication. It's possible for a configuration to authenticate against multiple services. This will return the first server that was used to authenticate the user.

Specified by:
getAuthRepositoryName in interface UserContextInterface
Returns:
The name of the repository that was used for authentication.
Throws:
ServiceException - in the event of a service failure.
java.rmi.RemoteException - in the event of a network failure.

getAuthRepository

public RepositoryInterface getAuthRepository()
                                      throws ServiceException,
                                             java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get a handle to the repository the user authenticated against. It's possible for a configuration to authenticate against multiple services. This will return the first server that was used to authenticate the user.

Specified by:
getAuthRepository in interface UserContextInterface
Returns:
The RepositoryInterface used for authentication.
Throws:
ServiceException - in the event of a service failure.
java.rmi.RemoteException - in the event of a network failure.

getAuthServer

public ServerInterface getAuthServer()
                              throws ServiceException,
                                     java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get a handle to the metadata server the user authenticated against.

Specified by:
getAuthServer in interface UserContextInterface
Returns:
The ServerInterface that the user authenticated against.
Throws:
ServiceException - If a server error occurs.
java.rmi.RemoteException - In the event of remote object failure.

getAuthServerName

public java.lang.String getAuthServerName()
                                   throws ServiceException,
                                          java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get the definition name of the server the user authenticated against.

Specified by:
getAuthServerName in interface UserContextInterface
Returns:
The Information Service configured Server definition name of the server that the user authenticated against.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

getRepositories

public java.util.List getRepositories()
                               throws java.rmi.RemoteException
Get an iterator of the repositories this user is connected to.

Specified by:
getRepositories in interface UserContextInterface
Returns:
The connected repositories
Throws:
java.rmi.RemoteException - in a networking issue is encountered.

refreshRepositoryData

public void refreshRepositoryData()
                           throws ServiceException,
                                  java.rmi.RemoteException
Description copied from interface: UserContextInterface
Refresh all of the data that's been retrieved using the Information Service during the life of this UserContext. This is potentially a very expensive operation, so use it with care.

Specified by:
refreshRepositoryData in interface UserContextInterface
Throws:
ServiceException - If an exception occurs during the refresh operation.
java.rmi.RemoteException - In the event of remote object failure.

equals

public boolean equals(java.lang.Object o)
Test against another object for equality. If it's a UserContextInterface and the keys match, then they're equal.

Overrides:
equals in class java.rmi.server.RemoteObject
Parameters:
o - An object to test against this one for equality.
Returns:
true if the objects are equal, false otherwise.

getPrincipals

public java.util.Set getPrincipals()
                            throws java.rmi.RemoteException
Gets the set of principals.

Specified by:
getPrincipals in interface UserContextInterface
Returns:
Set of principals.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

getPublicCredentials

public java.util.Set getPublicCredentials()
                                   throws java.rmi.RemoteException
Gets the set of public credentials.

Specified by:
getPublicCredentials in interface UserContextInterface
Returns:
Set of public credentials.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

getPrivateCredentials

public java.util.Set getPrivateCredentials()
                                    throws java.rmi.RemoteException
Gets the set of private credentials.

Specified by:
getPrivateCredentials in interface UserContextInterface
Returns:
Set of private credentials.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

getLoginCallback

public LoginCallbackHandler getLoginCallback()
                                      throws java.rmi.RemoteException
Get the callback handler. This is used by the Authenticator class to set information needed by the login modules to perform the authenticaton.

Specified by:
getLoginCallback in interface UserContextInterface
Returns:
Login callback handler.
Throws:
java.rmi.RemoteException - in a networking issue is encountered.

authenticate

public boolean authenticate()
                     throws java.rmi.RemoteException
Description copied from interface: UserContextInterface
Authenticate a user based on their current OS identity.

Specified by:
authenticate in interface UserContextInterface
Returns:
true if the authentication was successful, false otherwise.
Throws:
java.rmi.RemoteException - In the event of remote object failure.

authenticate

public boolean authenticate(UserIdentityInterface ident,
                            java.util.Map options)
                     throws java.rmi.RemoteException
Authenticates a user identity.

Specified by:
authenticate in interface UserContextInterface
Parameters:
ident - The identity to authenticate.
options - Additional options for the authentication process (this may include a host and port for an authentication server and other information).
Returns:
true if the authentication was successful, false otherwise.
Throws:
java.rmi.RemoteException - in a networking issue is encountered.

addException

public void addException(java.lang.Exception exception)
                  throws java.rmi.RemoteException
Adds an exception.

Specified by:
addException in interface UserContextInterface
Parameters:
exception - Exception to add.
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

clearExceptions

public void clearExceptions()
                     throws java.rmi.RemoteException
Clears the exceptions.

Specified by:
clearExceptions in interface UserContextInterface
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

getExceptions

public java.lang.Exception[] getExceptions()
                                    throws java.rmi.RemoteException
Gets the exceptions.

Specified by:
getExceptions in interface UserContextInterface
Returns:
Exceptions
Throws:
java.rmi.RemoteException - if a networking issue is encountered.

setChallengeCallbackHandler

public void setChallengeCallbackHandler(RemoteCallbackHandler handler)
                                 throws java.rmi.RemoteException
Set the object that will be used to handle credential challenge callbacks.

Specified by:
setChallengeCallbackHandler in interface UserContextInterface
Parameters:
handler - The credential callback handler. This object will have to be an implementation of the javax.security.auth.callback.CallbackHandler interface.
Throws:
java.rmi.RemoteException - In the event of a remote failure.

getChallengeCallbackHandler

public RemoteCallbackHandler getChallengeCallbackHandler()
                                                  throws java.rmi.RemoteException
Get the object that will handle credential challenge callbacks.

Specified by:
getChallengeCallbackHandler in interface UserContextInterface
Returns:
The callback handler
Throws:
java.rmi.RemoteException - in a networking issue is encountered.

getPerson

public IdentityInterface getPerson()
                            throws java.rmi.RemoteException
Description copied from interface: UserContextInterface
Return the IdentityInterface object that represents this user. This is the metadata object that the metadata server has determined represents the authenticated user. It may a PersonInterface or an IdentityGroupInterface object, if group logins are enabled in the UserService.

Specified by:
getPerson in interface UserContextInterface
Returns:
An IdentityInterface representing this user, or null if the authenticated user has no metadata presence (a public user).
Throws:
java.rmi.RemoteException - in the event of remote object failure.

setPerson

public void setPerson(IdentityInterface identity)
               throws java.rmi.RemoteException,
                      java.lang.IllegalStateException
This method gets called by UserService as part of the UserContext initialization. Client code should not call this method.

Specified by:
setPerson in interface UserContextInterface
Parameters:
identity - Person's identity.
Throws:
java.rmi.RemoteException - In the event of remote object failure.
java.lang.IllegalStateException - If the identity object has already been set.

getUniqueId

public java.lang.String getUniqueId()
                             throws java.rmi.RemoteException
Gets the unique ID associated with this user context.

Specified by:
getUniqueId in interface UserContextInterface
Returns:
User context's unique ID.
Throws:
java.rmi.RemoteException - if a network exception occurs.

isDestroyed

public boolean isDestroyed()
                    throws java.rmi.RemoteException
Determines whether or not this user context has been destroyed.

Specified by:
isDestroyed in interface UserContextInterface
Returns:
true if this user context has been destroyed.
Throws:
java.rmi.RemoteException - if a network exception occurs.

getLoginTime

public long getLoginTime()
                  throws java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get the timestamp when the user was authenticated.

Specified by:
getLoginTime in interface UserContextInterface
Returns:
A long representing the login date/time.
Throws:
java.rmi.RemoteException - In the event of remote object failure.

getSharedResource

public java.lang.Object getSharedResource(java.lang.String key)
                                   throws java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get an object from the shared resource map. Shared resources are generally used between repository instances, but can be shared among other objects as well.

Specified by:
getSharedResource in interface UserContextInterface
Parameters:
key - The key to the object in the resource map.
Returns:
The resource object, or null if nothing was found for the given key.
Throws:
java.rmi.RemoteException - In the event of remote object failure.

putSharedResource

public java.lang.Object putSharedResource(java.lang.String key,
                                          java.lang.Object value)
                                   throws java.rmi.RemoteException
Description copied from interface: UserContextInterface
Put an object into the shared resource map. This will make the object potentially available to other objects managed by the UserContext for sharing.

Specified by:
putSharedResource in interface UserContextInterface
Parameters:
key - The lookup key for the resource.
value - The resource object to store.
Returns:
The old value at the resource key, or null if it's a new key.
Throws:
java.rmi.RemoteException - In the event of remote object failure.

toString

public java.lang.String toString()
Overrides:
toString in class java.rmi.server.RemoteObject

toByteArray

public byte[] toByteArray()
                   throws java.rmi.RemoteException
Specified by:
toByteArray in interface UserContextInterface
Throws:
java.rmi.RemoteException

getLoginConfigAppName

protected java.lang.String getLoginConfigAppName()
                                          throws ServiceException,
                                                 java.rmi.RemoteException
Throws:
ServiceException
java.rmi.RemoteException

addLogChangeListener

public void addLogChangeListener(LogChangeListener listener)
                          throws java.rmi.RemoteException
Description copied from interface: UserContextInterface
Receive a notification when the UserContext's logger is changed. This normally only happens when the session context is set on this user context. The main purpose for this notification is so that repositories can use the session logger for all of their output, which can include the session and user context information in the layout.

Specified by:
addLogChangeListener in interface UserContextInterface
Parameters:
listener - An object that wishes to receive notification when the user context log changes.
Throws:
java.rmi.RemoteException - In the event of remote object failure.

getRoles

public java.util.List getRoles()
                        throws ServiceException,
                               java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get a List of the roles this user is a member of.

Specified by:
getRoles in interface UserContextInterface
Returns:
A List of Strings representing the role names this user is a member of.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

isInAnyRole

public boolean isInAnyRole(java.util.List roleList)
                    throws ServiceException,
                           java.rmi.RemoteException
Description copied from interface: UserContextInterface
Check whether the user is a member of any of the roles in the list.

Specified by:
isInAnyRole in interface UserContextInterface
Parameters:
roleList - A List of Strings representing role names.
Returns:
True if the user is a member of any roles in the list. False otherwise.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

isInRole

public boolean isInRole(java.lang.String role)
                 throws ServiceException,
                        java.rmi.RemoteException
Description copied from interface: UserContextInterface
Check whether the user is a member of a given role.

Specified by:
isInRole in interface UserContextInterface
Parameters:
role - The role name to check for.
Returns:
True if the user is a member of the role. False otherwise.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

getActions

public java.util.List getActions(java.lang.String appName)
                          throws ServiceException,
                                 java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get a List of actions associated with an application that this user can perform.

Specified by:
getActions in interface UserContextInterface
Parameters:
appName - The SoftwareComponent name associated with the application.
Returns:
A List of ApplicationAuthorizations representing the actions.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.
See Also:
com.sas.services.security.ApplicationAuthorization()

getActions

public java.util.List getActions(java.lang.String appName,
                                 boolean onlyGrantedActions)
                          throws ServiceException,
                                 java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get a List of actions associated with an application.

Specified by:
getActions in interface UserContextInterface
Parameters:
appName - The SoftwareComponent name associated with the application.
onlyGrantedActions - If true then return only the actions that are granted to this user; otherwise, return all actions.
Returns:
A List of ApplicationAuthorizations representing the actions.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.
See Also:
com.sas.services.security.ApplicationAuthorization()

hasCapability

public boolean hasCapability(java.lang.String appName,
                             java.lang.String action)
                      throws ServiceException,
                             java.rmi.RemoteException
Description copied from interface: UserContextInterface
Check whether this user has the capability to perform a specific action for a particular application.

Specified by:
hasCapability in interface UserContextInterface
Parameters:
appName - The SoftwareComponent name associated with the application.
action - The action to perform.
Returns:
True if the user has permission to perform the action; otherwise, false.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

isInGroup

public boolean isInGroup(java.lang.String group)
                  throws ServiceException,
                         java.rmi.RemoteException
Description copied from interface: UserContextInterface
Check whether the user is a member of a given group.

Specified by:
isInGroup in interface UserContextInterface
Parameters:
group - The group name to check for.
Returns:
True if the user is a member of the group. False otherwise.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

isInAnyGroup

public boolean isInAnyGroup(java.util.List groupList)
                     throws ServiceException,
                            java.rmi.RemoteException
Description copied from interface: UserContextInterface
Check whether the user is a member of any of the groups in the list.

Specified by:
isInAnyGroup in interface UserContextInterface
Parameters:
groupList - A List of Strings representing group names.
Returns:
True if the user is a member of any groups in the list. False otherwise.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

getGroups

public java.util.List getGroups()
                         throws ServiceException,
                                java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get a List of the groups this user is a member of.

Specified by:
getGroups in interface UserContextInterface
Returns:
A List of Strings representing the group names this user is a member of.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

requestCredentials

public com.sas.metadata.remote.MdCredential requestCredentials(java.lang.String authDomain,
                                                               boolean issueChallenge,
                                                               java.lang.String prompt)
                                                        throws java.rmi.RemoteException,
                                                               com.sas.metadata.remote.MdException
Specified by:
requestCredentials in interface com.sas.metadata.remote.CredentialResolver
Throws:
java.rmi.RemoteException
com.sas.metadata.remote.MdException

requestCredentialList

public java.util.List requestCredentialList(java.lang.String authDomain,
                                            boolean issueChallenge,
                                            java.lang.String prompt)
                                     throws java.rmi.RemoteException,
                                            com.sas.metadata.remote.MdException
Specified by:
requestCredentialList in interface com.sas.metadata.remote.CredentialResolver
Throws:
java.rmi.RemoteException
com.sas.metadata.remote.MdException

getResolvedUserId

public final java.lang.String getResolvedUserId()
                                         throws ServiceException,
                                                java.rmi.RemoteException
Return the metadata server resolved user id.

Specified by:
getResolvedUserId in interface UserContextInterface
Returns:
the user id as resolved by the metadata server. This is a domain-qualified user id (e.g., user@DefaultAuth).
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

isInternalUser

public final boolean isInternalUser()
                             throws ServiceException,
                                    java.rmi.RemoteException
Return a boolean indicating if this user was created using an internal userid.

Specified by:
isInternalUser in interface UserContextInterface
Returns:
true if the user was created using an internal userid, false otherwise.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

getLocale

public java.util.Locale getLocale()
                           throws ServiceException,
                                  java.rmi.RemoteException
Description copied from interface: UserContextInterface
Get the locale for this user. If it has been set explicitly, return that value. If the user has a profile, return the profile setting. If there's no other locale available, return the JVM default.

Specified by:
getLocale in interface UserContextInterface
Returns:
The user's current locale setting.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

enableLocalAdminMode

public void enableLocalAdminMode(java.lang.String authDomain)
                          throws ServiceException,
                                 java.rmi.RemoteException
Description copied from interface: UserContextInterface
This sets up a special case where an administrative user with an internal account is used to authenticate a user. Since the internal account cannot be used to authenticate against other resources like a workspace server, this creates a problem because the UserContext won't go get other credentials in the primary authentication domain. This overrides that behavior and makes the primary credential "sticky", so it won't really be removed if requested.

Specified by:
enableLocalAdminMode in interface UserContextInterface
Parameters:
authDomain - The domain to retrieve all credentials for. This overrides my default behavior of not getting any more credentials for the primary authentication domain.
Throws:
ServiceException - If a metadata or service-level error occurs.
java.rmi.RemoteException - In the event of remote object failure.

setLocale

public void setLocale(java.util.Locale locale)
               throws ServiceException,
                      java.rmi.RemoteException
Description copied from interface: UserContextInterface
Set the locale to use for this user session.

Specified by:
setLocale in interface UserContextInterface
Parameters:
locale - The preferred locale for this user for the live of this session.
Throws:
ServiceException - If a service level error occurs.
java.rmi.RemoteException - In the event of remote object failure.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.