|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
The IHTTPUtilities interface is a collection of methods that provide additional security related to HTTP requests, responses, sessions, cookies, headers, and logging.
| Method Summary | |
java.lang.String |
addCSRFToken(java.lang.String href)
Adds the current user's CSRF token (see User.getCSRFToken()) to the URL for purposes of preventing CSRF attacks. |
javax.servlet.http.HttpSession |
changeSessionIdentifier()
Invalidate the old session after copying all of its contents to a newly created session with a new session id. |
java.lang.String |
decryptHiddenField(java.lang.String encrypted)
Decrypts an encrypted hidden field value and returns the cleartest. |
java.util.Map |
decryptQueryString(java.lang.String encrypted)
Takes an encrypted querystring and returns a Map containing the original parameters. |
java.util.Map |
decryptStateFromCookie()
Retrieves a map of data from the encrypted cookie. |
void |
enableRememberToken(int maxAge,
java.lang.String domain,
java.lang.String path)
Set a cookie containing the current User's remember token for automatic authentication. |
java.lang.String |
encryptHiddenField(java.lang.String value)
Encrypts a hidden field value for use in HTML. |
java.lang.String |
encryptQueryString(java.lang.String query)
Takes a querystring (i.e. |
void |
encryptStateInCookie(java.util.Map cleartext)
Stores a Map of data in an encrypted cookie. |
java.lang.String |
getCookie(java.lang.String name)
Returns the first cookie matching the given name. |
javax.servlet.http.HttpServletRequest |
getCurrentRequest()
Retrieves the current HttpServletRequest |
javax.servlet.http.HttpServletResponse |
getCurrentResponse()
Retrieves the current HttpServletResponse |
java.util.List |
getSafeFileUploads(java.io.File tempDir,
java.io.File finalDir)
Extract uploaded files from a multipart HTTP requests. |
boolean |
isSecureChannel()
Returns true if the request and response are using an SSL-enabled connection. |
void |
killAllCookies()
Kill all cookies received in the last request from the browser. |
void |
killCookie(java.lang.String name)
Kills the specified cookie by setting a new cookie that expires immediately. |
void |
logHTTPRequest(ILogger logger)
Format the Source IP address, URL, URL parameters, and all form parameters into a string suitable for the log file. |
void |
logHTTPRequest(ILogger logger,
java.util.List parameterNamesToObfuscate)
Format the Source IP address, URL, URL parameters, and all form parameters into a string suitable for the log file. |
void |
safeAddCookie(java.lang.String name,
java.lang.String value,
int maxAge,
java.lang.String domain,
java.lang.String path)
Adds a cookie to the specified HttpServletResponse and adds the Http-Only flag. |
void |
safeAddHeader(java.lang.String name,
java.lang.String value)
Adds a header to an HttpServletResponse after checking for special characters (such as CRLF injection) that could enable attacks like response splitting and other header-based attacks that nobody has thought of yet. |
void |
safeSendForward(java.lang.String context,
java.lang.String location)
This method perform a forward to any resource located inside the WEB-INF directory. |
void |
safeSendRedirect(java.lang.String context,
java.lang.String location)
This method generates a redirect response that can only be used to redirect the browser to safe locations. |
void |
safeSetContentType()
Sets the content type on each HTTP response, to help protect against cross-site scripting attacks and other types of injection into HTML documents. |
void |
safeSetHeader(java.lang.String name,
java.lang.String value)
Sets a header in an HttpServletResponse after checking for special characters (such as CRLF injection) that could enable attacks like response splitting and other header-based attacks that nobody has thought of yet. |
void |
setCurrentHTTP(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Stores the current HttpRequest and HttpResponse so that they may be readily accessed throughout ESAPI (and elsewhere) |
void |
setNoCacheHeaders()
Set headers to protect sensitive information against being cached in the browser. |
void |
verifyCSRFToken()
Checks the CSRF token in the URL (see User.getCSRFToken()) against the user's CSRF token and throws an IntrusionException if it is missing. |
| Method Detail |
public java.lang.String addCSRFToken(java.lang.String href)
public void safeAddCookie(java.lang.String name,
java.lang.String value,
int maxAge,
java.lang.String domain,
java.lang.String path)
name - the namevalue - the valuedomain - the domainpath - the pathmaxAge - the max age
public void safeAddHeader(java.lang.String name,
java.lang.String value)
throws ValidationException
name - the namevalue - the value
ValidationException
public void safeSetHeader(java.lang.String name,
java.lang.String value)
throws ValidationException
name - the namevalue - the value
ValidationException
public javax.servlet.http.HttpSession changeSessionIdentifier()
throws AuthenticationException
EnterpriseSecurityException - the enterprise security exception
AuthenticationException
public void verifyCSRFToken()
throws IntrusionException
IntrusionExceptionpublic java.lang.String decryptHiddenField(java.lang.String encrypted)
encrypted -
public void enableRememberToken(int maxAge,
java.lang.String domain,
java.lang.String path)
maxAge - domain - path -
public java.lang.String encryptHiddenField(java.lang.String value)
throws EncryptionException
value -
EncryptionException
public java.lang.String encryptQueryString(java.lang.String query)
throws EncryptionException
EncryptionException
public java.util.Map decryptQueryString(java.lang.String encrypted)
throws EncryptionException
encrypted -
EncryptionExceptionpublic java.lang.String getCookie(java.lang.String name)
public java.util.List getSafeFileUploads(java.io.File tempDir,
java.io.File finalDir)
throws ValidationException
tempDir - the temp dirfinalDir - the final dir
ValidationException - the validation exception
public java.util.Map decryptStateFromCookie()
throws EncryptionException
EncryptionExceptionpublic boolean isSecureChannel()
public void killAllCookies()
public void killCookie(java.lang.String name)
name - the cookie name
public void encryptStateInCookie(java.util.Map cleartext)
throws EncryptionException
EncryptionException
public void safeSendRedirect(java.lang.String context,
java.lang.String location)
throws java.io.IOException
location - the URL to redirect to
java.io.IOException - Signals that an I/O exception has occurred.
public void safeSendForward(java.lang.String context,
java.lang.String location)
throws AccessControlException,
javax.servlet.ServletException,
java.io.IOException
context - location -
AccessControlException
javax.servlet.ServletException
java.io.IOExceptionpublic void safeSetContentType()
public void setNoCacheHeaders()
Cache-Control: no-storeNote that the header "pragma: no-cache" is only useful in HTTP requests, not HTTP responses. So even though there are many articles recommending the use of this header, it is not helpful for preventing browser caching. For more information, please refer to the relevant standards:
Cache-Control: no-cache
Cache-Control: must-revalidate
Expires: -1
public void setCurrentHTTP(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
request - the current requestresponse - the current responsepublic javax.servlet.http.HttpServletRequest getCurrentRequest()
public javax.servlet.http.HttpServletResponse getCurrentResponse()
public void logHTTPRequest(ILogger logger)
public void logHTTPRequest(ILogger logger,
java.util.List parameterNamesToObfuscate)
parameterNamesToObfuscate - the sensitive params
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||