Class FSServiceUtils


  • public class FSServiceUtils
    extends Object
    Util class to provide methods to manage ID-FF service.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static String addMetaAlias​(String url, String metaAlias)
      Appends meta alias to the URL.
      static jakarta.xml.soap.SOAPMessage convertDOMToSOAP​(Document doc)
      Converts DOM document to SOAP message.
      static Node createSOAPDOM​(jakarta.xml.soap.SOAPMessage message)
      Converts SOAP message to DOM element.
      static String getAffiliationID​(String realm, String entityID)
      Gets the Affiliation ID for the provider that it belongs.
      static String getAssertionConsumerServiceURL​(com.sun.identity.liberty.ws.meta.jaxb.SPDescriptorType spDescriptor, String id)
      Finds approriate assertion consumer service URL.
      static String getBaseURL()  
      static String getBaseURL​(jakarta.servlet.http.HttpServletRequest request)
      Returns base url of a request.
      static String getCommonLoginPageURL​(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig)
      Returns common login page URL.
      static String getCommonLoginPageURL​(String metaAlias, String resourceUrl, String requestId, jakarta.servlet.http.HttpServletRequest request, String baseURL)
      Returns common login page URL based on the deployment descriptor and the meta alias associated with the hosted provider.
      static String getConsentPageURL​(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig)
      Returns the list of circle of trusts page URL.
      static String getDefaultPageURL​(jakarta.servlet.http.HttpServletRequest request, String pageName)
      Returns default page URL.
      static String getDoFederatePageURL​(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig)
      Returns do federate page URL.
      static String getErrorPageURL​(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)
      Returns error page URL.
      static String getFederationDonePageURL​(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)
      Returns federation done page URL.
      static String getFirstProtocolProfile​(List profiles)
      Returns the first profile from the list.
      static String getLocale​(jakarta.servlet.http.HttpServletRequest request)
      Retrieves locale of a http request.
      static String getLogoutDonePageURL​(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)
      Returns logout done page URL.
      static String getMetaAlias​(jakarta.servlet.http.HttpServletRequest request)
      Retrieves meta alias of a provider from http request.
      static int getMinorVersion​(List protocolEnum)
      Returns the minor version of supported protocol.
      static String getRegistrationDonePageURL​(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)
      Returns registration done page URL.
      static String getServicesBaseURL​(jakarta.servlet.http.HttpServletRequest request)
      Returns the base URL for OpenAM services deployment.
      static FederationSPAdapter getSPAdapter​(String hostEntityID, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostSPConfig)  
      static Map getSPAuthContextInfo​(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostConfig)
      Returns service provider's authentication context mappings.
      static String getTerminationDonePageURL​(jakarta.servlet.http.HttpServletRequest request, com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig, String metaAlias)
      Returns termination done page URL.
      static boolean isLECPProfile​(jakarta.servlet.http.HttpServletRequest request)
      Determines whether the request contains LECP header or not.
      static boolean isRegisProfileSOAP​(String userID, String remoteEntityId, com.sun.identity.liberty.ws.meta.jaxb.SPDescriptorType remoteDescriptor, String metaAlias, com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType hostedDescriptor)
      Determines if the registration profile is SOAP or not.
      static boolean isSigningOn()
      Returns true if signing is enabled; otherwise, it will return false.
      static boolean isSigningOptional()
      Returns true if signing is optional else it will return false.
      static Map parseAttributeConfig​(List list)
      Parses the attribute map configuration and returns as java java.util.Map.
      static String printDocument​(Node root)
      Outputs the DOM representation given as root as XML string.
      static void redirectForAuthentication​(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String hostedProviderAlias)
      Redirects the HTTP request to the Authentication module.
      static void returnLocallyAfterOperation​(jakarta.servlet.http.HttpServletResponse response, String opDoneURL, boolean isSuccess, String successString, String failureString)
      Invoked at the end when an operation is done.
      static void returnToSource​(jakarta.servlet.http.HttpServletResponse response, String retURL, String commonErrorPage, String errorLocaleString, String remarkLocaleString)
      Determines the return location and redirects based on federation termination Return URL of the provider that sent the termination request
      static void showErrorPage​(jakarta.servlet.http.HttpServletResponse response, String commonErrorPage, String errorLocaleString, String remarkLocaleString)
      Displays error page.
    • Method Detail

      • isSigningOn

        public static boolean isSigningOn()
        Returns true if signing is enabled; otherwise, it will return false. If signing is enabled, all the liberty requests/responses must be signed/verfied.
        Returns:
        true if signing is on; otherwise, return false
      • isSigningOptional

        public static boolean isSigningOptional()
        Returns true if signing is optional else it will return false. If signing is optional, sign/verfy Response/Assertion only if it is required by the specification.
        Returns:
        true if signing is optional; otherwise return false
      • getCommonLoginPageURL

        public static String getCommonLoginPageURL​(String metaAlias,
                                                   String resourceUrl,
                                                   String requestId,
                                                   jakarta.servlet.http.HttpServletRequest request,
                                                   String baseURL)
        Returns common login page URL based on the deployment descriptor and the meta alias associated with the hosted provider.
        Parameters:
        metaAlias - the meta alias of the hosted provider
        resourceUrl - resource URL to redirect to
        requestId - the AuthnRequest Id
        request - HttpServletRequest object
        baseURL - deployment base URL
        Returns:
        the common login page URL; or null if an error occurred during the process.
      • getBaseURL

        public static String getBaseURL()
      • getMetaAlias

        public static String getMetaAlias​(jakarta.servlet.http.HttpServletRequest request)
        Retrieves meta alias of a provider from http request.
        Parameters:
        request - HttpServletRequest object
        Returns:
        meta alias of a provider embeded in the request url
      • getLocale

        public static String getLocale​(jakarta.servlet.http.HttpServletRequest request)
        Retrieves locale of a http request.
        Parameters:
        request - HttpServletRequest object
        Returns:
        locale of the request; or null if locale cannot be retrieved.
      • getServicesBaseURL

        public static String getServicesBaseURL​(jakarta.servlet.http.HttpServletRequest request)
        Returns the base URL for OpenAM services deployment.
        Parameters:
        request - HttpServletRequest
        Returns:
        service base url
      • getBaseURL

        public static String getBaseURL​(jakarta.servlet.http.HttpServletRequest request)
        Returns base url of a request.
        Parameters:
        request - HttpServletRequest object
        Returns:
        base url
      • createSOAPDOM

        public static Node createSOAPDOM​(jakarta.xml.soap.SOAPMessage message)
        Converts SOAP message to DOM element.
        Parameters:
        message - SOAP message
        Returns:
        DOM element
      • convertDOMToSOAP

        public static jakarta.xml.soap.SOAPMessage convertDOMToSOAP​(Document doc)
        Converts DOM document to SOAP message.
        Parameters:
        doc - DOM document
        Returns:
        SOAP message
      • isLECPProfile

        public static boolean isLECPProfile​(jakarta.servlet.http.HttpServletRequest request)
        Determines whether the request contains LECP header or not.
        Parameters:
        request - HttpServletRequest object
        Returns:
        true if the request contains LECP header; false otherwise.
      • getAffiliationID

        public static String getAffiliationID​(String realm,
                                              String entityID)
        Gets the Affiliation ID for the provider that it belongs.
        Parameters:
        realm - The realm under which the entity resides.
        entityID - provider's entity ID.
        Returns:
        Affiliation ID.
      • parseAttributeConfig

        public static Map parseAttributeConfig​(List list)
        Parses the attribute map configuration and returns as java java.util.Map.
        Parameters:
        list - attribute configuration.
        Returns:
        configured attribute mapping with key as the SAML attribute and the value being the local attribute.
      • showErrorPage

        public static void showErrorPage​(jakarta.servlet.http.HttpServletResponse response,
                                         String commonErrorPage,
                                         String errorLocaleString,
                                         String remarkLocaleString)
        Displays error page.
        Parameters:
        response - HttpServletResponse object
        commonErrorPage - redirect url for error page
        errorLocaleString - locale string for the error message
        remarkLocaleString - locale string for the error remark
      • redirectForAuthentication

        public static void redirectForAuthentication​(jakarta.servlet.http.HttpServletRequest request,
                                                     jakarta.servlet.http.HttpServletResponse response,
                                                     String hostedProviderAlias)
                                              throws IOException
        Redirects the HTTP request to the Authentication module. The authentication URL is built based on the organization that is associated with the provider
        Parameters:
        request - HttpServletRequest object that contains the request the client has made of the servlet.
        response - HttpServletResponse object that contains the response the servlet sends to the client.
        hostedProviderAlias - meta alias that identifies the local hosted provider
        Throws:
        IOException - If an input or output exception occurs
      • returnLocallyAfterOperation

        public static void returnLocallyAfterOperation​(jakarta.servlet.http.HttpServletResponse response,
                                                       String opDoneURL,
                                                       boolean isSuccess,
                                                       String successString,
                                                       String failureString)
        Invoked at the end when an operation is done. The isSuccess determines if success message or failure message is displayed.
        Parameters:
        response - the HttpServletResponse object
        opDoneURL - where to go when an operation is done
        isSuccess - determines the content of the operation-done.jsp
        successString - success string to be appended to url if isSuccess is true.
        failureString - failure string to be appended to url if isSuccess is false.
      • returnToSource

        public static void returnToSource​(jakarta.servlet.http.HttpServletResponse response,
                                          String retURL,
                                          String commonErrorPage,
                                          String errorLocaleString,
                                          String remarkLocaleString)
        Determines the return location and redirects based on federation termination Return URL of the provider that sent the termination request
        Parameters:
        response - http response object
        retURL - operation return url
        commonErrorPage - where to go if error occurs
        errorLocaleString - locale string for federation error
        remarkLocaleString - locale string for federation remark
      • getConsentPageURL

        public static String getConsentPageURL​(jakarta.servlet.http.HttpServletRequest request,
                                               com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig)
        Returns the list of circle of trusts page URL.
        Parameters:
        request - HttpServletRequest object
        hostedConfig - hosted provider's extended meta
        Returns:
        the list of circle of trusts page URL.
      • getCommonLoginPageURL

        public static String getCommonLoginPageURL​(jakarta.servlet.http.HttpServletRequest request,
                                                   com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig)
        Returns common login page URL.
        Parameters:
        request - HttpServletRequest object
        hostedConfig - hosted provider's extended meta
        Returns:
        common login page URL.
      • getErrorPageURL

        public static String getErrorPageURL​(jakarta.servlet.http.HttpServletRequest request,
                                             com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig,
                                             String metaAlias)
        Returns error page URL.
        Parameters:
        request - HttpServletRequest object
        hostedConfig - hosted provider's extended meta
        metaAlias - hosted provider's meta alias
        Returns:
        error page URL.
      • getTerminationDonePageURL

        public static String getTerminationDonePageURL​(jakarta.servlet.http.HttpServletRequest request,
                                                       com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig,
                                                       String metaAlias)
        Returns termination done page URL.
        Parameters:
        request - HttpServletRequest object
        hostedConfig - hosted provider's extended meta
        metaAlias - hosted provider's meta alias
        Returns:
        termination done page URL.
      • getRegistrationDonePageURL

        public static String getRegistrationDonePageURL​(jakarta.servlet.http.HttpServletRequest request,
                                                        com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig,
                                                        String metaAlias)
        Returns registration done page URL.
        Parameters:
        request - HttpServletRequest object
        hostedConfig - hosted provider's extended meta
        metaAlias - hosted provider's meta alias
        Returns:
        registration done page URL.
      • getLogoutDonePageURL

        public static String getLogoutDonePageURL​(jakarta.servlet.http.HttpServletRequest request,
                                                  com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig,
                                                  String metaAlias)
        Returns logout done page URL.
        Parameters:
        request - HttpServletRequest object
        hostedConfig - hosted provider's extended meta
        metaAlias - hosted provider's meta alias
        Returns:
        logout done page URL.
      • getFederationDonePageURL

        public static String getFederationDonePageURL​(jakarta.servlet.http.HttpServletRequest request,
                                                      com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig,
                                                      String metaAlias)
        Returns federation done page URL.
        Parameters:
        request - HttpServletRequest object
        hostedConfig - hosted provider's extended meta
        metaAlias - hosted provider's meta alias
        Returns:
        federation done page URL.
      • getDoFederatePageURL

        public static String getDoFederatePageURL​(jakarta.servlet.http.HttpServletRequest request,
                                                  com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostedConfig)
        Returns do federate page URL.
        Parameters:
        request - HttpServletRequest object
        hostedConfig - hosted provider's extended meta
        Returns:
        do federate page URL.
      • getDefaultPageURL

        public static String getDefaultPageURL​(jakarta.servlet.http.HttpServletRequest request,
                                               String pageName)
        Returns default page URL.
        Parameters:
        request - HTTP Servlet Request.
        pageName - the page name whose url to be retrieved
        Returns:
        String the Page URL.
      • addMetaAlias

        public static String addMetaAlias​(String url,
                                          String metaAlias)
        Appends meta alias to the URL.
        Parameters:
        url - string url
        metaAlias - meta alias to be appended
        Returns:
        the url with meta alias added
      • getAssertionConsumerServiceURL

        public static String getAssertionConsumerServiceURL​(com.sun.identity.liberty.ws.meta.jaxb.SPDescriptorType spDescriptor,
                                                            String id)
        Finds approriate assertion consumer service URL.
        Parameters:
        spDescriptor - sevice provider's meta descriptor
        id - requested assertion consumer service url id. It could be null.
        Returns:
        assertion consumer server URL.
      • getFirstProtocolProfile

        public static String getFirstProtocolProfile​(List profiles)
        Returns the first profile from the list.
        Parameters:
        profiles - list of profiles
        Returns:
        the first profile of the list
      • getSPAuthContextInfo

        public static Map getSPAuthContextInfo​(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostConfig)
        Returns service provider's authentication context mappings.
        Parameters:
        hostConfig - hosted provider' setended meta
        Returns:
        authentication context mapping
      • isRegisProfileSOAP

        public static boolean isRegisProfileSOAP​(String userID,
                                                 String remoteEntityId,
                                                 com.sun.identity.liberty.ws.meta.jaxb.SPDescriptorType remoteDescriptor,
                                                 String metaAlias,
                                                 com.sun.identity.liberty.ws.meta.jaxb.IDPDescriptorType hostedDescriptor)
        Determines if the registration profile is SOAP or not.
        Parameters:
        userID - id of the user subject to registration
        remoteEntityId - remote provider's entity ID
        remoteDescriptor - remote provider's meta descriptor
        metaAlias - hosted provider's meta alias
        hostedDescriptor - hosted provider's meta descriptor
        Returns:
        true if the registration profile is SOAP; false otherwise.
      • getMinorVersion

        public static int getMinorVersion​(List protocolEnum)
        Returns the minor version of supported protocol.
        Parameters:
        protocolEnum - list of supported protocols
        Returns:
        minor version of first supported protocol
      • getSPAdapter

        public static FederationSPAdapter getSPAdapter​(String hostEntityID,
                                                       com.sun.identity.federation.jaxb.entityconfig.BaseConfigType hostSPConfig)