fr.paris.lutece.util.signrequest
Class SimpleHashAuthenticator

java.lang.Object
  extended by fr.paris.lutece.util.signrequest.SimpleHashAuthenticator
All Implemented Interfaces:
RequestAuthenticator

public class SimpleHashAuthenticator
extends java.lang.Object
implements RequestAuthenticator

SimpleHashAuthenticator


Constructor Summary
SimpleHashAuthenticator()
           
 
Method Summary
 void authenticateRequest(org.apache.commons.httpclient.HttpMethodBase method, java.util.List<java.lang.String> elements)
          Authenticate a request
 java.lang.String buildSignature(java.util.List<java.lang.String> listElements, java.lang.String strTimestamp)
          Create a signature
 boolean isRequestAuthenticated(javax.servlet.http.HttpServletRequest request)
          Check the Authentication of a request
protected  boolean isValidTimestamp(java.lang.String strTimestamp)
          This method checks the date of the request
 void setHashService(HashService service)
          Sets the Hash service
 void setPrivateKey(java.lang.String strKey)
          Sets the private key
 void setSignatureElements(java.util.List<java.lang.String> list)
          Sets the list of signature elements
 void setValidityTimePeriod(long lPeriod)
          Sets validity time period (in seconds) between the timestamp in the request and the server timestamp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleHashAuthenticator

public SimpleHashAuthenticator()
Method Detail

setSignatureElements

public void setSignatureElements(java.util.List<java.lang.String> list)
Sets the list of signature elements

Parameters:
list - The list

setHashService

public void setHashService(HashService service)
Sets the Hash service

Parameters:
service - The Hash service

setPrivateKey

public void setPrivateKey(java.lang.String strKey)
Sets the private key

Parameters:
strKey - The private key

setValidityTimePeriod

public void setValidityTimePeriod(long lPeriod)
Sets validity time period (in seconds) between the timestamp in the request and the server timestamp

Parameters:
lPeriod - The validity time period

isRequestAuthenticated

public boolean isRequestAuthenticated(javax.servlet.http.HttpServletRequest request)
Check the Authentication of a request

Specified by:
isRequestAuthenticated in interface RequestAuthenticator
Parameters:
request - The HTTP request
Returns:
true if authenticated, otherwise false

authenticateRequest

public void authenticateRequest(org.apache.commons.httpclient.HttpMethodBase method,
                                java.util.List<java.lang.String> elements)
Authenticate a request

Specified by:
authenticateRequest in interface RequestAuthenticator
Parameters:
method - The HTTP method to authenticate
elements - List of elements to include in the signature

buildSignature

public java.lang.String buildSignature(java.util.List<java.lang.String> listElements,
                                       java.lang.String strTimestamp)
Create a signature

Parameters:
listElements - The list of elements that part of the hash
strTimestamp - The timestamp
Returns:
A signature as an Hexadecimal Hash

isValidTimestamp

protected boolean isValidTimestamp(java.lang.String strTimestamp)
This method checks the date of the request

Parameters:
strTimestamp - The timestamp
Returns:
true if the timestamp is valid, otherwise false


Copyright © 2011 Mairie de Paris. All Rights Reserved.