SunONE Application Server v8.0 PE

com.sun.appserv.security
Class ProgrammaticLogin

java.lang.Object
  extended bycom.sun.appserv.security.ProgrammaticLogin

public class ProgrammaticLogin
extends java.lang.Object

Implement programmatic login.

This class allows deployed applications to supply a name and password directly to the security service. This info will be used to attempt to login to the current realm. If authentication succeeds, a security context is established as this user.

This allows applications to programmatically handle authentication. The use of this mechanism is not recommended since it bypasses the standard J2EE mechanisms and places all burden on the application developer.

Invoking this method requires the permission ProgrammaticLoginPermission with the method name being invoked.

There are two forms of the login method, one which includes the HTTP request and response objects for use by servlets and one which can be used by EJBs.


Constructor Summary
ProgrammaticLogin()
           
 
Method Summary
 java.lang.Boolean login(java.lang.String user, java.lang.String password)
          Attempt to login.
 java.lang.Boolean login(java.lang.String user, java.lang.String password, HttpServletRequest request, HttpServletResponse response)
          Attempt to login.
 java.lang.Boolean login(java.lang.String user, java.lang.String password, java.lang.String realm, boolean errors)
          Attempt to login.
 java.lang.Boolean login(java.lang.String user, java.lang.String password, java.lang.String realm, HttpServletRequest request, HttpServletResponse response, boolean errors)
          Attempt to login.
 java.lang.Boolean logout()
          Attempt to logout.
 java.lang.Boolean logout(boolean errors)
          Attempt to logout.
 java.lang.Boolean logout(HttpServletRequest request, HttpServletResponse response)
          Attempt to logout.
 java.lang.Boolean logout(HttpServletRequest request, HttpServletResponse response, boolean errors)
          Attempt to logout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgrammaticLogin

public ProgrammaticLogin()
Method Detail

login

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

Upon successful return from this method the SecurityContext will be set in the name of the given user as its Subject.

This method is intented primarily for EJBs wishing to do programmatic login. If servlet code used this method the established identity will be propagated to EJB calls but will not be used for web container manager authorization. In general servlets should use the servlet-specific version of login instead.

Parameters:
user - User name.
password - Password for user.
realm - the realm name in which the user should be logged in.
errors - errors=true, propagate any exception encountered to the user errors=false, no exceptions are propagated.
Returns:
Boolean containing true or false to indicate success or failure of login.
Throws:
java.lang.Exception - any exception encountered during Login.

login

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

Upon successful return from this method the SecurityContext will be set in the name of the given user as its Subject.

This method is intented primarily for EJBs wishing to do programmatic login. If servlet code used this method the established identity will be propagated to EJB calls but will not be used for web container manager authorization. In general servlets should use the servlet-specific version of login instead.

Parameters:
user - User name.
password - Password for user.
Returns:
Boolean containing true or false to indicate success or failure of login.

login

public java.lang.Boolean login(java.lang.String user,
                               java.lang.String password,
                               java.lang.String realm,
                               HttpServletRequest request,
                               HttpServletResponse response,
                               boolean errors)
                        throws java.lang.Exception
Attempt to login. This method is specific to servlets (and JSPs).

Upon successful return from this method the SecurityContext will be set in the name of the given user as its Subject. In addition, the principal stored in the request is set to the user name. If a session is available, its principal is also set to the user provided.

Parameters:
realm -
errors -
user - User name.
password - Password for user.
request - HTTP request object provided by caller application. It should be an instance of HttpRequestFacade.
response - HTTP response object provided by called application. It should be an instance of HttpServletResponse.
Returns:
Boolean indicating true for successful login and false otherwise
Throws:
java.lang.Exception - any exceptions encountered during login

login

public java.lang.Boolean login(java.lang.String user,
                               java.lang.String password,
                               HttpServletRequest request,
                               HttpServletResponse response)
Attempt to login. This method is specific to servlets (and JSPs).

Upon successful return from this method the SecurityContext will be set in the name of the given user as its Subject. In addition, the principal stored in the request is set to the user name. If a session is available, its principal is also set to the user provided.

Parameters:
user - User name.
password - Password for user.
request - HTTP request object provided by caller application. It should be an instance of HttpRequestFacade.
response - HTTP response object provided by called application. It should be an instance of HttpServletResponse.
Returns:
Boolean containing true or false to indicate success or failure of login.

logout

public java.lang.Boolean logout()
Attempt to logout.


logout

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

Returns:
Boolean containing true or false to indicate success or failure of logout.
Throws:
java.lang.Exception - encountered while logging out, if errors==false

logout

public java.lang.Boolean logout(HttpServletRequest request,
                                HttpServletResponse response)
Attempt to logout. Also removes principal from request (and session if available).


logout

public java.lang.Boolean logout(HttpServletRequest request,
                                HttpServletResponse response,
                                boolean errors)
                         throws java.lang.Exception
Attempt to logout. Also removes principal from request (and session if available).

Returns:
Boolean containing true or false to indicate success or failure of logout.
Throws:
Exception, - exception encountered while logging out and if errors == true
java.lang.Exception

SunONE Application Server v8.0 PE

Submit a bug or feature

Copyright 2003 Sun Microsystems, Inc. All rights reserved.