com.caucho.server.security
Class DigestLogin

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

public class DigestLogin
extends AbstractLogin

Implements the "digest" 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
DigestLogin()
           
 
Method Summary
 java.security.Principal authenticate(HttpServletRequest request, HttpServletResponse response, ServletContext application)
          Logs a user in with a user name and a password.
protected  byte[] decodeDigest(java.lang.String digest)
           
 java.lang.String getAuthType()
          Returns the authentication type.
protected  java.security.Principal getDigestPrincipal(HttpServletRequest request, HttpServletResponse response, ServletContext application)
          Returns the principal from a basic authentication
protected  long getRandomLong(ServletContext application)
           
 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  java.lang.String scanKey(CharCursor cursor)
           
protected  java.lang.String scanValue(CharCursor cursor)
           
protected  void sendDigestChallenge(HttpServletResponse res, ServletContext application)
          Sends a challenge for basic authentication.
 void setRealmName(java.lang.String realm)
          Sets the login realm.
protected  void skipWhitespace(CharCursor cursor)
           
 
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

DigestLogin

public DigestLogin()
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

sendDigestChallenge

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

Throws:
ServletException
java.io.IOException

getRandomLong

protected long getRandomLong(ServletContext application)

getDigestPrincipal

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

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

decodeDigest

protected byte[] decodeDigest(java.lang.String digest)

scanKey

protected java.lang.String scanKey(CharCursor cursor)
                            throws ServletException
Throws:
ServletException

scanValue

protected java.lang.String scanValue(CharCursor cursor)
                              throws ServletException
Throws:
ServletException

skipWhitespace

protected void skipWhitespace(CharCursor cursor)