In many circumstances you need programmatic control of the IBM i authentication process, for example in single sign on situations. Please follow these basic steps for to implement.

Note that this method will work for both standard WebClient and for WebClient Mobile applications

1. Create a Plex function to accept your User Id and Password. You can create a panel for the user to enter in this information.

2. Add variables to the Local context:

  • IBMi Connection Property
  • Property Value
  • Return Value

3. Add Java source to authenticate the user to the IBMi

import com.ibm.as400.access.AS400;
import com.ibm.as400.access.AS400SecurityException;

{
	{
	   try {
			&(4:).set(new ObCharFld("   "));
			AS400 myas400 = new AS400(&(1:).getValue());        
			myas400.validateSignon(&(2:).getValue(),&(3:).getValue());
		}
	   	catch (AS400SecurityException i) {
			&(4:).set(new ObCharFld("INF"));
		}
		catch (Exception e){
			&(4:).set(new ObCharFld("ERR"));
		}     
	}
}

4. Once the user has been authenticated to the AS400, Java API calls are used to complete the process.

 

5. Make sure the obclient.properties file is located within the Java project in WebClient.

 

6. Obtain jt400.jar (Supplied by IBM) and add to your build path / deployment assembly in Eclipse. Compile and run the process.

First add to Java Project and add to build path

Copy and paste the jt400.jar file into the root of the Java project. Then right click and choose the build path option, libraries tab. Choose add JAR’s button.

Then add to Deployment Assembly in the Web project

Right click on the Web project. Select Properties, and select Deployment Assembly. Choose “Archives from Workspace”, then add the jar from the java project.

 

 

 

Note: This process is very similar to a standard Plex login to the IBMi. In client-server CA Plex apps each user has their own local copy of obclient.properties. The difference here is that WebClient maintains a user copy of the obclient.properties file in the session.  So that the login is maintained for a specific user for a specific session

Contributed by Mark Schroeder. Mark can be reached at mlschroeder@cmfirsttech.com