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


Java Response类代码示例

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


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

示例1: shouldReturnErrorResponseWhenAnAttributeQueryContainsAnExpiredAssertion

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
@Test
public void shouldReturnErrorResponseWhenAnAttributeQueryContainsAnExpiredAssertion() {
    AttributeQuery attributeQuery = AttributeQueryBuilder.anAttributeQuery()
            .withId(REQUEST_ID)
            .withIssuer(anIssuer().withIssuerId(HUB_ENTITY_ID).build())
            .withSubject(aSubjectWithAssertions(asList(
                    anAuthnStatementAssertion(),
                    aMatchingDatasetAssertion(Collections.emptyList(), true, REQUEST_ID)), REQUEST_ID, HUB_ENTITY_ID))
            .build();

    Response response = makeAttributeQueryRequest(MATCHING_SERVICE_URI, attributeQuery, signatureAlgorithmForHub, digestAlgorithmForHub, HUB_ENTITY_ID);

    assertThat(response.getStatus().getStatusCode().getValue()).isEqualTo(REQUESTER);
    assertThat(response.getStatus().getStatusMessage().getMessage()).contains("Bearer subject confirmation datas NotOnOrAfter timestamp");
    assertThat(response).is(signedBy(TEST_RP_MS_PUBLIC_SIGNING_CERT, TEST_RP_MS_PRIVATE_SIGNING_KEY));
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:17,代码来源:MatchingServiceAdapterAppRuleTest.java

示例2: newResponse

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
/**
 * 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 DateTime issueInstant,
                            final String recipient, final WebApplicationService service) {

    final Response samlResponse = newSamlObject(Response.class);
    samlResponse.setID(id);
    samlResponse.setIssueInstant(issueInstant);
    samlResponse.setVersion(SAMLVersion.VERSION_20);
    if (service instanceof SamlService) {
        final SamlService samlService = (SamlService) service;

        final String requestId = samlService.getRequestID();
        if (StringUtils.isNotBlank(requestId)) {
            samlResponse.setInResponseTo(requestId);
        }
    }
    return samlResponse;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:26,代码来源:AbstractSaml20ObjectBuilder.java

示例3: newResponse

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
/**
 * 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_20);
    if (StringUtils.isNotBlank(recipient)) {
        LOGGER.debug("Setting provided RequestId {} as InResponseTo", recipient);
        samlResponse.setInResponseTo(recipient);
    } else {
        LOGGER.debug("No recipient is provided. Skipping InResponseTo");
    }
    return samlResponse;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:25,代码来源:AbstractSaml20ObjectBuilder.java

示例4: encode

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
@Override
protected Response encode(final SamlRegisteredService service,
                          final Response samlResponse,
                          final HttpServletResponse httpResponse,
                          final SamlRegisteredServiceServiceProviderMetadataFacade adaptor,
                          final String relayState, 
                          final String binding) throws SamlException {
    try {
        if (httpResponse != null) {
            final HTTPPostEncoder encoder = new HTTPPostEncoder();
            encoder.setHttpServletResponse(httpResponse);
            encoder.setVelocityEngine(this.velocityEngineFactory.createVelocityEngine());
            final MessageContext outboundMessageContext = new MessageContext<>();
            outboundMessageContext.setMessage(samlResponse);
            SAMLBindingSupport.setRelayState(outboundMessageContext, relayState);
            SamlIdPUtils.preparePeerEntitySamlEndpointContext(outboundMessageContext, adaptor, binding);
            encoder.setMessageContext(outboundMessageContext);
            encoder.initialize();
            encoder.encode();
        }
        return samlResponse;
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:26,代码来源:SamlProfileSaml2ResponseBuilder.java

示例5: SamlMessageSenderHandler

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
@Inject
public SamlMessageSenderHandler(
        StringToOpenSamlObjectTransformer<Response> responseTransformer,
        StringToOpenSamlObjectTransformer<AuthnRequest> authnRequestTransformer,
        SamlMessageSignatureValidator samlMessageSignatureValidator,
        ExternalCommunicationEventLogger externalCommunicationEventLogger,
        ProtectiveMonitoringLogger protectiveMonitoringLogger,
        SessionProxy sessionProxy) {

    this.responseTransformer = responseTransformer;
    this.authnRequestTransformer = authnRequestTransformer;
    this.samlMessageSignatureValidator = samlMessageSignatureValidator;
    this.externalCommunicationEventLogger = externalCommunicationEventLogger;
    this.protectiveMonitoringLogger = protectiveMonitoringLogger;
    this.sessionProxy = sessionProxy;
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:17,代码来源:SamlMessageSenderHandler.java

示例6: formatAuthnResponse

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
public String formatAuthnResponse(Response samlResponse, Direction direction, Boolean validSignature) {
    Issuer issuer = samlResponse.getIssuer();
    String issuerString = issuer != null ? issuer.getValue() : "";

    Status status = samlResponse.getStatus();
    StatusCode subStatusCode = status.getStatusCode().getStatusCode();
    String subStatus = subStatusCode != null ? subStatusCode.getValue() : "";

    return String.format(AUTHN_RESPONSE,
            samlResponse.getID(),
            samlResponse.getInResponseTo(),
            direction,
            samlResponse.getDestination(),
            issuerString,
            validSignature,
            status.getStatusCode().getValue(),
            subStatus,
            getStatusDetailValues(status));
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:20,代码来源:ProtectiveMonitoringLogFormatter.java

示例7: generateAuthnResponseFromHub_shouldAddExternalCommunicationEvent

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
@Test
public void generateAuthnResponseFromHub_shouldAddExternalCommunicationEvent() throws Exception {
    SessionId sessionId = SessionId.createNewSessionId();
    String expectedSamlMessageId = UUID.randomUUID().toString();

    Response openSamlResponse = setUpAuthnResponseFromHub(sessionId, expectedSamlMessageId);

    SamlMessage authnResponse = samlMessageSenderHandler.generateAuthnResponseFromHub(sessionId, principalIpAddressAsSeenByHub);
    assertThat(authnResponse.getSamlMessage()).isEqualTo(samlRequest);
    assertThat(authnResponse.getPostEndpoint()).isEqualTo(postEndPoint.toString());
    assertThat(authnResponse.getRegistration().isPresent()).isFalse();
    assertThat(authnResponse.getRelayState().isPresent()).isTrue();
    assertThat(authnResponse.getRelayState().get()).isEqualTo(relayState.get());
    assertThat(authnResponse.getSamlMessageType()).isEqualTo(SamlMessageType.SAML_RESPONSE);

    verify(externalCommunicationEventLogger).logResponseFromHub(expectedSamlMessageId, sessionId, postEndPoint, principalIpAddressAsSeenByHub);
    verify(protectiveMonitoringLogger).logAuthnResponse(openSamlResponse, Direction.OUTBOUND, true);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:19,代码来源:SamlMessageSenderHandlerTest.java

示例8: shouldFormatAuthnCancelResponse

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
@Test
public void shouldFormatAuthnCancelResponse() throws IOException, URISyntaxException {
    String cancelXml = readXmlFile("status-cancel.xml");
    Response cancelResponse = stringtoOpenSamlObjectTransformer.apply(cancelXml);

    String logString = new ProtectiveMonitoringLogFormatter().formatAuthnResponse(cancelResponse, Direction.INBOUND, true);

    String expectedLogMessage = "Protective Monitoring – Authn Response Event – " +
            "{responseId: _ccb1eabc4827928c9cbb3db34fdbe9df186dfcb8, " +
            "inResponseTo: _7081cbd6-a811-440a-949a-12a9521ed7cc, " +
            "direction: INBOUND, " +
            "destination: https://www.signin.service.gov.uk:443/SAML2/SSO/Response/POST, " +
            "issuerId: http://stub-idp, " +
            "validSignature: true, " +
            "status: urn:oasis:names:tc:SAML:2.0:status:Responder, " +
            "subStatus: urn:oasis:names:tc:SAML:2.0:status:NoAuthnContext, " +
            "statusDetails: [authn-cancel]}";
    assertThat(logString).isEqualTo(expectedLogMessage);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:20,代码来源:ProtectiveMonitoringLogFormatterTest.java

示例9: shouldFormatAuthnSuccessResponse

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
@Test
public void shouldFormatAuthnSuccessResponse() throws IOException, URISyntaxException, MarshallingException, SignatureException {
    Response response = aResponse().build();

    String logString = new ProtectiveMonitoringLogFormatter().formatAuthnResponse(response, Direction.INBOUND, true);

    String expectedLogMessage = "Protective Monitoring – Authn Response Event – " +
            "{responseId: default-response-id, " +
            "inResponseTo: default-request-id, " +
            "direction: INBOUND, " +
            "destination: http://destination.com, " +
            "issuerId: a-test-entity, " +
            "validSignature: true, " +
            "status: urn:oasis:names:tc:SAML:2.0:status:Success, " +
            "subStatus: , " +
            "statusDetails: []}";
    assertThat(logString).isEqualTo(expectedLogMessage);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:19,代码来源:ProtectiveMonitoringLogFormatterTest.java

示例10: getCountryAuthnResponseTranslatorService

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
@Provides
private CountryAuthnResponseTranslatorService getCountryAuthnResponseTranslatorService(StringToOpenSamlObjectTransformer<Response> stringToOpenSamlResponseTransformer,
                                                                                       ResponseFromCountryValidator responseFromCountryValidator,
                                                                                       IdpIdaStatusUnmarshaller idpIdaStatusUnmarshaller,
                                                                                       @Named("ResponseAssertionsFromCountryValidator") Optional<ResponseAssertionsFromCountryValidator> responseAssertionFromCountryValidator,
                                                                                       Optional<ValidateSamlResponseIssuedByIdpDestination> validateSamlResponseIssuedByIdpDestination,
                                                                                       @Named("AES256DecrypterWithGCM") AssertionDecrypter assertionDecrypter,
                                                                                       AssertionBlobEncrypter assertionBlobEncrypter,
                                                                                       @Named("CountrySamlResponseSignatureValidator") Optional<SamlResponseSignatureValidator> responseSignatureValidator,
                                                                                       @Named("CountrySamlAssertionsSignatureValidator") Optional<SamlAssertionsSignatureValidator> assertionSignatureValidator,
                                                                                       PassthroughAssertionUnmarshaller passthroughAssertionUnmarshaller) {
    if (!responseAssertionFromCountryValidator.isPresent() || !validateSamlResponseIssuedByIdpDestination.isPresent() || !responseSignatureValidator.isPresent() || !assertionSignatureValidator.isPresent()) {
        throw new InvalidConfigurationException("Eidas not configured correctly");
    }
    return new CountryAuthnResponseTranslatorService(stringToOpenSamlResponseTransformer,
            responseFromCountryValidator,
            idpIdaStatusUnmarshaller,
            responseAssertionFromCountryValidator.get(),
            validateSamlResponseIssuedByIdpDestination.get(),
            assertionDecrypter,
            assertionBlobEncrypter,
            responseSignatureValidator.get(),
            assertionSignatureValidator.get(),
            passthroughAssertionUnmarshaller);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:26,代码来源:SamlEngineModule.java

示例11: translate

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
public InboundResponseFromMatchingServiceDto translate(SamlResponseDto samlResponseDto) {
    final Response response = responseUnmarshaller.apply(samlResponseDto.getSamlResponse());
    MdcHelper.addContextToMdc(response);
    final InboundResponseFromMatchingService responseFromMatchingService = responseToInboundResponseFromMatchingServiceTransformer.transform(response);

    Optional<String> assertionBlob = Optional.absent();
    Optional<LevelOfAssurance> levelOfAssurance = Optional.absent();
    // FIXME?: transformer can return null
    if(responseFromMatchingService.getMatchingServiceAssertion()!=null && responseFromMatchingService.getMatchingServiceAssertion().isPresent()) {
        assertionBlob = Optional.fromNullable(responseFromMatchingService.getMatchingServiceAssertion().get().getUnderlyingAssertionBlob());
        final Optional<AuthnContext> authnContext = responseFromMatchingService.getMatchingServiceAssertion().get().getAuthnContext();
        if(authnContext.isPresent()) {
            levelOfAssurance = Optional.of(LevelOfAssurance.valueOf(authnContext.get().name()));
        }
    }

    final InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = new InboundResponseFromMatchingServiceDto(
            responseFromMatchingService.getStatus(),
            responseFromMatchingService.getInResponseTo(),
            responseFromMatchingService.getIssuer(),
            assertionBlob,
            levelOfAssurance);

    return inboundResponseFromMatchingServiceDto;
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:26,代码来源:MatchingServiceResponseTranslatorService.java

示例12: setUpForTranslate

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
private void setUpForTranslate(Optional<AuthnContext> authnContext, Optional<FraudDetectedDetails> fraudDetectedDetails, String underlyingAssertionBlob, String inResponseTo, String issuer, String samlResponse, MatchingServiceIdaStatus status) {
    final PassthroughAssertion assertion = new PassthroughAssertion(new PersistentId("persistentId"),
            authnContext,
            underlyingAssertionBlob,
            fraudDetectedDetails,
            Optional.of("principalIpAddressAsSeenByIdp"));
    final InboundResponseFromMatchingService inboundResponseFromMatchingService = InboundResponseFromMatchingServiceBuilder
            .anInboundResponseFromMatchingService()
            .withInResponseTo(inResponseTo)
            .withIssuerId(issuer)
            .withMatchingServiceAssertion(assertion)
            .withStatus(status)
            .build();
    Response response = mock(Response.class);
    Issuer responseIssuer = mock(Issuer.class);
    when(response.getIssuer()).thenReturn(responseIssuer);
    when(responseUnmarshaller.apply(samlResponse)).thenReturn(response);
    when(responseToInboundResponseFromMatchingServiceTransformer.transform(response)).thenReturn(inboundResponseFromMatchingService);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:20,代码来源:MatchingServiceResponseTranslatorServiceTest.java

示例13: MatchingServiceHealthChecker

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
@Inject
public MatchingServiceHealthChecker(
        final Function<Element, AttributeQuery> elementToAttributeQueryTransformer,
        final Function<Element, Response> elementToResponseTransformer,
        @Named("matchingRequestSignatureValidator") SamlMessageSignatureValidator matchingRequestSignatureValidator,
        final SupportedMsaVersionsRepository supportedMsaVersionsRepository,
        final SamlEngineProxy samlEngineProxy,
        final MatchingServiceHealthCheckClient matchingServiceHealthCheckClient,
        HealthCheckEventLogger eventLogger) {
    this.elementToAttributeQueryTransformer = elementToAttributeQueryTransformer;
    this.elementToResponseTransformer = elementToResponseTransformer;
    this.matchingRequestSignatureValidator = matchingRequestSignatureValidator;
    this.supportedMsaVersionsRepository = supportedMsaVersionsRepository;
    this.matchingServiceHealthCheckClient = matchingServiceHealthCheckClient;
    this.samlEngineProxy = samlEngineProxy;
    this.eventLogger = eventLogger;
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:18,代码来源:MatchingServiceHealthChecker.java

示例14: setUp

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    attributeQueryContainerDto = anAttributeQueryContainerDto(anAttributeQuery().build())
            .withMatchingServiceUri(matchingServiceUri)
            .build();

    executeAttributeQueryRequest = new ExecuteAttributeQueryRequest(
            elementToAttributeQueryTransformer,
            elementToResponseTransformer,
            matchingRequestSignatureValidator,
            matchingResponseSignatureValidator,
            attributeQueryRequestClient,
            protectiveMonitoringLogger);

   DateTimeFreezer.freezeTime();

    when(matchingRequestSignatureValidator.validate(any(AttributeQuery.class), eq(AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME))).thenReturn(SamlValidationResponse.aValidResponse());
    when(matchingRequestSignatureValidator.validate(any(Response.class), eq(AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME))).thenReturn(SamlValidationResponse.anInvalidResponse(SamlTransformationErrorFactory.invalidMessageSignature()));
    when(matchingResponseSignatureValidator.validate(any(AttributeQuery.class), eq(AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME))).thenReturn(SamlValidationResponse.anInvalidResponse(SamlTransformationErrorFactory.invalidMessageSignature()));
    when(matchingResponseSignatureValidator.validate(any(Response.class), eq(AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME))).thenReturn(SamlValidationResponse.aValidResponse());
    when(elementToAttributeQueryTransformer.apply(any(Element.class))).thenReturn(attributeQuery);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:23,代码来源:ExecuteAttributeQueryRequestTest.java

示例15: shouldReturnFailureResponseWhenAttributesRequestedDoNotExist

import org.opensaml.saml.saml2.core.Response; //导入依赖的package包/类
@Test
public void shouldReturnFailureResponseWhenAttributesRequestedDoNotExist(){
    List<Attribute> requiredAttributes = asList(FIRST_NAME, MIDDLE_NAME).stream()
            .map(userAccountCreationAttribute -> new AttributeQueryAttributeFactory(new OpenSamlXmlObjectFactory()).createAttribute(userAccountCreationAttribute))
            .collect(toList());

    AttributeQuery attributeQuery = anAttributeQuery()
            .withId(REQUEST_ID)
            .withAttributes(requiredAttributes)
            .withIssuer(anIssuer().withIssuerId(applicationRule.getConfiguration().getHubEntityId()).build())
            .withSubject(aSubjectWithAssertions(asList(
                    anAuthnStatementAssertion(),
                    assertionWithOnlyFirstName()), REQUEST_ID, HUB_ENTITY_ID))
            .build();

    Response response = makeAttributeQueryRequest(UNKNOWN_USER_URI, attributeQuery, signatureAlgorithmForHub, digestAlgorithmForHub, HUB_ENTITY_ID);
    List<Assertion> decryptedAssertions = assertionDecrypter.decryptAssertions(response::getEncryptedAssertions);

    assertThat(response.getStatus().getStatusCode().getValue()).isEqualTo(RESPONDER);
    Assertions.assertThat(decryptedAssertions).hasSize(0);
    Assertions.assertThat(response.getInResponseTo()).isEqualTo(REQUEST_ID);
    Assertions.assertThat(response.getIssuer().getValue()).isEqualTo(TEST_RP_MS);
    assertThat(response).is(signedBy(TEST_RP_MS_PUBLIC_SIGNING_CERT, TEST_RP_MS_PRIVATE_SIGNING_KEY));
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:25,代码来源:UserAccountCreationAppRuleTest.java


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