+

Search Tips   |   Advanced Search

Programmatic login for JAAS

Programmatic login supports application presentation site-specific login forms. When enterprise bean client applications require the user to provide identifying information, the writer of the application must collect that information and authenticate the user.

Users of web applications can receive prompts for authentication data in many ways. The <login-config> element in the web application deployment descriptor file defines the mechanism used to collect this information. Programmers who want to customize login procedures, rather than relying on general purpose devices like a 401 dialog window in a browser, can use a form-based login to provide an application-specific HTML form for collecting login information.

No authentication occurs unless administrative security is enabled. If we want to use form-based login for web applications, specify FORM in the auth-method tag of the <login-config> element in the deployment descriptor of each web application.

Applications can present site-specific login forms using the WebSphere Application Server form-login type. The Java EE specification defines form login as one of the authentication methods for web applications. WAS provides a form-logout mechanism.


Java Authentication and Authorization Service programmatic login

JAAS is a new feature in WAS. It is also mandated by the Java EE 1.4 Specification. JAAS is a collection of strategic authentication API that replace the Common Object Request Broker Architecture (CORBA) (CORBA) programmatic login APIs. WAS provides some extensions to JAAS:

Before beginning developing with programmatic login APIs, consider the following points:


Finding the root cause login exception from a JAAS login

If we get a LoginException exception after issuing the LoginContext.login API, we can find the root cause exception from the configured user registry. In the login modules, the registry exceptions are wrapped by a com.ibm.websphere.security.auth.WSLoginFailedException class. This exception has a getCause method with which we can pull out the exception that was wrapped after issuing the previous command.

We are not always guaranteed to get a WSLoginFailedException exception, but most of the exceptions generated from the user registry display here. The following example illustrates a LoginContext.login API with the associated catch block. Cast the WSLoginFailedException exception to com.ibm.websphere.security.auth.WSLoginFailedException class to issue the getCause API.

The following determineCause example can be used for processing CustomUserRegistry exception types.


Finding the root cause login exception from a Servlet filter

We can also receive the root cause exception from a servlet filter when addressing post-form login processing. This exception is useful because it shows the user what happened. You can issue the following API to obtain the root cause exception:

When we have the exception, we can run it through the previous determineCause example to get the native registry root cause.


Enable root cause login exception propagation to pure Java clients

Currently, the root cause does not get propagated to a pure client for security reasons. However, we might want to propagate the root cause to a pure client in a trusted environment. To enable root cause login exception propagation to a pure client, click Security > Global security > Custom Properties on the WAS Administrative Console and set the following property:


Non-prompt programmatic login

WAS provides a non-prompt implementation of the javax.security.auth.callback.CallbackHandler interface, which is called com.ibm.websphere.security.auth.callback.WSCallbackHandlerImpl. Using this interface, an application can push authentication data to the WebSphere LoginModule instance to perform authentication. This capability is useful for server-side application code to authenticate an identity and to use that identity to invoke downstream Java EE resources.

Use the com.ibm.websphere.security.auth.callback.WSCallbackHandlerImpl callback handler with a pure Java client, a client application container, enterprise bean, JavaServer Pages (JSP) files, servlet, or other Java 2 Platform, Enterprise Edition (Java EE) resources.

The WSCallbackHandlerImpl callback handler is different depending on whether we use WAS security or Web Services Security. It is located in the sas.jar file for security, and in the was-wssecurity.jar file for Web Services Security.


User interface prompt programmatic login

WAS also provides a user interface implementation of the javax.security.auth.callback.CallbackHandler implementation to collect authentication data from a user through user interface login prompts. The com.ibm.websphere.security.auth.callback.WSGUICallbackHandlerImpl callback handler presents a user interface login panel to prompt users for authentication data.

(ZOS) (UNIX) Note: This behavior requires an X11 server to be called out by the DISPLAY environment.

Do not use the com.ibm.websphere.security.auth.callback.WSGUICallbackHandlerImpl callback handler for server-side resources like enterprise bean, servlet, JSP files, and so on. The user interface login prompt blocks the server for user input. This behavior is not good for a server process.

WAS also provides a Kerberos credential cache implementation of the javax.security.auth.callback.CallbackHandler interface. The callback handler, com.ibm.websphere.security.auth.callback.WSCcacheCallBackHandlerImpl. Using this interface, an application can push authentication data to the WebSphere LoginModule instance to perform authentication.

This capability is only for the client side application code to authenticate to WebSphere with the Kerberos credential cache.

If the following options exist in the wsjaas_client.conf file, set them to false:

useDefaultKeytab=false
useDefaultCcache=false
tryFirstPass=false
useFirstPass=false
forwardable=false
renewable=false
renewable=false
noaddress=false


WSKRB5Login module

The WSKRB5Login JAAS login configuration: is a generic JAAS login configuration that a Java client, client container application, servlet, JSP file, or enterprise bean can use to perform authentication based on a Kerberos principal name password or a Kerberos credential cache to the WAS security runtime. However, this configuration does not support the CallbackHandler handler specified in the client container deployment descriptor.

Place either the krb5.ini or krb5.conf files we have created in a default location. If either file is not located in the default location set the java.security.krb5.conf JVM system property with the correct path and Kerberos configuration file name.

On a Windows platform, the default location is c:\winnt\krb5.ini.

On a Linux platform, the default location is /etc/krb5.conf.

On other Unix platforms, the default location is /etc/krb5/krb5.conf.

Kerberos configuration settings, the Kerberos key distribution center (KDC) name, and realm settings are provided in the Kerberos configuration file or through java.security.krb5.kdc and java.security.krb5.realm system property files.


Stdin prompt programmatic login

WAS also provides a stdin implementation of the javax.security.auth.callback.CallbackHandler interface. The callback handler, com.ibm.websphere.security.auth.callback.WSStdinCallbackHandlerImpl, prompts and collects authentication data from a user through the stdin prompt.

Do not use the callback hanlder...

...for server-side resources like enterprise beans, servlets, JSP files, and so on. The input from the stdin prompt is not sent to the server environment. Most servers run in the background and do not have a console. However, if the server does have a console, the stdin prompt blocks the server for user input. This behavior is not good for a server process.


Related

  • Developing programmatic logins with the JAAS
  • Developing custom login modules for a system login configuration for JAAS
  • Customize a server-side JAAS authentication and login configuration
  • Getting the caller subject from the thread for JAAS
  • Getting the RunAs subject from the thread for JAAS
  • Overriding the RunAs subject on the thread for JAAS
  • Revoking users from a cache for JAAS






    Last updated: 05/04/2025 13:02:01