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


Java AudienceRestriction类代码示例

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


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

示例1: validateAudienceRestrictions

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
/**
 * Validate audience by matching the SP entityId.
 *
 * @param audienceRestrictions the audience restrictions
 * @param spEntityId the sp entity id
 */
protected final void validateAudienceRestrictions(final List<AudienceRestriction> audienceRestrictions,
                                                  final String spEntityId) {

    if (audienceRestrictions == null || audienceRestrictions.isEmpty()) {
        throw new SAMLException("Audience restrictions cannot be null or empty");
    }

    final Set<String> audienceUris = new HashSet<String>();
    for (final AudienceRestriction audienceRestriction : audienceRestrictions) {
        if (audienceRestriction.getAudiences() != null) {
            for (final Audience audience : audienceRestriction.getAudiences()) {
                audienceUris.add(audience.getAudienceURI());
            }
        }
    }
    if (!audienceUris.contains(spEntityId)) {
        throw new SAMLException("Assertion audience " + audienceUris + " does not match SP configuration "
                + spEntityId);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:27,代码来源:SAML2DefaultResponseValidator.java

示例2: newConditions

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
/**
 * New conditions element.
 *
 * @param notBefore the not before
 * @param notOnOrAfter the not on or after
 * @param audienceUri the service id
 * @return the conditions
 */
public Conditions newConditions(final DateTime notBefore, final DateTime notOnOrAfter, final String audienceUri) {
    final Conditions conditions = newSamlObject(Conditions.class);
    conditions.setNotBefore(notBefore);
    conditions.setNotOnOrAfter(notOnOrAfter);

    final AudienceRestriction audienceRestriction = newSamlObject(AudienceRestriction.class);
    final Audience audience = newSamlObject(Audience.class);
    audience.setAudienceURI(audienceUri);
    audienceRestriction.getAudiences().add(audience);
    conditions.getAudienceRestrictions().add(audienceRestriction);
    return conditions;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:AbstractSaml20ObjectBuilder.java

示例3: newConditions

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
/**
 * New conditions element.
 *
 * @param notBefore    the not before
 * @param notOnOrAfter the not on or after
 * @param audienceUri  the service id
 * @return the conditions
 */
public Conditions newConditions(final ZonedDateTime notBefore, final ZonedDateTime notOnOrAfter, final String audienceUri) {
    LOGGER.debug("Building conditions for audience [{}] that enforce not-before [{}] and not-after [{}]", audienceUri, notBefore, notOnOrAfter);
    final Conditions conditions = newSamlObject(Conditions.class);
    conditions.setNotBefore(DateTimeUtils.dateTimeOf(notBefore));
    conditions.setNotOnOrAfter(DateTimeUtils.dateTimeOf(notOnOrAfter));

    final AudienceRestriction audienceRestriction = newSamlObject(AudienceRestriction.class);
    final Audience audience = newSamlObject(Audience.class);
    audience.setAudienceURI(audienceUri);
    audienceRestriction.getAudiences().add(audience);
    conditions.getAudienceRestrictions().add(audienceRestriction);
    return conditions;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:22,代码来源:AbstractSaml20ObjectBuilder.java

示例4: validate

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
public void validate(List<AudienceRestriction> audienceRestrictions, String entityId) {
    if (audienceRestrictions == null || audienceRestrictions.size() != 1) {
        throw new SamlResponseValidationException("Exactly one audience restriction is expected.");
    }

    List<Audience> audiences = audienceRestrictions.get(0).getAudiences();
    if (audiences == null || audiences.size() != 1) {
        throw new SamlResponseValidationException("Exactly one audience is expected.");
    }

    String audience = audiences.get(0).getAudienceURI();
    if (!entityId.equals(audience)) {
        throw new SamlResponseValidationException(String.format("Audience must match entity ID. Expected %s but was %s", entityId, audience));
    }
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:16,代码来源:AudienceRestrictionValidator.java

示例5: shouldValidateConditionsAudienceRestrictions

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
@Test
public void shouldValidateConditionsAudienceRestrictions() {
    List<AudienceRestriction> audienceRestrictions = ImmutableList.of(anAudienceRestriction().build());
    when(conditions.getAudienceRestrictions()).thenReturn(audienceRestrictions);

    validator.validate(conditions, "some-entity-id");

    verify(audienceRestrictionValidator).validate(audienceRestrictions, "some-entity-id");
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:10,代码来源:ConditionsValidatorTest.java

示例6: shouldNotComplainWhenCorrectDataIsPassed

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
@Test
public void shouldNotComplainWhenCorrectDataIsPassed() {
    Audience audience = new AudienceBuilder().buildObject();
    audience.setAudienceURI("some-entity-id");

    AudienceRestriction audienceRestriction = mock(AudienceRestriction.class, Answers.RETURNS_DEEP_STUBS);
    when(audienceRestriction.getAudiences()).thenReturn(ImmutableList.of(audience));

    validator.validate(ImmutableList.of(audienceRestriction), "some-entity-id");
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:11,代码来源:AudienceRestrictionValidatorTest.java

示例7: shouldThrowExceptionWhenAudienceRestrictionsIsNull

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
@Test
public void shouldThrowExceptionWhenAudienceRestrictionsIsNull() {
    expectedException.expect(SamlResponseValidationException.class);
    expectedException.expectMessage("Exactly one audience restriction is expected.");

    List<AudienceRestriction> audienceRestrictions = null;
    validator.validate(audienceRestrictions, "any-entity-id");
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:9,代码来源:AudienceRestrictionValidatorTest.java

示例8: shouldThrowExceptionWhenAudienceRestrictionsHasMoreThanOneElements

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
@Test
public void shouldThrowExceptionWhenAudienceRestrictionsHasMoreThanOneElements() {
    expectedException.expect(SamlResponseValidationException.class);
    expectedException.expectMessage("Exactly one audience restriction is expected.");

    List<AudienceRestriction> audienceRestrictions = ImmutableList.of(
        anAudienceRestriction().build(),
        anAudienceRestriction().build()
    );

    validator.validate(audienceRestrictions, "any-entity-id");
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:13,代码来源:AudienceRestrictionValidatorTest.java

示例9: shouldThrowExceptionWhenAudiencesIsNull

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
@Test
public void shouldThrowExceptionWhenAudiencesIsNull() {
    AudienceRestriction audienceRestriction = mock(AudienceRestriction.class, Answers.RETURNS_DEEP_STUBS);
    when(audienceRestriction.getAudiences()).thenReturn(null);

    expectedException.expect(SamlResponseValidationException.class);
    expectedException.expectMessage("Exactly one audience is expected.");

    validator.validate(ImmutableList.of(audienceRestriction), "any-entity-id");
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:11,代码来源:AudienceRestrictionValidatorTest.java

示例10: shouldThrowExceptionWhenAudiencesIsMoreThanOne

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
@Test
public void shouldThrowExceptionWhenAudiencesIsMoreThanOne() {
    AudienceRestriction audienceRestriction = anAudienceRestriction().build();
    audienceRestriction.getAudiences().add(new AudienceBuilder().buildObject());
    audienceRestriction.getAudiences().add(new AudienceBuilder().buildObject());

    expectedException.expect(SamlResponseValidationException.class);
    expectedException.expectMessage("Exactly one audience is expected.");

    validator.validate(ImmutableList.of(audienceRestriction), "any-entity-id");
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:12,代码来源:AudienceRestrictionValidatorTest.java

示例11: shouldThrowExceptionWhenAudienceUriDoesNotMatchTheEntityId

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
@Test
public void shouldThrowExceptionWhenAudienceUriDoesNotMatchTheEntityId() {
    Audience audience = new AudienceBuilder().buildObject();
    audience.setAudienceURI("some-entity-id");

    AudienceRestriction audienceRestriction = mock(AudienceRestriction.class, Answers.RETURNS_DEEP_STUBS);
    when(audienceRestriction.getAudiences()).thenReturn(ImmutableList.of(audience));

    expectedException.expect(SamlResponseValidationException.class);
    expectedException.expectMessage(String.format("Audience must match entity ID. Expected %s but was %s", "unknown-entity-id", "some-entity-id"));

    validator.validate(ImmutableList.of(audienceRestriction), "unknown-entity-id");
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:14,代码来源:AudienceRestrictionValidatorTest.java

示例12: apply

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
public Assertion apply(MatchingServiceAssertion originalAssertion) {

        Assertion transformedAssertion = openSamlXmlObjectFactory.createAssertion();
        transformedAssertion.setIssueInstant(originalAssertion.getIssueInstant());

        Issuer transformedIssuer = openSamlXmlObjectFactory.createIssuer(originalAssertion.getIssuerId());
        transformedAssertion.setIssuer(transformedIssuer);
        transformedAssertion.setID(originalAssertion.getId());

        Subject subject = outboundAssertionToSubjectTransformer.transform(originalAssertion);
        transformedAssertion.setSubject(subject);

        MatchingServiceAuthnStatement authnStatement = originalAssertion.getAuthnStatement();

        transformedAssertion.getAuthnStatements().add(matchingServiceAuthnStatementToAuthnStatementTransformer.transform(authnStatement));

        Conditions conditions = openSamlXmlObjectFactory.createConditions();
        AudienceRestriction audienceRestriction = openSamlXmlObjectFactory.createAudienceRestriction(originalAssertion.getAudience());
        conditions.getAudienceRestrictions().add(audienceRestriction);
        transformedAssertion.setConditions(conditions);

        List<Attribute> userAttributesForAccountCreation = originalAssertion.getUserAttributesForAccountCreation();
        if (!userAttributesForAccountCreation.isEmpty()) {
            addAttributes(transformedAssertion, userAttributesForAccountCreation);
        }


        return transformedAssertion;
    }
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:30,代码来源:MatchingServiceAssertionToAssertionTransformer.java

示例13: AudienceRestrictionValidator

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
public AudienceRestrictionValidator(final Function<T, AudienceRestriction> valueProvider, final String audienceUri) {
    super(
        true,
        valueProvider,
        new RequiredValidator<>(DEFAULT_REQUIRED_MESSAGE),
        new FixedErrorValidator<>(audienceRestriction -> audienceRestriction.getAudiences().size() != 1, DEFAULT_AUDIENCES_MUST_CONTAIN_ONE_AUDIENCE_MESSAGE),
        new AudienceValidator<>(audienceRestriction -> audienceRestriction.getAudiences().get(0), audienceUri)
    );
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:10,代码来源:AudienceRestrictionValidator.java

示例14: aConditions

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
private static Conditions aConditions() {
    Conditions conditions = new ConditionsBuilder().buildObject();
    conditions.setNotBefore(DateTime.now());
    conditions.setNotOnOrAfter(DateTime.now().plusMinutes(10));
    AudienceRestriction audienceRestriction= new AudienceRestrictionBuilder().buildObject();
    Audience audience = new AudienceBuilder().buildObject();
    audience.setAudienceURI(HUB_SECONDARY_ENTITY_ID);
    audienceRestriction.getAudiences().add(audience);
    conditions.getAudienceRestrictions().add(audienceRestriction);
    return conditions;
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:12,代码来源:AssertionHelper.java

示例15: aConditions

import org.opensaml.saml.saml2.core.AudienceRestriction; //导入依赖的package包/类
private static Conditions aConditions() {
    Conditions conditions = new ConditionsBuilder().buildObject();
    conditions.setNotBefore(DateTime.now());
    conditions.setNotOnOrAfter(DateTime.now().plusMinutes(10));
    AudienceRestriction audienceRestriction = new AudienceRestrictionBuilder().buildObject();
    Audience audience = new AudienceBuilder().buildObject();
    audience.setAudienceURI(HUB_SECONDARY_ENTITY_ID);
    audienceRestriction.getAudiences().add(audience);
    conditions.getAudienceRestrictions().add(audienceRestriction);
    return conditions;
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:12,代码来源:CountryEnabledIntegrationTest.java


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