本文整理汇总了Java中org.opensaml.xml.security.SecurityHelper.getKeyAlgorithmFromURI方法的典型用法代码示例。如果您正苦于以下问题:Java SecurityHelper.getKeyAlgorithmFromURI方法的具体用法?Java SecurityHelper.getKeyAlgorithmFromURI怎么用?Java SecurityHelper.getKeyAlgorithmFromURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.xml.security.SecurityHelper
的用法示例。
在下文中一共展示了SecurityHelper.getKeyAlgorithmFromURI方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import org.opensaml.xml.security.SecurityHelper; //导入方法依赖的package包/类
/** {@inheritDoc} */
public boolean validate(Signature signature, CriteriaSet trustBasisCriteria) throws SecurityException {
checkParams(signature, trustBasisCriteria);
CriteriaSet criteriaSet = new CriteriaSet();
criteriaSet.addAll(trustBasisCriteria);
if (!criteriaSet.contains(UsageCriteria.class)) {
criteriaSet.add(new UsageCriteria(UsageType.SIGNING));
}
String jcaAlgorithm = SecurityHelper.getKeyAlgorithmFromURI(signature.getSignatureAlgorithm());
if (!DatatypeHelper.isEmpty(jcaAlgorithm)) {
criteriaSet.add(new KeyAlgorithmCriteria(jcaAlgorithm), true);
}
Iterable<Credential> trustedCredentials = getCredentialResolver().resolve(criteriaSet);
if (validate(signature, trustedCredentials)) {
return true;
}
// If the credentials extracted from Signature's KeyInfo (if any) did not verify the
// signature and/or establish trust, as a fall back attempt to verify the signature with
// the trusted credentials directly.
log.debug("Attempting to verify signature using trusted credentials");
for (Credential trustedCredential : trustedCredentials) {
if (verifySignature(signature, trustedCredential)) {
log.debug("Successfully verified signature using resolved trusted credential");
return true;
}
}
log.debug("Failed to verify signature using either KeyInfo-derived or directly trusted credentials");
return false;
}
示例2: buildKeyAlgorithmCriteria
import org.opensaml.xml.security.SecurityHelper; //导入方法依赖的package包/类
/**
* Dynamically construct key algorithm credential criteria based on the specified algorithm URI.
*
* @param encAlgorithmURI the algorithm URI
* @return a new key algorithm credential criteria instance, or null if criteria could not be determined
*/
private KeyAlgorithmCriteria buildKeyAlgorithmCriteria(String encAlgorithmURI) {
if (DatatypeHelper.isEmpty(encAlgorithmURI)) {
return null;
}
String jcaKeyAlgorithm = SecurityHelper.getKeyAlgorithmFromURI(encAlgorithmURI);
if (!DatatypeHelper.isEmpty(jcaKeyAlgorithm)) {
return new KeyAlgorithmCriteria(jcaKeyAlgorithm);
}
return null;
}