org.exoplatform.services.security.sso.spnego
Class ServletSpnegoHandler

java.lang.Object
  extended by org.exoplatform.services.security.sso.spnego.SpnegoHandler
      extended by org.exoplatform.services.security.sso.spnego.ServletSpnegoHandler

public class ServletSpnegoHandler
extends SpnegoHandler

Servlet specialisation of SpnegoHandler that introduces the Base64 encoding and transportation of WWW-Authenticate and Authroization headers.

Author:
Martin Algesten

Nested Class Summary
 
Nested classes/interfaces inherited from class org.exoplatform.services.security.sso.spnego.SpnegoHandler
SpnegoHandler.State
 
Constructor Summary
ServletSpnegoHandler()
           
 
Method Summary
 void authenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Method that will in order do: Inspect the current state of the handler.
 String authenticate(String challenge)
          Expects "Negotiate <base64 token>" input and returns the same kind of output.
 
Methods inherited from class org.exoplatform.services.security.sso.spnego.SpnegoHandler
authenticate, constructResponse, getGSSContext, getState, isComplete, isEstablished, isFailed, setUnauthorized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletSpnegoHandler

public ServletSpnegoHandler()
Method Detail

authenticate

public String authenticate(String challenge)
Expects "Negotiate <base64 token>" input and returns the same kind of output. It will decode and send the base64 encoded data to SpnegoHandler.authenticate(byte[]).

Parameters:
challenge - The challenge string from client such as "Negotiate ab3qfd32..."
Returns:
Null if SpnegoHandler.authenticate(byte[]) return null or the encoded result as "Negotiate 8sdf832hdf..."

authenticate

public void authenticate(javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response)
                  throws IOException
Method that will in order do:
  1. Inspect the current state of the handler. If SpnegoHandler.isComplete() is true it will return imediatelly and do nothing more.
  2. Check if the client has supplied any "Authorization" header, and if so and the header starts "Negotiate", it will try to call authenticate(String) using the value of the header. Otherwise it will call authenticate(String) with a null value to start the authentication.
  3. If the authenticate(String) method return a non-null result this will be set as a header "WWW-Authenticate" in the response.
  4. If SpnegoHandler.isEstablished() is not true, it will finally call response.sendError(401).

Parameters:
request - the request object to check for headers.
response - the response object ot set headers and perhaps do a sendError(401) on.
Throws:
IOException - from the servlet api.


Copyright © 2009 eXo Platform SAS. All Rights Reserved.