Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.64 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package org.gephi.moduletruststore;
  7.  
  8. import java.io.File;
  9. import java.io.IOException;
  10. import java.security.KeyStore;
  11. import java.security.KeyStoreException;
  12. import java.security.NoSuchAlgorithmException;
  13. import java.security.cert.CertificateException;
  14. import java.util.logging.Level;
  15. import java.util.logging.Logger;
  16. import org.openide.util.lookup.ServiceProvider;
  17.  
  18.  
  19. /**
  20.  *
  21.  * @author chunky
  22.  */
  23.  
  24. @ServiceProvider(service=org.netbeans.spi.autoupdate.KeyStoreProvider.class)
  25. public class GephiTruststoreProvider implements org.netbeans.spi.autoupdate.KeyStoreProvider {
  26.  
  27.     private KeyStore ks = null;
  28.  
  29.     public GephiTruststoreProvider() {
  30.         System.out.println("cookies");
  31.     }
  32.    
  33.     @Override
  34.     public KeyStore getKeyStore() {
  35.         if(null == ks) {
  36.             File keystoreFile = new File("gephitruststore.ks");
  37.             try (java.io.FileInputStream fis = new java.io.FileInputStream(keystoreFile)) {
  38.                 KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
  39.                 char[] password = "gephi".toCharArray();
  40.                 ks.load(fis, password);
  41.                 Logger.getLogger("").log(Level.INFO, "Sucessfully loaded truststore {0}", keystoreFile.getPath());
  42.             } catch (KeyStoreException | IOException | NoSuchAlgorithmException | CertificateException ex) {
  43.                 Logger.getLogger("").log(Level.SEVERE, null, ex);
  44.             }
  45.         }
  46.         return ks;
  47.     }
  48.    
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement