Package com.sun.identity.saml.assertion
Class AssertionBase
- java.lang.Object
-
- com.sun.identity.saml.assertion.AssertionBase
-
- Direct Known Subclasses:
Assertion
public abstract class AssertionBase extends Object
This object stands forAssertionelement.An Assertion is a package of information that supplies one or moreStatementmade by an issuer. There are three kinds of assertionsL Authentication, AuthorizationDecision and Attribute assertion. This class is an abstract base class for all Assertion implementations and encapsulates common functionality.
-
-
Field Summary
Fields Modifier and Type Field Description protected AdviceBase_adviceTheAdviceelement specifies additional information related to the assertion that may assist processing in certain situations but which can be ignored by applications that do not support its use.protected AssertionIDReference_assertionIDThe _assertionID attribute specifies the assertion identifier.protected Conditions_conditionsTheConditionselement specifies conditions that affect the validity of the asserted statement.protected Date_issueInstantThe IssueInstant attribute specifies the time instant of issue in Universal Coordinated Time.protected String_issuerThe Issuer attribute specifies the issuer of the assertion by means of a string.protected int_majorVersionThis value specifies the SAML major version.protected int_minorVersionThis value specifies the SAML minor version.protected Set_statementsThe statements variable is a HashSet of all the stataments in this assertion in the defined sequenceprotected static StringASSERTION_ID_ATTRIBUTEprotected static SAMLConstantsscprotected Elementsignatureprotected StringsignatureStringprotected booleansignedprotected booleanvalidprotected booleanvalidationDoneprotected StringxmlString
-
Constructor Summary
Constructors Modifier Constructor Description protectedAssertionBase()Default constructor, declaring protected to enable extensibilityAssertionBase(String assertionID, String issuer, Date issueInstant, Conditions conditions, AdviceBase advice, Set statements)This constructor is used to populate the data members: thessertionID, the issuer, time when assertion issued, the conditions when creating a new assertion ,Adviceapplicable to thisAssertionand a set ofStatement(s) in the assertion.AssertionBase(String assertionID, String issuer, Date issueInstant, Conditions conditions, Set statements)This constructor is used to populate the data members: theassertionID, the issuer, time when assertion issued, the conditions when creating a new assertion and a set ofStatement(s) in the assertion.AssertionBase(String assertionID, String issuer, Date issueInstant, Set statements)Contructor This constructor is used to populate the data members:assertionID, the issuer, time when assertion issued and a set ofStatement(s) in the assertion.AssertionBase(Element assertionElement)Contructor This constructor is used to buildAssertionobject from a block of existing XML that has already been built into a DOM.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanaddStatement(Statement statement)Adds a statement to thisAssertionprotected abstract AdviceBasecreateAdvice(Element adviceElement)Creates appropriate Advice instanceprotected abstract AssertionIDReferencecreateAssertionIDReference(String assertionID)Creates appropriate AssertionIDReference instanceprotected abstract AssertionIDReferencecreateAssertionIDReference(Element assertionIDRefElement)Creates appropriate AssertionIDReference instanceprotected abstract AttributeStatementcreateAttributeStatement(Element attributeElement)Creates appropriate AttributeStatement instanceprotected abstract AuthenticationStatementcreateAuthenticationStatement(Element authenticationElement)Creates appropriate AuthenticationStatement instanceprotected abstract AuthorizationDecisionStatementBasecreateAuthorizationDecisionStatement(Element authDecisionElement)Create appropriate AuthorizationDecisionStatement instanceprotected abstract ConditionscreateConditions(Element conditionsElement)Creates appropriate Conditions instanceStringgetAssertionID()Returns the assertion ID.ConditionsgetConditions()Returns the conditions of an assertion.DategetIssueInstant()Returns the time when the assertion was issued.StringgetIssuer()Returns the issuer of an assertion.intgetMajorVersion()Returns the major version number of an assertion.intgetMinorVersion()Returns the minor version number of an assertion.ElementgetSignature()Gets the Signature element of the Assertion.SetgetStatement()Returns a set ofStatementcontained within this assertion.booleanisSignatureValid()Returns whether the signature on the object is valid or not.booleanisSigned()Returns whether the object is signed or not.booleanisTimeValid()Gets the validity of the assertion evaluating its conditions if specified.booleansetAdvice(AdviceBase advice)Sets the advice for an assertionprotected booleansetAssertionID(String assertionID)Set theAssertionIDfor this assertionbooleansetConditions(Conditions conditions)Sets the Conditions information for an assertionprotected booleansetIssueInstant(Date issueInstant)Set the time when the assertion was issuedprotected booleansetIssuer(String issuer)Sets the issuer for an assertionvoidsetMajorVersion(int majorVersion)Sets the major version number of an assertion.voidsetMinorVersion(int minorVersion)Sets the minor version number of an assertion.booleansetSignature(Element elem)Sets the signature for the RequestvoidsignXML()Signs the Assertion.voidsignXML(String certAlias)Signs the Assertion.StringtoString()Returns a String representation of the element.StringtoString(boolean includeNS, boolean declareNS)Returns a String representation of the<Assertion>element.
-
-
-
Field Detail
-
sc
protected static SAMLConstants sc
-
_statements
protected Set _statements
The statements variable is a HashSet of all the stataments in this assertion in the defined sequence
-
_majorVersion
protected int _majorVersion
This value specifies the SAML major version. Each assertion MUST specify the SAML major version identifier.The identifier for this version of SAML is 1.
-
_minorVersion
protected int _minorVersion
This value specifies the SAML minor version. Each assertion MUST specify the SAML minor version identifier. The identifier for this version of SAML is 0.
-
_assertionID
protected AssertionIDReference _assertionID
The _assertionID attribute specifies the assertion identifier.
-
_issuer
protected String _issuer
The Issuer attribute specifies the issuer of the assertion by means of a string.
-
_issueInstant
protected Date _issueInstant
The IssueInstant attribute specifies the time instant of issue in Universal Coordinated Time.
-
_conditions
protected Conditions _conditions
TheConditionselement specifies conditions that affect the validity of the asserted statement.
-
_advice
protected AdviceBase _advice
TheAdviceelement specifies additional information related to the assertion that may assist processing in certain situations but which can be ignored by applications that do not support its use.
-
xmlString
protected String xmlString
-
signatureString
protected String signatureString
-
signature
protected Element signature
-
signed
protected boolean signed
-
valid
protected boolean valid
-
validationDone
protected boolean validationDone
-
ASSERTION_ID_ATTRIBUTE
protected static final String ASSERTION_ID_ATTRIBUTE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AssertionBase
protected AssertionBase()
Default constructor, declaring protected to enable extensibility
-
AssertionBase
public AssertionBase(Element assertionElement) throws SAMLException
Contructor This constructor is used to buildAssertionobject from a block of existing XML that has already been built into a DOM.- Parameters:
assertionElement- 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.
-
AssertionBase
public AssertionBase(String assertionID, String issuer, Date issueInstant, Set statements) throws SAMLException
Contructor This constructor is used to populate the data members:assertionID, the issuer, time when assertion issued and a set ofStatement(s) in the assertion.- Parameters:
assertionID-assertionIDattribute contained within thisAssertionif null, anassertionIDis 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.statements- set 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.
-
AssertionBase
public AssertionBase(String assertionID, String issuer, Date issueInstant, Conditions conditions, Set 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 and a set ofStatement(s) in the assertion.- Parameters:
assertionID-AssertionIDcontained 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.statements- Set 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.
-
AssertionBase
public AssertionBase(String assertionID, String issuer, Date issueInstant, Conditions conditions, AdviceBase advice, Set statements) throws SAMLException
This constructor is used to populate the data members: thessertionID, 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- Set 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.
-
-
Method Detail
-
isSigned
public boolean isSigned()
Returns whether the object is signed or not.- Returns:
- true if the object is signed; false otherwise.
-
isSignatureValid
public boolean isSignatureValid()
Returns whether the signature on the object is valid or not.- Returns:
- true if the signature on the object is valid; false otherwise.
-
signXML
public void signXML() throws SAMLExceptionSigns the Assertion.- Throws:
SAMLException- If it could not sign the Assertion.
-
signXML
public void signXML(String certAlias) throws SAMLException
Signs the Assertion.- Parameters:
certAlias- certification Alias used to sign Assertion.- Throws:
SAMLException- if it could not sign the Assertion.
-
getSignature
public Element getSignature()
Gets the Signature element of the Assertion.- Returns:
- Element the Signature of the Assertion in DOM element.
-
setSignature
public boolean setSignature(Element elem)
Sets the signature for the Request- Parameters:
elem- ds:Signature element- Returns:
- A boolean value: true if the operation succeeds; false otherwise.
-
createAdvice
protected abstract AdviceBase createAdvice(Element adviceElement) throws SAMLException
Creates appropriate Advice instance- Parameters:
adviceElement- the Advice Element- Returns:
- the Advice instance
- Throws:
SAMLException
-
createAuthorizationDecisionStatement
protected abstract AuthorizationDecisionStatementBase createAuthorizationDecisionStatement(Element authDecisionElement) throws SAMLException
Create appropriate AuthorizationDecisionStatement instance- Parameters:
authDecisionElement- the AuthorizationDecisionStatement Element- Returns:
- AuthorizationDecisionStatement instance
- Throws:
SAMLException
-
createAuthenticationStatement
protected abstract AuthenticationStatement createAuthenticationStatement(Element authenticationElement) throws SAMLException
Creates appropriate AuthenticationStatement instance- Parameters:
authenticationElement- the AuthenticationStatement Element- Returns:
- AuthenticationStatement instance
- Throws:
SAMLException
-
createAttributeStatement
protected abstract AttributeStatement createAttributeStatement(Element attributeElement) throws SAMLException
Creates appropriate AttributeStatement instance- Parameters:
attributeElement- the AttributeStatement Element- Returns:
- AttributeStatement instance
- Throws:
SAMLException
-
createAssertionIDReference
protected abstract AssertionIDReference createAssertionIDReference(Element assertionIDRefElement) throws SAMLException
Creates appropriate AssertionIDReference instance- Parameters:
assertionIDRefElement- the AssertionIDReference Element- Returns:
- AssertionIDReference instance
- Throws:
SAMLException
-
createAssertionIDReference
protected abstract AssertionIDReference createAssertionIDReference(String assertionID) throws SAMLException
Creates appropriate AssertionIDReference instance- Parameters:
assertionID- the AssertionID String- Returns:
- AssertionIDReference instance
- Throws:
SAMLException
-
createConditions
protected abstract Conditions createConditions(Element conditionsElement) throws SAMLException
Creates appropriate Conditions instance- Parameters:
conditionsElement- the Conditions Element- Returns:
- Conditions instance
- Throws:
SAMLException
-
isTimeValid
public boolean isTimeValid()
Gets the validity of the assertion evaluating its conditions if specified.- Returns:
- false if conditions is invalid based on it lying between
NotBefore(current time inclusive) andNotOnOrAfter(current time exclusive) values and true otherwise or if no conditions specified.
-
addStatement
public boolean addStatement(Statement statement)
Adds a statement to thisAssertion- Parameters:
statement-Statementto be added- Returns:
- boolean indicating success or failure of operation.
-
setIssueInstant
protected boolean setIssueInstant(Date issueInstant)
Set the time when the assertion was issued- Parameters:
issueInstant- :java.util.Daterepresenting the time of the assertion- Returns:
- A boolean indicating the success of the operation.
-
setAssertionID
protected boolean setAssertionID(String assertionID)
Set theAssertionIDfor this assertion- Parameters:
assertionID- : a String representing id of this assertion.- Returns:
- A boolean indicating the success of the operation.
-
setIssuer
protected boolean setIssuer(String issuer)
Sets the issuer for an assertion- Parameters:
issuer- : a string representing the issuer of the assertion- Returns:
- A boolean indicating the success of the operation.
-
setAdvice
public boolean setAdvice(AdviceBase advice)
Sets the advice for an assertion- Parameters:
advice- : a linked list representing the advice information- Returns:
- A boolean indicating the success of the operation.
-
setConditions
public boolean setConditions(Conditions conditions)
Sets the Conditions information for an assertion- Parameters:
conditions- a linked list representing the conditions information- Returns:
- A boolean indicating the success of the operation.
-
getMinorVersion
public int getMinorVersion()
Returns the minor version number of an assertion.- Returns:
- The minor version number of an assertion.
-
setMinorVersion
public void setMinorVersion(int minorVersion)
Sets the minor version number of an assertion.- Parameters:
minorVersion- minor version.
-
getMajorVersion
public int getMajorVersion()
Returns the major version number of an assertion.- Returns:
- The major version number of an assertion.
-
setMajorVersion
public void setMajorVersion(int majorVersion)
Sets the major version number of an assertion.- Parameters:
majorVersion- major version.
-
getIssueInstant
public Date getIssueInstant()
Returns the time when the assertion was issued.- Returns:
- The time in
java.util.Dateformat.
-
getIssuer
public String getIssuer()
Returns the issuer of an assertion.- Returns:
- The issuer of an assertion.
-
getAssertionID
public String getAssertionID()
Returns the assertion ID.- Returns:
- Assertion ID of the assertion.
-
getConditions
public Conditions getConditions()
Returns the conditions of an assertion.- Returns:
Conditionsobject containing conditions for an assertion being valid.
-
getStatement
public Set getStatement()
Returns a set ofStatementcontained within this assertion.- Returns:
- a set of
Statementcontained within this assertion.
-
toString
public String toString()
Returns a String representation of the element.
-
toString
public String toString(boolean includeNS, boolean declareNS)
Returns a String representation of the<Assertion>element.- Parameters:
includeNS- if true prepends all elements by their Namespace name example<saml:Assertion>declareNS- if true includes the namespace within the generated XML.- Returns:
- The valid XML for this element
-
-