Browse Source

修改获取实现方式

master
yechuan 1 year ago
parent
commit
df891d92f1
2 changed files with 11 additions and 2 deletions
  1. +10
    -0
      common/src/main/java/work/xuye/common/utils/signature/RSASignatureService.java
  2. +1
    -2
      common/src/main/java/work/xuye/common/utils/signature/SignatureFactory.java

+ 10
- 0
common/src/main/java/work/xuye/common/utils/signature/RSASignatureService.java View File

@@ -22,6 +22,16 @@ import java.security.spec.X509EncodedKeySpec;

class RSASignatureService extends AbstractSignatureService {

private RSASignatureService() {

}

public static AbstractSignatureService getInstance(SignatureConfig signatureConfig) throws GeneralSecurityException {
RSASignatureService result = new RSASignatureService();
result.init(signatureConfig);
return result;
}

@Override
public String signatureByPriKey(String content) throws GeneralSecurityException {
if (signatureContext == null) {


+ 1
- 2
common/src/main/java/work/xuye/common/utils/signature/SignatureFactory.java View File

@@ -20,13 +20,12 @@ public class SignatureFactory {

switch (SignatureEnumGroup.KeyAlgorithm.valueOf(signatureConfig.getKeyAlgorithm())) {
case RSA:
result = new RSASignatureService();
result = RSASignatureService.getInstance(signatureConfig);
break;
}
if (result == null) {
throw new RuntimeException(String.format("不支持的签名方式,signatureConfig:%s", signatureConfig));
}
result.init(signatureConfig);
return result;

}


Loading…
Cancel
Save