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


Java Response.getAssertions方法代码示例

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


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

示例1: setup

import org.opensaml.saml.saml2.core.Response; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
    IdaSamlBootstrap.bootstrap();
    service = new CountryAuthnResponseTranslatorService(
            stringToOpenSamlResponseTransformer,
            responseFromCountryValidator,
            new IdpIdaStatusUnmarshaller(new IdpIdaStatus.IdpIdaStatusFactory(), new SamlStatusToIdpIdaStatusMappingsFactory()),
            responseAssertionsFromCountryValidator,
            validateSamlResponseIssuedByIdpDestination,
            assertionDecrypter,
            assertionBlobEncrypter,
            samlResponseSignatureValidator,
            samlAssertionsSignatureValidator,
            new PassthroughAssertionUnmarshaller(new XmlObjectToBase64EncodedStringTransformer<>(), new AuthnContextFactory()));

    Response eidasSAMLResponse = (Response) buildResponseFromFile();
    ValidatedResponse validateEIDASSAMLResponse = new ValidatedResponse(eidasSAMLResponse);
    List<Assertion> decryptedAssertions = eidasSAMLResponse.getAssertions();

    when(samlAuthnResponseTranslatorDto.getSamlResponse()).thenReturn("eidas");
    when(samlAuthnResponseTranslatorDto.getMatchingServiceEntityId()).thenReturn("mid");
    when(stringToOpenSamlResponseTransformer.apply("eidas")).thenReturn(eidasSAMLResponse);
    doNothing().when(responseFromCountryValidator).validate(eidasSAMLResponse);
    when(samlResponseSignatureValidator.validate(eidasSAMLResponse, IDPSSODescriptor.DEFAULT_ELEMENT_NAME)).thenReturn(validateEIDASSAMLResponse);
    when(assertionDecrypter.decryptAssertions(validateEIDASSAMLResponse)).thenReturn(decryptedAssertions);
    when(assertionBlobEncrypter.encryptAssertionBlob(eq("mid"), any(String.class))).thenReturn(identityUnderlyingAssertionBlob);
    when(samlAssertionsSignatureValidator.validate(decryptedAssertions, IDPSSODescriptor.DEFAULT_ELEMENT_NAME)).thenReturn(new ValidatedAssertions(decryptedAssertions));
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:29,代码来源:CountryAuthnResponseTranslatorServiceTest.java

示例2: validateSamlSSOResponse

import org.opensaml.saml.saml2.core.Response; //导入方法依赖的package包/类
/**
 * Validates the SAML SSO response by finding a valid assertion with authn statements.
 * Populates the {@link SAML2MessageContext} with a subjectAssertion and a subjectNameIdentifier.
 *
 * @param response the response
 * @param context the context
 * @param engine the engine
 * @param decrypter the decrypter
 */
protected final void validateSamlSSOResponse(final Response response, final SAML2MessageContext context,
                                             final SignatureTrustEngine engine, final Decrypter decrypter) {

    for (final Assertion assertion : response.getAssertions()) {
        if (!assertion.getAuthnStatements().isEmpty()) {
            try {
                validateAssertion(assertion, context, engine, decrypter);
            } catch (final SAMLException e) {
                logger.error("Current assertion validation failed, continue with the next one", e);
                continue;
            }
            context.setSubjectAssertion(assertion);
            break;
        }
    }

    if (context.getSubjectAssertion() == null) {
        throw new SAMLException("No valid subject assertion found in response");
    }

    // We do not check EncryptedID here because it has been already decrypted and stored into NameID
    final List<SubjectConfirmation> subjectConfirmations = context.getSubjectConfirmations();
    final NameID nameIdentifier = (NameID) context.getSAMLSubjectNameIdentifierContext().getSubjectNameIdentifier();
    if ((nameIdentifier == null || nameIdentifier.getValue() == null) && context.getBaseID() == null
            && (subjectConfirmations == null || subjectConfirmations.isEmpty())) {
        throw new SAMLException(
                "Subject NameID, BaseID and EncryptedID cannot be all null at the same time if there are no Subject Confirmations.");
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:39,代码来源:SAML2DefaultResponseValidator.java


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