Web Sphere Log in
Web Sphere Log in
Web Sphere Log in
Sample part 1
The first part of the sample scenario shows an example for a custom login portlet that
uses the login portlet service as defined for WebSphere Portal V6.0.1. The input form for
the login takes an additional personnel number and stores this value in a
com.ibm.portal.example.PersonnelPrincipal object that is added to the principals of a new
javax.security.auth.Subject object. This subject is then passed to the login triggered with
the portlet login service. The JAAS login module
com.ibm.portal.example.PersonnelLoginModule reads the personnel number information
from the subject and verifies its accuracy. For simplicity, the sample code verifies only
that the personnel number is set and rejects all personnel numbers that start with the digit
1.
If an error occurs during login, the portlet renders the view with the login form again,
additionally displaying the message of the error on the top.
Back to top
Capabilities of the remember me cookie
The remember me feature allows Web applications to identify users who previously logged
in using any means of authentication, for example, a combination of username and
password or a client certificate. To realize this user identification, a manually performed
authentication is not required; instead an HTTP cookie holds the claim of identity. This
remember me cookie is persisted in the client’s Web browser upon an initial successful
login. If the user returns to the Web application later and the Web browser sends along the
cookie, the user is recognized automatically. With WebSphere Portal V6.1, this feature
eventually found its way into portal technology as an capability that is ready to use
without modification.
Scenarios and use cases
Most of the use cases involving a remember me cookie belong to the wide field of
personalization. Based on the user profile that is retrievable after a user has been
identified, the previously anonymous public portal area can be transformed into an
individual-centric starting point for navigating the portal site. To users the portal site can
be much more appealing than it has ever been.
Thereby, the opportunities go beyond a personal greeting on a welcome page: The
language of the portal site can be switched to the user’s preferred language instantly
upon the first access, or a password retrieval function could employ the email address
stored in the user profile. Moreover, information presented to the user can depend on the
user’s interests or department affiliation.
Extensions to the login portlet service
As described earlier, the public login portlet service lets you implement custom login
portlets that on their part trigger the user login to WebSphere Portal. In WebSphere Portal
V6.1, additions to this service take the new remember me cookie capabilities into account.
In particular, two constants have been added to the interface
com.ibm.portal.portlet.service.login.LoginService:
• DO_SET_REMEMBER_ME_COOKIE to indicate whether a remember me cookie is issued
for the requesting user if the login is successful
• DO_DELETE_REMEMBER_ME_COOKIE to indicate whether the remember me cookie is
revoked for the requesting user if the login is successful
Both DO_SET_REMEMBER_ME_COOKIE and DO_DELETE_REMEMBER_ME_COOKIE are to be
used as keys to store a java.lang.Boolean object in the portal login context map that is
passed into the login method of the login portlet service. These context parameters are
optional, and the default behavior of the default portal login logic is not to perform any
action; that is, the remember me cookie is neither set nor revoked. Furthermore, the
evaluation of these parameters assumes the activation of the remember me feature (see
also the WebSphere Portal V6.1 Information Center).
In addition, the login portlet service has been enhanced with regard to the methods it
offers. The new method isFormAuthenticated indicates whether the current portal user has
been authenticated using the default login mechanism of WebSphere Portal, which is a
form-based authentication. Used in conjunction with step-up authentication and an
automatic login based on the remember me cookie (see also the WebSphere Portal V6.1
iInformation Center), this method lets you determine whether a login portlet should still
render the login form. The user might have gained access to the protected portal area
because of presenting a valid remember me cookie. In this case, the login form should still
be rendered to allow the user to reach the higher authentication level linked to form-based
authentication.
Using the Puma Service in a public context
Starting with WebSphere Portal V6.1, the com.ibm.portal.um.PumaProfile interface allows
retrieval of a com.ibm.portal.um.User object representing the current user and querying
the current user’s profile attributes in public context. The only assumption made here is
that a remember me cookie is available to identify the requesting user. A user profile can
be obtained by calling the getPumaProfile method exposed by the PumaHome interfaces.
In total, there are three of these interfaces, each one of them serving a different purpose:
• com.ibm.portal.um.portletservice.PumaHome for JSR 168 and JSR 286 portlets
• com.ibm.portal.um.portletservice.legacy.PumaHome for legacy IBM portlets
• com.ibm.portal.um.PumaHome for other application code not related to portlet
programming, for example, custom session validation filter implementations
The code snippet shown in listing 2 illustrates how the current user and the user’s
preferred language can be retrieved by a JSR compliant portlet.
While the provided code can be used in portlets deployed to WebSphere Portal regardless
of the activation of the remember me service, it returns only the user’s preferred language
on public WebSphere Portal pages if the functionality is enabled and if a valid remember
me cookie is encapsulated in the request. That is to say, if the remember me function is
disabled or if the remember me cookie is not present, the current user object as returned
by the PumaHome service is null and user attributes cannot be fetched.
Remember me cookie portlet service
Apart from accessing the user profile of identified but still unauthenticated users in a
public context, it is desirable to allow the user to revoke the remember me cookie. This is
where the com.ibm.portal.portletservice.rememberme.RememberMeCookieService API
comes into play. This service is made available in WebSphere Portal V6.1 to JSR 168 or JSR
286 portlets. After a service object has been acquired, the following methods are
available:
• isRememberMeCookieEnabled. Checks whether the remember me function is
enabled and whether the initialization was successful.
• isCookieSet. Checks whether a remember me cookie is present in the current
request.
• getUserID. Retrieves the ID of the user to which the remember me cookie belongs.
• getInvalidateCookieURL. Generates a URL to revoke the remember me cookie.
The code snippet shown in listing 3 exemplifies how the RememberMeCookieService API
can be employed in portlet code.
The filter chains replace the former LoginUser command, which is still supported but
should no longer be used. The WebSphere Portal default filters now trigger the necessary
logic for the WebSphere Portal login itself. For the implicit login, there is no longer a
redirect operation unless the property redirect.login.authenticated.url of the WP
ConfigService is set or a custom filter explicitly sets a redirect target.
Detailed description of the authentication filter chains
In the following tables, the six filter chains are discussed in detail. For each use case, first
the Java interface is referenced. Then the points of invocations and the overall flow are
described. Finally, some examples of usage scenarios and, where it makes sense,
implementation comments are given for each kind of filter.
Table 1. Explicit login
Interface com.ibm.portal.auth.ExplicitLoginFilter
Points of Login by user ID and password either using the login portlet service (which is
invocation also used by the default login portlet) or the login URL.
In case of a successful login, a redirect operation is triggered directly after
Description
the filter chain has been processed completely. If there are exceptions
of overall
during the login, these are either passed to the login portlet service or, when
flow
using the login URL, the portal gives an HTTP error.
• Perform additional operations before the portal login (for example, a
check if a user has accepted the terms of conditions), with the option
not to trigger the next element in the chain to quit the login
Usage • Set dynamic redirect targets after successful login
scenarios • Perform additional operations after the portal login (for example,
logging)
• Catch and handle or transform exceptions thrown by the portal login
or subsequent filters
Table 2. Implicit login
Interface com.ibm.portal.auth.ImplicitLoginFilter
At the beginning of WebSphere Portal request processing, before calling
Points of the preprocessors, handling the actions, and rendering the page, when the
invocation user already has received a security context by the WebSphere
Application Server, but is not yet logged in to WebSphere Portal.
Description of In case of a successful WebSphere Portal login, the request processing
overall flow continues using the correct portal user context of the user that has been
just logged in. A redirect operation is triggered only if the property
redirect.login.authenticated.url of the WP ConfigService is set or a custom
filter explicitly sets a redirect URL. If there are exceptions during the login,
the portal gives an HTTP error.
• Perform additional operations before or after the implicit portal
Usage login (for example, to check particular conditions, set additional
scenarios context information or provide custom logging).
• Set dynamic redirect targets after successful login.
Inside a filter for the implicit login, the user to be logged in can be
retrieved using the PUMA API without context information
Implementati (com.ibm.portal.um.PumaHome.getProfile()).
on comments
To quit the implicit login, implementations must throw an exception, it is
not sufficient not to call the next element in the filter chain.
Conclusion
With version 6.0.1, the openness of WebSphere Portal in regards to user login
customizations was brought forward with the introduction of the public login portlet
service. As the sample provided with this article demonstrates, custom login portlets can
employ this service to trigger a form-based user login to WebSphere Portal.
Starting with WebSphere Portal V6.1, more sophisticated authentication and session
handling scenarios can be realized as a filter chain API named Authentication Filters has
been made publicly available. Filter implementations can be plugged into the WebSphere
Portal login, logout, request validation, and session timeout flow; hence, a new level of
customizations of the WebSphere Portal security processing is available. At the same time,
this filter infrastructure replaces customizations to login or logout based on commands
that had been published in a technote for earlier WebSphere Portal versions.
The sample comprises several custom authentication filters. It is complemented by a
demonstration of the capabilities of the public API that leverages the remember me
capability, combining state-of-the-art user identification techniques with portal technology.
The public login portlet service and the public Puma API have been extended to allow for
this new function in WebSphere Portal V6.1. Additionally, the remember me cookie portlet
service, whose usage is exemplified in the sample, provides further access to functions
related to this particular feature.