net.sf.jguard.authentication.callbacks
Class HttpCallbackHandler

java.lang.Object
  extended by net.sf.jguard.authentication.callbacks.HttpCallbackHandler
All Implemented Interfaces:
javax.security.auth.callback.CallbackHandler

public class HttpCallbackHandler
extends java.lang.Object
implements javax.security.auth.callback.CallbackHandler

Author:
Charles Gay

Constructor Summary
HttpCallbackHandler()
          constructor required by javadoc of the CallbackHandler interface.
HttpCallbackHandler(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String authScheme)
          constructor.
 
Method Summary
static java.lang.String buildBasicAuthHeader(java.lang.String login, java.lang.String password, java.lang.String encoding)
          construct a header value to simulate a Basic authentication with the provided credentials.
static void buildBasicChallenge(javax.servlet.http.HttpServletResponse response, java.lang.String realmName)
          send to the client the BASIC challenge into the response, according to the RFC 2617.
 void buildDigestChallenge(javax.servlet.http.HttpServletResponse response, java.lang.String token)
          send to the client the DIGEST challenge into the response, according to the RFC 2617.
 javax.servlet.http.HttpServletRequest getHttpRequest()
           
 javax.servlet.http.HttpServletResponse getHttpResponse()
           
static java.lang.String getPasswordField()
           
 void handle(javax.security.auth.callback.Callback[] callbacks)
          extract from the HttpServletRequest client's credentials.
 void setHttpRequest(javax.servlet.http.HttpServletRequest httpRequest)
           
 void setHttpResponse(javax.servlet.http.HttpServletResponse httpResponse)
           
static void setPasswordField(java.lang.String passwordField)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpCallbackHandler

public HttpCallbackHandler()
constructor required by javadoc of the CallbackHandler interface.


HttpCallbackHandler

public HttpCallbackHandler(javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response,
                           java.lang.String authScheme)
constructor.

Parameters:
request -
Method Detail

handle

public void handle(javax.security.auth.callback.Callback[] callbacks)
            throws java.io.IOException,
                   javax.security.auth.callback.UnsupportedCallbackException
extract from the HttpServletRequest client's credentials. if those are not recognised, we put the challenge in the HttpServletResponse.

Specified by:
handle in interface javax.security.auth.callback.CallbackHandler
Throws:
java.io.IOException
javax.security.auth.callback.UnsupportedCallbackException

getHttpRequest

public javax.servlet.http.HttpServletRequest getHttpRequest()

setHttpRequest

public void setHttpRequest(javax.servlet.http.HttpServletRequest httpRequest)

getHttpResponse

public javax.servlet.http.HttpServletResponse getHttpResponse()

setHttpResponse

public void setHttpResponse(javax.servlet.http.HttpServletResponse httpResponse)

buildBasicAuthHeader

public static java.lang.String buildBasicAuthHeader(java.lang.String login,
                                                    java.lang.String password,
                                                    java.lang.String encoding)
construct a header value to simulate a Basic authentication with the provided credentials.

Parameters:
login -
password -
encoding -
Returns:

buildBasicChallenge

public static void buildBasicChallenge(javax.servlet.http.HttpServletResponse response,
                                       java.lang.String realmName)
send to the client the BASIC challenge into the response, according to the RFC 2617.

Parameters:
response - reponse send to the Client
realmName - realm owned by the server => specify what kind of credential the user should provide

buildDigestChallenge

public void buildDigestChallenge(javax.servlet.http.HttpServletResponse response,
                                 java.lang.String token)
send to the client the DIGEST challenge into the response, according to the RFC 2617.

Parameters:
response - reponse send to the Client
realmName - realm owned by the server => specify what kind of credential the user should provide

getPasswordField

public static java.lang.String getPasswordField()

setPasswordField

public static void setPasswordField(java.lang.String passwordField)