当前位置: 首页>>代码示例>>Java>>正文


Java Response.setVersion方法代码示例

本文整理汇总了Java中org.opensaml.saml2.core.Response.setVersion方法的典型用法代码示例。如果您正苦于以下问题:Java Response.setVersion方法的具体用法?Java Response.setVersion怎么用?Java Response.setVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opensaml.saml2.core.Response的用法示例。


在下文中一共展示了Response.setVersion方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildResponse

import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
public Response buildResponse(SAMLSSOAuthnReqDTO authReqDTO, Assertion assertion)
        throws IdentityException {

    if (log.isDebugEnabled()) {
        log.debug("Building SAML Response for the consumer '"
                + authReqDTO.getAssertionConsumerURL() + "'");
    }
    Response response = new org.opensaml.saml2.core.impl.ResponseBuilder().buildObject();
    response.setIssuer(SAMLSSOUtil.getIssuer());
    response.setID(SAMLSSOUtil.createID());
    response.setInResponseTo(authReqDTO.getId());
    response.setDestination(authReqDTO.getAssertionConsumerURL());
    response.setStatus(buildStatus(SAMLSSOConstants.StatusCodes.SUCCESS_CODE, null));
    response.setVersion(SAMLVersion.VERSION_20);
    DateTime issueInstant = new DateTime();
    response.setIssueInstant(issueInstant);
    response.getAssertions().add(assertion);
    if (authReqDTO.isDoSignResponse()) {
        SAMLSSOUtil.setSignature(response, authReqDTO.getSigningAlgorithmUri(), authReqDTO.getDigestAlgorithmUri
                (), new SignKeyDataHolder(authReqDTO.getUser().getAuthenticatedSubjectIdentifier()));
    }
    return response;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:24,代码来源:DefaultResponseBuilder.java

示例2: generateErrorneousResponse

import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
public static String generateErrorneousResponse() {
    Response response = new ResponseBuilder().buildObject();
    response.setIssuer(getIssuer());
    response.setStatus(buildStatus());
    response.setVersion(SAMLVersion.VERSION_20);
    response.setID(UIDGenerator.generateUID());

    try {
        return encode(marshall(response));
    } catch (IdentityException e) {
        if (log.isDebugEnabled()) {
            log.debug("Error while encoding.", e);
        }
        return null;
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:17,代码来源:ErrorResponseBuilder.java

示例3: buildResponse

import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
/**
   * Build the SAML Response Object
   *
   * @param pRequestContext
   * @param pTimeoutMS
   * @param pRecipient
   * @param pAudienceURI
   * @param pAssertionAttributes
   * @param pSignResponse
   * @param pSignAssertion
   * @param pDigitalCertificateName
   * @return SAML Response Object
   */
  private Response buildResponse(ActionRequestContext pRequestContext
    , Integer pTimeoutMS
    , String pRecipient
    , String pAudienceURI
    , Map<String, String> pAssertionAttributes
    , boolean pSignResponse
    , boolean pSignAssertion
    , String pDigitalCertificateName
  ) {
    Response lResponse = new org.opensaml.saml2.core.impl.ResponseBuilder().buildObject();
    lResponse.setIssuer(buildIssuer(pRequestContext.getFoxRequest().getHttpRequest().getRequestURL().toString()));
    lResponse.setID(RESPONSE_ID_PREFIX + RandomString.getString(40));
//    lResponse.setInResponseTo(authReqDTO.getId());
//    lResponse.setDestination(authReqDTO.getAssertionConsumerURL());
    lResponse.setStatus(buildStatus(StatusCode.SUCCESS_URI));
    lResponse.setVersion(SAMLVersion.VERSION_20);

    DateTime issueInstant = new DateTime();
    lResponse.setIssueInstant(issueInstant);


    DateTime lNotOnOrAfter = new DateTime(issueInstant.getMillis() + pTimeoutMS);
    Assertion assertion = buildSAMLAssertion(pRequestContext, lNotOnOrAfter, pRecipient, pAudienceURI, pAssertionAttributes, pSignAssertion, pDigitalCertificateName);
    lResponse.getAssertions().add(assertion);

    // Sign the SAML Response object
    if (pSignResponse) {
      signSAMLObject(lResponse, pRequestContext, pDigitalCertificateName);
    }

    return lResponse;
  }
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:46,代码来源:SAMLResponseCommand.java

示例4: buildSAMLResponse

import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
/**
 * Build SAML response using IdP configuration & user name
 *
 * @param ssoIdPConfigs
 * @param userName
 * @return SAML Response object
 * @throws IdentityException
 */
public Response buildSAMLResponse(SAMLSSOServiceProviderDO ssoIdPConfigs, String userName)
        throws IdentityException {
    if (log.isDebugEnabled()) {
        log.debug("Building SAML Response for the consumer '" +
                ssoIdPConfigs.getAssertionConsumerUrl() + "'");
    }
    Response response = new org.opensaml.saml2.core.impl.ResponseBuilder().buildObject();
    response.setIssuer(SAMLSSOUtil.getIssuer());
    response.setID(SAMLSSOUtil.createID());
    response.setDestination(ssoIdPConfigs.getAssertionConsumerUrl());
    response.setStatus(buildStatus(SAMLSSOConstants.StatusCodes.SUCCESS_CODE, null));
    response.setVersion(SAMLVersion.VERSION_20);
    DateTime issueInstant = new DateTime();
    DateTime notOnOrAfter =
            new DateTime(issueInstant.getMillis() +
                    SAMLSSOUtil.getSAMLResponseValidityPeriod() * 60 *
                            1000);
    response.setIssueInstant(issueInstant);
    Assertion assertion = buildSAMLAssertion(ssoIdPConfigs, notOnOrAfter, userName);
    if (ssoIdPConfigs.isDoEnableEncryptedAssertion()) {
        String domainName = MultitenantUtils.getTenantDomain(userName);
        String alias = ssoIdPConfigs.getCertAlias();
        if (alias != null) {
            EncryptedAssertion encryptedAssertion =
                    SAMLSSOUtil.setEncryptedAssertion(assertion,
                            EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256,
                            alias,
                            domainName);
            response.getEncryptedAssertions().add(encryptedAssertion);
        }
    } else {
        response.getAssertions().add(assertion);
    }
    if (ssoIdPConfigs.isDoSignResponse()) {
        SAMLSSOUtil.setSignature(response, ssoIdPConfigs.getSigningAlgorithmUri(), ssoIdPConfigs
                .getDigestAlgorithmUri(), new SignKeyDataHolder(userName));
    }
    return response;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:48,代码来源:SAMLResponseBuilder.java

示例5: createResponse

import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
private Response createResponse(final DateTime issueDate, Issuer issuer, Status status, Assertion assertion) {
	ResponseBuilder responseBuilder = new ResponseBuilder();
	Response response = responseBuilder.buildObject();
	response.setID(UUID.randomUUID().toString());
	response.setIssueInstant(issueDate);
	response.setVersion(SAMLVersion.VERSION_20);
	response.setIssuer(issuer);
	response.setStatus(status);
	response.getAssertions().add(assertion);
	return response;
}
 
开发者ID:rackerlabs,项目名称:saml-generator,代码行数:12,代码来源:SamlAssertionProducer.java

示例6: buildMockResponse

import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
private Response buildMockResponse() throws Exception {
    Response samlMessage = new ResponseBuilder().buildObject();
    samlMessage.setID("foo");
    samlMessage.setVersion(SAMLVersion.VERSION_20);
    samlMessage.setIssueInstant(new DateTime(0));
    Issuer issuer = new IssuerBuilder().buildObject();
    issuer.setValue("MockedIssuer");
    samlMessage.setIssuer(issuer);
    Status status = new StatusBuilder().buildObject();
    StatusCode statusCode = new StatusCodeBuilder().buildObject();
    statusCode.setValue(StatusCode.SUCCESS_URI);
    status.setStatusCode(statusCode);
    samlMessage.setStatus(status);
    Assertion assertion = new AssertionBuilder().buildObject();
    Subject subject = new SubjectBuilder().buildObject();
    NameID nameID = new NameIDBuilder().buildObject();
    nameID.setValue("SOME-UNIQUE-ID");
    nameID.setFormat(NameIDType.PERSISTENT);
    subject.setNameID(nameID);
    assertion.setSubject(subject);
    AuthnStatement authnStatement = new AuthnStatementBuilder().buildObject();
    authnStatement.setSessionIndex("Some Session String");
    assertion.getAuthnStatements().add(authnStatement);
    AttributeStatement attributeStatement = new AttributeStatementBuilder().buildObject();
    assertion.getAttributeStatements().add(attributeStatement);
    samlMessage.getAssertions().add(assertion);
    return samlMessage;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:29,代码来源:SAML2LoginAPIAuthenticatorCmdTest.java

示例7: testResponseEncoding

import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
/**
 * Tests encoding a SAML message to an servlet response.
 * 
 * @throws Exception
 */
@SuppressWarnings("unchecked")
public void testResponseEncoding() throws Exception {
    SAMLObjectBuilder<StatusCode> statusCodeBuilder = (SAMLObjectBuilder<StatusCode>) builderFactory
            .getBuilder(StatusCode.DEFAULT_ELEMENT_NAME);
    StatusCode statusCode = statusCodeBuilder.buildObject();
    statusCode.setValue(StatusCode.SUCCESS_URI);

    SAMLObjectBuilder<Status> statusBuilder = (SAMLObjectBuilder<Status>) builderFactory
            .getBuilder(Status.DEFAULT_ELEMENT_NAME);
    Status responseStatus = statusBuilder.buildObject();
    responseStatus.setStatusCode(statusCode);

    SAMLObjectBuilder<Response> responseBuilder = (SAMLObjectBuilder<Response>) builderFactory
            .getBuilder(Response.DEFAULT_ELEMENT_NAME);
    Response samlMessage = responseBuilder.buildObject();
    samlMessage.setID("foo");
    samlMessage.setVersion(SAMLVersion.VERSION_20);
    samlMessage.setIssueInstant(new DateTime(0));
    samlMessage.setStatus(responseStatus);

    SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
            .getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
    Endpoint samlEndpoint = endpointBuilder.buildObject();
    samlEndpoint.setLocation("http://example.org");
    samlEndpoint.setResponseLocation("http://example.org/response");

    MockHttpServletResponse response = new MockHttpServletResponse();
    HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
    
    BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
    messageContext.setOutboundMessageTransport(outTransport);
    messageContext.setPeerEntityEndpoint(samlEndpoint);
    messageContext.setOutboundSAMLMessage(samlMessage);
    messageContext.setRelayState("relay");

    HTTPPostEncoder encoder = new HTTPPostEncoder(velocityEngine,
    "/templates/saml2-post-binding.vm");
    encoder.encode(messageContext);

    assertEquals("Unexpected content type", "text/html", response.getContentType());
    assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
    assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
    assertEquals(762244719, response.getContentAsString().hashCode());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:50,代码来源:HTTPPostEncoderTest.java

示例8: testResponseEncoding

import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
/**
 * Tests encoding a SAML message to an servlet response.
 * 
 * @throws Exception
 */
@SuppressWarnings("unchecked")
public void testResponseEncoding() throws Exception {
    SAMLObjectBuilder<StatusCode> statusCodeBuilder = (SAMLObjectBuilder<StatusCode>) builderFactory
            .getBuilder(StatusCode.DEFAULT_ELEMENT_NAME);
    StatusCode statusCode = statusCodeBuilder.buildObject();
    statusCode.setValue(StatusCode.SUCCESS_URI);

    SAMLObjectBuilder<Status> statusBuilder = (SAMLObjectBuilder<Status>) builderFactory
            .getBuilder(Status.DEFAULT_ELEMENT_NAME);
    Status responseStatus = statusBuilder.buildObject();
    responseStatus.setStatusCode(statusCode);

    SAMLObjectBuilder<Response> responseBuilder = (SAMLObjectBuilder<Response>) builderFactory
            .getBuilder(Response.DEFAULT_ELEMENT_NAME);
    Response samlMessage = responseBuilder.buildObject();
    samlMessage.setID("foo");
    samlMessage.setVersion(SAMLVersion.VERSION_20);
    samlMessage.setIssueInstant(new DateTime(0));
    samlMessage.setStatus(responseStatus);

    SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
            .getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
    Endpoint samlEndpoint = endpointBuilder.buildObject();
    samlEndpoint.setLocation("http://example.org");
    samlEndpoint.setResponseLocation("http://example.org/response");

    MockHttpServletResponse response = new MockHttpServletResponse();
    HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
    
    BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
    messageContext.setOutboundMessageTransport(outTransport);
    messageContext.setOutboundSAMLMessage(samlMessage);
    messageContext.setPeerEntityEndpoint(samlEndpoint);
    messageContext.setRelayState("relay");
    
    HTTPRedirectDeflateEncoder encoder = new HTTPRedirectDeflateEncoder();
    encoder.encode(messageContext);

    assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
    assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
    assertEquals(406515062, response.getRedirectedUrl().hashCode());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:48,代码来源:HTTPRedirectDeflateEncoderTest.java

示例9: testResponseEncodingWithSimpleSign

import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
/**
 * Tests encoding a SAML message to an servlet response with simple sign.
 * 
 * @throws Exception
 */
@SuppressWarnings("unchecked")
public void testResponseEncodingWithSimpleSign() throws Exception {
    SAMLObjectBuilder<StatusCode> statusCodeBuilder = (SAMLObjectBuilder<StatusCode>) builderFactory
            .getBuilder(StatusCode.DEFAULT_ELEMENT_NAME);
    StatusCode statusCode = statusCodeBuilder.buildObject();
    statusCode.setValue(StatusCode.SUCCESS_URI);

    SAMLObjectBuilder<Status> statusBuilder = (SAMLObjectBuilder<Status>) builderFactory
            .getBuilder(Status.DEFAULT_ELEMENT_NAME);
    Status responseStatus = statusBuilder.buildObject();
    responseStatus.setStatusCode(statusCode);

    SAMLObjectBuilder<Response> responseBuilder = (SAMLObjectBuilder<Response>) builderFactory
            .getBuilder(Response.DEFAULT_ELEMENT_NAME);
    Response samlMessage = responseBuilder.buildObject();
    samlMessage.setID("foo");
    samlMessage.setVersion(SAMLVersion.VERSION_20);
    samlMessage.setIssueInstant(new DateTime(0));
    samlMessage.setStatus(responseStatus);

    SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
            .getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
    Endpoint samlEndpoint = endpointBuilder.buildObject();
    samlEndpoint.setLocation("http://example.org");
    samlEndpoint.setResponseLocation("http://example.org/response");

    MockHttpServletResponse response = new MockHttpServletResponse();
    HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
    
    BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
    messageContext.setOutboundMessageTransport(outTransport);
    messageContext.setOutboundSAMLMessage(samlMessage);
    messageContext.setPeerEntityEndpoint(samlEndpoint);
    messageContext.setRelayState("relay");
    
    KeyPair kp = SecurityTestHelper.generateKeyPair("RSA", 1024, null);
    messageContext.setOutboundSAMLMessageSigningCredential(
            SecurityHelper.getSimpleCredential(kp.getPublic(), kp.getPrivate()));
    
    HTTPRedirectDeflateEncoder encoder = new HTTPRedirectDeflateEncoder();
    encoder.encode(messageContext);
    
    String queryString = new URL(response.getRedirectedUrl()).getQuery();
    
    assertNotNull("Signature parameter was not found", 
            HTTPTransportUtils.getRawQueryStringParameter(queryString, "Signature"));
    assertNotNull("SigAlg parameter was not found", 
            HTTPTransportUtils.getRawQueryStringParameter(queryString, "SigAlg"));
    
    // Note: to test that actual signature is cryptographically correct, really need a known good test vector.
    // Need to verify that we're signing over the right data in the right byte[] encoded form.
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:58,代码来源:HTTPRedirectDeflateEncoderTest.java

示例10: testResponseEncoding

import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
/**
 * Tests encoding a SAML message to an servlet response.
 * 
 * @throws Exception
 */
@SuppressWarnings("unchecked")
public void testResponseEncoding() throws Exception {
    SAMLObjectBuilder<StatusCode> statusCodeBuilder = (SAMLObjectBuilder<StatusCode>) builderFactory
            .getBuilder(StatusCode.DEFAULT_ELEMENT_NAME);
    StatusCode statusCode = statusCodeBuilder.buildObject();
    statusCode.setValue(StatusCode.SUCCESS_URI);

    SAMLObjectBuilder<Status> statusBuilder = (SAMLObjectBuilder<Status>) builderFactory
            .getBuilder(Status.DEFAULT_ELEMENT_NAME);
    Status responseStatus = statusBuilder.buildObject();
    responseStatus.setStatusCode(statusCode);

    SAMLObjectBuilder<Response> responseBuilder = (SAMLObjectBuilder<Response>) builderFactory
            .getBuilder(Response.DEFAULT_ELEMENT_NAME);
    Response samlMessage = responseBuilder.buildObject();
    samlMessage.setID("foo");
    samlMessage.setVersion(SAMLVersion.VERSION_20);
    samlMessage.setIssueInstant(new DateTime(0));
    samlMessage.setStatus(responseStatus);

    SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
            .getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
    Endpoint samlEndpoint = endpointBuilder.buildObject();
    samlEndpoint.setLocation("http://example.org");
    samlEndpoint.setResponseLocation("http://example.org/response");

    MockHttpServletResponse response = new MockHttpServletResponse();
    HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
    
    BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
    messageContext.setOutboundMessageTransport(outTransport);
    messageContext.setPeerEntityEndpoint(samlEndpoint);
    messageContext.setOutboundSAMLMessage(samlMessage);
    messageContext.setRelayState("relay");
    
    HTTPSOAP11Encoder encoder = new HTTPSOAP11Encoder();
    encoder.encode(messageContext);

    assertEquals("Unexpected content type", "text/xml", response.getContentType());
    assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
    assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
    assertEquals("http://www.oasis-open.org/committees/security", response.getHeader("SOAPAction"));
    assertEquals(1568886506, response.getContentAsString().hashCode());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:50,代码来源:HTTPSOAP11EncoderTest.java

示例11: testResponseEncoding

import org.opensaml.saml2.core.Response; //导入方法依赖的package包/类
/**
 * Tests encoding a SAML message to an servlet response.
 * 
 * @throws Exception
 */
@SuppressWarnings("unchecked")
public void testResponseEncoding() throws Exception {
    SAMLObjectBuilder<StatusCode> statusCodeBuilder = (SAMLObjectBuilder<StatusCode>) builderFactory
            .getBuilder(StatusCode.DEFAULT_ELEMENT_NAME);
    StatusCode statusCode = statusCodeBuilder.buildObject();
    statusCode.setValue(StatusCode.SUCCESS_URI);

    SAMLObjectBuilder<Status> statusBuilder = (SAMLObjectBuilder<Status>) builderFactory
            .getBuilder(Status.DEFAULT_ELEMENT_NAME);
    Status responseStatus = statusBuilder.buildObject();
    responseStatus.setStatusCode(statusCode);

    SAMLObjectBuilder<Response> responseBuilder = (SAMLObjectBuilder<Response>) builderFactory
            .getBuilder(Response.DEFAULT_ELEMENT_NAME);
    Response samlMessage = responseBuilder.buildObject();
    samlMessage.setID("foo");
    samlMessage.setVersion(SAMLVersion.VERSION_20);
    samlMessage.setIssueInstant(new DateTime(0));
    samlMessage.setStatus(responseStatus);

    SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory
            .getBuilder(AssertionConsumerService.DEFAULT_ELEMENT_NAME);
    Endpoint samlEndpoint = endpointBuilder.buildObject();
    samlEndpoint.setLocation("http://example.org");
    samlEndpoint.setResponseLocation("http://example.org/response");

    MockHttpServletResponse response = new MockHttpServletResponse();
    HttpServletResponseAdapter outTransport = new HttpServletResponseAdapter(response, false);
    
    BasicSAMLMessageContext messageContext = new BasicSAMLMessageContext();
    messageContext.setOutboundMessageTransport(outTransport);
    messageContext.setPeerEntityEndpoint(samlEndpoint);
    messageContext.setOutboundSAMLMessage(samlMessage);
    messageContext.setRelayState("relay");

    HTTPPostSimpleSignEncoder encoder = new HTTPPostSimpleSignEncoder(velocityEngine,
    "/templates/saml2-post-simplesign-binding.vm");
    encoder.encode(messageContext);

    assertEquals("Unexpected content type", "text/html", response.getContentType());
    assertEquals("Unexpected character encoding", response.getCharacterEncoding(), "UTF-8");
    assertEquals("Unexpected cache controls", "no-cache, no-store", response.getHeader("Cache-control"));
    assertEquals(-1652577171, response.getContentAsString().hashCode());
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:50,代码来源:HTTPPostSimpleSignEncoderTest.java


注:本文中的org.opensaml.saml2.core.Response.setVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。