Package com.sun.identity.saml2.meta
Class SAML2MetaSecurityUtils
- java.lang.Object
-
- com.sun.identity.saml2.meta.SAML2MetaSecurityUtils
-
public final class SAML2MetaSecurityUtils extends Object
TheSAML2MetaUtilsprovides metadata security related util methods.
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTR_IDstatic StringATTR_USEstatic StringNS_MD_QUERYstatic StringNS_METAstatic StringNS_XMLENCstatic StringNS_XMLSIGstatic StringPREFIX_MD_QUERYstatic StringPREFIX_XMLENCstatic StringPREFIX_XMLSIGstatic StringTAG_ENTITY_DESCRIPTORstatic StringTAG_IDP_SSO_DESCRIPTORstatic StringTAG_KEY_DESCRIPTORstatic StringTAG_KEY_INFOstatic StringTAG_SP_SSO_DESCRIPTOR
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringbuildX509Certificate(String certAlias)static StringformatBase64BinaryElement(String xmlstr)Restores Base64 encoded format.static Documentsign(String realm, EntityDescriptorElement descriptor)Signs the entity descriptor root element by the following rules: Hosted Entity If there is a signature already on the EntityDescriptor, removes it, then signs the EntityDescriptor.static voidupdateProviderKeyInfo(String realm, String entityID, Set<String> certAliases, boolean isSigning, boolean isIDP, String encAlgo, int keySize)Updates signing or encryption key info for SP or IDP.static voidverifySignature(Document doc)Verifies signatures in entity descriptor represented by theDocument.
-
-
-
Field Detail
-
NS_META
public static final String NS_META
- See Also:
- Constant Field Values
-
NS_XMLSIG
public static final String NS_XMLSIG
- See Also:
- Constant Field Values
-
NS_XMLENC
public static final String NS_XMLENC
- See Also:
- Constant Field Values
-
NS_MD_QUERY
public static final String NS_MD_QUERY
- See Also:
- Constant Field Values
-
PREFIX_XMLSIG
public static final String PREFIX_XMLSIG
- See Also:
- Constant Field Values
-
PREFIX_XMLENC
public static final String PREFIX_XMLENC
- See Also:
- Constant Field Values
-
PREFIX_MD_QUERY
public static final String PREFIX_MD_QUERY
- See Also:
- Constant Field Values
-
TAG_KEY_INFO
public static final String TAG_KEY_INFO
- See Also:
- Constant Field Values
-
TAG_KEY_DESCRIPTOR
public static final String TAG_KEY_DESCRIPTOR
- See Also:
- Constant Field Values
-
TAG_ENTITY_DESCRIPTOR
public static final String TAG_ENTITY_DESCRIPTOR
- See Also:
- Constant Field Values
-
TAG_SP_SSO_DESCRIPTOR
public static final String TAG_SP_SSO_DESCRIPTOR
- See Also:
- Constant Field Values
-
TAG_IDP_SSO_DESCRIPTOR
public static final String TAG_IDP_SSO_DESCRIPTOR
- See Also:
- Constant Field Values
-
ATTR_USE
public static final String ATTR_USE
- See Also:
- Constant Field Values
-
ATTR_ID
public static final String ATTR_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
sign
public static Document sign(String realm, EntityDescriptorElement descriptor) throws javax.xml.bind.JAXBException, SAML2MetaException
Signs the entity descriptor root element by the following rules:- Hosted Entity
- If there is a signature already on the EntityDescriptor, removes it, then signs the EntityDescriptor.
- Simply signs the EntityDescriptor otherwise.
- Remote Entity
- If there is a signature already on the EntityDescriptor, then does not change it, but returns the Document with the original signature.
- Simply signs the EntityDescriptor otherwise
- Parameters:
realm- The realm where the EntityDescriptor belongs to.descriptor- The entity descriptor.- Returns:
- Signed
Documentfor the entity descriptor or null if no metadata signing key is found in the configuration. - Throws:
SAML2MetaException- if unable to sign the entity descriptor.javax.xml.bind.JAXBException- if the entity descriptor is invalid.
- Hosted Entity
-
verifySignature
public static void verifySignature(Document doc) throws SAML2MetaException
Verifies signatures in entity descriptor represented by theDocument.- Parameters:
doc- The document.- Throws:
SAML2MetaException- if unable to verify the entity descriptor.
-
formatBase64BinaryElement
public static String formatBase64BinaryElement(String xmlstr)
Restores Base64 encoded format. JAXB will change<ds:X509Data> <ds:X509Certificate> ......... ......... </ds:X509Certificate> </ds:X509Data> to <ds:X509Data> <ds:X509Certificate>..................</ds:X509Certificate> </ds:X509Data>This method will restore the format.- Parameters:
xmlstr- The xml string containing element 'X509Certificate'.- Returns:
- the restored xmls string.
-
buildX509Certificate
public static String buildX509Certificate(String certAlias) throws SAML2MetaException
- Throws:
SAML2MetaException
-
updateProviderKeyInfo
public static void updateProviderKeyInfo(String realm, String entityID, Set<String> certAliases, boolean isSigning, boolean isIDP, String encAlgo, int keySize) throws SAML2MetaException
Updates signing or encryption key info for SP or IDP. This will update both signing/encryption alias on extended metadata and certificates in standard metadata.- Parameters:
realm- Realm the entity resides.entityID- ID of the entity to be updated.certAliases- The set of certificate aliases to be set for the entity. If null or empty, existing key information will be removed from the SP or IDP.isSigning- true if this is signing certificate alias, false if this is encryption certification alias.isIDP- true if this is for IDP signing/encryption alias, false if this is for SP signing/encryption aliasencAlgo- Encryption algorithm URI, this is applicable for encryption cert only.keySize- Encryption key size, this is applicable for encryption cert only.- Throws:
SAML2MetaException- if failed to update the certificate alias for the entity.
-
-