Class FSUtils


  • public class FSUtils
    extends Object
    This class contain constants used in the SDK.
    • 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.ServletException
        Checks 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 - HttpServletRequest instance 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 - HttpServletRequest
        url -
        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 - HttpServletRequest
        response - HttpServletResponse
        url - 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 null for 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:
        IDFFMetaManager instance; or null if it cannot retrieve the instance.
      • getAuthDomainURL

        public static String getAuthDomainURL​(String orgDN)
      • 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