com.ibm.websphere.samples.techsamp.security.jaas.jaasloginwar
Class JAASLoginServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.ibm.websphere.samples.techsamp.security.jaas.jaasloginwar.JAASLoginServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class JAASLoginServlet
extends javax.servlet.http.HttpServlet

This Servlet performs the server-side JAAS login. If the authentication is successful, it invokes a J2EE role-based protected SampleBean session EJB using the authenticated subject. The servlet retrieves all Principals and public Credentials of the authenticated user, and sends the information to the dspCred.jsp page.

See Also:
Serialized Form

Field Summary
static java.lang.String CONFIG_SEC
           
static java.lang.String CREDENTIALS
           
static java.lang.String DSP_CRED
           
static java.lang.String EJB_MSG
           
static java.lang.String ERR_MSG
           
static java.lang.String JAAS_LOGIN_JNDI
           
static java.lang.String LOGINERROR
           
static java.lang.String PASSWORD
           
static java.lang.String PRINCIPALS
           
static java.lang.String USERNAME
           
 
Constructor Summary
JAASLoginServlet()
           
 
Method Summary
 java.lang.Throwable determineCause(java.lang.Throwable e)
          Method used to drill down into the WSLoginFailedException to find the "root cause" exception from a JAAS login.
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Sends HTTP GET requests to processRequest to do the work.
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Sends HTTP POST requests to processRequest to do the work.
 void init()
          Initializes the servlet.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USERNAME

public static final java.lang.String USERNAME
See Also:
Constant Field Values

PASSWORD

public static final java.lang.String PASSWORD
See Also:
Constant Field Values

JAAS_LOGIN_JNDI

public static final java.lang.String JAAS_LOGIN_JNDI
See Also:
Constant Field Values

DSP_CRED

public static final java.lang.String DSP_CRED
See Also:
Constant Field Values

CONFIG_SEC

public static final java.lang.String CONFIG_SEC
See Also:
Constant Field Values

LOGINERROR

public static final java.lang.String LOGINERROR
See Also:
Constant Field Values

PRINCIPALS

public static final java.lang.String PRINCIPALS
See Also:
Constant Field Values

CREDENTIALS

public static final java.lang.String CREDENTIALS
See Also:
Constant Field Values

EJB_MSG

public static final java.lang.String EJB_MSG
See Also:
Constant Field Values

ERR_MSG

public static final java.lang.String ERR_MSG
See Also:
Constant Field Values
Constructor Detail

JAASLoginServlet

public JAASLoginServlet()
Method Detail

init

public void init()
          throws javax.servlet.ServletException
Initializes the servlet.

Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException - Thrown if the servlet could not be initialized.

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse resp)
           throws javax.servlet.ServletException,
                  java.io.IOException
Sends HTTP GET requests to processRequest to do the work.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
req - an object that encapsulates the request to the servlet.
resp - an object that encapsulates the response from the servlet.
Throws:
javax.servlet.ServletException - This exception is thrown to indicate a servlet problem.
java.io.IOException - Signals that an I/O exception of some sort has occurred.

doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse resp)
            throws javax.servlet.ServletException,
                   java.io.IOException
Sends HTTP POST requests to processRequest to do the work.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
req - an object that encapsulates the request to the servlet.
resp - an object that encapsulates the response from the servlet.
Throws:
javax.servlet.ServletException - This exception is thrown to indicate a servlet problem.
java.io.IOException - Signals that an I/O exception of some sort has occurred.

determineCause

public java.lang.Throwable determineCause(java.lang.Throwable e)
Method used to drill down into the WSLoginFailedException to find the "root cause" exception from a JAAS login.

Parameters:
e - an exception of type LoginException.
Returns:
the root cause login exception.