use of org.keycloak.dom.saml.v2.protocol.StatusResponseType in project keycloak by keycloak.
the class SAMLParserTest method testLogoutResponseStatusDetail.
@Test
public void testLogoutResponseStatusDetail() throws Exception {
StatusResponseType resp = assertParsed("saml20-logout-response-status-detail.xml", StatusResponseType.class);
assertThat(resp.getIssuer(), notNullValue());
assertThat(resp.getIssuer().getValue(), is("http://idp.example.com/metadata.php"));
assertThat(resp.getIssuer().getFormat(), is(JBossSAMLURIConstants.NAMEID_FORMAT_ENTITY.getUri()));
assertThat(resp.getStatus(), notNullValue());
assertThat(resp.getStatus().getStatusDetail(), notNullValue());
assertThat(resp.getStatus().getStatusDetail().getAny(), notNullValue());
assertThat(resp.getStatus().getStatusDetail().getAny().size(), is(2));
assertThat(resp.getStatus().getStatusCode(), notNullValue());
assertThat(resp.getStatus().getStatusCode().getValue(), is(URI.create("urn:oasis:names:tc:SAML:2.0:status:Responder")));
assertThat(resp.getStatus().getStatusCode().getStatusCode(), nullValue());
}
use of org.keycloak.dom.saml.v2.protocol.StatusResponseType in project keycloak by keycloak.
the class SAMLParserTest method testLogoutResponseSimpleStatus.
@Test
public void testLogoutResponseSimpleStatus() throws Exception {
StatusResponseType resp = assertParsed("saml20-logout-response-status.xml", StatusResponseType.class);
assertThat(resp.getStatus(), notNullValue());
assertThat(resp.getStatus().getStatusMessage(), is("Status Message"));
assertThat(resp.getStatus().getStatusCode(), notNullValue());
assertThat(resp.getStatus().getStatusCode().getValue(), is(URI.create("urn:oasis:names:tc:SAML:2.0:status:Responder")));
assertThat(resp.getStatus().getStatusCode().getStatusCode(), nullValue());
}
use of org.keycloak.dom.saml.v2.protocol.StatusResponseType in project keycloak by keycloak.
the class SAMLParserTest method testLogoutResponseDeepNestedStatus.
@Test
public void testLogoutResponseDeepNestedStatus() throws Exception {
StatusResponseType resp = assertParsed("saml20-logout-response-nested-status-deep.xml", StatusResponseType.class);
assertThat(resp.getStatus(), notNullValue());
assertThat(resp.getStatus().getStatusDetail(), notNullValue());
assertThat(resp.getStatus().getStatusDetail().getAny(), notNullValue());
assertThat(resp.getStatus().getStatusDetail().getAny().size(), is(2));
assertThat(resp.getStatus().getStatusCode(), notNullValue());
assertThat(resp.getStatus().getStatusCode().getValue(), is(URI.create("urn:oasis:names:tc:SAML:2.0:status:Responder")));
assertThat(resp.getStatus().getStatusCode().getStatusCode(), notNullValue());
assertThat(resp.getStatus().getStatusCode().getStatusCode().getValue(), is(URI.create("urn:oasis:names:tc:SAML:2.0:status:AuthnFailed")));
assertThat(resp.getStatus().getStatusCode().getStatusCode().getStatusCode(), notNullValue());
assertThat(resp.getStatus().getStatusCode().getStatusCode().getStatusCode().getValue(), is(URI.create("urn:oasis:names:tc:SAML:2.0:status:VersionMismatch")));
}
use of org.keycloak.dom.saml.v2.protocol.StatusResponseType in project keycloak by keycloak.
the class SAMLParserTest method testLogoutResponseNestedStatus.
@Test
public void testLogoutResponseNestedStatus() throws Exception {
StatusResponseType resp = assertParsed("saml20-logout-response-nested-status.xml", StatusResponseType.class);
assertThat(resp.getStatus(), notNullValue());
assertThat(resp.getStatus().getStatusCode(), notNullValue());
assertThat(resp.getStatus().getStatusCode().getValue(), is(URI.create("urn:oasis:names:tc:SAML:2.0:status:Responder")));
assertThat(resp.getStatus().getStatusCode().getStatusCode(), notNullValue());
assertThat(resp.getStatus().getStatusCode().getStatusCode().getValue(), is(URI.create("urn:oasis:names:tc:SAML:2.0:status:AuthnFailed")));
assertThat(resp.getStatus().getStatusCode().getStatusCode().getStatusCode(), nullValue());
}
use of org.keycloak.dom.saml.v2.protocol.StatusResponseType in project keycloak by keycloak.
the class SAML2Response method convert.
/**
* Convert a SAML2 Response into a Document
*
* @param responseType
*
* @return
*
* @throws ParsingException
* @throws ConfigurationException
* @throws ProcessingException
*/
public Document convert(StatusResponseType responseType) throws ProcessingException, ConfigurationException, ParsingException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
SAMLResponseWriter writer = new SAMLResponseWriter(StaxUtil.getXMLStreamWriter(bos));
if (responseType instanceof ResponseType) {
ResponseType response = (ResponseType) responseType;
writer.write(response);
} else {
writer.write(responseType, new QName(PROTOCOL_NSURI.get(), JBossSAMLConstants.LOGOUT_RESPONSE.get(), "samlp"));
}
return DocumentUtil.getDocument(new ByteArrayInputStream(bos.toByteArray()));
}
Aggregations