本文整理汇总了Java中org.opensaml.saml2.core.Conditions.getAudienceRestrictions方法的典型用法代码示例。如果您正苦于以下问题:Java Conditions.getAudienceRestrictions方法的具体用法?Java Conditions.getAudienceRestrictions怎么用?Java Conditions.getAudienceRestrictions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.saml2.core.Conditions
的用法示例。
在下文中一共展示了Conditions.getAudienceRestrictions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateAudienceRestriction
import org.opensaml.saml2.core.Conditions; //导入方法依赖的package包/类
/**
* Validate the AudienceRestriction of SAML2 Response
*
* @param assertion SAML2 Assertion
* @return validity
*/
protected void validateAudienceRestriction(Assertion assertion) throws SSOAgentException {
if (assertion != null) {
Conditions conditions = assertion.getConditions();
if (conditions != null) {
List<AudienceRestriction> audienceRestrictions = conditions.getAudienceRestrictions();
if (audienceRestrictions != null && !audienceRestrictions.isEmpty()) {
boolean audienceFound = false;
for (AudienceRestriction audienceRestriction : audienceRestrictions) {
if (audienceRestriction.getAudiences() != null && !audienceRestriction.getAudiences().isEmpty()
) {
for (Audience audience : audienceRestriction.getAudiences()) {
if (ssoAgentConfig.getSAML2().getSPEntityId().equals(audience.getAudienceURI())) {
audienceFound = true;
break;
}
}
}
if (audienceFound) {
break;
}
}
if (!audienceFound) {
throw new SSOAgentException("SAML2 Assertion Audience Restriction validation failed");
}
} else {
throw new SSOAgentException("SAML2 Response doesn't contain AudienceRestrictions");
}
} else {
throw new SSOAgentException("SAML2 Response doesn't contain Conditions");
}
}
}
示例2: validateAudienceRestriction
import org.opensaml.saml2.core.Conditions; //导入方法依赖的package包/类
/**
* Validate the AudienceRestriction of SAML2 Response
*
* @param assertion SAML2 Assertion
* @return validity
*/
private void validateAudienceRestriction(Assertion assertion) throws SAMLSSOException {
if (assertion != null) {
Conditions conditions = assertion.getConditions();
if (conditions != null) {
List<AudienceRestriction> audienceRestrictions = conditions.getAudienceRestrictions();
if (audienceRestrictions != null && !audienceRestrictions.isEmpty()) {
for (AudienceRestriction audienceRestriction : audienceRestrictions) {
if (CollectionUtils.isNotEmpty(audienceRestriction.getAudiences())) {
boolean audienceFound = false;
for (Audience audience : audienceRestriction.getAudiences()) {
if (properties.get(IdentityApplicationConstants.Authenticator.SAML2SSO.SP_ENTITY_ID)
.equals(audience.getAudienceURI())) {
audienceFound = true;
break;
}
}
if (!audienceFound) {
throw new SAMLSSOException("SAML Assertion Audience Restriction validation failed");
}
} else {
throw new SAMLSSOException("SAML Response's AudienceRestriction doesn't contain Audiences");
}
}
} else {
throw new SAMLSSOException("SAML Response doesn't contain AudienceRestrictions");
}
} else {
throw new SAMLSSOException("SAML Response doesn't contain Conditions");
}
}
}
示例3: validateAudienceRestrictionInAssertion
import org.opensaml.saml2.core.Conditions; //导入方法依赖的package包/类
/**
* Validate the AudienceRestriction of SAML2 Assertion
*
* @param assertion SAML2 Assertion
* @return validity
*/
public boolean validateAudienceRestrictionInAssertion(Assertion assertion) {
if (assertion != null) {
Conditions conditions = assertion.getConditions();
if (conditions != null) {
List<AudienceRestriction> audienceRestrictions = conditions.getAudienceRestrictions();
if (audienceRestrictions != null && !audienceRestrictions.isEmpty()) {
for (AudienceRestriction audienceRestriction : audienceRestrictions) {
if (audienceRestriction.getAudiences() != null && audienceRestriction.getAudiences().size() > 0) {
for (Audience audience : audienceRestriction.getAudiences()) {
String spId = org.wso2.carbon.identity.authenticator.saml2.sso.common.Util.getServiceProviderId();
if (spId == null) {
org.wso2.carbon.identity.authenticator.saml2.sso.common.Util.initSSOConfigParams();
spId = org.wso2.carbon.identity.authenticator.saml2.sso.common.Util.getServiceProviderId();
}
if (spId != null) {
if (spId.equals(audience.getAudienceURI())) {
return true;
}
} else {
log.warn("No SAML2 service provider ID defined.");
}
}
} else {
log.warn("SAML2 Response's AudienceRestriction doesn't contain Audiences");
}
}
} else {
log.error("SAML2 Response doesn't contain AudienceRestrictions");
}
} else {
log.error("SAML2 Response doesn't contain Conditions");
}
}
return false;
}