Class WSFederationMetaUtils


  • public final class WSFederationMetaUtils
    extends Object
    The WSFederationMetaUtils provides metadata related utility methods.
    • Field Detail

      • debug

        public static Debug debug
      • bundle

        public static ResourceBundle bundle
        Resource bundle for the WS-Federation implementation.
    • Method Detail

      • getMetaJAXBContext

        public static JAXBContext getMetaJAXBContext()
        Returns JAXB context for the metadata service.
        Returns:
        JAXB context object.
      • convertStringToJAXB

        public static Object convertStringToJAXB​(String str)
                                          throws JAXBException
        Converts a String object to a JAXB object.
        Parameters:
        str - a String object
        Returns:
        a JAXB object converted from the String object.
        Throws:
        JAXBException - if an error occurs while converting String object
      • convertInputStreamToJAXB

        public static Object convertInputStreamToJAXB​(InputStream is)
                                               throws JAXBException
        Reads from the InputStream and converts to a JAXB object.
        Parameters:
        is - a InputStream object
        Returns:
        a JAXB object converted from the InputStream object.
        Throws:
        JAXBException - if an error occurs while converting InputStream object
      • convertNodeToJAXB

        public static Object convertNodeToJAXB​(Node node)
                                        throws JAXBException
        Converts a Node object to a JAXB object.
        Parameters:
        node - a Node object
        Returns:
        a JAXB object converted from the Node object.
        Throws:
        JAXBException - if an error occurs while converting Node object
      • convertJAXBToString

        public static String convertJAXBToString​(Object jaxbObj)
                                          throws JAXBException
        Converts a JAXB object to a String object.
        Parameters:
        jaxbObj - a JAXB object
        Returns:
        a String representing the JAXB object.
        Throws:
        JAXBException - if an error occurs while converting JAXB object
      • convertJAXBToOutputStream

        public static void convertJAXBToOutputStream​(Object jaxbObj,
                                                     OutputStream os)
                                              throws JAXBException
        Converts a JAXB object and writes to an OutputStream object.
        Parameters:
        jaxbObj - a JAXB object
        os - an OutputStream object
        Throws:
        JAXBException - if an error occurs while converting JAXB object
      • convertJAXBToAttrMap

        protected static Map convertJAXBToAttrMap​(String attrName,
                                                  Object jaxbObj)
                                           throws JAXBException
        Converts a JAXB object to a String object and creates a Map. The key is 'attrName' and the value is a Set contains the String object.
        Parameters:
        attrName - attribute name
        jaxbObj - a JAXB object
        Returns:
        a Map. The key is 'attrName' and the value is a Set contains the String object converted from the JAXB object.
        Throws:
        JAXBException - if an error occurs while converting JAXB object
      • getAttributes

        public static Map<String,​List<String>> getAttributes​(BaseConfigType config)
        Gets attribute value pairs from BaseConfigType and put in a Map. The key is attribute name and the value is a List of attribute values;
        Parameters:
        config - the BaseConfigType object
        Returns:
        a attrbute value Map
      • getAttributes

        public static List<String> getAttributes​(BaseConfigType config,
                                                 String key)
        Returns all attribute values associated with they key provided.
        Parameters:
        config - The configuration object.
        key - The attribute key.
        Returns:
        All attribute values associated with the key provided.
      • setAttributes

        public static void setAttributes​(BaseConfigType config,
                                         Map<String,​List<String>> map)
                                  throws JAXBException
        Sets attribute value pairs in BaseConfigType. NOTE - existing AVPs are discarded! The key is
        Parameters:
        config - the BaseConfigType object
        map - mapping from attribute names to Lists of attribute values;
        Throws:
        JAXBException
      • getAttribute

        public static String getAttribute​(BaseConfigType config,
                                          String key)
        Gets a single attribute value from BaseConfigType
        Parameters:
        config - the BaseConfigType object
        key - attribute key.
        Returns:
        the attribute value
      • getAttribute

        public static String getAttribute​(BaseConfigType config,
                                          String key,
                                          String defaultValue)
        Gets a single attribute value from BaseConfigType.
        Parameters:
        config - The BaseConfigType object.
        key - Attribute key.
        defaultValue - The defaultValue to return if the attribute was not set.
        Returns:
        The attribute value.
      • getIntAttribute

        public static int getIntAttribute​(BaseConfigType config,
                                          String key,
                                          int defaultValue)
        Gets the int value stored in the configuration under the provided key, or the default value if it was not defined or if it was malformed.
        Parameters:
        config - The configuration object to investigate.
        key - The configuration key.
        defaultValue - The default value to return if the config is missing or malformed.
        Returns:
        The int value associated with the requested configuration key.
      • getRealmByMetaAlias

        public static String getRealmByMetaAlias​(String metaAlias)
        Returns the realm by parsing the metaAlias. MetaAlias format is
         <realm>/<any string without '/'> for non-root realm or
         /<any string without '/'> for root realm.
         
        Parameters:
        metaAlias - The metaAlias.
        Returns:
        the realm associated with the metaAlias.
      • getMetaAliasByUri

        public static String getMetaAliasByUri​(String uri)
        Returns metaAlias embedded in uri.
        Parameters:
        uri - The uri string.
        Returns:
        the metaAlias embedded in uri or null if not found.
      • getFirstEntry

        public static String getFirstEntry​(Map attrMap,
                                           String key)
        Get the first value of set by given key searching in the given map. return null if attrMap is null or key is null.
        Parameters:
        attrMap - Map of which set is to be added.
        key - Key of the entry to be added.
        Returns:
        the first value of a matching set by the given key.
      • fillEntriesInSet

        public static void fillEntriesInSet​(Map attrMap,
                                            String key,
                                            String value)
        Adds a set of a given value to a map. Set will not be added if attrMap is null or value is null or key is null.
        Parameters:
        attrMap - Map of which set is to be added.
        key - Key of the entry to be added.
        value - Value to be added to the Set.
      • getEndpointBaseUrl

        public static String getEndpointBaseUrl​(IDPSSOConfigElement idpConfig,
                                                jakarta.servlet.http.HttpServletRequest request)
        Returns the endpoint baseURL as stored in the configuration, or if absent, generates the base URL based on the incoming HTTP request.
        Parameters:
        idpConfig - The configuration object.
        request - The HTTP request corresponding to the current WS-Fed action.
        Returns:
        The Base URL of the OpenAM deployment.