FileDocCategorySizeDatePackage
TrustManagerFactoryImpl.javaAPI DocAndroid 1.5 API5156Wed May 06 22:41:06 BST 2009org.apache.harmony.xnet.provider.jsse

TrustManagerFactoryImpl

public class TrustManagerFactoryImpl extends TrustManagerFactorySpi
TrustManagerFactory service provider interface implementation.
see
javax.net.ssl.TrustManagerFactorySpi

Fields Summary
private KeyStore
keyStore
Constructors Summary
Methods Summary
public javax.net.ssl.TrustManager[]engineGetTrustManagers()

see
javax.net.ssl#engineGetTrustManagers()

        if (keyStore == null) {
            throw new IllegalStateException(
                    "TrustManagerFactory is not initialized");
        }
        return new TrustManager[] { new TrustManagerImpl(keyStore) };
    
public voidengineInit(java.security.KeyStore ks)

see
javax.net.ssl.TrustManagerFactorySpi#engineInit(KeyStore)

        if (ks != null) {
            keyStore = ks;
        } else {
            // BEGIN android-added
            if (System.getProperty("javax.net.ssl.trustStore") == null) {
                String file = System.getProperty("java.home")
                    + java.io.File.separator + "etc" + java.io.File.separator
                    + "security" + java.io.File.separator
                    + "cacerts.bks";

                System.setProperty("javax.net.ssl.trustStore", file);
            }
            // END android-added
            keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
            String keyStoreName = AccessController
                    .doPrivileged(new java.security.PrivilegedAction<String>() {
                        public String run() {
                            return System
                                    .getProperty("javax.net.ssl.trustStore");
                        }
                    });
            String keyStorePwd = null;
            if (keyStoreName == null || keyStoreName.equalsIgnoreCase("NONE")
                    || keyStoreName.length() == 0) {
                try {
                    keyStore.load(null, null);
                } catch (IOException e) {
                    throw new KeyStoreException(e);
                } catch (CertificateException e) {
                    throw new KeyStoreException(e);
                } catch (NoSuchAlgorithmException e) {
                    throw new KeyStoreException(e);
                }
            } else {
                keyStorePwd = AccessController
                        .doPrivileged(new java.security.PrivilegedAction<String>() {
                            public String run() {
                                return System
                                        .getProperty("javax.net.ssl.trustStorePassword");
                            }
                        });
                char[] pwd;
                if (keyStorePwd == null) {
                    pwd = new char[0];
                } else {
                    pwd = keyStorePwd.toCharArray();
                }
                try {
                    keyStore.load(new FileInputStream(new File(keyStoreName)), pwd);
                } catch (FileNotFoundException e) {
                    throw new KeyStoreException(e);
                } catch (IOException e) {
                    throw new KeyStoreException(e);
                } catch (CertificateException e) {
                    throw new KeyStoreException(e);
                } catch (NoSuchAlgorithmException e) {
                    throw new KeyStoreException(e);
                }
            }
        }

    
public voidengineInit(javax.net.ssl.ManagerFactoryParameters spec)

see
javax.net.ssl#engineInit(ManagerFactoryParameters)

        throw new InvalidAlgorithmParameterException(
                "ManagerFactoryParameters not supported");