use of org.opensaml.saml2.core.AudienceRestriction in project verify-hub by alphagov.
the class MatchingServiceAssertionToAssertionTransformer method transform.
public Assertion transform(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;
}
use of org.opensaml.saml2.core.AudienceRestriction in project cxf by apache.
the class SamlOAuthValidator method validateAudience.
private void validateAudience(Message message, Conditions cs) {
String absoluteAddress = getAbsoluteTargetAddress(message);
List<AudienceRestriction> restrictions = cs.getAudienceRestrictions();
for (AudienceRestriction ar : restrictions) {
List<Audience> audiences = ar.getAudiences();
for (Audience a : audiences) {
if (absoluteAddress.equals(a.getAudienceURI())) {
return;
}
}
}
throw ExceptionUtils.toNotAuthorizedException(null, null);
}
use of org.opensaml.saml2.core.AudienceRestriction in project cxf by apache.
the class SAMLSSOResponseValidator method matchSaml2AudienceRestriction.
private boolean matchSaml2AudienceRestriction(String appliesTo, List<AudienceRestriction> audienceRestrictions) {
boolean oneMatchFound = false;
if (audienceRestrictions != null && !audienceRestrictions.isEmpty()) {
for (AudienceRestriction audienceRestriction : audienceRestrictions) {
if (audienceRestriction.getAudiences() != null) {
boolean matchFound = false;
for (org.opensaml.saml.saml2.core.Audience audience : audienceRestriction.getAudiences()) {
if (appliesTo.equals(audience.getAudienceURI())) {
matchFound = true;
oneMatchFound = true;
break;
}
}
if (!matchFound) {
return false;
}
}
}
}
return oneMatchFound;
}
use of org.opensaml.saml2.core.AudienceRestriction in project MaxKey by dromara.
the class ConditionsGenerator method generateConditions.
public Conditions generateConditions(String audienceUrl, int validInSeconds) {
Conditions conditions = new ConditionsBuilder().buildObject();
conditions.setNotBefore(new DateTime());
conditions.setNotOnOrAfter(new DateTime().plus(validInSeconds * 1000));
AudienceRestriction audienceRestriction = builderAudienceRestriction(audienceUrl);
conditions.getAudienceRestrictions().add(audienceRestriction);
return conditions;
}
use of org.opensaml.saml2.core.AudienceRestriction in project MaxKey by dromara.
the class ConditionsGenerator method builderAudienceRestriction.
public AudienceRestriction builderAudienceRestriction(String audienceUrl) {
AudienceRestriction audienceRestriction = new AudienceRestrictionBuilder().buildObject();
Audience audience = new AudienceBuilder().buildObject();
audience.setAudienceURI(audienceUrl);
audienceRestriction.getAudiences().add(audience);
logger.debug("Audience URL " + audienceUrl);
return audienceRestriction;
}
Aggregations