Classes are provided by the IBM® Toolbox for Java™ that interact with the security services provided by i5/OS™. Specifically, support is provided to authenticate a user identity, sometimes referred to as a principal, and password against the i5/OS user registry. A credential representing the authenticated user can then be established. You can use the credential to alter the identity of the current i5/OS thread to perform work under the authorities and permissions of the authenticated user. In effect, this swap of identity results in the thread acting as if a signon was performed by the authenticated user.
The AS400 object provides authentication for a given user profile and password against the server. You can also retrieve Kerberos tickets and profile tokens that represent authenticated user profiles and passwords for the system.
To use Kerberos tickets, set only the system name (and not the password) into the AS400 object. The user identity is retrieved through the JGSS framework. You can set only one means of authentication in an AS400 object at a time. Setting the password clears any Kerberos ticket or profile token.
To use profile tokens, use the getProfileToken() methods to retrieve instances of the ProfileTokenCredential class. Think of profile tokens as a representation of an authenticated user profile and password for a specific server. Profile tokens expire based on time, up to one hour, but can be refreshed in certain cases to provide an extended life span.
The following example creates a system object and uses that object to generate a profile token. The example then uses the profile token to create another system object, and uses the second system object to connect to the command service:
AS400 system = new AS400("mySystemName", "MYUSERID", "MYPASSWORD"); ProfileTokenCredential myPT = system.getProfileToken(); AS400 system2 = new AS400("mySystemName", myPT); system2.connectService(AS400.COMMAND);
You can establish a credential on either a remote or local context. Once created, you can serialize or distribute the credential as required by the calling application. When passed to a running process on the associated server, a credential can be used to modify or swap the i5/OS thread identity and perform work on behalf of the previously authenticated user.
A practical application of this support might be in a two tier application, with authentication of a user profile and password being performed by a graphical user interface on the first tier (i.e. a PC) and work being performed for that user on the second tier (the server). By utilizing ProfileTokenCredentials, the application can avoid directly passing user IDs and passwords over the network. The profile token can then be distributed to the program on the second tier, which can perform the swap() and operate under the i5/OS authorities and permissions assigned to the user.
The methods for setting tokens in ProfileTokenCredential class require that you distinguish different ways to specify passwords:
Additionally, the setToken methods allow remote users to specify password special values and allow longer user profile passwords of up to 128 characters.
To specify a password special value integer, such as *NOPWD or *NOPWDCHK, use one of the following methods:
The ProfileTokenCredential class includes the following static constants for password special value integers:
To specify a user profile password as a String, use one of the following methods:
The setTokenExended methods do not allow you to pass password special value strings as the password parameter. For example, these methods do not allow a password string of *NOPWD.
For more information, see the following Javadoc reference information:
ProfileTokenCredential
Refer to this code for an example of how to use a profile token credential to swap the i5/OS thread identity and perform work on behalf of a specific user.