Search in sources :

Example 6 with Response

use of org.opensaml.saml.saml1.core.Response in project ddf by codice.

the class SamlProtocolTest method testCreateResponse.

@Test
public void testCreateResponse() throws WSSecurityException {
    Response response = SamlProtocol.createResponse(SamlProtocol.createIssuer("myissuer"), SamlProtocol.createStatus("mystatus"), "myid", null);
    assertEquals("myissuer", response.getIssuer().getValue());
    assertEquals("mystatus", response.getStatus().getStatusCode().getValue());
    assertEquals("myid", response.getInResponseTo());
}
Also used : LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) Response(org.opensaml.saml.saml2.core.Response) Test(org.junit.Test)

Example 7 with Response

use of org.opensaml.saml.saml1.core.Response in project ddf by codice.

the class LoginFilter method createSamlResponse.

/**
     * Creates the SAML response that we use for validation against the CXF
     * code.
     *
     * @param inResponseTo
     * @param issuer
     * @param status
     * @return Response
     */
private static Response createSamlResponse(String inResponseTo, String issuer, Status status) {
    if (responseBuilder == null) {
        responseBuilder = (SAMLObjectBuilder<Response>) builderFactory.getBuilder(Response.DEFAULT_ELEMENT_NAME);
    }
    Response response = responseBuilder.buildObject();
    response.setID(UUID.randomUUID().toString());
    response.setIssueInstant(new DateTime());
    response.setInResponseTo(inResponseTo);
    response.setIssuer(createIssuer(issuer));
    response.setStatus(status);
    response.setVersion(SAMLVersion.VERSION_20);
    return response;
}
Also used : Response(org.opensaml.saml.saml2.core.Response) ServletResponse(javax.servlet.ServletResponse) DateTime(org.joda.time.DateTime)

Example 8 with Response

use of org.opensaml.saml.saml1.core.Response in project cas by apereo.

the class Saml10ObjectBuilder method newAssertion.

/**
     * Create a new SAML1 response object.
     *
     * @param authnStatement the authn statement
     * @param issuer the issuer
     * @param issuedAt the issued at
     * @param id the id
     * @return the assertion
     */
public Assertion newAssertion(final AuthenticationStatement authnStatement, final String issuer, final ZonedDateTime issuedAt, final String id) {
    final Assertion assertion = newSamlObject(Assertion.class);
    assertion.setID(id);
    assertion.setIssueInstant(DateTimeUtils.dateTimeOf(issuedAt));
    assertion.setIssuer(issuer);
    assertion.getAuthenticationStatements().add(authnStatement);
    return assertion;
}
Also used : Assertion(org.opensaml.saml.saml1.core.Assertion)

Example 9 with Response

use of org.opensaml.saml.saml1.core.Response in project cas by apereo.

the class Saml10ObjectBuilder method encodeSamlResponse.

/**
     * Encode response and pass it onto the outbound transport.
     * Uses {@link CasHttpSoap11Encoder} to handle encoding.
     *
     * @param httpResponse the http response
     * @param httpRequest the http request
     * @param samlMessage the saml response
     * @throws Exception the exception in case encoding fails.
     */
public void encodeSamlResponse(final HttpServletResponse httpResponse, final HttpServletRequest httpRequest, final Response samlMessage) throws Exception {
    SamlUtils.logSamlObject(this.configBean, samlMessage);
    final HTTPSOAP11Encoder encoder = new CasHttpSoap11Encoder();
    final MessageContext<SAMLObject> context = new MessageContext();
    context.setMessage(samlMessage);
    encoder.setHttpServletResponse(httpResponse);
    encoder.setMessageContext(context);
    encoder.initialize();
    encoder.prepareContext();
    encoder.encode();
}
Also used : SAMLObject(org.opensaml.saml.common.SAMLObject) HTTPSOAP11Encoder(org.opensaml.saml.saml1.binding.encoding.impl.HTTPSOAP11Encoder) MessageContext(org.opensaml.messaging.context.MessageContext)

Example 10 with Response

use of org.opensaml.saml.saml1.core.Response in project cas by apereo.

the class Saml10ObjectBuilder method newResponse.

/**
     * Create a new SAML response object.
     * @param id the id
     * @param issueInstant the issue instant
     * @param recipient the recipient
     * @param service the service
     * @return the response
     */
public Response newResponse(final String id, final ZonedDateTime issueInstant, final String recipient, final WebApplicationService service) {
    final Response samlResponse = newSamlObject(Response.class);
    samlResponse.setID(id);
    samlResponse.setIssueInstant(DateTimeUtils.dateTimeOf(issueInstant));
    samlResponse.setVersion(SAMLVersion.VERSION_11);
    samlResponse.setInResponseTo(recipient);
    setInResponseToForSamlResponseIfNeeded(service, samlResponse);
    return samlResponse;
}
Also used : Response(org.opensaml.saml.saml1.core.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Aggregations

Response (org.opensaml.saml.saml2.core.Response)9 HttpServletResponse (javax.servlet.http.HttpServletResponse)8 Response (org.opensaml.saml2.core.Response)5 Document (org.w3c.dom.Document)4 Element (org.w3c.dom.Element)4 IOException (java.io.IOException)3 LoginCmdResponse (org.apache.cloudstack.api.response.LoginCmdResponse)3 DateTime (org.joda.time.DateTime)3 Assertion (org.opensaml.saml.saml1.core.Assertion)3 Assertion (org.opensaml.saml.saml2.core.Assertion)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 X509Certificate (java.security.cert.X509Certificate)2 ServletResponse (javax.servlet.ServletResponse)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 FactoryConfigurationError (javax.xml.stream.FactoryConfigurationError)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 SAMLProviderMetadata (org.apache.cloudstack.saml.SAMLProviderMetadata)2 SamlAssertionWrapper (org.apache.wss4j.common.saml.SamlAssertionWrapper)2 Response (org.opensaml.saml.saml1.core.Response)2 CloudAuthenticationException (com.cloud.exception.CloudAuthenticationException)1