use of org.opensaml.soap.soap11.Header in project cas by apereo.
the class SamlProfileSamlSoap11ResponseBuilder method buildResponse.
@Override
protected Envelope buildResponse(final Assertion assertion, final Object casAssertion, final RequestAbstractType authnRequest, final SamlRegisteredService service, final SamlRegisteredServiceServiceProviderMetadataFacade adaptor, final HttpServletRequest request, final HttpServletResponse response, final String binding) throws SamlException {
LOGGER.debug("Locating the assertion consumer service url for binding [{}]", binding);
@NonNull final AssertionConsumerService acs = adaptor.getAssertionConsumerService(binding);
LOGGER.debug("Located assertion consumer service url [{}]", acs);
final Response ecpResponse = newEcpResponse(acs.getLocation());
final Header header = newSoapObject(Header.class);
header.getUnknownXMLObjects().add(ecpResponse);
final Body body = newSoapObject(Body.class);
final org.opensaml.saml.saml2.core.Response saml2Response = buildSaml2Response(casAssertion, authnRequest, service, adaptor, request, binding);
body.getUnknownXMLObjects().add(saml2Response);
final Envelope envelope = newSoapObject(Envelope.class);
envelope.setHeader(header);
envelope.setBody(body);
SamlUtils.logSamlObject(this.configBean, envelope);
return envelope;
}
use of org.opensaml.soap.soap11.Header in project cas by apereo.
the class ECPSamlIdPProfileHandlerControllerTests method getEnvelope.
private Envelope getEnvelope(final String entityId) {
var builder = (SOAPObjectBuilder) openSamlConfigBean.getBuilderFactory().getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
var envelope = (Envelope) builder.buildObject();
builder = (SOAPObjectBuilder) openSamlConfigBean.getBuilderFactory().getBuilder(Header.DEFAULT_ELEMENT_NAME);
val header = (Header) builder.buildObject();
envelope.setHeader(header);
builder = (SOAPObjectBuilder) openSamlConfigBean.getBuilderFactory().getBuilder(Body.DEFAULT_ELEMENT_NAME);
val body = (Body) builder.buildObject();
body.getUnknownXMLObjects().add(getAuthnRequest(entityId));
envelope.setBody(body);
return envelope;
}
use of org.opensaml.soap.soap11.Header in project cas by apereo.
the class SamlIdPSaml1ArtifactResolutionProfileHandlerControllerTests method verifyOK.
@Test
@Order(1)
public void verifyOK() throws Exception {
val response = new MockHttpServletResponse();
val request = new MockHttpServletRequest();
request.setMethod("POST");
request.setContentType(MediaType.TEXT_XML_VALUE);
var builder = (SOAPObjectBuilder) openSamlConfigBean.getBuilderFactory().getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
var envelope = (Envelope) builder.buildObject();
builder = (SOAPObjectBuilder) openSamlConfigBean.getBuilderFactory().getBuilder(Header.DEFAULT_ELEMENT_NAME);
val header = (Header) builder.buildObject();
envelope.setHeader(header);
builder = (SOAPObjectBuilder) openSamlConfigBean.getBuilderFactory().getBuilder(Body.DEFAULT_ELEMENT_NAME);
val body = (Body) builder.buildObject();
val artifactResolve = getArtifactResolve();
body.getUnknownXMLObjects().add(artifactResolve);
envelope.setBody(body);
val xml = SamlUtils.transformSamlObject(openSamlConfigBean, envelope).toString();
request.setContent(xml.getBytes(StandardCharsets.UTF_8));
val ticket = samlArtifactTicketFactory.create("https://cassp.example.org", CoreAuthenticationTestUtils.getAuthentication(), new MockTicketGrantingTicket("casuser"), "https://cas.example.org", "https://cassp.example.org", artifactResolve);
ticketRegistry.addTicket(ticket);
controller.handlePostRequest(response, request);
assertEquals(HttpStatus.SC_OK, response.getStatus());
}
use of org.opensaml.soap.soap11.Header in project ddf by codice.
the class SamlProtocol method createSoapMessage.
public static Envelope createSoapMessage(SignableSAMLObject signableSAMLObject) {
Body body = soapBodyBuilder.buildObject();
body.getUnknownXMLObjects().add(signableSAMLObject);
Envelope envelope = soapEnvelopeBuilder.buildObject();
envelope.setBody(body);
Header header = soapHeaderBuilder.buildObject();
envelope.setHeader(header);
return envelope;
}
Aggregations