UserRegistry interface methods

Implementing this interface enables WAS security to use custom registries. This capability should extend the java.rmi file. With a remote registry, one can complete this process remotely.

Implementation of this interface must provide implementations for:

  • initialize(java.util.Properties)

  • checkPassword(String,String)

  • mapCertificate(X509Certificate[])

  • getRealm

  • getUsers(String,int)

  • getUserDisplayName(String)

  • getUniqueUserId(String)

  • getUserSecurityName(String)

  • isValidUser(String)

  • getGroups(String,int)

  • getGroupDisplayName(String)

  • getUniqueGroupId(String)

  • getUniqueGroupIds(String)

  • getGroupSecurityName(String)

  • isValidGroup(String)

  • getGroupsForUser(String)

  • getUsersForGroup(String,int)

  • createCredential(String)

public void initialize(java.util.Properties props)
throws CustomRegistryException,
RemoteException; This method is called to initialize the UserRegistry method. All the properties defined in the Custom User Registry panel propagate to this method.

For the sample, the initialize method retrieves the names of the registry files containing the user and group information.

This method is called during server bring up to initialize the registry. This method is also called when validation is performed by the administrative console, when security is on. This method remains the same as in v4.x.

public String checkPassword(String userSecurityName, String password)
throws PasswordCheckFailedException,
CustomRegistryException,
RemoteException; The checkPassword method is called to authenticate users when they log in using a name (or user ID) and a password. This method returns a string which, in most cases, is the user being authenticated. Then, a credential is created for the user for authorization purposes. This user name is also returned for the enterprise bean call, getCallerPrincipal(), and the servlet calls, getUserPrincipal() and getRemoteUser(). See the getUserDisplayName method for more information if you have display names in your registry. In some situations, if you return a user other than the one who is logged in, verify that the user is valid in the registry.

For the sample, the mapCertificate method gets the distinguished name (DN) from the certificate chain and makes sure it is a valid user in the registry before returning the user. For the sample, the checkPassword method checks the name and password combination in the registry and (if they match) returns the user being authenticated.

This method is called for various scenarios. It is called by the administrative console to validate the user information once the registry is initialized. It is also called when you access protected resources in the product for authenticating the user and before proceeding with the authorization. This method is the same as in v4.x.

public String mapCertificate(X509Certificate[] cert)
throws CertificateMapNotSupportedException,
CertificateMapFailedException,
CustomRegistryException,
RemoteException;
The mapCertificate method is called to obtain a user name from an X.509 certificate chain supplied by the browser. The complete certificate chain is passed to this method and the implementation can validate the chain if needed and get the user information. A credential is created for this user for authorization purposes. If browser certificates are not supported in your configuration, one can throw the exception, CertificateMapNotSupportedException. The consequence of not supporting certificates is authentication failure if the challenge type is certificates, even if valid certificates are in the browser.

This method is called when certificates are provided for authentication. For Web applications, when the authentication constraints are set to CLIENT-CERT in the web.xml file of the application, this method is called to map a certificate to a valid user in the registry. For Java clients, this method is called to map the client certificates in the transport layer, when using the transport layer authentication. Also, when the Identity Assertion Token (when using the CSIv2 authentication protocol) is set to contain certificates, this method is called to map the certificates to a valid user.

In WAS V4.x, the input parameter was the X509Certificate. In WebSphere Application Server V5.x and later, this parameter changes to accept an array of X509Certificate certificates (such as a certificate chain). In v4.x, this parameter was called only for Web applications, but in v5.x and later one can call this method for both Web and Java clients.

public String getRealm()
throws CustomRegistryException,
RemoteException; The getRealm method is called to get the name of the security realm. The name of the realm identifies the security domain for which the registry authenticates users. If this method returns a null value, a default name of customRealm is used.

For the sample, the getRealm method returns the string, customRealm. One of the calls to this method is when the registry information is validated. This method is the same as in v4.x.

public Result getUsers(String pattern, int limit)
throws CustomRegistryException,
RemoteException; The getUsers method returns the list of users from the registry. The names of users depend on the pattern parameter. The number of users are limited by the limit parameter. In a registry that has many users, getting all the users is not practical. So the limit parameter is introduced to limit the number of users retrieved from the registry. A limit of 0 indicates to return all the users that match the pattern and might cause problems for large registries. Use this limit with care.

The custom registry implementations are expected to support at least the wildcard search (*). For example, a pattern of (*) returns all the users and a pattern of (b*) returns the users starting with b.

The return parameter is an object of type com.ibm.websphere.security.Result. This object contains two attributes, a java.util.List and a java.lang.boolean. The list contains the users returned and the Boolean flag indicates if there are more users available in the registry for the search pattern. This Boolean flag is used to indicate to the client whether more users are available in the registry.

In the sample, the getUsers retrieves the required number of users from the registry and sets them as a list in the result object. To find out if there are more users than requested, the sample gets one more user than requested and if it finds the additional user, it sets the Boolean flag to true. For pattern matching, the match method in the RegExpSample class is used, which supports wildcard characters such as the asterisk (*) and question mark (?).

