!--a11y-->
Customized Authentication
Implementation 
In this section a customized authentication is implemented that will accept a password if it is equal to the user name after a cyclic right-shiftby one character. The comparison is not case sensitive.
The class of the example is called com.sap.security.demo.DemoLoginModule.
The LoginModuleinterface provides the method necessary to implement the customized authentication. In the following we describe the methods that have to be implemented.
This method verifies the password.

The password parameter pwd comes in a character array in compliance with the JAAS standard.
The method is implemented as follows:
/** |
This method is called when the service is initialized, for example when the portal is started.
Subject _subject = null; |

To save resources the portal cannot keep the login context. Therefore the settings are not available in the sharedState map for an entire logon/logoff cycle. A new sharedState map is instantiated before the methods login() or logoff() are called.
This method is called, when the user chooses the Logon button on the logon screen. The login() method gets the username and password. It checks the password and returns true, when the password is correct, or an exception when the password is incorrect.
public boolean login() throws LoginException |
If a LoginException exception is thrown in the method login(), like shown in the example above, the standard logon page of the portal displays the standard error messages for the standard error cases, like user or password incorrect.
To display a specific message on the logon page, a javax.security.auth.login.LoginException with a defined error constant has to be thrown. The error constants are defined as String constants in the core class com.sap.security.core.logon.imp.SecurityPolicy. Since the core class is not part of the published UME API the error codes have to be defined as follows:
public final static String MISSING_UID = "MISSING_UID"; |
This method is called, when the login() method returned true. It provides the identity of the authenticated user.
public boolean commit () |
The user name used to create the Principal object has to be the logon user ID of an existing portal user. The SAP Enterprise Portal will instantiate a com.sap.security.api.IUserobject with the method IUserFactory.getUserByLogonID(String logonuid).
Build a Java Archive (JAR) file that contains the customized authentication implementation and other classes that the implementation needs.
For this example the class files of the com.sap.security.demo.DemoLoginModule implementation is put into the demolm.jar file. The demolm.jar file has to be copied into the folder <j2ee home>/cluster/server/additional-lib.
To register the customized authentication the configuration of the portal has to be changed. See section Configure the Portal for Customized Authentication for more details.