Class FSUtils
- java.lang.Object
-
- com.sun.identity.federation.common.FSUtils
-
public class FSUtils extends Object
This class contain constants used in the SDK.
-
-
Field Summary
Fields Modifier and Type Field Description static ResourceBundlebundlestatic StringBUNDLE_NAMEstatic Debugdebugstatic StringdeploymentURIstatic StringFSID_PREFIXstatic IDFFMetaManagermetaInstancestatic IFSConstantssc
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckHTTPRequestLength(jakarta.servlet.http.HttpServletRequest request)Checks content length of a http request to avoid dos attack.static StringfindPreferredIDP(String realm, jakarta.servlet.http.HttpServletRequest request)Finds the preferred IDP from the HttpServletRequest.static voidforwardRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String url)Forwards or redirects to a new URL.static StringgenerateAssertionHandle()Generates assertion handle.static StringgenerateID()Generates an ID String with length of IFSConstants.ID_LENGTH.static StringgenerateSourceID(String entityID)Generates source ID Stringstatic StringgetAuthDomainURL(String orgDN)static IDFFMetaManagergetIDFFMetaManager()Returns an instance of the IDFF meta manager class.static StringgetlbCookieName()static StringgetlbCookieValue()static ListgetRemoteServiceURLs(jakarta.servlet.http.HttpServletRequest request)Gets remote service URLsstatic booleanisSameContainer(jakarta.servlet.http.HttpServletRequest request, String url)Test if url in argument is in the same web container as current opensso web apps serving the request.static booleanneedSetLBCookieAndRedirect(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, boolean isIDP)Detects if a request simply needs loadbalancer cookies adding and to be redirected to be handled elsewhere.static voidpostToTarget(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String SAMLmessageName, String SAMLmessageValue, String relayStateName, String relayStateValue, String targetURL)static StringremoveNewLineChars(String s)Removes new line characters (useful for Base64 decoding)static booleanrequireAddCookie(jakarta.servlet.http.HttpServletRequest request)static booleanrequireRedirect(jakarta.servlet.http.HttpServletRequest request)static voidsetlbCookie(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)Sets load balancer cookie.static voidsetLocale(String localeName)Sets the locale of the resource bundlestatic StringstringToBase64(String succinctID)Converts a string to Base64 encoded string.
-
-
-
Field Detail
-
deploymentURI
public static String deploymentURI
-
BUNDLE_NAME
public static final String BUNDLE_NAME
- See Also:
- Constant Field Values
-
sc
public static IFSConstants sc
-
bundle
public static ResourceBundle bundle
-
debug
public static Debug debug
-
FSID_PREFIX
public static final String FSID_PREFIX
- See Also:
- Constant Field Values
-
metaInstance
public static IDFFMetaManager metaInstance
-
-
Method Detail
-
setLocale
public static void setLocale(String localeName)
Sets the locale of the resource bundle
-
generateID
public static String generateID()
Generates an ID String with length of IFSConstants.ID_LENGTH.- Returns:
- string the ID String; or null if it fails.
-
generateSourceID
public static String generateSourceID(String entityID)
Generates source ID String- Parameters:
entityID- the entity ID of the source site- Returns:
- source ID
-
generateAssertionHandle
public static String generateAssertionHandle()
Generates assertion handle.- Returns:
- 20-byte random string to be used to form an artifact.
-
stringToBase64
public static String stringToBase64(String succinctID)
Converts a string to Base64 encoded string.- Parameters:
succinctID- provider's succinctID string- Returns:
- Base64 encoded string
-
checkHTTPRequestLength
public static void checkHTTPRequestLength(jakarta.servlet.http.HttpServletRequest request) throws jakarta.servlet.ServletExceptionChecks content length of a http request to avoid dos attack. In case IDFF inter-op with other IDFF vendor who may not provide content length in HttpServletRequest. We decide to support no length restriction for Http communication. Here, we use a special value (e.g. 0) to indicate that no enforcement is required.- Parameters:
request-HttpServletRequestinstance to be checked.- Throws:
jakarta.servlet.ServletException- if context length of the request exceeds maximum content length allowed.
-
isSameContainer
public static boolean isSameContainer(jakarta.servlet.http.HttpServletRequest request, String url)Test if url in argument is in the same web container as current opensso web apps serving the request.- Parameters:
request- HttpServletRequesturl-- Returns:
- true if request and url are in the same web container else false
-
forwardRequest
public static void forwardRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String url)Forwards or redirects to a new URL. This method will do forwarding if the target url is in the same web deployment URI as current web apps. Otherwise will do redirecting.- Parameters:
request- HttpServletRequestresponse- HttpServletResponseurl- the target URL to be forwarded to redirected.
-
findPreferredIDP
public static String findPreferredIDP(String realm, jakarta.servlet.http.HttpServletRequest request)
Finds the preferred IDP from the HttpServletRequest.- Parameters:
realm- The realm under which the entity resides.request- HttpServletRequest.- Returns:
- String preferred IDP entity ID; or
nullfor failure or unable to find in the request.
-
removeNewLineChars
public static String removeNewLineChars(String s)
Removes new line characters (useful for Base64 decoding)- Parameters:
s- String- Returns:
- result String
-
getIDFFMetaManager
public static IDFFMetaManager getIDFFMetaManager()
Returns an instance of the IDFF meta manager class.- Returns:
IDFFMetaManagerinstance; ornullif it cannot retrieve the instance.
-
requireAddCookie
public static boolean requireAddCookie(jakarta.servlet.http.HttpServletRequest request)
-
requireRedirect
public static boolean requireRedirect(jakarta.servlet.http.HttpServletRequest request)
-
needSetLBCookieAndRedirect
public static boolean needSetLBCookieAndRedirect(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, boolean isIDP)Detects if a request simply needs loadbalancer cookies adding and to be redirected to be handled elsewhere.- Parameters:
request- The HTTP request in question.response- The response associated with the request.isIDP- Whether this entity is acting as an IDP.- Returns:
- false if not, otherwise redirects.
-
getRemoteServiceURLs
public static List getRemoteServiceURLs(jakarta.servlet.http.HttpServletRequest request)
Gets remote service URLs- Parameters:
request- http request- Returns:
- remote service URLs
-
setlbCookie
public static void setlbCookie(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)Sets load balancer cookie.- Parameters:
response- HttpServletResponse object
-
getlbCookieName
public static String getlbCookieName()
-
getlbCookieValue
public static String getlbCookieValue()
-
postToTarget
public static void postToTarget(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String SAMLmessageName, String SAMLmessageValue, String relayStateName, String relayStateValue, String targetURL) throws SAML2Exception- Throws:
SAML2Exception
-
-