Package java.security

Examples of java.security.KeyStore.load()


    protected void setUp() throws Exception {
        KeyStore ks = KeyStore.getInstance("JKS");

        FileInputStream fis = new FileInputStream(
                "src/test/resources/keymanager-test.jks");
        ks.load(fis, "".toCharArray());

        KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
        kmf.init(ks, "".toCharArray());

        km = kmf.getKeyManagers()[0];
View Full Code Here


    protected void setUp() throws Exception {
        KeyStore ks = KeyStore.getInstance("JKS");

        FileInputStream fis = new FileInputStream(
                "src/test/resources/keymanager-test.jks");
        ks.load(fis, "".toCharArray());

        KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
        kmf.init(ks, "".toCharArray());

        km = kmf.getKeyManagers()[0];
View Full Code Here

            ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
           
            KeyManager[] keystoreManagers = null;
            if (keyStorePassword != null) {
                try {
                    ks.load(bin, keyStorePassword.toCharArray());
                    kmf.init(ks, keyStorePassword.toCharArray());
                    keystoreManagers = kmf.getKeyManagers();
                    LogUtils.log(LOG, Level.INFO, "LOADED_KEYSTORE", new Object[]{keyStoreLocation});
                } catch (Exception e) {
                    LogUtils.log(LOG, Level.WARNING, "FAILED_TO_LOAD_KEYSTORE",
View Full Code Here

            // ************************* Load Trusted CA file *************************
           
            TrustManager[] trustStoreManagers = null;
            KeyStore trustedCertStore = KeyStore.getInstance(trustStoreType);
           
            trustedCertStore.load(new FileInputStream(trustStoreLocation), null);
            TrustManagerFactory tmf  =
                TrustManagerFactory.getInstance(trustStoreKeyManagerFactoryAlgorithm);
            try {
                tmf.init(trustedCertStore);
                trustStoreManagers = tmf.getTrustManagers();
View Full Code Here

            byte[] sslCert = loadClientCredential(keyStoreLocation);
           
            if (sslCert != null && sslCert.length > 0 && keyStorePassword != null) {
                ByteArrayInputStream bin = new ByteArrayInputStream(sslCert);
                try {
                    ks.load(bin, keyStorePassword.toCharArray());
                    kmf.init(ks, keyStorePassword.toCharArray());
                    keystoreManagers = kmf.getKeyManagers();
                    LogUtils.log(LOG, Level.INFO, "LOADED_KEYSTORE", new Object[]{keyStoreLocation});
                } catch (Exception e) {
                    LogUtils.log(LOG, Level.WARNING, "FAILED_TO_LOAD_KEYSTORE",
View Full Code Here

            // ************************* Load Trusted CA file *************************
            //TODO could support multiple trust cas
            TrustManager[] trustStoreManagers = new TrustManager[1];
            
            KeyStore trustedCertStore = KeyStore.getInstance(trustStoreType);
            trustedCertStore.load(null, "".toCharArray());
            CertificateFactory cf = CertificateFactory.getInstance(CERTIFICATE_FACTORY_TYPE);
            byte[] caCert = loadCACert(trustStoreLocation);
            try {
                if (caCert != null) {
                    ByteArrayInputStream cabin = new ByteArrayInputStream(caCert);
View Full Code Here

    try {
      String filename = getTestKeyStoreFilename();
     
      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");
View Full Code Here

                throw new WinstoneException(SSL_RESOURCES.getString(
                        "HttpsListener.KeyStoreNotFound", ksFile.getPath()));
            InputStream in = new FileInputStream(ksFile);
            char[] passwordChars = password == null ? null : password.toCharArray();
            KeyStore ks = KeyStore.getInstance("JKS");
            ks.load(in, passwordChars);
            kmf.init(ks, passwordChars);
            Logger.log(Logger.FULL_DEBUG, SSL_RESOURCES,
                    "HttpsListener.KeyCount", ks.size() + "");
            for (Enumeration e = ks.aliases(); e.hasMoreElements();) {
                String alias = (String) e.nextElement();
View Full Code Here

    */
   public static void main(String unused[]) throws Exception {

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

      ks.load(
         new java.io.FileInputStream(
         "data/com/sun/org/apache/xml/internal/security/samples/input/keystore.jks"),
            "xmlsecurity".toCharArray());

      KeyStoreResolver krs = new KeyStoreResolver(ks);
View Full Code Here

            );

            String keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword");
            if(System.getProperty("javax.net.ssl.keyStore") != null)
            {
                ks.load(
                        new FileInputStream(System.getProperty("javax.net.ssl.keyStore")),
                        null
                    );
            }
            else
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.