Package java.security

Examples of java.security.NoSuchAlgorithmException


     * Test for <code>NoSuchAlgorithmException(String, Throwable)</code>
     * constructor Assertion: constructs NoSuchAlgorithmException when
     * <code>cause</code> is null <code>msg</code> is null
     */
    public void testNoSuchAlgorithmException06() {
        NoSuchAlgorithmException tE = new NoSuchAlgorithmException(null, null);
        assertNull("getMessage() must return null", tE.getMessage());
        assertNull("getCause() must return null", tE.getCause());
    }
View Full Code Here


     * Test for <code>NoSuchAlgorithmException(String, Throwable)</code>
     * constructor Assertion: constructs NoSuchAlgorithmException when
     * <code>cause</code> is null <code>msg</code> is not null
     */
    public void testNoSuchAlgorithmException07() {
        NoSuchAlgorithmException tE;
        for (int i = 0; i < msgs.length; i++) {
            tE = new NoSuchAlgorithmException(msgs[i], null);
            assertEquals("getMessage() must return: ".concat(msgs[i]), tE
                    .getMessage(), msgs[i]);
            assertNull("getCause() must return null", tE.getCause());
        }
    }
View Full Code Here

     * Test for <code>NoSuchAlgorithmException(String, Throwable)</code>
     * constructor Assertion: constructs NoSuchAlgorithmException when
     * <code>cause</code> is not null <code>msg</code> is null
     */
    public void testNoSuchAlgorithmException08() {
        NoSuchAlgorithmException tE = new NoSuchAlgorithmException(null, tCause);
        if (tE.getMessage() != null) {
            String toS = tCause.toString();
            String getM = tE.getMessage();
            assertTrue("getMessage() must should ".concat(toS), (getM
                    .indexOf(toS) != -1));
        }
        assertNotNull("getCause() must not return null", tE.getCause());
        assertEquals("getCause() must return ".concat(tCause.toString()), tE
                .getCause(), tCause);
    }
View Full Code Here

     * Test for <code>NoSuchAlgorithmException(String, Throwable)</code>
     * constructor Assertion: constructs NoSuchAlgorithmException when
     * <code>cause</code> is not null <code>msg</code> is not null
     */
    public void testNoSuchAlgorithmException09() {
        NoSuchAlgorithmException tE;
        for (int i = 0; i < msgs.length; i++) {
            tE = new NoSuchAlgorithmException(msgs[i], tCause);
            String getM = tE.getMessage();
            String toS = tCause.toString();
            if (msgs[i].length() > 0) {
                assertTrue("getMessage() must contain ".concat(msgs[i]), getM
                        .indexOf(msgs[i]) != -1);
                if (!getM.equals(msgs[i])) {
                    assertTrue("getMessage() should contain ".concat(toS), getM
                            .indexOf(toS) != -1);
                }
            }
            assertNotNull("getCause() must not return null", tE.getCause());
            assertEquals("getCause() must return ".concat(tCause.toString()),
                    tE.getCause(), tCause);
        }
    }
View Full Code Here

        super();
        TrustManagerFactory factory = TrustManagerFactory.getInstance("SunX509");
        factory.init(keystore);
        TrustManager[] trustmanagers = factory.getTrustManagers();
        if (trustmanagers.length == 0) {
            throw new NoSuchAlgorithmException("SunX509 trust manager not supported");
        }
        this.standardTrustManager = (X509TrustManager)trustmanagers[0];
    }
