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


Java SubjectConfirmationData类代码示例

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


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

示例1: newSubject

import org.opensaml.saml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
/**
 * New subject element.
 *
 * @param nameIdFormat the name id format
 * @param nameIdValue the name id value
 * @param recipient the recipient
 * @param notOnOrAfter the not on or after
 * @param inResponseTo the in response to
 * @return the subject
 */
public Subject newSubject(final String nameIdFormat, final String nameIdValue,
                          final String recipient, final DateTime notOnOrAfter,
                          final String inResponseTo) {

    final SubjectConfirmation confirmation = newSamlObject(SubjectConfirmation.class);
    confirmation.setMethod(SubjectConfirmation.METHOD_BEARER);

    final SubjectConfirmationData data = newSamlObject(SubjectConfirmationData.class);
    data.setRecipient(recipient);
    data.setNotOnOrAfter(notOnOrAfter);
    data.setInResponseTo(inResponseTo);

    confirmation.setSubjectConfirmationData(data);

    final Subject subject = newSamlObject(Subject.class);
    subject.setNameID(getNameID(nameIdFormat, nameIdValue));
    subject.getSubjectConfirmations().add(confirmation);
    return subject;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:30,代码来源:AbstractSaml20ObjectBuilder.java

示例2: newSubject

import org.opensaml.saml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
/**
 * New subject element.
 *
 * @param nameIdFormat the name id format
 * @param nameIdValue  the name id value
 * @param recipient    the recipient
 * @param notOnOrAfter the not on or after
 * @param inResponseTo the in response to
 * @return the subject
 */
public Subject newSubject(final String nameIdFormat, final String nameIdValue,
                          final String recipient, final ZonedDateTime notOnOrAfter,
                          final String inResponseTo) {

    LOGGER.debug("Building subject for NameID [{}]/[{}] and recipient [{}], in response to [{}]",
            nameIdValue, nameIdFormat, recipient, inResponseTo);
    final SubjectConfirmation confirmation = newSamlObject(SubjectConfirmation.class);
    confirmation.setMethod(SubjectConfirmation.METHOD_BEARER);

    final SubjectConfirmationData data = newSamlObject(SubjectConfirmationData.class);
    data.setRecipient(recipient);
    data.setNotOnOrAfter(DateTimeUtils.dateTimeOf(notOnOrAfter));
    data.setInResponseTo(inResponseTo);
    confirmation.setSubjectConfirmationData(data);

    final Subject subject = newSamlObject(Subject.class);
    subject.setNameID(getNameID(nameIdFormat, nameIdValue));
    subject.getSubjectConfirmations().add(confirmation);

    LOGGER.debug("Built subject [{}]", subject);
    return subject;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:33,代码来源:AbstractSaml20ObjectBuilder.java

示例3: SubjectConfirmationDataValidator

import org.opensaml.saml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
public SubjectConfirmationDataValidator(Function<T, SubjectConfirmationData> valueProvider, DateTimeComparator dateTimeComparator) {
    super(
        true,
        valueProvider,
        new RequiredValidator<>(SUBJECT_CONFIRMATION_DATA_NOT_PRESENT),
        new RequiredValidator<>(NOT_ON_OR_AFTER_NOT_PRESENT, SubjectConfirmationData::getNotOnOrAfter),
        TimeRestrictionValidators.notInPastValidator(dateTimeComparator,  SubjectConfirmationData::getNotOnOrAfter, NOT_ON_OR_AFTER_INVALID),
        new RequiredValidator<>(IN_RESPONSE_TO_NOT_PRESENT, SubjectConfirmationData::getInResponseTo),
        new RequiredValidator<>(RECIPIENT_NOT_PRESENT, SubjectConfirmationData::getRecipient)
    );
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:12,代码来源:SubjectConfirmationDataValidator.java

示例4: aSubjectWithAssertions

import org.opensaml.saml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
public static Subject aSubjectWithAssertions(List<Assertion> assertions, String requestId, String hubEntityId, String pid) {
    final NameID nameId = aNameId().withValue(pid).withNameQualifier("").withSpNameQualifier(hubEntityId).build();
    SubjectConfirmationDataBuilder subjectConfirmationDataBuilder = aSubjectConfirmationData().withInResponseTo(requestId);
    assertions.stream().forEach(subjectConfirmationDataBuilder::addAssertion);
    final SubjectConfirmationData subjectConfirmationData = subjectConfirmationDataBuilder.build();
    final SubjectConfirmation subjectConfirmation = SubjectConfirmationBuilder.aSubjectConfirmation()
        .withSubjectConfirmationData(subjectConfirmationData).build();

    return aSubject().withNameId(nameId).withSubjectConfirmation(subjectConfirmation).build();
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:11,代码来源:AssertionHelper.java

示例5: aSubjectWithEncryptedAssertions

import org.opensaml.saml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
public static Subject aSubjectWithEncryptedAssertions(List<EncryptedAssertion> assertions, String requestId, String hubEntityId) {
    final NameID nameId = aNameId().withNameQualifier("").withSpNameQualifier(hubEntityId).build();

    SubjectConfirmationDataBuilder subjectConfirmationDataBuilder = aSubjectConfirmationData().withInResponseTo(requestId);
    assertions.stream().forEach(subjectConfirmationDataBuilder::addAssertion);

    final SubjectConfirmationData subjectConfirmationData = subjectConfirmationDataBuilder.build();
    final SubjectConfirmation subjectConfirmation = SubjectConfirmationBuilder.aSubjectConfirmation()
            .withSubjectConfirmationData(subjectConfirmationData).build();

    return aSubject().withNameId(nameId).withSubjectConfirmation(subjectConfirmation).build();
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:13,代码来源:AssertionHelper.java

示例6: handleSuccessfullyDecryptsAssertionsInAttributeQuery

import org.opensaml.saml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void handleSuccessfullyDecryptsAssertionsInAttributeQuery() {
    MatchingService delegate = mock(MatchingService.class);
    MatchingServiceRequestContext requestContext = new MatchingServiceRequestContext(attributeQueryDocument);
    when(serviceLocator.findServiceFor(requestContext)).thenReturn(delegate);

    Subject subject = mock(Subject.class);
    SubjectConfirmation subjectConfirmation = mock(SubjectConfirmation.class);
    SubjectConfirmationData subjectConfirmationData = mock(SubjectConfirmationData.class);
    EncryptedAssertion encryptedAssertion = mock(EncryptedAssertion.class);
    when(subject.getSubjectConfirmations()).thenReturn(Arrays.asList(subjectConfirmation));
    when(subjectConfirmation.getSubjectConfirmationData()).thenReturn(subjectConfirmationData);
    when(subjectConfirmationData.getUnknownXMLObjects(EncryptedAssertion.DEFAULT_ELEMENT_NAME)).thenReturn(Arrays.asList(encryptedAssertion));
    when(attributeQuery.getSubject()).thenReturn(subject);

    service.handle(requestContext);

    assertThat(requestContext.getAttributeQuery(), sameInstance(attributeQuery));
    assertThat(requestContext.getAssertions(), equalTo(Collections.emptyList()));

    ArgumentCaptor<ValidatedEncryptedAssertionContainer> encryptedAssertionContainerArgumentCaptor = ArgumentCaptor.forClass(ValidatedEncryptedAssertionContainer.class);
    verify(assertionDecrypter).decryptAssertions(encryptedAssertionContainerArgumentCaptor.capture());
    assertThat(encryptedAssertionContainerArgumentCaptor.getValue().getEncryptedAssertions(), equalTo(Arrays.asList(encryptedAssertion)));

    verify(serviceLocator).findServiceFor(requestContext);
    verify(delegate).handle(requestContext);
    verifyNoMoreInteractions(delegate, serviceLocator);
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:30,代码来源:DelegatingMatchingServiceTest.java

示例7: shouldGenerateNoErrorsWhenSubjectConfirmationDataIsValid

import org.opensaml.saml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
@Test
public void shouldGenerateNoErrorsWhenSubjectConfirmationDataIsValid() {
    SubjectConfirmationData subjectConfirmationData = aSubjectConfirmationData().build();

    Messages messages = validator.validate(subjectConfirmationData, messages());

    assertThat(messages.hasErrors()).isFalse();
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:9,代码来源:SubjectConfirmationDataValidatorTest.java

示例8: shouldGenerateErrorWhenSubjectConfirmationDataNotOnOrAfterIsMissing

import org.opensaml.saml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
@Test
public void shouldGenerateErrorWhenSubjectConfirmationDataNotOnOrAfterIsMissing() throws Exception {
    SubjectConfirmationData subjectConfirmationData = aSubjectConfirmationData().withNotOnOrAfter(null).build();

    Messages messages = validator.validate(subjectConfirmationData, messages());

    assertThat(messages.hasErrorLike(NOT_ON_OR_AFTER_NOT_PRESENT)).isTrue();
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:9,代码来源:SubjectConfirmationDataValidatorTest.java

示例9: shouldGenerateErrorWhenSubjectConfirmationDataNotOnOrAfterIsInThePast

import org.opensaml.saml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
@Test
public void shouldGenerateErrorWhenSubjectConfirmationDataNotOnOrAfterIsInThePast() throws Exception {
    SubjectConfirmationData subjectConfirmationData = aSubjectConfirmationData().withNotOnOrAfter(DateTime.now().minusMinutes(5)).withNotBefore(DateTime.now()).build();

    Messages messages = validator.validate(subjectConfirmationData, messages());

    assertThat(messages.hasErrorLike(NOT_ON_OR_AFTER_INVALID)).isTrue();
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:9,代码来源:SubjectConfirmationDataValidatorTest.java

示例10: shouldGenerateErrorWhenSubjectConfirmationDataHasNoInResponseTo

import org.opensaml.saml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
@Test
public void shouldGenerateErrorWhenSubjectConfirmationDataHasNoInResponseTo() throws Exception {
    SubjectConfirmationData subjectConfirmationData = aSubjectConfirmationData().withNotBefore(DateTime.now()).withInResponseTo(null).build();

    Messages messages = validator.validate(subjectConfirmationData, messages());

    assertThat(messages.hasErrorLike(IN_RESPONSE_TO_NOT_PRESENT)).isTrue();
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:9,代码来源:SubjectConfirmationDataValidatorTest.java

示例11: shouldGenerateErrorWhenSubjectConfirmationDataHasNoRecipient

import org.opensaml.saml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
@Test
public void shouldGenerateErrorWhenSubjectConfirmationDataHasNoRecipient() throws Exception {
    SubjectConfirmationData subjectConfirmationData = aSubjectConfirmationData().withNotBefore(DateTime.now()).withRecipient(null).build();

    Messages messages = validator.validate(subjectConfirmationData, messages());

    assertThat(messages.hasErrorLike(RECIPIENT_NOT_PRESENT)).isTrue();
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:9,代码来源:SubjectConfirmationDataValidatorTest.java

示例12: aSubjectWithEncryptedAssertion

import org.opensaml.saml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
private Subject aSubjectWithEncryptedAssertion(final EncryptedAssertion encryptedAssertion,
                                               final String requestId,
                                               final String hubEntityId) {
    final NameID nameId = aNameId().withNameQualifier("").withSpNameQualifier(hubEntityId).build();
    final SubjectConfirmationData subjectConfirmationData = aSubjectConfirmationData().withInResponseTo(requestId).addAssertion(encryptedAssertion).build();
    final SubjectConfirmation subjectConfirmation = aSubjectConfirmation().withSubjectConfirmationData(subjectConfirmationData).build();

    return aSubject().withNameId(nameId).withSubjectConfirmation(subjectConfirmation).build();
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:10,代码来源:EidasAttributeQueryValidatorTest.java

示例13: validate

import org.opensaml.saml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
public void validate(Subject subject, String expectedInResponseTo) {
    if (subject == null) {
        throw new SamlResponseValidationException("Subject is missing from the assertion.");
    }

    if (subject.getSubjectConfirmations().size() != 1) {
        throw new SamlResponseValidationException("Exactly one subject confirmation is expected.");
    }

    SubjectConfirmation subjectConfirmation = subject.getSubjectConfirmations().get(0);
    if (!METHOD_BEARER.equals(subjectConfirmation.getMethod())) {
        throw new SamlResponseValidationException("Subject confirmation method must be 'bearer'.");
    }

    SubjectConfirmationData subjectConfirmationData = subjectConfirmation.getSubjectConfirmationData();
    if (subjectConfirmationData == null) {
        throw new SamlResponseValidationException("Subject confirmation data is missing from the assertion.");
    }

    timeRestrictionValidator.validateNotBefore(subjectConfirmationData.getNotBefore());

    DateTime notOnOrAfter = subjectConfirmationData.getNotOnOrAfter();
    if (notOnOrAfter == null) {
        throw new SamlResponseValidationException("Subject confirmation data must contain 'NotOnOrAfter'.");
    }

    timeRestrictionValidator.validateNotOnOrAfter(notOnOrAfter);

    String actualInResponseTo = subjectConfirmationData.getInResponseTo();
    if (actualInResponseTo == null) {
        throw new SamlResponseValidationException("Subject confirmation data must contain 'InResponseTo'.");
    }

    if (!expectedInResponseTo.equals(actualInResponseTo)) {
        throw new SamlResponseValidationException(String.format("'InResponseTo' must match requestId. Expected %s but was %s", expectedInResponseTo, actualInResponseTo));
    }

    if (subject.getNameID() == null) {
        throw new SamlResponseValidationException("NameID is missing from the subject of the assertion.");
    }
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:42,代码来源:SubjectValidator.java

示例14: isValidBearerSubjectConfirmationData

import org.opensaml.saml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
/**
 * Validate Bearer subject confirmation data
 *  - notBefore
 *  - NotOnOrAfter
 *  - recipient
 *
 * @param data the data
 * @param context the context
 * @return true if all Bearer subject checks are passing
 */
protected final boolean isValidBearerSubjectConfirmationData(final SubjectConfirmationData data,
                                                             final SAML2MessageContext context) {
    if (data == null) {
        logger.debug("SubjectConfirmationData cannot be null for Bearer confirmation");
        return false;
    }

    // TODO Validate inResponseTo

    if (data.getNotBefore() != null) {
        logger.debug("SubjectConfirmationData notBefore must be null for Bearer confirmation");
        return false;
    }

    if (data.getNotOnOrAfter() == null) {
        logger.debug("SubjectConfirmationData notOnOrAfter cannot be null for Bearer confirmation");
        return false;
    }

    if (data.getNotOnOrAfter().plusSeconds(acceptedSkew).isBeforeNow()) {
        logger.debug("SubjectConfirmationData notOnOrAfter is too old");
        return false;
    }

    try {
        if (data.getRecipient() == null) {
            logger.debug("SubjectConfirmationData recipient cannot be null for Bearer confirmation");
            return false;
        } else {
            final Endpoint endpoint = context.getSAMLEndpointContext().getEndpoint();
            if (endpoint == null) {
                logger.warn("No endpoint was found in the SAML endpoint context");
                return false;
            }

            final URI recipientUri = new URI(data.getRecipient());
            final URI appEndpointUri = new URI(endpoint.getLocation());
            if (!UriUtils.urisEqualAfterPortNormalization(recipientUri, appEndpointUri)) {
                logger.debug("SubjectConfirmationData recipient {} does not match SP assertion consumer URL, found. SP ACS URL from context: {}", recipientUri, appEndpointUri);
                return false;
            }
        }
    } catch (URISyntaxException use) {
        logger.error("Unable to check SubjectConfirmationData recipient, a URI has invalid syntax.", use);
        return false;
    }
    
    return true;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:60,代码来源:SAML2DefaultResponseValidator.java


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