com.caucho.server.security
Class BasicLogin

java.lang.Object
  extended by com.caucho.server.security.AbstractLogin
      extended by com.caucho.server.security.BasicLogin
All Implemented Interfaces:
LoginFilter

public class BasicLogin
extends AbstractLogin

Implements the "basic" auth-method. Basic uses the HTTP authentication with WWW-Authenticate and SC_UNAUTHORIZE.


Field Summary
protected  java.lang.String _realm
           
 
Fields inherited from class com.caucho.server.security.AbstractLogin
_auth, log
 
Constructor Summary
BasicLogin()
           
 
Method Summary
 java.security.Principal authenticate(HttpServletRequest request, HttpServletResponse response, ServletContext application)
          Logs a user in with a user name and a password.
 java.lang.String getAuthType()
          Returns the authentication type.
protected  java.security.Principal getBasicPrincipal(HttpServletRequest request, HttpServletResponse response, ServletContext application)
          Returns the principal from a basic authentication
 java.lang.String getRealmName()
          Gets the realm.
 java.security.Principal getUserPrincipal(HttpServletRequest request, HttpServletResponse response, ServletContext application)
          Returns the current user with the user name and password.
protected  void sendBasicChallenge(HttpServletResponse res)
          Sends a challenge for basic authentication.
 void setRealmName(java.lang.String realm)
          Sets the login realm.
 
Methods inherited from class com.caucho.server.security.AbstractLogin
getAuthenticator, init, isUserInRole, logout, setAuthenticator, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_realm

protected java.lang.String _realm
Constructor Detail

BasicLogin

public BasicLogin()
Method Detail

setRealmName

public void setRealmName(java.lang.String realm)
Sets the login realm.


getRealmName

public java.lang.String getRealmName()
Gets the realm.


getAuthType

public java.lang.String getAuthType()
Returns the authentication type.

Overrides:
getAuthType in class AbstractLogin

authenticate

public java.security.Principal authenticate(HttpServletRequest request,
                                            HttpServletResponse response,
                                            ServletContext application)
                                     throws ServletException,
                                            java.io.IOException
Logs a user in with a user name and a password. Basic authentication extracts the user and password from the authorization header. If the user/password is missing, authenticate will send a basic challenge.

Overrides:
authenticate in class AbstractLogin
Parameters:
request - servlet request
response - servlet response, in case any cookie need sending.
application - servlet application
Returns:
the logged in principal on success, null on failure.
Throws:
ServletException
java.io.IOException

getUserPrincipal

public java.security.Principal getUserPrincipal(HttpServletRequest request,
                                                HttpServletResponse response,
                                                ServletContext application)
                                         throws ServletException
Returns the current user with the user name and password.

Overrides:
getUserPrincipal in class AbstractLogin
Parameters:
request - servlet request
response - servlet response, in case any cookie need sending.
application - servlet application
Returns:
the logged in principal on success, null on failure.
Throws:
ServletException

sendBasicChallenge

protected void sendBasicChallenge(HttpServletResponse res)
                           throws ServletException,
                                  java.io.IOException
Sends a challenge for basic authentication.

Throws:
ServletException
java.io.IOException

getBasicPrincipal

protected java.security.Principal getBasicPrincipal(HttpServletRequest request,
                                                    HttpServletResponse response,
                                                    ServletContext application)
                                             throws ServletException
Returns the principal from a basic authentication

Parameters:
auth - the authenticator for this application.
Throws:
ServletException