Package com.onelogin.saml2.settings
Class Metadata
java.lang.Object
com.onelogin.saml2.settings.Metadata
Metadata class of OneLogin's Java Toolkit.
A class that contains methods related to the metadata of the SP
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AttributeConsumingServiceAttributeConsumingServiceprivate final IntegercacheDuration of the metadata.private static final org.slf4j.LoggerPrivate property to construct a logger for this class.private final StringGenerated metadata in string formatprivate static final intprivate static final intprivate final CalendarvalidUntilTime of the metadata. -
Constructor Summary
ConstructorsConstructorDescriptionMetadata(Saml2Settings settings) Constructs the Metadata object.Metadata(Saml2Settings settings, Calendar validUntilTime, Integer cacheDuration) Constructs the Metadata object.Metadata(Saml2Settings settings, Calendar validUntilTime, Integer cacheDuration, AttributeConsumingService attributeConsumingService) Constructs the Metadata object. -
Method Summary
Modifier and TypeMethodDescriptionprivate org.apache.commons.lang3.text.StrSubstitutorgenerateSubstitutor(Saml2Settings settings) Substitutes metadata variables within a string by values.private StringGenerates the AttributeConsumingService section of the metadata's templatefinal Stringprivate static StringBuilderprotected StringpostProcessXml(String metadataXml, Saml2Settings settings) Allows for an extension class to post-process the SAML metadata XML generated for this metadata instance, in order to customize the result.static StringsignMetadata(String metadata, PrivateKey key, X509Certificate cert, String signAlgorithm) Signs the metadata with the key/cert providedstatic StringsignMetadata(String metadata, PrivateKey key, X509Certificate cert, String signAlgorithm, String digestAlgorithm) Signs the metadata with the key/cert providedprivate StringtoContactsXml(List<Contact> contacts) Generates the contact section of the metadata's templateprivate StringtoOrganizationXml(Organization organization) Generates the organization section of the metadata's templateprivate Stringprivate StringtoX509KeyDescriptorsXML(X509Certificate cert, Boolean wantsEncrypted) Generates the KeyDescriptor section of the metadata's templateprivate StringtoX509KeyDescriptorsXML(X509Certificate certCurrent, X509Certificate certNew, Boolean wantsEncrypted) Generates the KeyDescriptor section of the metadata's template
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGERPrivate property to construct a logger for this class. -
N_DAYS_VALID_UNTIL
private static final int N_DAYS_VALID_UNTIL- See Also:
-
SECONDS_CACHED
private static final int SECONDS_CACHED- See Also:
-
attributeConsumingService
AttributeConsumingService -
metadataString
Generated metadata in string format -
validUntilTime
validUntilTime of the metadata. How long the metadata is valid -
cacheDuration
cacheDuration of the metadata. Duration of the cache in seconds
-
-
Constructor Details
-
Metadata
public Metadata(Saml2Settings settings, Calendar validUntilTime, Integer cacheDuration, AttributeConsumingService attributeConsumingService) throws CertificateEncodingException Constructs the Metadata object.- Parameters:
settings- Saml2Settings object. Setting datavalidUntilTime- Metadata's valid timecacheDuration- Duration of the cache in secondsattributeConsumingService- AttributeConsumingService of service provider- Throws:
CertificateEncodingException
-
Metadata
public Metadata(Saml2Settings settings, Calendar validUntilTime, Integer cacheDuration) throws CertificateEncodingException Constructs the Metadata object.- Parameters:
settings- Saml2Settings object. Setting datavalidUntilTime- Metadata's valid timecacheDuration- Duration of the cache in seconds- Throws:
CertificateEncodingException
-
Metadata
Constructs the Metadata object.- Parameters:
settings- Saml2Settings object. Setting data- Throws:
CertificateEncodingException
-
-
Method Details
-
postProcessXml
Allows for an extension class to post-process the SAML metadata XML generated for this metadata instance, in order to customize the result.This method is invoked at construction time, after all the other fields of this class have already been initialised. Its default implementation simply returns the input XML as-is, with no change.
- Parameters:
metadataXml- the XML produced for this metadata instance by the standard implementation provided byMetadatasettings- the settings- Returns:
- the post-processed XML for this metadata instance, which will then be
returned by any call to
getMetadataString()
-
generateSubstitutor
private org.apache.commons.lang3.text.StrSubstitutor generateSubstitutor(Saml2Settings settings) throws CertificateEncodingException Substitutes metadata variables within a string by values.- Parameters:
settings- Saml2Settings object. Setting data- Returns:
- the StrSubstitutor object of the metadata
- Throws:
CertificateEncodingException
-
getMetadataTemplate
- Returns:
- the metadata's template
-
getAttributeConsumingServiceXml
Generates the AttributeConsumingService section of the metadata's template- Returns:
- the AttributeConsumingService section of the metadata's template
-
toContactsXml
Generates the contact section of the metadata's template- Parameters:
contacts- List of contact objects- Returns:
- the contact section of the metadata's template
-
toOrganizationXml
Generates the organization section of the metadata's template- Parameters:
organization- organization object- Returns:
- the organization section of the metadata's template
-
toX509KeyDescriptorsXML
private String toX509KeyDescriptorsXML(X509Certificate cert, Boolean wantsEncrypted) throws CertificateEncodingException Generates the KeyDescriptor section of the metadata's template- Parameters:
cert- the public cert that will be used by the SP to sign and encryptwantsEncrypted- Whether to include the KeyDescriptor for encryption- Returns:
- the KeyDescriptor section of the metadata's template
- Throws:
CertificateEncodingException
-
toX509KeyDescriptorsXML
private String toX509KeyDescriptorsXML(X509Certificate certCurrent, X509Certificate certNew, Boolean wantsEncrypted) throws CertificateEncodingException Generates the KeyDescriptor section of the metadata's template- Parameters:
certCurrent- the public cert that will be used by the SP to sign and encryptcertNew- the public cert that will be used by the SP to sign and encrypt in futurewantsEncrypted- Whether to include the KeyDescriptor for encryption- Returns:
- the KeyDescriptor section of the metadata's template
- Throws:
CertificateEncodingException
-
toSLSXml
- Returns:
- the md:SingleLogoutService section of the metadata's template
-
getMetadataString
- Returns:
- the metadata
-
signMetadata
public static String signMetadata(String metadata, PrivateKey key, X509Certificate cert, String signAlgorithm) throws XPathExpressionException, org.apache.xml.security.exceptions.XMLSecurityException Signs the metadata with the key/cert provided- Parameters:
metadata- SAML Metadata XMLkey- Private Keycert- x509 Public certificatesignAlgorithm- Signature Algorithm- Returns:
- string Signed Metadata
- Throws:
org.apache.xml.security.exceptions.XMLSecurityExceptionXPathExpressionException
-
signMetadata
public static String signMetadata(String metadata, PrivateKey key, X509Certificate cert, String signAlgorithm, String digestAlgorithm) throws XPathExpressionException, org.apache.xml.security.exceptions.XMLSecurityException Signs the metadata with the key/cert provided- Parameters:
metadata- SAML Metadata XMLkey- Private Keycert- x509 Public certificatesignAlgorithm- Signature AlgorithmdigestAlgorithm- Digest Algorithm- Returns:
- string Signed Metadata
- Throws:
org.apache.xml.security.exceptions.XMLSecurityExceptionXPathExpressionException
-