Package org.owasp.csrfguard.util
Class CsrfGuardUtils
- java.lang.Object
-
- org.owasp.csrfguard.util.CsrfGuardUtils
-
public final class CsrfGuardUtils extends Object
Various utility methods/helpers.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddResponseTokenHeader(CsrfGuard csrfGuard, javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, TokenTO tokenTO)static <T> Class<T>forName(String origClassName)Returns the class object.static StringhttpProtocolAndDomain(String url, boolean includeProtocol)for a url, get the protocol and domain, e.g.static booleanisAjaxRequest(javax.servlet.http.HttpServletRequest request)static <T> TnewInstance(Class<T> theClass)Construct a classstatic StringnormalizeResourceURI(String resourceURI)static StringnormalizeResourceURI(javax.servlet.http.HttpServletRequest httpServletRequest)static StringreadFileContent(String fileNameWithAbsolutePath)static StringreadInputStreamContent(InputStream inputStream)static StringreadResourceFileContent(String resourceName)
-
-
-
Method Detail
-
httpProtocolAndDomain
public static String httpProtocolAndDomain(String url, boolean includeProtocol)
for a url, get the protocol and domain, e.g. for url https://a.b/path, will return https://a.b- Parameters:
url- a string representing a URLincludeProtocol- whether to include the HTTP or HTTPS protocol in the result- Returns:
- the path with or without the protocol
-
forName
public static <T> Class<T> forName(String origClassName)
Returns the class object.
- Type Parameters:
T- the type of the desired class- Parameters:
origClassName- is fully qualified- Returns:
- the class
-
newInstance
public static <T> T newInstance(Class<T> theClass)
Construct a class- Type Parameters:
T- template type- Parameters:
theClass- the class on which to invoke newInstance()- Returns:
- the instance
-
addResponseTokenHeader
public static void addResponseTokenHeader(CsrfGuard csrfGuard, javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, TokenTO tokenTO)
-
isAjaxRequest
public static boolean isAjaxRequest(javax.servlet.http.HttpServletRequest request)
-
normalizeResourceURI
public static String normalizeResourceURI(javax.servlet.http.HttpServletRequest httpServletRequest)
-
readInputStreamContent
public static String readInputStreamContent(InputStream inputStream)
-
-