This method is called by the administrative console to add users to roles in the various map users to roles panels. The administrative console uses the Boolean set in the result object to indicate that more entries matching the pattern are available in the registry.

In WAS V4.x, this method specifies to take only the pattern parameter. The return is a list. In WebSphere Application Server V5.x or later, this method is changed to take one additional parameter, the limit. Ideally, your implementation should change to take the limit value and limit the users returned. The return is changed to return a result object, which consists of the list (as in v4) and a flag indicating if more entries exist. So, when the list returns, use the Result.setList(List) to set the List in the result object. If there are more entries than requested in the limit parameter, set the Boolean attribute to true in the result object, using Result.setHasMore() method. The default for the Boolean attribute in the result object is false.

public String getUserDisplayName(String userSecurityName)
throws EntryNotFoundException,
CustomRegistryException,
RemoteException; The getUserDisplayName method returns a display name for a user, if one exists. The display name is an optional string that describes the user that one can set in some registries. This is a descriptive name for the user and does not have to be unique in the registry.

For example in Windows systems, one can display the full name of the user.

If you do not need display names in your registry, return null or an empty string for this method.

Note: In WAS V4.x, if display names existed for any user these names were useful for the EJB method call getCallerPrincipal() and the servlet calls getUserPrincipal() and getRemoteUser(). If the display names were not the same as the security name for any user, the display names are returned for the previously mentioned enterprise beans and servlet methods. Returning display names for these methods might become problematic is some situations because the display names might not be unique in the registry. Avoid this problem by changing the default behavior to return the user's security name instead of the user's display name in this version of the product. However, if you want to have the same behavior as in Version 4, set the property WAS_UseDisplayName to true in the Custom Registry Properties panel in the administrative console. For more information on how to set properties for the custom registry, see the section on Setting Properties for Custom Registries.

In the sample, this method returns the display name of the user whose name matches the user name provided. If the display name does not exist this returns an empty string.

This method can be called by the product to present the display names in the administrative console, or using the command line using the wsadmin tool. Use this method only for displaying. This method is the same as in Version 4.0.

public String getUniqueUserId(String userSecurityName)
throws EntryNotFoundException,
CustomRegistryException,
RemoteException;
This method returns the unique ID of the user given the security name.

In the sample, this method returns the uniqueId of the user whose name matches the supplied name. This method is called when forming a credential for a user and also when creating the authorization table for the application.

public String getUserSecurityName(String uniqueUserId)
throws EntryNotFoundException,
CustomRegistryException,
RemoteException; This method returns the security name of a user given the unique ID. In the sample, this method returns the security name of the user whose unique ID matches the supplied ID.

This method is called to make sure a valid user exists for a given uniqueUserId. This method is called to get the security name of the user when the uniqueUserId is obtained from a token.

public boolean isValidUser(String userSecurityName)
throws CustomRegistryException,
RemoteException;
This method indicates whether the given user is a valid user in the registry.

In the Sample, this method returns true if the user is found in the registry, otherwise this method returns false. This method is primarily called in situations where knowing if the user exists in the directory prevents problems later. For example, in the mapCertificate call, once the name is obtained from the certificate if the user is found to be an invalid user in the registry, one can avoid trying to create the credential for the user.

public Result getGroups(String pattern, int limit)
throws CustomRegistryException,
RemoteException; The getGroups method returns the list of groups from the registry. The names of groups depend on the pattern parameter. The number of groups is limited by the limit parameter. In a registry that has many groups, getting all the groups is not practical. So, the limit parameter is introduced to limit the number of groups retrieved from the registry. A limit of 0 implies to return all the groups that match the pattern and can cause problems for large registries. Use this limit with care. The custom registry implementations are expected to support at least the wildcard search (*). For example, a pattern of (*) returns all the users and a pattern of (b*) returns the users starting with b.

The return parameter is an object of type com.ibm.websphere.security.Result. This object contains two attributes, a java.util.List and a java.lang.boolean. The list contains the groups returned and the Boolean flag indicates whether there are more groups available in the registry for the pattern searched. This Boolean flag is used to indicate to the client if more groups are available in the registry.

In the sample, the getUsers retrieves the required number of groups from the registry and sets them as a list in the result object. To find out if there are more groups than requested, the sample gets one more user than requested and if it finds the additional user, it sets the Boolean flag to true. For pattern matching, the match method in the RegExpSample class is used. It supports wildcards like *, ?.

This method is called by the administrative console to add groups to roles in the various map groups to roles panels. The administrative console will use the boolean set in the Result object to indicate that more entries matching the pattern are available in the registry.

In WAS V4, this method is used to take the pattern parameter only and returns a list. In WebSphere Application Server V5.x or later, this method is changed to take one additional parameter, the limit. Change to take the limit value and limit the users returned. The return is changed to return a result object, which consists of the list (as in v4) and a flag indicating whether more entries exist. Use the Result.setList(List) to set the list in the result object. If there are more entries than requested in the limit parameter, set the Boolean attribute to true in the result object using Result.setHasMore(). The default for the Boolean attribute in the result object is false.

