Class Assertion
- java.lang.Object
-
- com.sun.xml.wss.saml.internal.saml11.jaxb20.AssertionType
-
- com.sun.xml.wss.saml.assertion.saml11.jaxb20.Assertion
-
- All Implemented Interfaces:
com.sun.xml.ws.security.Token,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] <Conditions NotBefore="2005-08-16T13:21:50.503+05:30" NotOnOrAfter="2005-08-16T15:21:50.504+05:30" xmlns="urn:oasis:names:tc:SAML:1.0:assertion"/> [java] <Subject xmlns="urn:oasis:names:tc:SAML:1.0:assertion"> [java] <NameIdentifier Format="urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName">CN=SAML User,OU=SU,O=SAML User,L=Los Angeles,ST=CA,C=US</NameIdentifier> [java] <SubjectConfirmation> [java] <ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:sender-vouches</ConfirmationMethod> [java] </SubjectConfirmation> [java] </Subject> [java] <Attribute AttributeName="attribute1" AttributeNamespace="urn:com:sun:xml:wss:attribute" xmlns="urn:oasis:names:tc:SAML:1.0:assertion"> [java] <AttributeValue>ATTRIBUTE1</AttributeValue> [java] </Attribute>thentication, Authorization Decision and Attribute assertion.
-
-
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.saml11.jaxb20.AssertionType
advice, assertionID, conditions, issueInstant, issuer, majorVersion, minorVersion, signature, statementOrSubjectStatementOrAuthenticationStatement
-
-
Constructor Summary
Constructors Constructor Description Assertion(AssertionType assertion)Assertion(String assertionID, String issuer, GregorianCalendar issueInstant, Conditions conditions, Advice advice, 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, String issuer, GregorianCalendar issueInstant, Conditions conditions, Advice advice, 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.ConditionsgetConditions()Gets the value of the conditions property.StringgetID()Get the SAML Assertion ID for SAML2.0StringgetIssueInstance()Gets the value of the issueInstant property.StringgetSamlIssuer()Get the issuer of SAML AssertionList<Object>getStatements()Return all statements presents in the SAML Assertion.SubjectgetSubject()Gets the value of the subject property of SAML 2.0 This method should be applied only on SAML 2.0 assertion.ObjectgetTokenValue()StringgetType()StringgetVersion()Get the SAML Vertion SAML2.0booleanisSigned()voidsetVersion(String version)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 alwaysIncludeCert)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.saml11.jaxb20.AssertionType
getAssertionID, getIssueInstant, getIssuer, getMajorVersion, getMinorVersion, getSignature, getStatementOrSubjectStatementOrAuthenticationStatement, setAdvice, setAssertionID, setConditions, setIssueInstant, setIssuer, setMajorVersion, setMinorVersion, setSignature
-
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
getAssertionID, getMajorVersion, getMinorVersion, setMajorVersion, setMinorVersion
-
-
-
-
Constructor Detail
-
Assertion
public Assertion(AssertionType assertion)
-
Assertion
public Assertion(String assertionID, String issuer, GregorianCalendar issueInstant, Conditions conditions, Advice advice, 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, String issuer, GregorianCalendar issueInstant, Conditions conditions, Advice advice, 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
-
getVersion
public String getVersion()
Description copied from interface:AssertionGet the SAML Vertion SAML2.0- Specified by:
getVersionin interfaceAssertion- Returns:
- An
java.lang.Stringrepresenting saml version.
-
setVersion
public void setVersion(String version)
- Specified by:
setVersionin interfaceAssertion- Parameters:
version- Ajava.lang.Stringrepresenting saml version
-
getID
public String getID()
Description copied from interface:AssertionGet the SAML Assertion ID for SAML2.0
-
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 interface:AssertionGets the value of the subject property of SAML 2.0 This method should be applied only on SAML 2.0 assertion. For SAML1.1 and SAML1.0, first get a list of statements of the SAML assertion by calling getStatements() on theAssertionobject, then call the getSubject() on each statement.- Specified by:
getSubjectin interfaceAssertion- Returns:
- A
Subjectrepresenting Subject of SAML 2.0
-
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 alwaysIncludeCert) 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.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(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 com.sun.xml.wss.XWSSecurityException
Description copied from interface:AssertionConvert SAML Assertion toorg.w3c.dom.Element
-
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.
-
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.Listofjava.lang.Objectrepresenting all statements present inside the SAML assertion.
-
getType
public String getType()
- Specified by:
getTypein interfacecom.sun.xml.ws.security.Token
-
getTokenValue
public Object getTokenValue()
- Specified by:
getTokenValuein interfacecom.sun.xml.ws.security.Token
-
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
-
-