Class AssertionImpl
- java.lang.Object
-
- com.sun.identity.saml2.assertion.impl.AssertionImpl
-
- All Implemented Interfaces:
Assertion
public class AssertionImpl extends Object implements Assertion
TheAssertionelement is a package of information that supplies one or moreStatementmade by an issuer. There are three kinds of assertions: Authentication, Authorization Decision, and Attribute assertions.
-
-
Field Summary
Fields Modifier and Type Field Description static StringASSERTION_ADVICEstatic StringASSERTION_ATTRIBUTESTATEMENTstatic StringASSERTION_AUTHNSTATEMENTstatic StringASSERTION_AUTHZDECISIONSTATEMENTstatic StringASSERTION_CONDITIONSstatic StringASSERTION_ELEMENTstatic StringASSERTION_ID_ATTRstatic StringASSERTION_ISSUEINSTANT_ATTRstatic StringASSERTION_ISSUERstatic StringASSERTION_SIGNATUREstatic StringASSERTION_STATEMENTstatic StringASSERTION_SUBJECTstatic StringASSERTION_VERSION_ATTRstatic StringXSI_TYPE_ATTR
-
Constructor Summary
Constructors Constructor Description AssertionImpl()Default constructorAssertionImpl(String xml)This constructor is used to buildAssertionobject from a XML string.AssertionImpl(Element element)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 Concrete Methods Modifier and Type Method Description EncryptedAssertionencrypt(Key recipientPublicKey, String dataEncAlgorithm, int dataEncStrength, String recipientEntityID)Returns anEncryptedAssertionobject.AdvicegetAdvice()Returns the advice of the assertionList<AttributeStatement>getAttributeStatements()Returns the attribute statements of the assertionList<AuthnStatement>getAuthnStatements()Returns the Authn statements of the assertionList<AuthzDecisionStatement>getAuthzDecisionStatements()Returns theAuthzDecisionStatementsof the assertionConditionsgetConditions()Returns the conditions of the assertionStringgetID()Returns the id of the assertionDategetIssueInstant()Returns the time when the assertion was issuedIssuergetIssuer()Returns the issuer of the assertionStringgetSignature()Returns the signature of the assertionList<Object>getStatements()Returns the statements of the assertionSubjectgetSubject()Returns the subject of the assertionStringgetVersion()Returns the version number of the assertion.booleanisMutable()Returns true if the object is mutablebooleanisSignatureValid(Set<X509Certificate> verificationCerts)Return whether the signature is valid or not.booleanisSigned()Return whether the assertion is signedbooleanisTimeValid()Gets the validity of the assertion evaluating its conditions if specified.voidmakeImmutable()Makes the object immutablevoidsetAdvice(Advice advice)Sets the advice of the assertionvoidsetAttributeStatements(List<AttributeStatement> statements)Sets the attribute statements of the assertionvoidsetAuthnStatements(List<AuthnStatement> statements)Sets theAuthnStatementsof the assertionvoidsetAuthzDecisionStatements(List<AuthzDecisionStatement> statements)Sets theAuthzDecisionStatementsof the assertionvoidsetConditions(Conditions conditions)Sets the conditions of the assertionvoidsetID(String id)Sets the id of the assertionvoidsetIssueInstant(Date issueInstant)Set the time when the assertion was issuedvoidsetIssuer(Issuer issuer)Sets the issuer of the assertionvoidsetStatements(List<Object> statements)Sets the statements of the assertionvoidsetSubject(Subject subject)Sets the subject of the assertionvoidsetVersion(String version)Sets the version number of the assertion.voidsign(PrivateKey privateKey, X509Certificate cert)Sign the Assertion.StringtoXMLString()Returns a String representationStringtoXMLString(boolean includeNSPrefix, boolean declareNS)Returns a String representation
-
-
-
Field Detail
-
ASSERTION_ELEMENT
public static String ASSERTION_ELEMENT
-
ASSERTION_VERSION_ATTR
public static String ASSERTION_VERSION_ATTR
-
ASSERTION_ID_ATTR
public static String ASSERTION_ID_ATTR
-
ASSERTION_ISSUEINSTANT_ATTR
public static String ASSERTION_ISSUEINSTANT_ATTR
-
XSI_TYPE_ATTR
public static String XSI_TYPE_ATTR
-
ASSERTION_ISSUER
public static String ASSERTION_ISSUER
-
ASSERTION_SIGNATURE
public static String ASSERTION_SIGNATURE
-
ASSERTION_SUBJECT
public static String ASSERTION_SUBJECT
-
ASSERTION_CONDITIONS
public static String ASSERTION_CONDITIONS
-
ASSERTION_ADVICE
public static String ASSERTION_ADVICE
-
ASSERTION_STATEMENT
public static String ASSERTION_STATEMENT
-
ASSERTION_AUTHNSTATEMENT
public static String ASSERTION_AUTHNSTATEMENT
-
ASSERTION_AUTHZDECISIONSTATEMENT
public static String ASSERTION_AUTHZDECISIONSTATEMENT
-
ASSERTION_ATTRIBUTESTATEMENT
public static String ASSERTION_ATTRIBUTESTATEMENT
-
-
Constructor Detail
-
AssertionImpl
public AssertionImpl()
Default constructor
-
AssertionImpl
public AssertionImpl(String xml) throws SAML2Exception
This constructor is used to buildAssertionobject from a XML string.- Parameters:
xml- Ajava.lang.Stringrepresenting aAssertionobject- Throws:
SAML2Exception- if it could not process the XML string
-
AssertionImpl
public AssertionImpl(Element element) throws SAML2Exception
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:
SAML2Exception- if it could not process the Element
-
-
Method Detail
-
getVersion
public String getVersion()
Returns the version number of the assertion.- Specified by:
getVersionin interfaceAssertion- Returns:
- The version number of the assertion.
-
setVersion
public void setVersion(String version) throws SAML2Exception
Sets the version number of the assertion.- Specified by:
setVersionin interfaceAssertion- Parameters:
version- the version number.- Throws:
SAML2Exception- if the object is immutable
-
getIssueInstant
public Date getIssueInstant()
Returns the time when the assertion was issued- Specified by:
getIssueInstantin interfaceAssertion- Returns:
- the time of the assertion issued
-
setIssueInstant
public void setIssueInstant(Date issueInstant) throws SAML2Exception
Set the time when the assertion was issued- Specified by:
setIssueInstantin interfaceAssertion- Parameters:
issueInstant- the issue time of the assertion- Throws:
SAML2Exception- if the object is immutable
-
getSubject
public Subject getSubject()
Returns the subject of the assertion- Specified by:
getSubjectin interfaceAssertion- Returns:
- the subject of the assertion
-
setSubject
public void setSubject(Subject subject) throws SAML2Exception
Sets the subject of the assertion- Specified by:
setSubjectin interfaceAssertion- Parameters:
subject- the subject of the assertion- Throws:
SAML2Exception- if the object is immutable
-
getAdvice
public Advice getAdvice()
Returns the advice of the assertion
-
setAdvice
public void setAdvice(Advice advice) throws SAML2Exception
Sets the advice of the assertion- Specified by:
setAdvicein interfaceAssertion- Parameters:
advice- the advice of the assertion- Throws:
SAML2Exception- if the object is immutable
-
getSignature
public String getSignature()
Returns the signature of the assertion- Specified by:
getSignaturein interfaceAssertion- Returns:
- the signature of the assertion
-
getConditions
public Conditions getConditions()
Returns the conditions of the assertion- Specified by:
getConditionsin interfaceAssertion- Returns:
- the conditions of the assertion
-
setConditions
public void setConditions(Conditions conditions) throws SAML2Exception
Sets the conditions of the assertion- Specified by:
setConditionsin interfaceAssertion- Parameters:
conditions- the conditions of the assertion- Throws:
SAML2Exception- if the object is immutable
-
getID
public String getID()
Returns the id of the assertion
-
setID
public void setID(String id) throws SAML2Exception
Sets the id of the assertion- Specified by:
setIDin interfaceAssertion- Parameters:
id- the id of the assertion- Throws:
SAML2Exception- if the object is immutable
-
getStatements
public List<Object> getStatements()
Returns the statements of the assertion- Specified by:
getStatementsin interfaceAssertion- Returns:
- the statements of the assertion
-
getAuthnStatements
public List<AuthnStatement> getAuthnStatements()
Returns the Authn statements of the assertion- Specified by:
getAuthnStatementsin interfaceAssertion- Returns:
- the Authn statements of the assertion
-
getAuthzDecisionStatements
public List<AuthzDecisionStatement> getAuthzDecisionStatements()
Returns theAuthzDecisionStatementsof the assertion- Specified by:
getAuthzDecisionStatementsin interfaceAssertion- Returns:
- the
AuthzDecisionStatementsof the assertion
-
getAttributeStatements
public List<AttributeStatement> getAttributeStatements()
Returns the attribute statements of the assertion- Specified by:
getAttributeStatementsin interfaceAssertion- Returns:
- the attribute statements of the assertion
-
setStatements
public void setStatements(List<Object> statements) throws SAML2Exception
Sets the statements of the assertion- Specified by:
setStatementsin interfaceAssertion- Parameters:
statements- the statements of the assertion- Throws:
SAML2Exception- if the object is immutable
-
setAuthnStatements
public void setAuthnStatements(List<AuthnStatement> statements) throws SAML2Exception
Sets theAuthnStatementsof the assertion- Specified by:
setAuthnStatementsin interfaceAssertion- Parameters:
statements- theAuthnStatementsof the assertion- Throws:
SAML2Exception- if the object is immutable
-
setAuthzDecisionStatements
public void setAuthzDecisionStatements(List<AuthzDecisionStatement> statements) throws SAML2Exception
Sets theAuthzDecisionStatementsof the assertion- Specified by:
setAuthzDecisionStatementsin interfaceAssertion- Parameters:
statements- theAuthzDecisionStatementsof the assertion- Throws:
SAML2Exception- if the object is immutable
-
setAttributeStatements
public void setAttributeStatements(List<AttributeStatement> statements) throws SAML2Exception
Sets the attribute statements of the assertion- Specified by:
setAttributeStatementsin interfaceAssertion- Parameters:
statements- the attribute statements of the assertion- Throws:
SAML2Exception- if the object is immutable
-
getIssuer
public Issuer getIssuer()
Returns the issuer of the assertion
-
setIssuer
public void setIssuer(Issuer issuer) throws SAML2Exception
Sets the issuer of the assertion- Specified by:
setIssuerin interfaceAssertion- Parameters:
issuer- the issuer of the assertion- Throws:
SAML2Exception- if the object is immutable
-
isSigned
public boolean isSigned()
Return whether the assertion is signed
-
isSignatureValid
public boolean isSignatureValid(Set<X509Certificate> verificationCerts) throws SAML2Exception
Description copied from interface:AssertionReturn whether the signature is valid or not.- Specified by:
isSignatureValidin interfaceAssertion- Parameters:
verificationCerts- Certificates containing the public keys which may be used for signature verification; This certificate may also may be used to check against the certificate included in the signature.- Returns:
- true if the signature is valid; false otherwise.
- Throws:
SAML2Exception- if the signature could not be verified
-
sign
public void sign(PrivateKey privateKey, X509Certificate cert) throws SAML2Exception
Sign the Assertion.- Specified by:
signin interfaceAssertion- Parameters:
privateKey- Signing keycert- Certificate which contain the public key correlated to the signing key; It if is not null, then the signature will include the certificate; Otherwise, the signature will not include any certificate- Throws:
SAML2Exception- if it could not sign the assertion.
-
encrypt
public EncryptedAssertion encrypt(Key recipientPublicKey, String dataEncAlgorithm, int dataEncStrength, String recipientEntityID) throws SAML2Exception
Returns anEncryptedAssertionobject.- Specified by:
encryptin interfaceAssertion- Parameters:
recipientPublicKey- Public key used to encrypt the data encryption (secret) key, it is the public key of the recipient of the XML document to be encrypted.dataEncAlgorithm- Data encryption algorithm.dataEncStrength- Data encryption strength.recipientEntityID- Unique identifier of the recipient, it is used as the index to the cached secret key so that the key can be reused for the same recipient; It can be null in which case the secret key will be generated every time and will not be cached and reused. Note that the generation of a secret key is a relatively expensive operation.- Returns:
EncryptedAssertionobject- Throws:
SAML2Exception- if error occurs during the encryption process.
-
isTimeValid
public boolean isTimeValid()
Gets the validity of the assertion evaluating its conditions if specified.- Specified by:
isTimeValidin interfaceAssertion- 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.
-
toXMLString
public String toXMLString(boolean includeNSPrefix, boolean declareNS) throws SAML2Exception
Returns a String representation- Specified by:
toXMLStringin interfaceAssertion- Parameters:
includeNSPrefix- Determines whether or not the namespace qualifier is prepended to the Element when converteddeclareNS- Determines whether or not the namespace is declared within the Element.- Returns:
- A String representation
- Throws:
SAML2Exception- if something is wrong during conversion
-
toXMLString
public String toXMLString() throws SAML2Exception
Returns a String representation- Specified by:
toXMLStringin interfaceAssertion- Returns:
- A String representation
- Throws:
SAML2Exception- if something is wrong during conversion
-
makeImmutable
public void makeImmutable()
Makes the object immutable- Specified by:
makeImmutablein interfaceAssertion
-
-