Package java.security

Examples of java.security.KeyStore.load()


      try {
        char[] pass =  AgentServer.getProperty(PASS, "changeit").toCharArray();
        String keyFile = AgentServer.getProperty(KEYFILE, ".keystore");
        KeyStore ks = KeyStore.getInstance("JKS");
        ks.load(new FileInputStream(keyFile), pass);

        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
        kmf.init(ks, pass);

        SSLContext ctx = SSLContext.getInstance("TLS");
View Full Code Here


    if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG,
                 "SSLTcpProxyService.createSocketFactory : keystoreFile=" + keystoreFile);
   
    KeyStore keystore = KeyStore.getInstance(ksType);
    keystore.load(new FileInputStream(keystoreFile),keyStorePass);
   
    KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
    kmf.init(keystore,keyStorePass);
   
    TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
View Full Code Here

        {
            if (_keystore!=null)
            {
                keystoreInputStream=Resource.newResource(_keystore).getInputStream();
                keyStore = KeyStore.getInstance(_keystoreType);
                keyStore.load(keystoreInputStream,_password==null?null:_password.toString().toCharArray());
            }
        }
        finally
        {
            if (keystoreInputStream != null)
View Full Code Here

        {
            if (_truststore!=null)
            {
                truststoreInputStream = Resource.newResource(_truststore).getInputStream();
                trustStore=KeyStore.getInstance(_truststoreType);
                trustStore.load(truststoreInputStream,_trustPassword==null?null:_trustPassword.toString().toCharArray());
            }
        }
        finally
        {
            if (truststoreInputStream != null)
View Full Code Here

    char[] pass =  AgentServer.getProperty(PASS, "changeit").toCharArray();
    String keyFile = AgentServer.getProperty(KEYFILE, ".keystore");

    KeyStore keystore = KeyStore.getInstance(AgentServer.getProperty(KTYPE, "JKS"));
    keystore.load(new FileInputStream(keyFile), pass);

    KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
    kmf.init(keystore, pass);

    TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
View Full Code Here

    if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG,
                 "SSLTcpProxyService.createServerSocketFactory:" + keystoreFile + ':' + new String(keyStorePass));

    KeyStore keystore = KeyStore.getInstance(ksType);
    keystore.load(new FileInputStream(keystoreFile), keyStorePass);

    KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
    kmf.init(keystore,keyStorePass);

    TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
View Full Code Here

      throw new IllegalStateException("Error while getting a keystore ':" + e.getMessage());
    }

    // Load the keystore file
    try {
      keyStore.load(new BufferedInputStream(new FileInputStream(f)), keystorePass.toCharArray());
    } catch (NoSuchAlgorithmException e) {
      throw new IllegalStateException("Error while loading the keystore file '" + f + "'." + e.getMessage());
    } catch (CertificateException e) {
      throw new IllegalStateException("Error while loading the keystore file '" + f + "'." + e.getMessage());
    } catch (FileNotFoundException e) {
View Full Code Here

    public static SymmetricCryptor getSymmectricCryptor(URL keyResource) throws CryptoException, IOException {
    ArgCheck.isNotNull(keyResource);
    InputStream stream = keyResource.openStream();
    try {
        KeyStore store = KeyStore.getInstance("JCEKS"); //$NON-NLS-1$
        store.load(stream, DEFAULT_STORE_PASSWORD.toCharArray());
        Key key = store.getKey(DEFAULT_ALIAS, DEFAULT_STORE_PASSWORD.toCharArray());
        return new SymmetricCryptor(key);
        } catch (GeneralSecurityException e) {
            throw new CryptoException(e);
    } finally {
View Full Code Here

    private static void saveKey(String file, SecretKey key) throws CryptoException, IOException {
      ArgCheck.isNotNull(file);
      FileOutputStream fos = new FileOutputStream(file);
      try {
          KeyStore store = KeyStore.getInstance("JCEKS"); //$NON-NLS-1$
          store.load(null,null);
        store.setKeyEntry(DEFAULT_ALIAS, key, DEFAULT_STORE_PASSWORD.toCharArray(),null);
        store.store(fos, DEFAULT_STORE_PASSWORD.toCharArray());
      } catch (GeneralSecurityException e) {
        throw new CryptoException(e);
      } finally {
View Full Code Here

   
      KeyStore keystore = KeyStore.getInstance( KEYSTORE_TYPE );
     
      if ( !new File(name).exists()){
   
        keystore.load(null,null);
     
        FileOutputStream  out = null;
       
        try{
          out = new FileOutputStream(name);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.