com.aliyun.auth.signature.signer.SignAlgorithmSHA256withRSA Maven / Gradle / Ivy
The newest version!
package com.aliyun.auth.signature.signer;
import com.aliyun.auth.signature.exception.SignatureException;
import java.security.NoSuchAlgorithmException;
import java.security.Signature;
public enum SignAlgorithmSHA256withRSA {
SHA256withRSA("SHA256withRSA", "RSA");
private final ThreadLocal reference;
private final String algorithmName;
private final String keyName;
SignAlgorithmSHA256withRSA(String algorithmName, String keyName) {
this.algorithmName = algorithmName;
this.keyName = keyName;
reference = new MacThreadLocal(algorithmName);
}
public String getAlgorithmName(){
return this.algorithmName;
}
@Override
public String toString(){
return this.keyName;
}
public Signature getSignature() {
return reference.get();
}
private static class MacThreadLocal extends ThreadLocal {
private final String algorithmName;
MacThreadLocal(String algorithmName) {
this.algorithmName = algorithmName;
}
@Override
protected Signature initialValue() {
try {
return Signature.getInstance(algorithmName);
} catch (NoSuchAlgorithmException e) {
throw new SignatureException("Unable to fetch Signature instance for Algorithm "
+ algorithmName + e.getMessage());
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy