Presentation is loading. Please wait.

Presentation is loading. Please wait.

System I (AS400) Login You will need to develop Login procedures for your web applications. This short section describes how to do this for System I.

Similar presentations


Presentation on theme: "System I (AS400) Login You will need to develop Login procedures for your web applications. This short section describes how to do this for System I."— Presentation transcript:

1 System I (AS400) Login You will need to develop Login procedures for your web applications. This short section describes how to do this for System I machines.

2  System I Login Resources
To develop your Login procedure, you will need the following: Login Page Java Class to authenticate through an AS400Object Success failure logic This workshop will describe all of these resources. You can find a complete, working PIF solution in the attachments: As400authentication.zip EGL JSFHandler Function authenticate() Call to Java Class If successful forward to next page… AS400Authenticate (Java Class) Create new AS400Object Invoke Authenticate Method Return success/failure indicator

3  System I Login Resources – Java Class
In the src folder, create a new Java package, named: as400Security Then create a new Java Class, named: AS400Authentication Note that this snapshot is taken from a different project and workspace. You can add the resources into EGLWeb As long as the Java package and class names match package as400Security; import java.io.IOException; import com.ibm.as400.access.AS400; import com.ibm.as400.access.AS400SecurityException; sanjay chandru */ public class AS400Authentication { static AS400 as400Object; public static void setSystemName(String systemName) { as400Object = new AS400(systemName); } public static int authenticate(String username, String password) int intValue = 0; boolean returnValue = false; try returnValue = as400Object.authenticate(username, password); catch (AS400SecurityException ex1) intValue = 0; catch (IOException ex2) if (returnValue) intValue = 1; return intValue; public static String getUserId() return as400Object.getUserId();

4  System I Login Resources – Login Page – EGL Code
In the \WebContent\ folder, create a new Web page named: TestSecurity.JSP From the page’s EGL code, add the statements in the Notes section of this slide. Study the comments – in particular, note: externalType declaration Call through externalType to Java class for AS400 authentication // Nov 19, :25:33 AM - EGL V7.0 Migration package jsfhandlers; import com.ibm.egl.jsf.UIViewRoot; handler TestSecurity type JSFHandler {onConstructionFunction = onPageLoad, view = "TestSecurity.jsp", viewRootVar = viewRoot, cancelOnPageTransition = YES} password string; //Logon Password username string; //Logon ID aS400 AS400Authentication; //ExternalType to a Java Class for authentication //Note that the Java Class is: AS400Authentication.java viewRoot UIViewRoot; //used for JSF Component Tree access Function onPageLoad() //syslib.setRemoteUser ("EGL4RPG", "EGL4YOU" ); //Login to the iSeries //iseriesd.dfw.ibm.com End function authenticate() rc int; //Return code for authentication call forwardLabel string; //Next page //assign the name of your host System i machine (ping-able) address aS400.setSystemName("iseriesd.dfw.ibm.com"); //Call the Java Class through the as400 ExternalType, passing UID/PWD rc = aS400.authenticate(username, password); if (rc == 0) //0 is a bad return code from the System i setError("Invalid User"); else forwardLabel = "NextPage"; forward to forwardLabel; //You are logged in end externalType AS400Authentication type JavaObject {JavaName = "AS400Authentication", PackageName = "as400Security"} static function setSystemName (systemName string in); static function authenticate (username string in, password string in) returns (int);

5  System I Login Resources – Login Page – JSP Page
From Page Designer: Create a page header (Login Page) Drag an HTML Table on to the page. Make it: 1 row/1 column/100% width From the Table’s properties, Horizontally align the row: Center From Page Data: Drag the UserName and PassWord fields onto the page Make them both input fields Drag the authenticate() function on to the page – where it will become a Submit Button From Page Designer Feel free to change the table’s color (the picture above, uses a custom color: #ddaaaa To add a true password field: Select and delete the default password control From the Enhanced Faces (JSF) Components drawer, drag an: Input – Password control into the table From Page Data, drag and drop the password field on top of the input – Password JSF control // Nov 19, :25:33 AM - EGL V7.0 Migration package jsfhandlers; import com.ibm.egl.jsf.UIViewRoot; handler TestSecurity type JSFHandler {onConstructionFunction = onPageLoad, view = "TestSecurity.jsp", viewRootVar = viewRoot, cancelOnPageTransition = YES} password string; //Logon Password username string; //Logon ID aS400 AS400Authentication; //ExternalType to a Java Class for authentication //Note that the Java Class is: AS400Authentication.java viewRoot UIViewRoot; //used for JSF Component Tree access Function onPageLoad() //syslib.setRemoteUser ("EGL4RPG", "EGL4YOU" ); //Login to the iSeries //iseriesd.dfw.ibm.com End function authenticate() rc int; //Return code for authentication call forwardLabel string; //Next page //assign the name of your host System i machine (ping-able) address aS400.setSystemName("iseriesd.dfw.ibm.com"); //Call the Java Class through the as400 ExternalType, passing UID/PWD rc = aS400.authenticate(username, password); if (rc == 0) //0 is a bad return code from the System i setError("Invalid User"); else forwardLabel = "NextPage"; forward to forwardLabel; //You are logged in end externalType AS400Authentication type JavaObject {JavaName = "AS400Authentication", PackageName = "as400Security"} static function setSystemName (systemName string in); static function authenticate (username string in, password string in) returns (int);

6  System I Login Resources – Next Page
From the \WebContent\ folder, create a new page named: NextPage.jsp Using Page Designer: Add any page heading text, or image you’d like  Here we’ve saved an image from the IBM site into our project (\WebContent\ folder), and dragged it on to the page. From Project Explorer Right-click over TestSecurity.JSP and run the page on the server Userid: EGL4RPG Password: EGL4YOU // Nov 19, :25:33 AM - EGL V7.0 Migration package jsfhandlers; import com.ibm.egl.jsf.UIViewRoot; handler TestSecurity type JSFHandler {onConstructionFunction = onPageLoad, view = "TestSecurity.jsp", viewRootVar = viewRoot, cancelOnPageTransition = YES} password string; //Logon Password username string; //Logon ID aS400 AS400Authentication; //ExternalType to a Java Class for authentication //Note that the Java Class is: AS400Authentication.java viewRoot UIViewRoot; //used for JSF Component Tree access Function onPageLoad() //syslib.setRemoteUser ("EGL4RPG", "EGL4YOU" ); //Login to the iSeries //iseriesd.dfw.ibm.com End function authenticate() rc int; //Return code for authentication call forwardLabel string; //Next page //assign the name of your host System i machine (ping-able) address aS400.setSystemName("iseriesd.dfw.ibm.com"); //Call the Java Class through the as400 ExternalType, passing UID/PWD rc = aS400.authenticate(username, password); if (rc == 0) //0 is a bad return code from the System i setError("Invalid User"); else forwardLabel = "NextPage"; forward to forwardLabel; //You are logged in end externalType AS400Authentication type JavaObject {JavaName = "AS400Authentication", PackageName = "as400Security"} static function setSystemName (systemName string in); static function authenticate (username string in, password string in) returns (int);


Download ppt "System I (AS400) Login You will need to develop Login procedures for your web applications. This short section describes how to do this for System I."

Similar presentations


Ads by Google