Package java.security

Examples of java.security.KeyStoreException


  /**
   * @tests java.security.KeyStoreException#KeyStoreException(java.lang.String)
   */
  public void test_ConstructorLjava_lang_String() {
    // Test for method java.security.KeyStoreException(java.lang.String)
    KeyStoreException e = new KeyStoreException("test message");
    assertEquals("Failed toString test for constructed instance",
            "java.security.KeyStoreException: test message", e
        .toString());
  }
View Full Code Here


        PKCS10CertificationRequest csr = new PKCS10CertificationRequest(sigalg,
                subject, publicKey, attributes, signingKey);

        if (!csr.verify()) {
            throw new KeyStoreException("CSR verification failed");
        }

        ByteArrayOutputStream os = new ByteArrayOutputStream();
        DEROutputStream deros = new DEROutputStream(os);
        deros.writeObject(csr.getDERObject());
View Full Code Here

        } else if (this.keystore.isKeyEntry(alias)) {
            // private key entry
            info = new KeyEntryInfo(alias, "private key", keystore
                    .getCreationDate(alias));
        } else {
            throw new KeyStoreException("invalid key entry type");
        }
        return info;
    }
View Full Code Here

            certs = new Certificate[1];
            certs[0] = cert;
        } else if (keystore.isKeyEntry(alias)) {
            certs = keystore.getCertificateChain(alias);
        } else if (keystore.containsAlias(alias)) {
            throw new KeyStoreException("Unsupported key-store-entry, alias = "
                    + alias);
        } else {
            throw new KeyStoreException(
                    "Key-store-entry alias not found, alias = " + alias);
        }

        return certs;
    }
View Full Code Here

        PKCS10CertificationRequest csr = new PKCS10CertificationRequest(sigalg,
                subject, publicKey, attributes, signingKey);

        if (!csr.verify()) {
            throw new KeyStoreException("CSR verification failed");
        }

        ByteArrayOutputStream os = new ByteArrayOutputStream();
        DEROutputStream deros = new DEROutputStream(os);
        deros.writeObject(csr.getDERObject());
View Full Code Here

        Enumeration aliases = keyStore.aliases();
        if (keyAlias == null) {
            if(aliases.hasMoreElements()) {
                keyAlias = (String) aliases.nextElement();
            } else {
                throw new KeyStoreException("No alias was found in keystore.");
            }
            if (aliases.hasMoreElements()) {
                throw new KeyStoreException("No <keyAlias> was given and more than one alias was found in keystore.");
               
            }
        }
       
        if (keyAliasPassword == null) {
            keyAliasPassword = keyStorePassword;
        }
       
        this.privateKey = (PrivateKey) keyStore.getKey(keyAlias, keyAliasPassword.toCharArray());
        if (this.privateKey == null) {
            throw new KeyStoreException("The \"" + keyAlias + "\" PrivateKey alias was not found in keystore.");
        }
       
        this.certificate = (X509Certificate) keyStore.getCertificate(keyAlias);
        if (this.certificate == null) {
            throw new KeyStoreException("The \"" + keyAlias + "\" X509Certificate alias was not found in keystore.");
        }
        java.security.cert.Certificate[] certificateChain = keyStore.getCertificateChain(keyAlias);
        ArrayList certList = new ArrayList();
        if (certificateChain == null) {
            certList.add(this.certificate);
View Full Code Here

        catch ( GeneralSecurityException e )
        {
            this.masterPassword = null;
            this.keystore = null;

            throw new KeyStoreException( e );
        }
        // Catch for the following exceptions that may be raised while
        // handling the file:
        // - java.io.IOException
        // - java.io.FileNotFoundException
        catch ( IOException e )
        {
            this.masterPassword = null;
            this.keystore = null;

            throw new KeyStoreException( e );
        }
    }
View Full Code Here

            // - java.security.KeyStoreException
            // - java.security.NoSuchAlgorithmException
            // - java.security.cert.CertificateException
            catch ( GeneralSecurityException e )
            {
                throw new KeyStoreException( e );
            }
            // Catch for the following exceptions that may be raised while
            // handling the file:
            // - java.io.IOException
            // - java.io.FileNotFoundException
            catch ( IOException e )
            {
                throw new KeyStoreException( e );
            }
        }
    }
View Full Code Here

        PKCS10CertificationRequest csr = new PKCS10CertificationRequest(sigalg,
                subject, publicKey, attributes, signingKey);

        if (!csr.verify()) {
            throw new KeyStoreException("CSR verification failed");
        }

        ByteArrayOutputStream os = new ByteArrayOutputStream();
        DEROutputStream deros = new DEROutputStream(os);
        deros.writeObject(csr.getDERObject());
View Full Code Here

    /**
     * Test for <code>KeyStoreException()</code> constructor Assertion:
     * constructs KeyStoreException with no detail message
     */
    public void testKeyStoreException01() {
        KeyStoreException tE = new KeyStoreException();
        assertNull("getMessage() must return null.", tE.getMessage());
        assertNull("getCause() must return null", tE.getCause());
    }
View Full Code Here

TOP

Related Classes of java.security.KeyStoreException

Copyright © 2018 www.massapicom. 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.