• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Audience类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: validateAudienceRestrictions

import org.opensaml.saml.saml2.core.Audience; //导入依赖的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.Audience; //导入依赖的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.Audience; //导入依赖的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.Audience; //导入依赖的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: shouldNotComplainWhenCorrectDataIsPassed

import org.opensaml.saml.saml2.core.Audience; //导入依赖的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


示例6: shouldThrowExceptionWhenAudienceUriDoesNotMatchTheEntityId

import org.opensaml.saml.saml2.core.Audience; //导入依赖的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


示例7: AudienceValidator

import org.opensaml.saml.saml2.core.Audience; //导入依赖的package包/类
public AudienceValidator(final Function<T, Audience> valueProvider, final String audienceUri) {
    super(
        true,
        valueProvider,
        new RequiredValidator<>(DEFAULT_REQUIRED_MESSAGE),
        new RequiredValidator<>(DEFAULT_REQUIRED_URI_MESSAGE, Audience::getAudienceURI),
        new FixedErrorValidator<>(a -> !a.getAudienceURI().equals(audienceUri), generateMismatchedAudienceUriMessage(audienceUri))
    );
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:10,代码来源:AudienceValidator.java


示例8: aConditions

import org.opensaml.saml.saml2.core.Audience; //导入依赖的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


示例9: aConditions

import org.opensaml.saml.saml2.core.Audience; //导入依赖的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


示例10: shouldReturnErrorIfAudienceUriIsNotFound

import org.opensaml.saml.saml2.core.Audience; //导入依赖的package包/类
@Test
public void shouldReturnErrorIfAudienceUriIsNotFound() {
    Audience audience = new AudienceBuilder().buildObject();
    Messages messages = validator.validate(audience, messages());

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


示例11: shouldReturnErrorIfAudienceUriIsEmpty

import org.opensaml.saml.saml2.core.Audience; //导入依赖的package包/类
@Test
public void shouldReturnErrorIfAudienceUriIsEmpty() {
    Audience audience = new AudienceBuilder().buildObject();
    audience.setAudienceURI("");
    Messages messages = validator.validate(audience, messages());

    assertThat(messages.size()).isEqualTo(1);
    assertThat(messages.hasErrorLike(DEFAULT_REQUIRED_URI_MESSAGE)).isTrue();
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:10,代码来源:AudienceValidatorTest.java


示例12: shouldReturnErrorIfAudienceUriDoesNotMatchExpectedEntityId

import org.opensaml.saml.saml2.core.Audience; //导入依赖的package包/类
@Test
public void shouldReturnErrorIfAudienceUriDoesNotMatchExpectedEntityId() {
    Audience audience = new AudienceBuilder().buildObject();
    audience.setAudienceURI("invalidEntityId");
    Messages messages = validator.validate(audience, messages());

    assertThat(messages.size()).isEqualTo(1);
    assertThat(messages.hasErrorLike(generateMismatchedAudienceUriMessage(AUDIENCE_URI))).isTrue();
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:10,代码来源:AudienceValidatorTest.java


示例13: shouldValidateAudienceUriSuccessfully

import org.opensaml.saml.saml2.core.Audience; //导入依赖的package包/类
@Test
public void shouldValidateAudienceUriSuccessfully() {
    Audience audience = new AudienceBuilder().buildObject();
    audience.setAudienceURI(AUDIENCE_URI);
    Messages messages = validator.validate(audience, messages());

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


示例14: setUp

import org.opensaml.saml.saml2.core.Audience; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    DateTimeUtils.setCurrentMillisFixed(NOW.getMillis());
    validator = new ConditionsValidator<>(conditions -> conditions, AUDIENCE_URI);

    audienceRestriction= new AudienceRestrictionBuilder().buildObject();
    Audience audience = new AudienceBuilder().buildObject();
    audience.setAudienceURI(AUDIENCE_URI);
    audienceRestriction.getAudiences().add(audience);
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:11,代码来源:ConditionsValidatorTest.java


示例15: aConditions

import org.opensaml.saml.saml2.core.Audience; //导入依赖的package包/类
private 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_CONNECTOR_ENTITY_ID);
    audienceRestriction.getAudiences().add(audience);
    conditions.getAudienceRestrictions().add(audienceRestriction);
    return conditions;
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:12,代码来源:EidasAttributeQueryValidatorTest.java


示例16: shouldValidateAudienceRestrictionSuccessfully

import org.opensaml.saml.saml2.core.Audience; //导入依赖的package包/类
@Test
public void shouldValidateAudienceRestrictionSuccessfully() {
    AudienceRestriction audienceRestriction= new AudienceRestrictionBuilder().buildObject();
    Audience audience = new AudienceBuilder().buildObject();
    audience.setAudienceURI(AUDIENCE_URI);
    audienceRestriction.getAudiences().add(audience);

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

    assertThat(messages.size()).isEqualTo(0);
}
 
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:12,代码来源:AudienceRestrictionValidatorTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ClusterValve类代码示例发布时间:2022-05-23
下一篇:
Java CyLayoutAlgorithmManager类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap