Sun Java System Application Server Enterprise Edition 8.1 2005Q2 Developer's Guide

- Previous: Granting Programmatic Login Permission
- Next: User Authentication for Single Sign-on

## The ProgrammaticLogin Class

The `com.sun.appserv.security.ProgrammaticLogin` class enables a user to perform login programmatically. This class has four `login` methods, two for servlets or JSP files and two for EJB components.

The login methods for servlets or JSP files have the following signatures:

    public java.lang.Boolean login(String user, String password,
    javax.servlet.http.HttpServletRequest request,
    javax.servlet.http.HttpServletResponse response)

    public java.lang.Boolean login(String user, String password,
    String realm, javax.servlet.http.HttpServletRequest request,
    javax.servlet.http.HttpServletResponse response, boolean errors)
    throws java.lang.Exception

The login methods for EJB components have the following signatures:

    public java.lang.Boolean login(String user, String password)

    public java.lang.Boolean login(String user, String password,
    String realm, boolean errors) throws java.lang.Exception

All of these`login` methods:

- Perform the authentication

- Return `true` if login succeeded, `false` if login failed

The login occurs on the `realm` specified unless it is null, in which case the domain’s default realm is used. The methods with no `realm` parameter use the domain’s default realm.

If the `errors` flag is set to `true`, any exceptions encountered during the logout are propagated to the caller. If set to `false`, exceptions are thrown.

The logout methods for servlets or JSP files have the following signatures:

    public java.lang.Boolean logout(HttpServletRequest request,
    HttpServletResponse response)

    public java.lang.Boolean logout(HttpServletRequest request,
    HttpServletResponse response, boolean errors)
    throws java.lang.Exception

The logout methods for EJB components have the following signatures:

    public java.lang.Boolean logout()

    public java.lang.Boolean logout(boolean errors)
    throws java.lang.Exception

All of these`logout` methods return `true` if logout succeeded, `false` if logout failed.

If the `errors` flag is set to `true`, any exceptions encountered during the logout are propagated to the caller. If set to `false`, exceptions are thrown.

- Previous: Granting Programmatic Login Permission
- Next: User Authentication for Single Sign-on

- © 2010, Oracle Corporation and/or its affiliates