Class SAML2Response
- java.lang.Object
-
- org.keycloak.saml.processing.api.saml.v2.response.SAML2Response
-
public class SAML2Response extends Object
API for dealing with SAML2 Response objects- Since:
- Jan 5, 2009
- Author:
- Anil.Saldhana@redhat.com
-
-
Constructor Summary
Constructors Constructor Description SAML2Response()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Documentconvert(EncryptedElementType encryptedElementType)Convert an EncryptedElement into a DocumentDocumentconvert(StatusResponseType responseType)Convert a SAML2 Response into a DocumentAssertionTypecreateAssertion(String id, NameIDType issuer)Create an assertionAuthnStatementTypecreateAuthnStatement(String authnContextDeclRef, XMLGregorianCalendar issueInstant)Create an AuthnStatementAuthzDecisionStatementTypecreateAuthzDecisionStatementType(String resource, DecisionType decision, EvidenceType evidence, ActionType... actions)Create an Authorization Decision Statement TypeResponseTypecreateResponseType(String ID)Create an empty response typeResponseTypecreateResponseType(String ID, IssuerInfoHolder issuerInfo, AssertionType assertion)Create a ResponseTypeResponseTypecreateResponseType(String ID, IssuerInfoHolder issuerInfo, Element encryptedAssertion)Create a ResponseTypeResponseTypecreateResponseType(String ID, SPInfoHolder sp, IDPInfoHolder idp, IssuerInfoHolder issuerInfo)Create a ResponseType NOTE:: The PicketLink STS is used to issue/update the assertion If you want to control over the assertion being issued, then use#createResponseType(String, SPInfoHolder, IDPInfoHolder, IssuerInfoHolder, AssertionType)voidcreateTimedConditions(AssertionType assertion, long durationInMilis)Add validity conditions to the SAML2 AssertionAssertionTypegetAssertionType(InputStream is)Read an assertion from an input streamEncryptedAssertionTypegetEncryptedAssertion(InputStream is)Get an encrypted assertion from the streamResponseTypegetResponseType(InputStream is)Read a ResponseType from an input streamSAML2ObjectgetSAML2ObjectFromStream(InputStream is)Read aSAML2Objectfrom an input streamSAMLDocumentHoldergetSamlDocumentHolder()Get the parsedSAMLDocumentHoldervoidmarshall(ResponseType responseType, OutputStream os)Marshall the response type to the output streamvoidmarshall(ResponseType responseType, Writer writer)Marshall the ResponseType into a writer
-
-
-
Method Detail
-
createAssertion
public AssertionType createAssertion(String id, NameIDType issuer)
Create an assertion- Parameters:
id-issuer-- Returns:
-
createAuthnStatement
public AuthnStatementType createAuthnStatement(String authnContextDeclRef, XMLGregorianCalendar issueInstant)
Create an AuthnStatement- Parameters:
authnContextDeclRef- such as JBossSAMLURIConstants.AC_PASSWORD_PROTECTED_TRANSPORTissueInstant-- Returns:
-
createAuthzDecisionStatementType
public AuthzDecisionStatementType createAuthzDecisionStatementType(String resource, DecisionType decision, EvidenceType evidence, ActionType... actions)
Create an Authorization Decision Statement Type- Parameters:
resource-decision-evidence-actions-- Returns:
-
createResponseType
public ResponseType createResponseType(String ID, SPInfoHolder sp, IDPInfoHolder idp, IssuerInfoHolder issuerInfo) throws ProcessingException
Create a ResponseType NOTE:: The PicketLink STS is used to issue/update the assertion If you want to control over the assertion being issued, then use#createResponseType(String, SPInfoHolder, IDPInfoHolder, IssuerInfoHolder, AssertionType)- Parameters:
ID- id of the responsesp- holder with the information about the Service Provideridp- holder with the information on the Identity ProviderissuerInfo- holder with information on the issuer- Returns:
- Throws:
ConfigurationExceptionProcessingException
-
createResponseType
public ResponseType createResponseType(String ID)
Create an empty response type- Returns:
-
createResponseType
public ResponseType createResponseType(String ID, IssuerInfoHolder issuerInfo, AssertionType assertion)
Create a ResponseType- Parameters:
ID-issuerInfo-assertion-- Returns:
- Throws:
ConfigurationException
-
createResponseType
public ResponseType createResponseType(String ID, IssuerInfoHolder issuerInfo, Element encryptedAssertion) throws ConfigurationException
Create a ResponseType- Parameters:
ID-issuerInfo-encryptedAssertion- a DOMElementthat represents an encrypted assertion- Returns:
- Throws:
ConfigurationException
-
createTimedConditions
public void createTimedConditions(AssertionType assertion, long durationInMilis) throws ConfigurationException, IssueInstantMissingException
Add validity conditions to the SAML2 Assertion- Parameters:
assertion-durationInMilis-- Throws:
ConfigurationExceptionIssueInstantMissingException
-
getEncryptedAssertion
public EncryptedAssertionType getEncryptedAssertion(InputStream is) throws ParsingException, ConfigurationException, ProcessingException
Get an encrypted assertion from the stream- Parameters:
is-- Returns:
- Throws:
ParsingExceptionProcessingExceptionConfigurationException
-
getAssertionType
public AssertionType getAssertionType(InputStream is) throws ParsingException, ConfigurationException, ProcessingException
Read an assertion from an input stream- Parameters:
is-- Returns:
- Throws:
ParsingExceptionProcessingExceptionConfigurationException
-
getSamlDocumentHolder
public SAMLDocumentHolder getSamlDocumentHolder()
Get the parsedSAMLDocumentHolder- Returns:
-
getResponseType
public ResponseType getResponseType(InputStream is) throws ParsingException, ConfigurationException, ProcessingException
Read a ResponseType from an input stream- Parameters:
is-- Returns:
- Throws:
ParsingExceptionConfigurationExceptionProcessingException
-
getSAML2ObjectFromStream
public SAML2Object getSAML2ObjectFromStream(InputStream is) throws ParsingException, ConfigurationException, ProcessingException
Read aSAML2Objectfrom an input stream- Parameters:
is-- Returns:
- Throws:
ParsingExceptionConfigurationExceptionProcessingException
-
convert
public Document convert(EncryptedElementType encryptedElementType) throws ConfigurationException
Convert an EncryptedElement into a Document- Parameters:
encryptedElementType-- Returns:
- Throws:
ConfigurationException
-
convert
public Document convert(StatusResponseType responseType) throws ProcessingException, ConfigurationException, ParsingException
Convert a SAML2 Response into a Document- Parameters:
responseType-- Returns:
- Throws:
ParsingExceptionConfigurationExceptionProcessingException
-
marshall
public void marshall(ResponseType responseType, OutputStream os) throws ProcessingException
Marshall the response type to the output stream- Parameters:
responseType-os-- Throws:
ProcessingException
-
marshall
public void marshall(ResponseType responseType, Writer writer) throws ProcessingException
Marshall the ResponseType into a writer- Parameters:
responseType-writer-- Throws:
ProcessingException
-
-