本文整理汇总了Java中sun.security.x509.AlgorithmId.checkKeyAndSigAlgMatch方法的典型用法代码示例。如果您正苦于以下问题:Java AlgorithmId.checkKeyAndSigAlgMatch方法的具体用法?Java AlgorithmId.checkKeyAndSigAlgMatch怎么用?Java AlgorithmId.checkKeyAndSigAlgMatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.security.x509.AlgorithmId
的用法示例。
在下文中一共展示了AlgorithmId.checkKeyAndSigAlgMatch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: signatureAlgorithm
import sun.security.x509.AlgorithmId; //导入方法依赖的package包/类
/**
* Sets the signature algorithm. If no signature algorithm
* is specified, the default signature algorithm returned by
* {@link #getDefaultSignatureAlgorithm} for the private key
* will be used.
*
* @param algorithm the standard name of the algorithm. See
* the {@code Signature} section in the <a href=
* "{@docRoot}/../specs/security/standard-names.html#signature-algorithms">
* Java Cryptography Architecture Standard Algorithm Name
* Documentation</a> for information about standard algorithm names.
* @return the {@code JarSigner.Builder} itself.
* @throws NoSuchAlgorithmException if {@code algorithm} is not available.
* @throws IllegalArgumentException if {@code algorithm} is not
* compatible with the algorithm of the signer's private key.
*/
public Builder signatureAlgorithm(String algorithm)
throws NoSuchAlgorithmException {
// Check availability
Signature.getInstance(Objects.requireNonNull(algorithm));
AlgorithmId.checkKeyAndSigAlgMatch(
privateKey.getAlgorithm(), algorithm);
this.sigalg = algorithm;
this.sigProvider = null;
return this;
}