public String getGroupDisplayName(String groupSecurityName)
throws EntryNotFoundException,
CustomRegistryException,
RemoteException; The getGroupDisplayName method returns a display name for a group if one exists. The display name is an optional string describing the group that one can set in some registries. This name is a descriptive name for the group and does not have to be unique in the registry. If you do not need to have display names for groups in your registry, return null or an empty string for this method.

In the sample, this method returns the display name of the group whose name matches the group name provided. If the display name does not exist, this method returns an empty string.

The product can call this method to present the display names in the administrative console or through command line using the wsadmin tool. This method is only used for displaying.

public String getUniqueGroupId(String groupSecurityName)
throws EntryNotFoundException,
CustomRegistryException,
RemoteException; This method returns the unique ID of the group given the security name.

In the sample, this method returns the unique ID of the group whose name matches the supplied name. This method is called when creating the authorization table for the application.

public List getUniqueGroupIds(String uniqueUserId)
throws EntryNotFoundException,
CustomRegistryException,
RemoteException;
This method returns the unique IDs of all the groups to which a user belongs.

In the sample, this method returns the unique ID of all the groups that contain this uniqueUserID. This method is called when creating the credential for the user. As part of creating the credential, all the groupUniqueIds in which the user belongs are collected and put in the credential for authorization purposes when groups are given access to a resource.

public String getGroupSecurityName(String uniqueGroupId)
throws EntryNotFoundException,
CustomRegistryException,
RemoteException;
This method returns the security name of a group given its unique ID.

In the sample, this method returns the security name of the group whose unique ID matches the supplied ID. This method verifies that a valid group exists for a given uniqueGroupId.

public boolean isValidGroup(String groupSecurityName)
throws CustomRegistryException,
RemoteException; This method indicates if the given group is a valid group in the registry.

In the sample, this method returns true if the group is found in the registry, otherwise the method returns false. This method can be used in situations where knowing whether the group exists in the directory might prevent problems later.

public List getGroupsForUser(String userSecurityName)
throws EntryNotFoundException,
CustomRegistryException,
RemoteException; This method returns all the groups to which a user belongs whose name matches the supplied name. This method is similar to the getUniqueGroupIds method with the exception that the security names are used instead of the unique IDs.

In the sample, this method returns all the group security names that contain the userSecurityName.

This method is called by the administrative console or the scripting tool to verify that the users entered for the RunAs roles are already part of that role in the users and groups to role mapping. This check is required to ensure that a user cannot be added to a RunAs role unless that user is assigned to the role in the users and groups to role mapping either directly or indirectly (through a group that contains this user). Since a group in which the user belongs can be part of the role in the users and groups to role mapping, this method is called to check if any of the groups that this user belongs to mapped to that role.

public Result getUsersForGroup(String groupSecurityName, int limit)
throws NotImplementedException,
EntryNotFoundException,
CustomRegistryException,
RemoteException;
This method retrieves users from the specified group. The number of users returned is limited by the limit parameter. A limit of 0 indicates to return all of the users in that group. This method is not directly called by the WAS security component. However, this can be called by other components. In rare situations, if you are working with a registry where getting all the users from any of your groups is not practical (for example, if there are a large number of users), one can throw the NotImplementedException exception for the particular groups. In this case, verify that if the process choreographer is installed (or if it is installed later) the staff assignments are not modeled using these particular groups. If there is no concern about returning the users from groups in the registry, it is recommended that you do not throw the NotImplemented exception when implementing this method.

The return parameter is an object of type com.ibm.websphere.security.Result. This object contains two attributes, java.util.List and java.lang.boolean. The list contains the users returned and the Boolean flag, which indicates whether there are more users available in the registry for the search pattern. This Boolean flag indicates to the client whether users are available in the registry.

In the example, this method gets one user more than the requested number of users for a group if the limit parameter is not set to 0. If it succeeds in getting one more user, it sets the Boolean flag to true.

In WAS V4, this getUsers method was mandatory for the product. For WebSphere Application Server V5.x or later, this method can throw the exception NotImplementedException exception in situations where it is not practical to get the requested set of users. However, this exception should be thrown in rare situations, as other components can be affected. In v4, this method accepted only the pattern parameter and the returned a list. In v5, this method accepts one additional parameter, the limit. Change your implementation to take the limit value and limit the users returned. The return changes to return a result object, which consists of the list (as in v4) and a flag indicating whether more entries exist. When the list is returned, use the Result.setList(List) method to set the list in the Result object. If there are more entries than requested in the limit parameter, set the Boolean attribute to true in the result object using Result.setHasMore(). The default for the Boolean attribute in the Result object is false.

Attention: The first two lines of the following code sample is one continuous line.

public com.ibm.websphere.security.cred.WSCredential
createCredential(String userSecurityName)
throws NotImplementedException,
EntryNotFoundException,
CustomRegistryException,
RemoteException; In this release of the WebSphere Application Server, the createCredential method is not called. We can return null. In the example, a null is returned.


 

Related Tasks


Developing custom user registries
Migrating custom user registries

 

See Also


Configuring custom user registries
FileRegistrySample.java file