Search in sources :

Example 1 with Audience

use of org.opensaml.saml.saml2.core.Audience in project cas by apereo.

the class AbstractSaml20ObjectBuilder method newConditions.

/**
     * 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) {
    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;
}
Also used : AudienceRestriction(org.opensaml.saml.saml2.core.AudienceRestriction) Audience(org.opensaml.saml.saml2.core.Audience) Conditions(org.opensaml.saml.saml2.core.Conditions)

Example 2 with Audience

use of org.opensaml.saml.saml2.core.Audience in project cas by apereo.

the class Saml10ObjectBuilder method newConditions.

/**
     * New conditions element.
     *
     * @param issuedAt the issued at
     * @param audienceUri the service id
     * @param issueLength the issue length
     * @return the conditions
     */
public Conditions newConditions(final ZonedDateTime issuedAt, final String audienceUri, final long issueLength) {
    final Conditions conditions = newSamlObject(Conditions.class);
    conditions.setNotBefore(DateTimeUtils.dateTimeOf(issuedAt));
    conditions.setNotOnOrAfter(DateTimeUtils.dateTimeOf(issuedAt.plus(issueLength, ChronoUnit.MILLIS)));
    final AudienceRestrictionCondition audienceRestriction = newSamlObject(AudienceRestrictionCondition.class);
    final Audience audience = newSamlObject(Audience.class);
    audience.setUri(audienceUri);
    audienceRestriction.getAudiences().add(audience);
    conditions.getAudienceRestrictionConditions().add(audienceRestriction);
    return conditions;
}
Also used : Audience(org.opensaml.saml.saml1.core.Audience) AudienceRestrictionCondition(org.opensaml.saml.saml1.core.AudienceRestrictionCondition) Conditions(org.opensaml.saml.saml1.core.Conditions)

Aggregations

Audience (org.opensaml.saml.saml1.core.Audience)1 AudienceRestrictionCondition (org.opensaml.saml.saml1.core.AudienceRestrictionCondition)1 Conditions (org.opensaml.saml.saml1.core.Conditions)1 Audience (org.opensaml.saml.saml2.core.Audience)1 AudienceRestriction (org.opensaml.saml.saml2.core.AudienceRestriction)1 Conditions (org.opensaml.saml.saml2.core.Conditions)1