chibenwa commented on a change in pull request #626:
URL: https://github.com/apache/james-project/pull/626#discussion_r698417937



##########
File path: 
server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/crypto/SecurityKeyLoader.java
##########
@@ -54,15 +55,25 @@
     public AsymmetricKeys load() throws Exception {
         Preconditions.checkState(jmapDraftConfiguration.isEnabled(), "JMAP is 
not enabled");
 
-        KeyStore keystore = KeyStore.getInstance(JKS);
+        if (jmapDraftConfiguration.getKeystore().isPresent()) {
+            return loadFromKeystore();
+        }
+        return loadFromPEM();
+    }
+
+    private AsymmetricKeys loadFromKeystore() throws Exception {
+        
Preconditions.checkState(jmapDraftConfiguration.getKeystore().isPresent());
+        
Preconditions.checkState(jmapDraftConfiguration.getSecret().isPresent());
+
+        KeyStore keystore = 
KeyStore.getInstance(jmapDraftConfiguration.getKeystoreType());
         char[] secret;
-        try (InputStream fis = 
fileSystem.getResource(jmapDraftConfiguration.getKeystore())) {
-            secret = jmapDraftConfiguration.getSecret().toCharArray();
+        try (InputStream fis = 
fileSystem.getResource(jmapDraftConfiguration.getKeystore().get())) {
+            secret = jmapDraftConfiguration.getSecret().get().toCharArray();
             keystore.load(fis, secret);

Review comment:
       The dependency was already there so I applied your suggestion.
   
   Thanks!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to