Package com.sun.identity.saml2.meta
Class SAML2MetaUtils
- java.lang.Object
-
- com.sun.identity.saml2.meta.SAML2MetaUtils
-
public final class SAML2MetaUtils extends Object
TheSAML2MetaUtilsprovides metadata related util methods.
-
-
Field Summary
Fields Modifier and Type Field Description static Debugdebugprotected static StringRESOURCE_BUNDLE_NAMEprotected static ResourceBundleresourceBundle
-
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 StringexportStandardMeta(String realm, String entityID, boolean sign)static voidfillEntriesInSet(Map attrMap, String key, String value)Adds a set of a given value to a map.static AttributeAuthorityDescriptorElementgetAttributeAuthorityDescriptor(EntityDescriptorElement eDescriptor)Returns attribute authority descriptor in an entity descriptor.static AttributeQueryDescriptorElementgetAttributeQueryDescriptor(EntityDescriptorElement eDescriptor)Returns attribute query descriptor in an entity descriptor.static Map<String,List<String>>getAttributes(BaseConfigType config)Gets attribute value pairs fromBaseConfigTypeand put in aMap.static AuthnAuthorityDescriptorElementgetAuthnAuthorityDescriptor(EntityDescriptorElement eDescriptor)Returns authentication authority descriptor in an entity descriptor.static EntityDescriptorElementgetEntityDescriptorElement(String metadata)static StringgetFirstEntry(Map attrMap, String key)Get the first value of set by given key searching in the given map.static IDPSSOConfigElementgetIDPSSOConfig(EntityConfigElement eConfig)Returns first identity provider's SSO configuration in an entitystatic IDPSSODescriptorElementgetIDPSSODescriptor(EntityDescriptorElement eDescriptor)Returns first identity provider's SSO descriptor in an entity descriptor.static StringgetMetaAliasByUri(String uri)Returns metaAlias embedded in uri.static JAXBContextgetMetaJAXBContext()ReturnsJAXBcontext for the metadata service.static XACMLPDPDescriptorElementgetPolicyDecisionPointDescriptor(EntityDescriptorElement eDescriptor)Returns first policy decision point descriptor in an entity descriptor.static XACMLAuthzDecisionQueryDescriptorElementgetPolicyEnforcementPointDescriptor(EntityDescriptorElement eDescriptor)Returns first policy enforcement point descriptor in an entity descriptor.static StringgetRealmByMetaAlias(String metaAlias)Returns the realm by parsing the metaAlias.static SPSSOConfigElementgetSPSSOConfig(EntityConfigElement eConfig)Returns first service provider's SSO configuration in an entity.static SPSSODescriptorElementgetSPSSODescriptor(EntityDescriptorElement eDescriptor)Returns first service provider's SSO descriptor in an entity descriptor.static List<String>importSAML2Document(SAML2MetaManager metaManager, String realm, Document doc)For the given XML metadata document representing either a SAML2 EntityDescriptorElement or EntitiesDescriptorElement, return a list of entityId's for all the Entities created.
-
-
-
Field Detail
-
RESOURCE_BUNDLE_NAME
protected static final String RESOURCE_BUNDLE_NAME
- See Also:
- Constant Field Values
-
resourceBundle
protected static ResourceBundle resourceBundle
-
debug
public static Debug debug
-
-
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
-
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.
-
getPolicyDecisionPointDescriptor
public static XACMLPDPDescriptorElement getPolicyDecisionPointDescriptor(EntityDescriptorElement eDescriptor)
Returns first policy decision point descriptor in an entity descriptor.- Parameters:
eDescriptor- The entity descriptor.- Returns:
- policy decision point descriptor or null if it is not found.
-
getPolicyEnforcementPointDescriptor
public static XACMLAuthzDecisionQueryDescriptorElement getPolicyEnforcementPointDescriptor(EntityDescriptorElement eDescriptor)
Returns first policy enforcement point descriptor in an entity descriptor.- Parameters:
eDescriptor- The entity descriptor.- Returns:
- policy enforcement point descriptor or null if it is not found.
-
getSPSSODescriptor
public static SPSSODescriptorElement getSPSSODescriptor(EntityDescriptorElement eDescriptor)
Returns first service provider's SSO descriptor in an entity descriptor.- Parameters:
eDescriptor- The entity descriptor.- Returns:
SPSSODescriptorElementfor the entity or null if not found.
-
getIDPSSODescriptor
public static IDPSSODescriptorElement getIDPSSODescriptor(EntityDescriptorElement eDescriptor)
Returns first identity provider's SSO descriptor in an entity descriptor.- Parameters:
eDescriptor- The entity descriptor.- Returns:
IDPSSODescriptorElementfor the entity or null if not found.
-
getAttributeAuthorityDescriptor
public static AttributeAuthorityDescriptorElement getAttributeAuthorityDescriptor(EntityDescriptorElement eDescriptor)
Returns attribute authority descriptor in an entity descriptor.- Parameters:
eDescriptor- The entity descriptor.- Returns:
- an
AttributeAuthorityDescriptorElementobject for the entity or null if not found.
-
getAttributeQueryDescriptor
public static AttributeQueryDescriptorElement getAttributeQueryDescriptor(EntityDescriptorElement eDescriptor)
Returns attribute query descriptor in an entity descriptor.- Parameters:
eDescriptor- The entity descriptor.- Returns:
- an
AttributeQueryDescriptorElementobject for the entity or null if not found.
-
getAuthnAuthorityDescriptor
public static AuthnAuthorityDescriptorElement getAuthnAuthorityDescriptor(EntityDescriptorElement eDescriptor)
Returns authentication authority descriptor in an entity descriptor.- Parameters:
eDescriptor- The entity descriptor.- Returns:
- an
AuthnAuthorityDescriptorElementobject for the entity 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.
-
getSPSSOConfig
public static SPSSOConfigElement getSPSSOConfig(EntityConfigElement eConfig) throws SAML2MetaException
Returns first service provider's SSO configuration in an entity.- Parameters:
eConfig-EntityConfigElementof the entity to be retrieved.- Returns:
SPSSOConfigElementfor the entity or null if not found.- Throws:
SAML2MetaException- if unable to retrieve the first service provider's SSO configuration.
-
getIDPSSOConfig
public static IDPSSOConfigElement getIDPSSOConfig(EntityConfigElement eConfig) throws SAML2MetaException
Returns first identity provider's SSO configuration in an entity- Parameters:
eConfig-EntityConfigElementof the entity to be retrieved.- Returns:
IDPSSOConfigElementfor the entity or null if not found.- Throws:
SAML2MetaException- if unable to retrieve the first identity provider's SSO configuration.
-
exportStandardMeta
public static String exportStandardMeta(String realm, String entityID, boolean sign) throws SAML2MetaException
- Throws:
SAML2MetaException
-
getEntityDescriptorElement
public static EntityDescriptorElement getEntityDescriptorElement(String metadata) throws SAML2MetaException, JAXBException
- Parameters:
metadata- A string representing an EntityDescriptorElement XML document- Returns:
- EntityDescriptorElement an EntityDescriptorElement from the passed metadata
- Throws:
SAML2MetaException- If there was a problem with the parsed metadataJAXBException- If there was a problem parsing the metadata
-
importSAML2Document
public static List<String> importSAML2Document(SAML2MetaManager metaManager, String realm, Document doc) throws SAML2MetaException, JAXBException
For the given XML metadata document representing either a SAML2 EntityDescriptorElement or EntitiesDescriptorElement, return a list of entityId's for all the Entities created. Carries out a signature validation of the document as part of the import process.- Parameters:
metaManager- An instance of the SAML2MetaManager, used to do the actual create.realm- The realm to create the Entities indoc- The XML document that represents either an EntityDescriptorElement or EntitiesDescriptorElement- Returns:
- A list of all entityId's imported or an empty list if no Entities were imported.
- Throws:
SAML2MetaException- for any issues as a result of trying to create the Entities.JAXBException- for any issues converting the document into a JAXB document.
-
-