Class Assertion
- java.lang.Object
-
- com.sun.xml.wss.saml.internal.saml20.jaxb20.AssertionType
-
- com.sun.xml.wss.saml.assertion.saml20.jaxb20.Assertion
-
public class Assertion extends AssertionType implements Assertion
This object stands forAssertionelement. An Assertion is a package of information that supplies one or moreStatementmade by an issuer. There are three kinds of assertions Au [java] <?xml version="1.0" encoding="UTF-8" standalone="yes"?> [java][java] [java] [java]CN=SAML User,OU=SU,O=SAML User,L=Los Angeles,ST=CA,C=US [java][java] [java]urn:oasis:names:tc:SAML:1.0:cm:sender-vouches [java][java] thentication, Authorization Decision and Attribute assertion.ATTRIBUTE1 [java]
-
-
Field Summary
Fields Modifier and Type Field Description protected static Loggerlogstatic StringXMLNS_URIXML Information Set REC all namespace attributes (including those named xmlns, whose [prefix] property has no value) have a namespace URI of http://www.w3.org/2000/xmlns/-
Fields inherited from class com.sun.xml.wss.saml.internal.saml20.jaxb20.AssertionType
advice, conditions, id, issueInstant, issuer, signature, statementOrAuthnStatementOrAuthzDecisionStatement, subject, version
-
-
Constructor Summary
Constructors Constructor Description Assertion(AssertionType assertion)Assertion(String assertionID, NameID issuer, GregorianCalendar issueInstant, Conditions conditions, Advice advice, Subject subject, List statements)This constructor is used to populate the data members: theassertionID, the issuer, time when assertion issued, the conditions when creating a new assertion ,Adviceapplicable to thisAssertionand a set ofStatement(s) in the assertion.Assertion(String assertionID, NameID issuer, GregorianCalendar issueInstant, Conditions conditions, Advice advice, Subject subject, List statements, jakarta.xml.bind.JAXBContext jcc)This constructor is used to populate the data members: theassertionID, the issuer, time when assertion issued, the conditions when creating a new assertion ,Adviceapplicable to thisAssertion,a set ofStatement(s) and a JAXBContext for the assertion.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AssertionfromElement(Element element)This constructor is used to buildAssertionobject from a block of existing XML that has already been built into a DOM.AdvicegetAdvice()Gets the value of the advice property.StringgetAssertionID()Get the SAML Assertion ID for SAML1.0 and SAML1.1ConditionsgetConditions()Gets the value of the conditions property.StringgetIssueInstance()Gets the value of the issueInstant property.BigIntegergetMajorVersion()Get the SAML Major Vertion for SAML1.0 and SAML1.1BigIntegergetMinorVersion()Get the SAML Minor Vertion for SAML1.0 and SAML1.1StringgetSamlIssuer()Get the issuer of SAML AssertionList<Object>getStatements()Return all statements presents in the SAML Assertion.SubjectgetSubject()Gets the value of the subject property.ObjectgetTokenValue()The token ValueStringgetType()The type of the TokenbooleanisSigned()voidsetMajorVersion(BigInteger majorValue)voidsetMinorVersion(BigInteger minorValue)Elementsign(X509Certificate cert, PrivateKey privKey)Sign the SAML Assertion - Enveloped SignatureElementsign(X509Certificate cert, PrivateKey privKey, boolean alwaysIncludeCert)Sign the SAML Assertion - Enveloped SignatureElementsign(X509Certificate cert, PrivateKey privKey, boolean alwaysIncludeCert, String sigAlgorithm, String canonicalizationAlgorithm)Sign the SAML Assertion - Enveloped SignatureElementsign(PublicKey pubKey, PrivateKey privKey)sign the saml assertion (Enveloped Signature)Elementsign(DigestMethod digestMethod, String signatureMethod, X509Certificate cert, PrivateKey privKey)Sign the SAML Assertion - Enveloped SignatureElementsign(DigestMethod digestMethod, String signatureMethod, X509Certificate cert, PrivateKey privKey, boolean includeCert)Sign the SAML Assertion - Enveloped SignatureElementsign(DigestMethod digestMethod, String signatureMethod, PublicKey pubKey, PrivateKey privKey)sign the saml assertion (Enveloped Signature)ElementtoElement(Node doc)Convert SAML Assertion toorg.w3c.dom.ElementbooleanverifySignature(PublicKey pubKey)Verify the SAML signature with the Public Key-
Methods inherited from class com.sun.xml.wss.saml.internal.saml20.jaxb20.AssertionType
getID, getIssueInstant, getIssuer, getSignature, getStatementOrAuthnStatementOrAuthzDecisionStatement, getVersion, setAdvice, setConditions, setID, setIssueInstant, setIssuer, setSignature, setSubject, setVersion
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.sun.xml.wss.saml.Assertion
getID, getVersion, setVersion
-
-
-
-
Constructor Detail
-
Assertion
public Assertion(AssertionType assertion)
-
Assertion
public Assertion(String assertionID, NameID issuer, GregorianCalendar issueInstant, Conditions conditions, Advice advice, Subject subject, List statements) throws SAMLException
This constructor is used to populate the data members: theassertionID, the issuer, time when assertion issued, the conditions when creating a new assertion ,Adviceapplicable to thisAssertionand a set ofStatement(s) in the assertion.- Parameters:
assertionID-AssertionIDobject contained within thisAssertionif null its generated internally.issuer- The issuer of this assertion.issueInstant- Time instant of the issue. It has typedateTimewhich is built in to the W3C XML Schema Types specification. if null, current time is used.conditions-Conditionsunder which the thisAssertionis valid.advice-Adviceapplicable for thisAssertion.statements- List ofStatementobjects within thisAssertion. It could be of typeAuthenticationStatement,AuthorizationDecisionStatementandAttributeStatement. Each Assertion can have multiple type of statements in it.- Throws:
SAMLException- if there is an error in processing input.
-
Assertion
public Assertion(String assertionID, NameID issuer, GregorianCalendar issueInstant, Conditions conditions, Advice advice, Subject subject, List statements, jakarta.xml.bind.JAXBContext jcc) throws SAMLException
This constructor is used to populate the data members: theassertionID, the issuer, time when assertion issued, the conditions when creating a new assertion ,Adviceapplicable to thisAssertion,a set ofStatement(s) and a JAXBContext for the assertion.- Parameters:
assertionID-AssertionIDobject contained within thisAssertionif null its generated internally.issuer- The issuer of this assertion.issueInstant- Time instant of the issue. It has typedateTimewhich is built in to the W3C XML Schema Types specification. if null, current time is used.conditions-Conditionsunder which the thisAssertionis valid.advice-Adviceapplicable for thisAssertion.statements- List ofStatementobjects within thisAssertion. It could be of typeAuthenticationStatement,AuthorizationDecisionStatementandAttributeStatement. Each Assertion can have multiple type of statements in it.jcc- JAXBContext to be used for marshaling and unmarshalling the asertions.- Throws:
SAMLException- if there is an error in processing input.
-
-
Method Detail
-
getMajorVersion
public BigInteger getMajorVersion()
Description copied from interface:AssertionGet the SAML Major Vertion for SAML1.0 and SAML1.1- Specified by:
getMajorVersionin interfaceAssertion- Returns:
- An
java.math.BigIntegerrepresenting saml major version.
-
getMinorVersion
public BigInteger getMinorVersion()
Description copied from interface:AssertionGet the SAML Minor Vertion for SAML1.0 and SAML1.1- Specified by:
getMinorVersionin interfaceAssertion- Returns:
- An
java.math.BigIntegerrepresenting saml minor version.
-
setMajorVersion
public void setMajorVersion(BigInteger majorValue)
- Specified by:
setMajorVersionin interfaceAssertion- Parameters:
majorValue- Ajava.math.BigIntegerrepresenting saml major version.
-
setMinorVersion
public void setMinorVersion(BigInteger minorValue)
- Specified by:
setMinorVersionin interfaceAssertion- Parameters:
minorValue- Ajava.math.BigIntegerrepresenting saml minor version.
-
getAssertionID
public String getAssertionID()
Description copied from interface:AssertionGet the SAML Assertion ID for SAML1.0 and SAML1.1- Specified by:
getAssertionIDin interfaceAssertion- Returns:
- An
java.lang.Stringrepresenting saml assertion ID.
-
getSamlIssuer
public String getSamlIssuer()
Description copied from interface:AssertionGet the issuer of SAML Assertion- Specified by:
getSamlIssuerin interfaceAssertion- Returns:
- An
java.lang.Stringrepresenting saml issuer.
-
getIssueInstance
public String getIssueInstance()
Description copied from interface:AssertionGets the value of the issueInstant property.- Specified by:
getIssueInstancein interfaceAssertion- Returns:
- A
Stringrepresenting the issue timestamp of the SAML Assertion
-
getConditions
public Conditions getConditions()
Description copied from class:AssertionTypeGets the value of the conditions property.- Specified by:
getConditionsin interfaceAssertion- Overrides:
getConditionsin classAssertionType- Returns:
- possible object is
ConditionsType
-
getAdvice
public Advice getAdvice()
Description copied from class:AssertionTypeGets the value of the advice property.- Specified by:
getAdvicein interfaceAssertion- Overrides:
getAdvicein classAssertionType- Returns:
- possible object is
AdviceType
-
getSubject
public Subject getSubject()
Description copied from class:AssertionTypeGets the value of the subject property.- Specified by:
getSubjectin interfaceAssertion- Overrides:
getSubjectin classAssertionType- Returns:
- possible object is
SubjectType
-
sign
public Element sign(PublicKey pubKey, PrivateKey privKey) throws SAMLException
sign the saml assertion (Enveloped Signature)- Specified by:
signin interfaceAssertion- Parameters:
pubKey- PublicKey to be used for Signature verificationprivKey- PrivateKey to be used for Signature calculation- Returns:
- An
org.w3c.dom.Elementrepresentation of Signed SAML Assertion - Throws:
SAMLException
-
sign
public Element sign(X509Certificate cert, PrivateKey privKey, boolean alwaysIncludeCert) throws SAMLException
Description copied from interface:AssertionSign the SAML Assertion - Enveloped Signature- Specified by:
signin interfaceAssertion- Parameters:
cert- Ajava.security.cert.X509Certificaterepresenting the certificate used for Signature verificationprivKey- Ajava.security.PrivateKeyrepresenting the private key used for Signature calculation.alwaysIncludeCert- A flag to tell whether to incude the certificate in the SAML signature. By Default DigestMethod.SHA1, SignatureMethod.RSA_SHA1 and CanonicalizationMethod.EXCLUSIVE will be used.- Returns:
- An
org.w3c.dom.Elementrepresentation of Signed SAML Assertion - Throws:
SAMLException
-
sign
public Element sign(X509Certificate cert, PrivateKey privKey, boolean alwaysIncludeCert, String sigAlgorithm, String canonicalizationAlgorithm) throws SAMLException
Description copied from interface:AssertionSign the SAML Assertion - Enveloped Signature- Specified by:
signin interfaceAssertion- Parameters:
cert- Ajava.security.cert.X509Certificaterepresenting the certificate used for Signature verificationprivKey- Ajava.security.PrivateKeyrepresenting the private key used for Signature calculation.alwaysIncludeCert- A flag to tell whether to incude the certificate in the SAML signature.sigAlgorithm- Ajavax.xml.crypto.dsig.SignatureMethodrepresenting the signature algorithm used SAML signature.canonicalizationAlgorithm- Ajavax.xml.crypto.dsig.CanonicalizationMethodrepresenting the canonicalization algorithm used SAML signature. By Default DigestMethod.SHA1, SignatureMethod.RSA_SHA1 and CanonicalizationMethod.EXCLUSIVE will be used.- Returns:
- An
org.w3c.dom.Elementrepresentation of Signed SAML Assertion - Throws:
SAMLException
-
sign
public Element sign(X509Certificate cert, PrivateKey privKey) throws SAMLException
Description copied from interface:AssertionSign the SAML Assertion - Enveloped Signature- Specified by:
signin interfaceAssertion- Parameters:
cert- Ajava.security.cert.X509Certificaterepresenting the certificate used for Signature verificationprivKey- Ajava.security.PrivateKeyrepresenting the private key used for Signature calculation. By Default DigestMethod.SHA1, SignatureMethod.RSA_SHA1 and CanonicalizationMethod.EXCLUSIVE will be used.- Returns:
- An
org.w3c.dom.Elementrepresentation of Signed SAML Assertion - Throws:
SAMLException
-
sign
public Element sign(DigestMethod digestMethod, String signatureMethod, PublicKey pubKey, PrivateKey privKey) throws SAMLException
sign the saml assertion (Enveloped Signature)- Specified by:
signin interfaceAssertion- Parameters:
digestMethod- DigestMethod to be usedsignatureMethod- SignatureMethod to be used.pubKey- PublicKey to be used for Signature verificationprivKey- PrivateKey to be used for Signature calculation- Returns:
- An
org.w3c.dom.Elementrepresentation of Signed SAML Assertion - Throws:
SAMLException
-
sign
public Element sign(DigestMethod digestMethod, String signatureMethod, X509Certificate cert, PrivateKey privKey, boolean includeCert) throws SAMLException
Description copied from interface:AssertionSign the SAML Assertion - Enveloped Signature- Specified by:
signin interfaceAssertion- Parameters:
digestMethod- Ajavax.xml.crypto.dsig.DigestMethodrepresenting the digest method used for SAML signature.signatureMethod- Ajavax.xml.crypto.dsig.SignatureMethodrepresenting the signature algorithm used SAML signature.cert- Ajava.security.cert.X509Certificaterepresenting the certificate used for Signature verificationprivKey- Ajava.security.PrivateKeyrepresenting the private key used for Signature calculation.includeCert- A flag to tell whether to incude the certificate in the SAML signature. By Default DigestMethod.SHA1, SignatureMethod.RSA_SHA1 and CanonicalizationMethod.EXCLUSIVE will be used.- Returns:
- An
org.w3c.dom.Elementrepresentation of Signed SAML Assertion - Throws:
SAMLException
-
sign
public Element sign(DigestMethod digestMethod, String signatureMethod, X509Certificate cert, PrivateKey privKey) throws SAMLException
Description copied from interface:AssertionSign the SAML Assertion - Enveloped Signature- Specified by:
signin interfaceAssertion- Parameters:
digestMethod- Ajavax.xml.crypto.dsig.DigestMethodrepresenting the digest method used for SAML signature.signatureMethod- Ajavax.xml.crypto.dsig.SignatureMethodrepresenting the signature algorithm used SAML signature.cert- Ajava.security.cert.X509Certificaterepresenting the certificate used for Signature verificationprivKey- Ajava.security.PrivateKeyrepresenting the private key used for Signature calculation. By Default DigestMethod.SHA1, SignatureMethod.RSA_SHA1 and CanonicalizationMethod.EXCLUSIVE will be used.- Returns:
- An
org.w3c.dom.Elementrepresentation of Signed SAML Assertion - Throws:
SAMLException
-
toElement
public Element toElement(Node doc) throws XWSSecurityException
Description copied from interface:AssertionConvert SAML Assertion toorg.w3c.dom.Element- Specified by:
toElementin interfaceAssertion- Parameters:
doc- the contextorg.w3c.dom.Nodefor the creation of the resultingorg.w3c.dom.Element.- Returns:
- org.w3c.dom.Element element representation of SAML Assertion
- Throws:
XWSSecurityException
-
isSigned
public boolean isSigned()
-
fromElement
public static Assertion fromElement(Element element) throws SAMLException
This constructor is used to buildAssertionobject from a block of existing XML that has already been built into a DOM.- Parameters:
element- Aorg.w3c.dom.Elementrepresenting DOM tree forAssertionobject- Throws:
SAMLException- if it could not process the Element properly, implying that there is an error in the sender or in the element definition.
-
getTokenValue
public Object getTokenValue()
Description copied from interface:TokenThe token Value- Specified by:
getTokenValuein interfaceToken
-
getStatements
public List<Object> getStatements()
Description copied from interface:AssertionReturn all statements presents in the SAML Assertion.- Specified by:
getStatementsin interfaceAssertion- Returns:
- An
java.util.Listof java.lang.Object representing all statements present inside the SAML assertion.
-
verifySignature
public boolean verifySignature(PublicKey pubKey) throws SAMLException
Description copied from interface:AssertionVerify the SAML signature with the Public Key- Specified by:
verifySignaturein interfaceAssertion- Parameters:
pubKey- Ajava.security.PublicKeyrepresenting the public key used for Signature verification- Returns:
- An
Booleanrepresenting whether SAML signature verification is successful or not. - Throws:
SAMLException
-
-