| .. | .. |
|---|
| 36 | 36 | private static SignatureHelper singleton = new SignatureHelper(); |
|---|
| 37 | 37 | |
|---|
| 38 | 38 | private static final String DEFAULT_ALGORITHM = "RSA"; |
|---|
| 39 | | - protected static final String SIGNATURE_GENERATION_ALGORITHM = "SHA256withRSA"; |
|---|
| 39 | + public static final String SIGNATURE_GENERATION_ALGORITHM = "SHA256withRSA"; |
|---|
| 40 | 40 | |
|---|
| 41 | 41 | private SignatureHelper() { |
|---|
| 42 | 42 | } |
|---|
| .. | .. |
|---|
| 45 | 45 | return singleton; |
|---|
| 46 | 46 | } |
|---|
| 47 | 47 | |
|---|
| 48 | | - protected void prepareSignature(Signature signature, LicenseBean licBean) throws SeCurisException { |
|---|
| 48 | + public void prepareSignature(Signature signature, LicenseBean licBean) throws SeCurisException { |
|---|
| 49 | 49 | try { |
|---|
| 50 | 50 | log.info("JSON: {}", JsonUtils.toJSON(licBean)); |
|---|
| 51 | 51 | signature.update(JsonUtils.toJSON(licBean).getBytes("utf-8")); |
|---|
| .. | .. |
|---|
| 98 | 98 | return publicKey; |
|---|
| 99 | 99 | } |
|---|
| 100 | 100 | |
|---|
| 101 | | - protected PrivateKey generatePrivateKey(File privateKeyFile) throws NoSuchAlgorithmException, InvalidKeySpecException, IOException { |
|---|
| 101 | + public PrivateKey generatePrivateKey(File privateKeyFile) throws NoSuchAlgorithmException, InvalidKeySpecException, IOException { |
|---|
| 102 | 102 | String privKeyBase64 = FileUtils.readFileToString(privateKeyFile); |
|---|
| 103 | 103 | int from = privKeyBase64.indexOf('\n'); |
|---|
| 104 | 104 | int to = privKeyBase64.indexOf("-----END", from); |
|---|
| .. | .. |
|---|
| 111 | 111 | return privateKey; |
|---|
| 112 | 112 | } |
|---|
| 113 | 113 | |
|---|
| 114 | | - private KeyPair generateKeyPair(File privateKeyFile, File publicKeyFile) throws NoSuchAlgorithmException, InvalidKeySpecException, IOException { |
|---|
| 114 | + public KeyPair generateKeyPair(File privateKeyFile, File publicKeyFile) throws NoSuchAlgorithmException, InvalidKeySpecException, IOException { |
|---|
| 115 | 115 | |
|---|
| 116 | 116 | PublicKey publicKey = generatePublicKey(publicKeyFile); |
|---|
| 117 | 117 | PrivateKey privateKey = generatePrivateKey(privateKeyFile); |
|---|