Search in sources :

Example 41 with Envelope

use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope 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());
}
Also used : lombok.val(lombok.val) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) SOAPObjectBuilder(org.opensaml.soap.common.SOAPObjectBuilder) Header(org.opensaml.soap.soap11.Header) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Envelope(org.opensaml.soap.soap11.Envelope) Body(org.opensaml.soap.soap11.Body) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Test(org.junit.jupiter.api.Test)

Example 42 with Envelope

use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ddf by codice.

the class LogoutRequestService method getSamlpSoapLogoutResponse.

private Response getSamlpSoapLogoutResponse(LogoutWrapper<LogoutResponse> samlResponse, String statusCode, String statusMessage) {
    if (samlResponse == null) {
        return Response.serverError().build();
    }
    LOGGER.debug("Configuring SAML Response for SOAP.");
    Document doc = DOMUtils.createDocument();
    doc.appendChild(doc.createElement(ROOT_NODE_NAME));
    LOGGER.debug("Setting SAML status on Response for SOAP");
    if (statusCode != null) {
        if (statusMessage != null) {
            samlResponse.getMessage().setStatus(SamlProtocol.createStatus(statusCode, statusMessage));
        } else {
            samlResponse.getMessage().setStatus(SamlProtocol.createStatus(statusCode));
        }
    }
    try {
        LOGGER.debug("Signing SAML Response for SOAP.");
        LogoutResponse logoutResponse = simpleSign.forceSignSamlObject(samlResponse.getMessage());
        Envelope soapMessage = SamlProtocol.createSoapMessage(logoutResponse);
        LOGGER.debug("Converting SAML Response to DOM");
        String assertionResponse = DOM2Writer.nodeToString(OpenSAMLUtil.toDom(soapMessage, doc));
        String encodedSamlResponse = Base64.getEncoder().encodeToString(assertionResponse.getBytes(StandardCharsets.UTF_8));
        return Response.ok(encodedSamlResponse).build();
    } catch (SignatureException | WSSecurityException | XMLStreamException e) {
        LOGGER.debug("Failure constructing SOAP LogoutResponse", e);
        return Response.serverError().build();
    }
}
Also used : LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) XMLStreamException(javax.xml.stream.XMLStreamException) WSSecurityException(org.apache.wss4j.common.ext.WSSecurityException) SignatureException(ddf.security.samlp.SignatureException) Document(org.w3c.dom.Document) Envelope(org.opensaml.soap.soap11.Envelope)

Example 43 with Envelope

use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project cas by apereo.

the class SamlProfileSamlSoap11ResponseBuilder method buildResponse.