View Full Code Here

        this.provider = provider;
        this.interfaceDigest = interfaceDigest;
        // message digest
        digestAlgorithmOid = DigestAlgorithms.getAllowedDigests(hashAlgorithm);
        if (digestAlgorithmOid == null)
            throw new NoSuchAlgorithmException(MessageLocalization.getComposedMessage("unknown.hash.algorithm.1", hashAlgorithm));

        // Copy the certificates
        signCert = (X509Certificate)certChain[0];
        certs = new ArrayList<Certificate>();
        for (Certificate element : certChain) {
            certs.add(element);
        }


        // initialize and add the digest algorithms.
        digestalgos = new HashSet<String>();
        digestalgos.add(digestAlgorithmOid);
       
        // find the signing algorithm (RSA or DSA)
        if (privKey != null) {
            digestEncryptionAlgorithmOid = privKey.getAlgorithm();
            if (digestEncryptionAlgorithmOid.equals("RSA")) {
                digestEncryptionAlgorithmOid = SecurityIDs.ID_RSA;
            }
            else if (digestEncryptionAlgorithmOid.equals("DSA")) {
                digestEncryptionAlgorithmOid = SecurityIDs.ID_DSA;
            }
            else {
                throw new NoSuchAlgorithmException(MessageLocalization.getComposedMessage("unknown.key.algorithm.1", digestEncryptionAlgorithmOid));
            }
        }
       
        // initialize the RSA data
        if (hasRSAdata) {
View Full Code Here

            }
            else if (digestEncryptionAlgorithm.equals("ECDSA")) {
                this.digestEncryptionAlgorithmOid = SecurityIDs.ID_ECDSA;
            }
            else
                throw new ExceptionConverter(new NoSuchAlgorithmException(MessageLocalization.getComposedMessage("unknown.key.algorithm.1", digestEncryptionAlgorithm)));
        }
    }
View Full Code Here

        this.privKey = privKey;
        this.provider = provider;

        digestAlgorithm = allowedDigests.get(hashAlgorithm.toUpperCase());
        if (digestAlgorithm == null)
            throw new NoSuchAlgorithmException(MessageLocalization.getComposedMessage("unknown.hash.algorithm.1", hashAlgorithm));

        version = signerversion = 1;
        certs = new ArrayList<Certificate>();
        crls = new ArrayList<CRL>();
        digestalgos = new HashSet<String>();
        digestalgos.add(digestAlgorithm);

        //
        // Copy in the certificates and crls used to sign the private key.
        //
        signCert = (X509Certificate)certChain[0];
        for (Certificate element : certChain) {
            certs.add(element);
        }

        if (crlList != null) {
            for (CRL element : crlList) {
                crls.add(element);
            }
        }

        if (privKey != null) {
            //
            // Now we have private key, find out what the digestEncryptionAlgorithm is.
            //
            digestEncryptionAlgorithm = privKey.getAlgorithm();
            if (digestEncryptionAlgorithm.equals("RSA")) {
                digestEncryptionAlgorithm = ID_RSA;
            }
            else if (digestEncryptionAlgorithm.equals("DSA")) {
                digestEncryptionAlgorithm = ID_DSA;
            }
            else {
                throw new NoSuchAlgorithmException(MessageLocalization.getComposedMessage("unknown.key.algorithm.1", digestEncryptionAlgorithm));
            }
        }
        if (hasRSAdata) {
            RSAdata = new byte[0];
            if (provider == null || provider.startsWith("SunPKCS11"))
View Full Code Here

            }
            else if (digestEncryptionAlgorithm.equals("DSA")) {
                this.digestEncryptionAlgorithm = ID_DSA;
            }
            else
                throw new ExceptionConverter(new NoSuchAlgorithmException(MessageLocalization.getComposedMessage("unknown.key.algorithm.1", digestEncryptionAlgorithm)));
        }
    }
View Full Code Here

        if (kdf != null)
        {
            if (!algorithms.containsKey(algorithm))
            {
                throw new NoSuchAlgorithmException("unknown algorithm encountered: " + algorithm);
            }
           
            int    keySize = ((Integer)algorithms.get(algorithm)).intValue();

            DHKDFParameters params = new DHKDFParameters(new DERObjectIdentifier(algorithm), keySize, secret);
View Full Code Here

TOP

Related Classes of java.security.NoSuchAlgorithmException

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.