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 Document
convert(EncryptedElementType encryptedElementType)
Convert an EncryptedElement into a DocumentDocument
convert(StatusResponseType responseType)
Convert a SAML2 Response into a DocumentAssertionType
createAssertion(String id, NameIDType issuer)
Create an assertionAuthnStatementType
createAuthnStatement(String authnContextDeclRef, XMLGregorianCalendar issueInstant)
Create an AuthnStatementAuthzDecisionStatementType
createAuthzDecisionStatementType(String resource, DecisionType decision, EvidenceType evidence, ActionType... actions)
Create an Authorization Decision Statement TypeResponseType
createResponseType(String ID)
Create an empty response typeResponseType
createResponseType(String ID, IssuerInfoHolder issuerInfo, AssertionType assertion)
Create a ResponseTypeResponseType
createResponseType(String ID, IssuerInfoHolder issuerInfo, Element encryptedAssertion)
Create a ResponseTypeResponseType
createResponseType(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)
void
createTimedConditions(AssertionType assertion, long durationInMilis)
Add validity conditions to the SAML2 AssertionAssertionType
getAssertionType(InputStream is)
Read an assertion from an input streamEncryptedAssertionType
getEncryptedAssertion(InputStream is)
Get an encrypted assertion from the streamResponseType
getResponseType(InputStream is)
Read a ResponseType from an input streamSAML2Object
getSAML2ObjectFromStream(InputStream is)
Read aSAML2Object
from an input streamSAMLDocumentHolder
getSamlDocumentHolder()
Get the parsedSAMLDocumentHolder
void
marshall(ResponseType responseType, OutputStream os)
Marshall the response type to the output streamvoid
marshall(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:
ConfigurationException
ProcessingException
-
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 DOMElement
that 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:
ConfigurationException
IssueInstantMissingException
-
getEncryptedAssertion
public EncryptedAssertionType getEncryptedAssertion(InputStream is) throws ParsingException, ConfigurationException, ProcessingException
Get an encrypted assertion from the stream- Parameters:
is
-- Returns:
- Throws:
ParsingException
ProcessingException
ConfigurationException
-
getAssertionType
public AssertionType getAssertionType(InputStream is) throws ParsingException, ConfigurationException, ProcessingException
Read an assertion from an input stream- Parameters:
is
-- Returns:
- Throws:
ParsingException
ProcessingException
ConfigurationException
-
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:
ParsingException
ConfigurationException
ProcessingException
-
getSAML2ObjectFromStream
public SAML2Object getSAML2ObjectFromStream(InputStream is) throws ParsingException, ConfigurationException, ProcessingException
Read aSAML2Object
from an input stream- Parameters:
is
-- Returns:
- Throws:
ParsingException
ConfigurationException
ProcessingException
-
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:
ParsingException
ConfigurationException
ProcessingException
-
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
-
-