Skip to main content  
        iSeries home   |   Easy400     |   CGIDEV2  
Freeware
 
Introduction
LogInOut approach
Defining users
Application develpment
Appendix A - Installation
Appendix B - LOGINOUT service program
Appendix C - HTTP-based login technique
 
Download
 
 

 
Application development


The session login/logout prototype available in library LOGINOUT can be used in CGI applications of your own.

However, you must not try to customize to your needs the contents of library LOGINOUT.
Never change the contents of library LOGINOUT (unless you need to install a refresh of this library).
Library LOGINOUT provides command SETLIB for populating your your development libraries with the appropriate tools.

Topics in this page
1. Command LOGINOUT/SETLIB
2. Command object_library/HTTPCFG
3. Maintaining the validation list object_library/LOGINOUT
4. Developing the session logon CGI program
5. Developing the other CGI programs

 

1. Command LOGINOUT/SETLIB
Use this command to populate your development libraries with the tools available from library LOGINOUT:
Figure D1
Figure D1 - Command LOGINOUT/SETLIB

  • Source library
    This must be the name of your application development library containing the source files (for instance QCLSRC, QRPGLESRC, etc.).
  • Object library
    This is the name of your application library containing the executable objects (programs, data areas, etc.).
Note 1. If the application is made of just one library containing both the source files and the executable objects, enter its name in the first parameter and leave *SRCLIB in the second parameter.
Note 2. The libraries mentioned in this command may not yet exist. If they are not found, they are automatically created.
Note 3. In case some of the generated objects is accidentally deleted, you may rerun this command. Only the missing objects will be regenerated.

The following objects are generated in the source library:
ObjectTypeAttribute
QRPGLESRC*FILEPF
LOGINOUT*BNDDIR 
Figure D2 - Objects generated in the source library

The following members are generated in source file QRPGLESRC of the source library:
MemberTypeText
HSPECSRPGLE/copy: H specifications
HSPECSBNDRPGLE/copy: H specification for binding directories
HTTPCFGRPGLEAdd HTTP directives
PROTOTYPEBRPGLE/copy: Function prototypes test
SAMPLEPAG1RPGLECGI- Sample application- Page 1
SAMPLEPAG2RPGLECGI- Sample application- Page 2
USECRPGLE/copy: Our version of qusec data structure
VARIABLES3RPGLEVariables common to ILE-RPG CGI programs
WRKVLDLRPGLECGI- Maintain validation list LOGINOUT
XPROTOTYPERPGLESRVPGM- Subprocedure prototypes
Figure D3 - Members added to source file QRPGLESRC in the source library

The following objects are generated in the object library:
ObjectTypeAttributeDescription
HTTPCFG*PGMRPGLEAdd HTTP directives
SAMPLEPAG1*PGMRPGLECGI- Sample application- Page 1
SAMPLEPAG2*PGMRPGLECGI- Sample application- Page 2
WRKVLDL*PGMRPGLECGI- Maintain validation list
CGISRVPGM2*SRVPGMRPGLE
LOGINOUT*SRVPGM
LOGINOUT*VLDL
APACHECONF*FILEPF
HTTPCFG*FILEDSPFInstall HTTP configuration
MBRLIST*FILEPFOutput file for DSPFD TYPE(*MBRLIST)
QATMHINSTC*FILEPFCUSTOMER Instance physical file
QATMHTTPC*FILEPFHTTP SERVER CONFIGURATION
HTTPCFG*CMDAdd HTTP directives
Figure D4 - Objects generated in the object library

An IFS directory with the same name as the object library is generated:
Directory . . . . : /object_library
cssDIR
graphicsDIR
htmlDIR
Directory . . . . : /object_library/html
sampleExpired.htmSTMF
samplePag1.htmSTMF
samplePag2.htmSTMF
wrkvldl.htmSTMF
Figure D5 - Generated IFS directory and subdirectories

