Class WSFederationMetaUtils
- java.lang.Object
-
- com.sun.identity.wsfederation.meta.WSFederationMetaUtils
-
public final class WSFederationMetaUtils extends Object
TheWSFederationMetaUtilsprovides metadata related utility methods.
-
-
Field Summary
Fields Modifier and Type Field Description static ResourceBundlebundleResource bundle for the WS-Federation implementation.static Debugdebug
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectconvertInputStreamToJAXB(InputStream is)Reads from theInputStreamand converts to a JAXB object.protected static MapconvertJAXBToAttrMap(String attrName, Object jaxbObj)Converts a JAXB object to aStringobject and creates aMap.static voidconvertJAXBToOutputStream(Object jaxbObj, OutputStream os)Converts a JAXB object and writes to anOutputStreamobject.static StringconvertJAXBToString(Object jaxbObj)Converts a JAXB object to aStringobject.static ObjectconvertNodeToJAXB(Node node)Converts aNodeobject to a JAXB object.static ObjectconvertStringToJAXB(String str)Converts aStringobject to a JAXB object.static voidfillEntriesInSet(Map attrMap, String key, String value)Adds a set of a given value to a map.static StringgetAttribute(BaseConfigType config, String key)Gets a single attribute value fromBaseConfigTypestatic StringgetAttribute(BaseConfigType config, String key, String defaultValue)Gets a single attribute value fromBaseConfigType.static Map<String,List<String>>getAttributes(BaseConfigType config)Gets attribute value pairs fromBaseConfigTypeand put in aMap.static List<String>getAttributes(BaseConfigType config, String key)Returns all attribute values associated with they key provided.static StringgetEndpointBaseUrl(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.static StringgetFirstEntry(Map attrMap, String key)Get the first value of set by given key searching in the given map.static intgetIntAttribute(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.static StringgetMetaAliasByUri(String uri)Returns metaAlias embedded in uri.static JAXBContextgetMetaJAXBContext()ReturnsJAXBcontext for the metadata service.static StringgetRealmByMetaAlias(String metaAlias)Returns the realm by parsing the metaAlias.static voidsetAttributes(BaseConfigType config, Map<String,List<String>> map)Sets attribute value pairs inBaseConfigType.
-
-
-
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()
ReturnsJAXBcontext for the metadata service.- Returns:
JAXBcontext object.
-
convertStringToJAXB
public static Object convertStringToJAXB(String str) throws JAXBException
Converts aStringobject to a JAXB object.- Parameters:
str- aStringobject- Returns:
- a JAXB object converted from the
Stringobject. - Throws:
JAXBException- if an error occurs while convertingStringobject
-
convertInputStreamToJAXB
public static Object convertInputStreamToJAXB(InputStream is) throws JAXBException
Reads from theInputStreamand converts to a JAXB object.- Parameters:
is- aInputStreamobject- Returns:
- a JAXB object converted from the
InputStreamobject. - Throws:
JAXBException- if an error occurs while convertingInputStreamobject
-
convertNodeToJAXB
public static Object convertNodeToJAXB(Node node) throws JAXBException
Converts aNodeobject to a JAXB object.- Parameters:
node- aNodeobject- Returns:
- a JAXB object converted from the
Nodeobject. - Throws:
JAXBException- if an error occurs while convertingNodeobject
-
convertJAXBToString
public static String convertJAXBToString(Object jaxbObj) throws JAXBException
Converts a JAXB object to aStringobject.- Parameters:
jaxbObj- a JAXB object- Returns:
- a
Stringrepresenting 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 anOutputStreamobject.- Parameters:
jaxbObj- a JAXB objectos- anOutputStreamobject- 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 aStringobject and creates aMap. The key is 'attrName' and the value is aSetcontains theStringobject.- Parameters:
attrName- attribute namejaxbObj- a JAXB object- Returns:
- a
Map. The key is 'attrName' and the value is aSetcontains theStringobject 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 fromBaseConfigTypeand put in aMap. The key is attribute name and the value is aListof attribute values;- Parameters:
config- theBaseConfigTypeobject- 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 inBaseConfigType. NOTE - existing AVPs are discarded! The key is- Parameters:
config- theBaseConfigTypeobjectmap- mapping from attribute names toLists of attribute values;- Throws:
JAXBException
-
getAttribute
public static String getAttribute(BaseConfigType config, String key)
Gets a single attribute value fromBaseConfigType- Parameters:
config- theBaseConfigTypeobjectkey- attribute key.- Returns:
- the attribute value
-
getAttribute
public static String getAttribute(BaseConfigType config, String key, String defaultValue)
Gets a single attribute value fromBaseConfigType.- Parameters:
config- TheBaseConfigTypeobject.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 ifattrMapis null orkeyis 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 ifattrMapis null orvalueis null orkeyis 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.
-
-