public class SAMLUtils extends Object
Constructor and Description |
---|
SAMLUtils() |
Modifier and Type | Method and Description |
---|---|
static org.opensaml.saml1.core.Assertion |
buildAssertion(Element assertionElement)
Builds an assertion from an XML element.
|
static org.opensaml.xml.XMLObject |
buildXMLObject(QName objectQName)
Builds the requested XMLObject.
|
static org.joda.time.DateTime |
convertToDateTime(Date date)
Converts java.util.Date to opensaml DateTime object.
|
static org.opensaml.saml1.core.Assertion |
createAssertion(String issuerName,
org.joda.time.DateTime notBefore,
org.joda.time.DateTime notOnOrAfter,
List<org.opensaml.saml1.core.Statement> statements)
This method creates the final SAML assertion.
|
static org.opensaml.saml1.core.Attribute |
createAttribute(String name,
String namespace,
String value)
Creates a SAML attribute similar to following,
|
static org.opensaml.saml1.core.AttributeStatement |
createAttributeStatement(org.opensaml.saml1.core.Subject subject,
List<org.opensaml.saml1.core.Attribute> attributeList)
Creates an attribute statement.
|
static org.opensaml.saml1.core.AuthenticationStatement |
createAuthenticationStatement(org.opensaml.saml1.core.Subject subject,
String authenticationMethod,
org.joda.time.DateTime authenticationInstant)
Creates an AuthenticationStatement.
|
static org.opensaml.saml1.core.Conditions |
createConditions(org.joda.time.DateTime notBefore,
org.joda.time.DateTime notOnOrAfter)
Creates Conditions object.
|
static org.opensaml.xml.signature.KeyInfo |
createKeyInfo()
Creates a KeyInfo object
|
static org.opensaml.xml.signature.KeyInfo |
createKeyInfo(org.opensaml.xml.encryption.EncryptedKey encryptedKey)
Creates a KeyInfo element given EncryptedKey.
|
static org.opensaml.xml.signature.KeyInfo |
createKeyInfo(org.opensaml.xml.signature.X509Data x509Data)
Creates a KeyInfo element given EncryptedKey.
|
static org.opensaml.saml1.core.NameIdentifier |
createNamedIdentifier(String principalName,
String format)
Create named identifier.
|
static org.opensaml.saml1.core.Subject |
createSubject(org.opensaml.saml1.core.NameIdentifier nameIdentifier,
String confirmationMethod,
org.opensaml.xml.signature.KeyInfo keyInfoContent)
Creates an opensaml Subject representation.
|
static org.opensaml.saml1.core.SubjectConfirmation |
createSubjectConfirmation(String confirmationMethod,
org.opensaml.xml.signature.KeyInfo keyInfoContent)
Creates opensaml SubjectConfirmation representation.
|
static org.opensaml.saml1.core.ConfirmationMethod |
createSubjectConfirmationMethod(String confirmationMethod)
Creates the subject confirmation method.
|
static Collection<X509Certificate> |
getCertChainCollection(X509Certificate[] issuerCerts) |
static org.opensaml.xml.signature.KeyInfo |
getCertificateBasedKeyInfo(X509Certificate certificate)
Creates the certificate based KeyInfo object.
|
static String |
getSAML11SubjectConfirmationMethod(org.opensaml.saml1.core.Assertion assertion)
Get subject confirmation method of the given SAML 1.1 Assertion.
|
static org.opensaml.xml.signature.KeyInfo |
getSymmetricKeyBasedKeyInfo(Document doc,
RahasData data,
X509Certificate serviceCert,
int keySize,
org.apache.ws.security.components.crypto.Crypto crypto,
int keyComputation)
This method creates KeyInfo element of an assertion.
|
static void |
signAssertion(org.opensaml.saml1.core.Assertion assertion,
org.apache.ws.security.components.crypto.Crypto crypto,
String issuerKeyAlias,
String issuerKeyPassword)
Signs the SAML assertion.
|
public static Collection<X509Certificate> getCertChainCollection(X509Certificate[] issuerCerts)
public static org.opensaml.xml.XMLObject buildXMLObject(QName objectQName) throws TrustException
objectQName
- name of the XMLObjectTrustException
- If unable to find the appropriate builder.public static org.opensaml.saml1.core.Assertion buildAssertion(Element assertionElement)
assertionElement
- The XML element.public static void signAssertion(org.opensaml.saml1.core.Assertion assertion, org.apache.ws.security.components.crypto.Crypto crypto, String issuerKeyAlias, String issuerKeyPassword) throws TrustException
Credential
objectSignature
objectassertion
- The assertion to be signed.crypto
- Certificate and private key data are stored in Crypto objectissuerKeyAlias
- Key aliasissuerKeyPassword
- Key passwordTrustException
- If an error occurred while signing the assertion.public static String getSAML11SubjectConfirmationMethod(org.opensaml.saml1.core.Assertion assertion)
assertion
- SAML 1.1 Assertionpublic static org.opensaml.saml1.core.NameIdentifier createNamedIdentifier(String principalName, String format) throws TrustException
principalName
- Name of the subject.format
- Format of the subject, whether it is an email, uid etc ...TrustException
- If unable to find the builder.public static org.opensaml.saml1.core.ConfirmationMethod createSubjectConfirmationMethod(String confirmationMethod) throws TrustException
confirmationMethod
- Name of the actual confirmation method. Could be
holder-of-key - "urn:oasis:names:tc:SAML:1.0:cm:holder-of-key"
sender-vouches - "urn:oasis:names:tc:SAML:1.0:cm:sender-vouches"
bearer - TODOTrustException
- If unable to find appropriate XMLObject builder for confirmation QName.public static org.opensaml.saml1.core.SubjectConfirmation createSubjectConfirmation(String confirmationMethod, org.opensaml.xml.signature.KeyInfo keyInfoContent) throws TrustException
confirmationMethod
- The subject confirmation method. Bearer, Sender-Vouches or Holder-Of-Key.keyInfoContent
- The KeyInfo content. According to SPEC (SAML 1.1) this could be null.TrustException
- If unable to find any of the XML builders.public static org.opensaml.saml1.core.Subject createSubject(org.opensaml.saml1.core.NameIdentifier nameIdentifier, String confirmationMethod, org.opensaml.xml.signature.KeyInfo keyInfoContent) throws TrustException
nameIdentifier
- Represent the "NameIdentifier" of XML element above.confirmationMethod
- Represent the bearer, HOK or Sender-Vouches.keyInfoContent
- Key info information. This could be null.TrustException
- If a relevant XML builder is unable to find.public static org.opensaml.saml1.core.AuthenticationStatement createAuthenticationStatement(org.opensaml.saml1.core.Subject subject, String authenticationMethod, org.joda.time.DateTime authenticationInstant) throws TrustException
subject
- OpenSAML Subject implementation.authenticationMethod
- How subject is authenticated ? i.e. by using a password, kerberos, certificate
etc ... The method is defined as a URL in SAML specification.authenticationInstant
- Time which authentication took place.TrustException
- If unable to find the builder.public static org.opensaml.saml1.core.AttributeStatement createAttributeStatement(org.opensaml.saml1.core.Subject subject, List<org.opensaml.saml1.core.Attribute> attributeList) throws TrustException
subject
- The OpenSAML representation of the Subject.attributeList
- List of attribute values to include within the message.TrustException
- If unable to find the appropriate builder.public static org.opensaml.saml1.core.Conditions createConditions(org.joda.time.DateTime notBefore, org.joda.time.DateTime notOnOrAfter) throws TrustException
notBefore
- The validity of the Assertion starts from this value.notOnOrAfter
- The validity ends from this value.TrustException
- If unable to find appropriate builder.public static org.opensaml.saml1.core.Assertion createAssertion(String issuerName, org.joda.time.DateTime notBefore, org.joda.time.DateTime notOnOrAfter, List<org.opensaml.saml1.core.Statement> statements) throws TrustException
issuerName
- Represents the "Issuer" in Assertion.notBefore
- The Condition's NotBefore valuenotOnOrAfter
- The Condition's NotOnOrAfter valuestatements
- Other statements.TrustException
- If unable to find the appropriate builder.public static org.opensaml.saml1.core.Attribute createAttribute(String name, String namespace, String value) throws TrustException
name
- attribute namenamespace
- attribute namespace.value
- attribute value.TrustException
- If unable to find the appropriate builder.public static org.opensaml.xml.signature.KeyInfo createKeyInfo() throws TrustException
TrustException
- If an error occurred while creating KeyInfo.public static org.opensaml.xml.signature.KeyInfo createKeyInfo(org.opensaml.xml.encryption.EncryptedKey encryptedKey) throws TrustException
encryptedKey
- The OpemSAML representation of encrypted key.TrustException
- If unable to find the builder.public static org.opensaml.xml.signature.KeyInfo createKeyInfo(org.opensaml.xml.signature.X509Data x509Data) throws TrustException
x509Data
- The OpemSAML representation X509DataTrustException
- If unable to find the builder.public static org.opensaml.xml.signature.KeyInfo getCertificateBasedKeyInfo(X509Certificate certificate) throws TrustException
certificate
- The public key certificate used to create the KeyInfo object.TrustException
- If an error occurred while creating the KeyInfopublic static org.opensaml.xml.signature.KeyInfo getSymmetricKeyBasedKeyInfo(Document doc, RahasData data, X509Certificate serviceCert, int keySize, org.apache.ws.security.components.crypto.Crypto crypto, int keyComputation) throws org.apache.ws.security.WSSecurityException, TrustException
doc
- An Axiom based DOM Document.data
- The ephemeral key which we use here need in encrypting the message also. Therefore
we need to save the ephemeral key in RahasData passed here.serviceCert
- Public key used to encrypt the assertion is extracted from this certificate.keySize
- Size of the key to be usedcrypto
- The relevant private keykeyComputation
- Key computation mechanism.org.apache.ws.security.WSSecurityException
- We use WSS4J to generate encrypted key. This exception will trigger if an
error occurs while generating the encrypted key.TrustException
- If an error occurred while creating KeyInfo object.public static org.joda.time.DateTime convertToDateTime(Date date)
date
- Java util dateCopyright © Apache Software Foundation. All Rights Reserved.