if (conditionsV1Builder == null) {
conditionsV1Builder = (SAMLObjectBuilder<Conditions>)
builderFactory.getBuilder(Conditions.DEFAULT_ELEMENT_NAME);
}
Conditions conditions = conditionsV1Builder.buildObject();
if (conditionsBean == null) {
DateTime newNotBefore = new DateTime();
conditions.setNotBefore(newNotBefore);
conditions.setNotOnOrAfter(newNotBefore.plusMinutes(5));
return conditions;
}
int tokenPeriodMinutes = conditionsBean.getTokenPeriodMinutes();
DateTime notBefore = conditionsBean.getNotBefore();
DateTime notAfter = conditionsBean.getNotAfter();
if (notBefore != null && notAfter != null) {
if (notBefore.isAfter(notAfter)) {
throw new IllegalStateException(
"The value of notBefore may not be after the value of notAfter"
);
}
conditions.setNotBefore(notBefore);
conditions.setNotOnOrAfter(notAfter);
} else {
DateTime newNotBefore = new DateTime();
conditions.setNotBefore(newNotBefore);
conditions.setNotOnOrAfter(newNotBefore.plusMinutes(tokenPeriodMinutes));
}
if (conditionsBean.getAudienceURI() != null) {
AudienceRestrictionCondition audienceRestriction =
createSamlv1AudienceRestriction(conditionsBean.getAudienceURI());
conditions.getAudienceRestrictionConditions().add(audienceRestriction);
}
return conditions;
}