Example #1
0
 private static void saveKeyStore() {
   try {
     ByteArrayOutputStream bout = new ByteArrayOutputStream();
     keystore.store(bout, KEY_STORE_PASSWORD.toCharArray());
     File keyStoreFile = new File(KEY_STORE_FILENAME);
     logger.trace("Saving key store to file [" + keyStoreFile + "]");
     FileOutputStream fileOutputStream = null;
     try {
       fileOutputStream = new FileOutputStream(keyStoreFile);
       fileOutputStream.write(bout.toByteArray());
     } finally {
       if (fileOutputStream != null) {
         fileOutputStream.close();
       }
     }
     keyStoreFile.deleteOnExit();
   } catch (Exception e) {
     throw new RuntimeException("Exception while saving KeyStore", e);
   }
 }