SOME REMARKS ON THE GENERATED OBJECTS

  • service programs
    Two service programs are duplicated in the object library:
    • CGISRVPGM2
      This is the CGIDEV2 service program used to implement ILE-RPG CGI programs.
    • LOGINOUT
      This is the service program for the LogInOut session approach documented in a separate page. It contains subprocedures supporting the LogInOut session approach.
    Binding directory LOGINOUT in the source library (see Figure D2) contains entries for both these service programs and is mentioned in /COPY member HSPECSBND of QRPGLESRC.
  • Generated IFS directory and subdirectories (see Figure D5)
    Stream files in subdirectories /.../html and /.../css are related to the external HTML for the object_library CGI programs WRKVLDL, SAMPLEPAG1 and SAMPLEPAG2.
  • HTTP directives
    HTTP directives allowing execution of the object_library CGI programs are available in files QATMHTTPC ("Original" HTTP) and APACHECONF ("Apache" HTTP) of the object_library. These HTTP directives are installed through command object_library/HTTPCFG.
  • /COPY statements for CGI programs
    A number of source members in QRPGLESRC ((see Figure D3) must be included in ILE-RPG CGI programs to enable use of subprocedures from service programs CGIDEV2 and LOGINOUT:
    /copy source_library/qrpglesrc,hspecs    
    /copy source_library/qrpglesrc,hspecsbnd
    ... File spec.s ... 
    /copy source_library/qrpglesrc,prototypeb
    /copy source_library/qrpglesrc,xprototype
    /copy source_library/qrpglesrc,usec      
    /copy source_library/qrpglesrc,variables3
    
    Figure D6 - /COPY statements in ILE-RPG CGI program sources
    (replace "source_library" with the actual name of your source library)

2. Command object_library/HTTPCFG
Command object_library/HTTPCFG (generated in your application object library by command LOGINOUT/SETLIB) provides a convenient way for installing the HTTP directives needed to run the CGI programs in your object_library.

Enter this command from a green-screen workstation.

  1. If your OS release is before V5R3, you are asked to choose between Original and Apache directives.
    If your OS release is after V5R2, you have no choice, as only Apache directives are accepted, and you come directly to step ii).
  2. You receive a list of the available HTTP instances.
    You must select the HTTP instance to be added the new HTTP directives. Before making the choice, make sure that the user profile you are using is authorized to change the related HTTP configuration file. If you take chances, you may receive a message telling that you are not authorized to.
  3. The update of the configuration file takes place. Following this, you are displayed the updated HTTP instance configuration file. If the result looks correct, then you may restart the HTTP instance.

3. Maintaining the validation list object_library/LOGINOUT
As explained in the "LogInOut approach", you need a validation list to support user login validation. This validation list is in your object library and is named LOGINOUT.
You will need to add at least an entry (one username/password) to test the login / logout process for your application.
If you have installed the HTTP directives for your application (see Command object_library/HTTPCFG), you may use for that the validation list utility - CGI program WRKVLDL - generated in your object_library. To run this utility from the browser, use the URL

http://.../xxxp/wrkvldl.pgm

where
  • "..." should be replaced by the IP address of your iSeries
  • "xxx" should be replaced by the name of your object_library.
This utility behaves exactly as the one for library LOGINOUT, but it operates on the validation list in your object_library.

4. Developing the session logon CGI program
In your object_library you already have a session logon CGI program, that operates on validation list LOGINOUT in your object_library.
This is program object_library/SAMPLEPAG1 and looks exactly as the one for library LOGINOUT.
In case you want to re-style it to match your presentation standards and to add some logic, please note the following:

  1. It works on a single external HTML stream file:
    1. /object_library/html/samplePag1.htm
      This is the one that you may want to modify to match your presentation standards
  2. The program source is in your_source_library/QRPGLESRC member SAMPLEPAG1.

5. Developing the other CGI programs
CGI program SAMPLEPAG2 in your object_library is a prototype for any other (than the login program) CGI program you need to implement in your application.

  1. This prototype works on two external HTML stream files:
    1. /object_library/html/samplePag2.htm
      Instead of using this script, your application program will use the one that you will design and develop for it.
    2. /object_library/html/sampleExpired.htm
      This must be used by all CGI programs in your application. It is needed to force logout whenever the CGI programs detects that the user validation has failed.
  2. The program source of this prototype is in your_source_library/QRPGLESRC member SAMPLEPAG2.
    A few comments on its structure:
    1. External HTML.
      Always use multiple stream files, as it is now. Stream file /object_library/html/sampleExpired.htm should always be kept, as it is needed by the user validation process.
      0048.00 C                   eval      extHtml='/'+%trim(objlib)+               
      0049.00 C                             '/html/SAMPLEPAG2.htm /' +               
      0050.00 C                             %trim(objlib) +                          
      0051.00 C                             '/html/SAMPLEEXPIRED.htm'                
      0052.00  * Load external html                                                  
      0053.00 C                   eval      IfsMultIndicators = getHtmlIfsMult(      
      0054.00 C                             %trim(exthtml):'')
      Never take off the statements in lines 50-51.
    2. User validation process.
      Never change it.
      0061.00  * Validate user name and password through the validation list loginout
      0062.00 C                   eval      rc=chkUsrID(xVldl:xname:xpwd)            
      0063.00  * If validation successful,                                           
      0064.00  *  - continue by displaying the user name                             
      0065.00 C                   IF        rc=0                                     
      0066.00 C                   callp     updhtmlvar('user':xname)                 
      0067.00  *  - perform application logic                                        
      0068.00 C                   exsr      AppLogic                                 
      0069.00 C                   ENDIF                                              
      0070.00  * If validation failed,                                               
      0071.00  *  send out a page that fetches the logon page                        
      0072.00 C                   if        rc<>0                                    
      0073.00 C                   callp     wrtsection('expired')                    
      0074.00 C                   endif                                              
      0075.00  *                                                                     
      0076.00 C                   exsr      Exit
      Start your application logic from subroutine "AppLogic" (see statement 68).



    Contact