!--a11y-->
Advanced Authentication Example 
The portal allows the access to the http request for all custom logon modules during the authentication process. With access to the http request it is possible to read and set cookies or http header values, for example to reject certain namespaces.
In the following chapter we extend the example with an access to the http request.
We extend the LoginModule implementation, described in section Customized Authentication Implementation, that in addition to the password the IP address of the client has to be in a predefined range.
For the further coding, we need the options parameter, which is available in initialize(). We store the options parameter locally.
Extended initialize() method:
Subject _subject = null; _options = options; } |
We extend the existing login() method, because, we still want to check the password. Therefore we create the com.sap.security.demo.DemoLoginModule2, inherit a new LoginModule class from our exsting LoginModule class from section Customized Authentication Implementation and overwrite the method login() method the following way:
Exception on_the_way = null; " is not in range" + ip_range_str); |
The method ip_address_in_range() checks if the IP address of the client is in a given range. Therefore, it first flips all bits in the array iprange_as_byte_array and performs then a logical AND with the IP address. The result of the AND operation is zero, when all bits are in the allowed range.
The method getClientIP() gets the client IP. To get access to the http request object, we call the handle() method with an instance of WebCallback. The handle() method is the interface of the LoginModule to the calling environment and enables the access to the object data. Refer to the JAAS documentation for more details.
private boolean ip_address_ok (byte [] client_ip, |
To use the com.sap.security.demo.DemoLoginModule2 implementation we have to add an authscheme to the authschemes.xml file.
The entry has following format:
<authscheme name="myNewLogon2"> |
The priority of this authentication is higher, because the authentication mechanism is stronger.