public class DefaultEncryptionUtils extends java.lang.Object implements EncryptionUtils
| Modifier and Type | Field and Description |
|---|---|
protected Encryptor |
encryptor |
protected static java.lang.String |
HEADER_ALGORITHM_PARAMETERS |
protected static java.lang.String |
HEADER_MAC |
protected static java.lang.String |
HEADER_TIMESTAMP |
protected java.lang.String |
localIP |
protected static org.apache.commons.logging.Log |
logger |
protected MACUtils |
macUtils |
protected long |
messageTimeout |
protected java.lang.String |
remoteIP |
| Constructor and Description |
|---|
DefaultEncryptionUtils() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
authenticate(byte[] expectedMAC,
MACUtils.MACInput macInput) |
boolean |
authenticate(javax.servlet.http.HttpServletRequest req,
byte[] decryptedBody)
Authenticate the http request: validate the MAC, check that the remote IP is
as expected and that the timestamp is recent.
|
boolean |
authenticateResponse(org.apache.commons.httpclient.HttpMethod method,
java.lang.String remoteIP,
byte[] decryptedBody)
Authenticate the http method response: validate the MAC, check that the remote IP is
as expected and that the timestamp is recent.
|
protected java.security.AlgorithmParameters |
decodeAlgorithmParameters(org.apache.commons.httpclient.HttpMethod method)
Decode cipher algorithm parameters from the HTTP method
|
protected java.security.AlgorithmParameters |
decodeAlgorithmParameters(javax.servlet.http.HttpServletRequest req)
Decode cipher algorithm parameters from the HTTP method
|
byte[] |
decryptBody(javax.servlet.http.HttpServletRequest req)
Decrypt the body of the http request
|
byte[] |
decryptResponseBody(org.apache.commons.httpclient.HttpMethod method)
Decrypt the response body of the http method
|
protected java.lang.String |
getLocalIPAddress()
Get the local registered IP address for authentication purposes
|
protected byte[] |
getMac(javax.servlet.http.HttpServletRequest req)
Get the MAC (Message Authentication Code) on the HTTP request
|
java.lang.String |
getRemoteIP() |
protected byte[] |
getResponseMac(org.apache.commons.httpclient.HttpMethod res)
Get the MAC (Message Authentication Code) on the HTTP response
|
protected java.lang.Long |
getResponseTimestamp(org.apache.commons.httpclient.HttpMethod method)
Get the timestamp on the HTTP response
|
protected java.lang.Long |
getTimestamp(javax.servlet.http.HttpServletRequest method)
Get the timestamp on the HTTP request
|
protected void |
setAlgorithmParameters(javax.servlet.http.HttpServletResponse response,
java.security.AlgorithmParameters params)
Set the algorithm parameters header on the HTTP response
|
void |
setEncryptor(Encryptor encryptor) |
protected void |
setMac(javax.servlet.http.HttpServletResponse response,
byte[] mac)
Set the MAC on the HTTP response
|
void |
setMacUtils(MACUtils macUtils) |
void |
setMessageTimeout(long messageTimeout) |
void |
setRemoteIP(java.lang.String remoteIP) |
void |
setRequestAlgorithmParameters(org.apache.commons.httpclient.HttpMethod method,
java.security.AlgorithmParameters params)
Set the algorithm parameters header on the method request
|
void |
setRequestAuthentication(org.apache.commons.httpclient.HttpMethod method,
byte[] message)
Encrypt the http method request body
|
protected void |
setRequestMac(org.apache.commons.httpclient.HttpMethod method,
byte[] mac) |
protected void |
setRequestTimestamp(org.apache.commons.httpclient.HttpMethod method,
long timestamp)
Set the timestamp on the HTTP request
|
void |
setResponseAuthentication(javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse,
byte[] responseBody,
java.security.AlgorithmParameters params)
Sets authentication headers on the HTTP response.
|
protected void |
setTimestamp(javax.servlet.http.HttpServletResponse res,
long timestamp)
Set the timestamp on the HTTP response
|
protected boolean |
validateTimestamp(long timestamp) |
protected static org.apache.commons.logging.Log logger
protected static java.lang.String HEADER_ALGORITHM_PARAMETERS
protected static java.lang.String HEADER_MAC
protected static java.lang.String HEADER_TIMESTAMP
protected Encryptor encryptor
protected MACUtils macUtils
protected long messageTimeout
protected java.lang.String remoteIP
protected java.lang.String localIP
public java.lang.String getRemoteIP()
public void setRemoteIP(java.lang.String remoteIP)
protected java.lang.String getLocalIPAddress()
public void setMessageTimeout(long messageTimeout)
public void setEncryptor(Encryptor encryptor)
public void setMacUtils(MACUtils macUtils)
protected void setRequestMac(org.apache.commons.httpclient.HttpMethod method,
byte[] mac)
protected void setMac(javax.servlet.http.HttpServletResponse response,
byte[] mac)
response - mac - protected byte[] getMac(javax.servlet.http.HttpServletRequest req)
throws java.io.IOException
req - java.io.IOExceptionprotected byte[] getResponseMac(org.apache.commons.httpclient.HttpMethod res)
throws java.io.IOException
res - java.io.IOExceptionprotected void setRequestTimestamp(org.apache.commons.httpclient.HttpMethod method,
long timestamp)
method - timestamp - (ms, in UNIX time)protected void setTimestamp(javax.servlet.http.HttpServletResponse res,
long timestamp)
res - timestamp - (ms, in UNIX time)protected java.lang.Long getResponseTimestamp(org.apache.commons.httpclient.HttpMethod method)
throws java.io.IOException
method - java.io.IOExceptionprotected java.lang.Long getTimestamp(javax.servlet.http.HttpServletRequest method)
throws java.io.IOException
method - java.io.IOExceptionpublic void setRequestAlgorithmParameters(org.apache.commons.httpclient.HttpMethod method,
java.security.AlgorithmParameters params)
throws java.io.IOException
setRequestAlgorithmParameters in interface EncryptionUtilsjava.io.IOExceptionprotected void setAlgorithmParameters(javax.servlet.http.HttpServletResponse response,
java.security.AlgorithmParameters params)
throws java.io.IOException
response - params - java.io.IOExceptionprotected java.security.AlgorithmParameters decodeAlgorithmParameters(org.apache.commons.httpclient.HttpMethod method)
throws java.io.IOException
method - java.io.IOExceptionprotected java.security.AlgorithmParameters decodeAlgorithmParameters(javax.servlet.http.HttpServletRequest req)
throws java.io.IOException
req - java.io.IOExceptionpublic byte[] decryptResponseBody(org.apache.commons.httpclient.HttpMethod method)
throws java.io.IOException
decryptResponseBody in interface EncryptionUtilsjava.io.IOExceptionpublic byte[] decryptBody(javax.servlet.http.HttpServletRequest req)
throws java.io.IOException
decryptBody in interface EncryptionUtilsjava.io.IOExceptionpublic boolean authenticateResponse(org.apache.commons.httpclient.HttpMethod method,
java.lang.String remoteIP,
byte[] decryptedBody)
authenticateResponse in interface EncryptionUtilspublic boolean authenticate(javax.servlet.http.HttpServletRequest req,
byte[] decryptedBody)
authenticate in interface EncryptionUtilspublic void setRequestAuthentication(org.apache.commons.httpclient.HttpMethod method,
byte[] message)
throws java.io.IOException
setRequestAuthentication in interface EncryptionUtilsjava.io.IOExceptionpublic void setResponseAuthentication(javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse,
byte[] responseBody,
java.security.AlgorithmParameters params)
throws java.io.IOException
setResponseAuthentication in interface EncryptionUtilsjava.io.IOExceptionprotected boolean authenticate(byte[] expectedMAC,
MACUtils.MACInput macInput)
protected boolean validateTimestamp(long timestamp)
Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.