Examples of KeyManagerFactory


Examples of javax.net.ssl.KeyManagerFactory

     
      char[] passphrase = PASSWORD.toCharArray();
      KeyStore ks = KeyStore.getInstance("JKS");
      ks.load(new FileInputStream(filename), passphrase);
 
      KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
      kmf.init(ks, passphrase);
     
      TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
      tmf.init(ks);
 
      SSLContext sslContext = SSLContext.getInstance("TLS");
      sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);

      return sslContext;

    } catch (Exception e) {
      return null;
View Full Code Here

Examples of javax.net.ssl.KeyManagerFactory

     
      char[] passphrase = PASSWORD.toCharArray();
      KeyStore ks = KeyStore.getInstance("JKS");
      ks.load(new FileInputStream(filename), passphrase);
 
      KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
      kmf.init(ks, passphrase);
     
      TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
      tmf.init(ks);
 
      SSLContext sslContext = SSLContext.getInstance("TLS");
      sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);

      return sslContext;

    } catch (Exception e) {
      return null;
View Full Code Here

Examples of javax.net.ssl.KeyManagerFactory

            ks.load(stream, keyStorePwd.toCharArray());
            stream.close();
           
            // creating a keystore factory
            if (this.log.isFine()) this.log.logFine("Initializing key manager factory ...");
            final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            kmf.init(ks,keyStorePwd.toCharArray());
           
            // initializing the ssl context
            if (this.log.isFine()) this.log.logFine("Initializing SSL context ...");
            final SSLContext sslcontext = SSLContext.getInstance("TLS");
            sslcontext.init(kmf.getKeyManagers(), null, null);
           
            final SSLSocketFactory factory = sslcontext.getSocketFactory();
            this.log.logInfo("SSL support initialized successfully");
            return factory;
        } catch (final Exception e) {
View Full Code Here

Examples of javax.net.ssl.KeyManagerFactory

                            KEYSTORE_KEY + "," + KEYSTOREPASS_KEY,
                            "ERROR loading keys !, passphrase " + String.valueOf(keyPassPhrase));
        }
       
        //Step 6: create and initialize KeyManagerFactory
        KeyManagerFactory kmf;
        try
        {
            kmf = KeyManagerFactory.getInstance(ConstsIf.KM_TYPE_SUN);

        } catch (NoSuchAlgorithmException e4)
        {
            throw new ConfigurationException(
                        "",
                        "creating KeyManagerFactory: ERROR no such algorithm");
        }
        try
        {
            kmf.init(myKeys, keyPassPhrase);

        } catch (Exception e5)
        {
            throw new ConfigurationException(
                        "",
                        "initing kmf: " + e5.getMessage());
        }
       
        //Step 7: initialize context with the key manager factory
        try
        {
            context.init(kmf.getKeyManagers(), null, null);

        } catch (KeyManagementException e6)
        {
            throw new ConfigurationException(
                        "",
View Full Code Here

Examples of javax.net.ssl.KeyManagerFactory

    if (_keystore != null)
      keystoreInputStream = Resource.newResource(_keystore).getInputStream();
    KeyStore keyStore = KeyStore.getInstance(_keystoreType);
    keyStore.load(keystoreInputStream, _password == null ? null : _password.toString().toCharArray());

    KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(_sslKeyManagerFactoryAlgorithm);
    keyManagerFactory.init(keyStore, _keyPassword == null ? null : _keyPassword.toString().toCharArray());
    keyManagers = keyManagerFactory.getKeyManagers();

    TrustManager[] trustManagers = null;
    InputStream truststoreInputStream = null;
    if (_truststore != null)
      truststoreInputStream = Resource.newResource(_truststore).getInputStream();
View Full Code Here

Examples of javax.net.ssl.KeyManagerFactory

    SSLServerSocketFactory factory = null;
   
    if (_keyStore != null) {
      SSLContext sslContext = SSLContext.getInstance(_sslContext);

      KeyManagerFactory kmf
        = KeyManagerFactory.getInstance(_keyManagerFactory);
   
      kmf.init(_keyStore, _password.toCharArray());
     
      sslContext.init(kmf.getKeyManagers(), null, null);

      /*
      if (_cipherSuites != null)
        sslContext.createSSLEngine().setEnabledCipherSuites(_cipherSuites);

View Full Code Here

Examples of javax.net.ssl.KeyManagerFactory

 
  private KeyManagerFactory getKeyManagerFactory()
    throws NoSuchAlgorithmException, IOException, GeneralSecurityException
  {
    if (_kmf == null) {
      KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");

      KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());

      ks.load(null, "password".toCharArray());

       
      ks.setKeyEntry("anonymous", getPrivateKey(),
                     "key-password".toCharArray(), getCertificateChain());
     
      kmf.init(ks, "key-password".toCharArray());

      _kmf = kmf;
    }
     
    return _kmf;
View Full Code Here

Examples of javax.net.ssl.KeyManagerFactory

            if (log.isDebugEnabled()) {
                log.debug("Creating a IdentityKeyManagerFactory instance");
            }

            KeyStore keyStore = this.getIdentityKeyStore();
            KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(
                    KeyManagerFactory.getDefaultAlgorithm());
            keyManagerFactory.init(keyStore, keyPasswordProvider.getResolvedSecret().toCharArray());

            return keyManagerFactory;
        } catch (Exception e) {
            handleException("Error getting KeyManagerFactory: ", e);
        }
View Full Code Here

Examples of javax.net.ssl.KeyManagerFactory

            }
            InputStream in = getCertificate();
            Exception except = null;
            if (in != null) {
                KeyStore ks = null;
                KeyManagerFactory kmf = null;
                SSLContext sslcontext = null;
                try {
                    ks = KeyStore.getInstance(KEYSTORE_TYPE);
                    ks.load(in, KEYSTORE_PASSWORD);
                    kmf = KeyManagerFactory.getInstance(KEYMANAGERFACTORY);
                    kmf.init(ks, KEY_PASSWORD);
                    sslcontext = SSLContext.getInstance(SSLCONTEXT_PROTOCOL);
                    sslcontext.init(kmf.getKeyManagers(), null, null);
                    SSLSocketFactory sslFactory = sslcontext.getSocketFactory();
                    hashHost.put(host, sslFactory);
                    log.info("KeyStore for SSL loaded OK and put host in map ("+host+")");
                    return sslFactory;
                } catch (NoSuchAlgorithmException e) {
View Full Code Here

Examples of javax.net.ssl.KeyManagerFactory

      FGCPCredentials currentCreds = checkNotNull(creds.get(), "fgcpcredential supplier returned null");
      PrivateKey privateKey = checkNotNull(currentCreds.privateKey, "fgcpcredential's privateKey is null");
      Collection<X509Certificate> certs = checkNotNull(currentCreds.certificates, "fgcpcredential's certificates returned null");

      try {
         KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
         KeyStore keyStore = KeyStore.getInstance("pkcs12");
         keyStore.load(null, null);
         keyStore.setKeyEntry("dummy alias", privateKey, null, (Certificate[]) certs.toArray(new Certificate[0]));
         kmf.init(keyStore, null);

         SSLContext sc = SSLContext.getInstance("TLS");
         sc.init(kmf.getKeyManagers(), trustManager, new SecureRandom());
         return sc;
      } catch (GeneralSecurityException e) {
         throw propagate(e);
      } catch (IOException e) {
         throw propagate(e);
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.