本文整理汇总了Java中org.opensaml.saml1.core.Assertion.getConditions方法的典型用法代码示例。如果您正苦于以下问题:Java Assertion.getConditions方法的具体用法?Java Assertion.getConditions怎么用?Java Assertion.getConditions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.saml1.core.Assertion
的用法示例。
在下文中一共展示了Assertion.getConditions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateDoNotCache
import org.opensaml.saml1.core.Assertion; //导入方法依赖的package包/类
protected void validateDoNotCache(Assertion assertion) throws ValidationException {
if (assertion.getMinorVersion() == 0) {
Conditions conditions = assertion.getConditions();
if (conditions != null) {
for (Condition condition : conditions.getConditions()) {
if (condition instanceof DoNotCacheCondition) {
throw new ValidationException("DoNotCacheCondition not valid in SAML1.0");
}
}
}
}
}
示例2: createCredentialFromToken
import org.opensaml.saml1.core.Assertion; //导入方法依赖的package包/类
/**
* createCredentialFromToken converts a SAML 1.1 assertion to a WSFederationCredential.
*
* @param assertion the provided assertion
* @return an equivalent credential.
*/
public static WsFederationCredential createCredentialFromToken(final Assertion assertion) {
final DateTime retrievedOn = new DateTime().withZone(DateTimeZone.UTC);
LOGGER.debug("createCredentialFromToken: retrieved on {}", retrievedOn);
final WsFederationCredential credential = new WsFederationCredential();
credential.setRetrievedOn(retrievedOn);
credential.setId(assertion.getID());
credential.setIssuer(assertion.getIssuer());
credential.setIssuedOn(assertion.getIssueInstant());
final Conditions conditions = assertion.getConditions();
if (conditions != null) {
credential.setNotBefore(conditions.getNotBefore());
credential.setNotOnOrAfter(conditions.getNotOnOrAfter());
credential.setAudience(conditions.getAudienceRestrictionConditions().get(0).getAudiences().get(0).getUri());
}
if (assertion.getAuthenticationStatements() != null && assertion.getAuthenticationStatements().size() > 0) {
credential.setAuthenticationMethod(assertion.getAuthenticationStatements().get(0).getAuthenticationMethod());
}
//retrieve an attributes from the assertion
final HashMap<String, Object> attributes = new HashMap<String, Object>();
for (final Attribute item : assertion.getAttributeStatements().get(0).getAttributes()) {
LOGGER.debug("createCredentialFromToken: processed attribute: {}", item.getAttributeName());
if (item.getAttributeValues().size() == 1) {
attributes.put(item.getAttributeName(), ((XSAny) item.getAttributeValues().get(0)).getTextContent());
} else {
final List<String> itemList = new ArrayList<String>();
for (int i = 0; i < item.getAttributeValues().size(); i++) {
itemList.add(((XSAny) item.getAttributeValues().get(i)).getTextContent());
}
if (!itemList.isEmpty()) {
attributes.put(item.getAttributeName(), itemList);
}
}
}
credential.setAttributes(attributes);
LOGGER.debug("createCredentialFromToken: {}", credential);
return credential;
}