@Override
protected Envelope buildResponse(final Assertion assertion, final org.jasig.cas.client.validation.Assertion casAssertion, final AuthnRequest authnRequest, final SamlRegisteredService service, final SamlRegisteredServiceServiceProviderMetadataFacade adaptor, final HttpServletRequest request, final HttpServletResponse response) throws SamlException {
    final Response ecpResponse = newEcpResponse(adaptor.getAssertionConsumerService().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 = (org.opensaml.saml.saml2.core.Response) saml2ResponseBuilder.build(authnRequest, request, response, casAssertion, service, adaptor);
    body.getUnknownXMLObjects().add(saml2Response);
    final Envelope envelope = newSoapObject(Envelope.class);
    envelope.setHeader(header);
    envelope.setBody(body);
    return envelope;
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(org.opensaml.saml.saml2.ecp.Response) Header(org.opensaml.soap.soap11.Header) Envelope(org.opensaml.soap.soap11.Envelope) Body(org.opensaml.soap.soap11.Body)

Example 44 with Envelope

use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project cas by apereo.

the class SamlProfileArtifactResponseBuilder 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 {
    final org.jasig.cas.client.validation.Assertion castedAssertion = org.jasig.cas.client.validation.Assertion.class.cast(casAssertion);
    final SamlArtifactTicket ticket = (SamlArtifactTicket) castedAssertion.getAttributes().get("artifact");
    final ArtifactResponse artifactResponse = new ArtifactResponseBuilder().buildObject();
    artifactResponse.setIssueInstant(DateTime.now());
    artifactResponse.setIssuer(newIssuer(ticket.getIssuer()));
    artifactResponse.setInResponseTo(ticket.getRelyingPartyId());
    artifactResponse.setID(ticket.getId());
    artifactResponse.setStatus(newStatus(StatusCode.SUCCESS, "Success"));
    final SAMLObject samlResponse = SamlUtils.transformSamlObject(configBean, ticket.getObject(), SAMLObject.class);
    artifactResponse.setMessage(samlResponse);
    final Header header = newSoapObject(Header.class);
    final Body body = newSoapObject(Body.class);
    body.getUnknownXMLObjects().add(artifactResponse);
    final Envelope envelope = newSoapObject(Envelope.class);
    envelope.setHeader(header);
    envelope.setBody(body);
    SamlUtils.logSamlObject(this.configBean, envelope);
    return envelope;
}
Also used : Header(org.opensaml.soap.soap11.Header) SAMLObject(org.opensaml.saml.common.SAMLObject) ArtifactResponse(org.opensaml.saml.saml2.core.ArtifactResponse) ArtifactResponseBuilder(org.opensaml.saml.saml2.core.impl.ArtifactResponseBuilder) SamlArtifactTicket(org.apereo.cas.ticket.artifact.SamlArtifactTicket) Envelope(org.opensaml.soap.soap11.Envelope) Body(org.opensaml.soap.soap11.Body)

Example 45 with Envelope

use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project cas by apereo.

the class SamlProfileAttributeQueryResponseBuilder method build.

@Override
public Envelope build(final RequestAbstractType authnRequest, final HttpServletRequest request, final HttpServletResponse response, final Object casAssertion, final SamlRegisteredService service, final SamlRegisteredServiceServiceProviderMetadataFacade adaptor, final String binding) throws SamlException {
    final AttributeQuery query = (AttributeQuery) authnRequest;
    final Header header = newSoapObject(Header.class);
    final Body body = newSoapObject(Body.class);
    final Response saml2Response = buildSaml2Response(casAssertion, query, service, adaptor, request, SAMLConstants.SAML2_POST_BINDING_URI);
    body.getUnknownXMLObjects().add(saml2Response);
    final Envelope envelope = newSoapObject(Envelope.class);
    envelope.setHeader(header);
    envelope.setBody(body);
    SamlUtils.logSamlObject(this.configBean, envelope);
    return encodeFinalResponse(request, response, service, adaptor, envelope, binding, authnRequest, casAssertion);
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(org.opensaml.saml.saml2.core.Response) Header(org.opensaml.soap.soap11.Header) AttributeQuery(org.opensaml.saml.saml2.core.AttributeQuery) Envelope(org.opensaml.soap.soap11.Envelope) Body(org.opensaml.soap.soap11.Body)

Aggregations

Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)57 Test (org.junit.Test)52 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)45 RemoteDependencyData (com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData)28 Envelope (org.opensaml.soap.soap11.Envelope)16 Body (org.opensaml.soap.soap11.Body)11 Header (org.opensaml.soap.soap11.Header)11 AiSmokeTest (com.microsoft.applicationinsights.smoketest.AiSmokeTest)10 TargetUri (com.microsoft.applicationinsights.smoketest.TargetUri)10 ExceptionData (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData)9 MessageData (com.microsoft.applicationinsights.smoketest.schemav2.MessageData)9 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)8 EventData (com.microsoft.applicationinsights.smoketest.schemav2.EventData)6 MetricData (com.microsoft.applicationinsights.smoketest.schemav2.MetricData)6 RequestDataMatchers.hasDuration (com.microsoft.applicationinsights.smoketest.matchers.RequestDataMatchers.hasDuration)4 DataPoint (com.microsoft.applicationinsights.smoketest.schemav2.DataPoint)4 ExceptionDetails (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionDetails)4 Duration (com.microsoft.applicationinsights.smoketest.telemetry.Duration)4 PageViewData (com.microsoft.applicationinsights.smoketest.schemav2.PageViewData)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3