Examples of TestKeyPair


Examples of org.apache.harmony.security.tests.support.TestKeyPair

     * KeyStore.PrivateKeyEntry is used.
     *
     */   
    public void testEntry02() throws Exception {
        assertTrue(NotSupportMsg, JKSSupported);
        TestKeyPair tkp = new TestKeyPair("DSA");
        KeyStoreTestSupport.MCertificate certs[] = {
                new KeyStoreTestSupport.MCertificate("DSA", tkp.getPrivate()
                        .getEncoded()),
                new KeyStoreTestSupport.MCertificate("DSA", tkp.getPrivate()
                        .getEncoded()) };
        PrivateKey privKey = tkp.getPrivate();
        KeyStore.PrivateKeyEntry pKey = new KeyStore.PrivateKeyEntry(privKey,
                certs);
        char[] pwd = { 'p', 'a', 's', 's', 'w', 'd' };
        KeyStore.PasswordProtection pPath = new KeyStore.PasswordProtection(pwd);
        KeyStore.PasswordProtection anotherPath = new KeyStore.PasswordProtection(
View Full Code Here

Examples of org.apache.harmony.security.tests.support.TestKeyPair

     * FIXME: this test should be changed to verify SecretKeyEntry.
     * It is not supported. 
     */   
    public void testEntry03() throws Exception {
        assertTrue(NotSupportMsg, JKSSupported);
        TestKeyPair tkp = new TestKeyPair("DSA");
        KeyStoreTestSupport.SKey secKey = new KeyStoreTestSupport.SKey("DSA",
                tkp.getPrivate().getEncoded());
        KeyStore.SecretKeyEntry sKey = new KeyStore.SecretKeyEntry(
                secKey);       
        char [] pwd = {'p', 'a', 's', 's', 'w', 'd'};
        KeyStore.PasswordProtection pPath = new KeyStore.PasswordProtection(pwd);
        KeyStoreTestSupport.AnotherEntry aEntry = new KeyStoreTestSupport.AnotherEntry();
View Full Code Here

Examples of org.apache.harmony.security.tests.support.TestKeyPair

                new KeyStoreTestSupport.MCertificate("type1", new byte[10]),
                new KeyStoreTestSupport.MCertificate("type2", new byte[10]) };
        KeyStoreTestSupport.MCertificate cert = new KeyStoreTestSupport.MCertificate(
                "type", new byte[0]);
        char[] pwd = new char[0];
        TestKeyPair tkp = new TestKeyPair("DSA");
        PrivateKey key = tkp.getPrivate();
        KeyStore [] kss = createKS();
        assertNotNull("KeyStore objects were not created", kss);
        for (int i = 0; i < kss.length; i++) {
            kss[i].load(null, null);
           
View Full Code Here

Examples of org.apache.harmony.security.tests.support.TestKeyPair

    public void testEntry06() throws Exception {
        assertTrue(NotSupportMsg, JKSSupported);
        KeyStore.TrustedCertificateEntry tCert = new KeyStore.TrustedCertificateEntry(
                new KeyStoreTestSupport.MCertificate("type", new byte[0]));

        TestKeyPair tkp = new TestKeyPair("DSA");
        KeyStoreTestSupport.MCertificate certs[] = {
                new KeyStoreTestSupport.MCertificate("DSA", tkp.getPrivate()
                        .getEncoded()),
                new KeyStoreTestSupport.MCertificate("DSA", tkp.getPrivate()
                        .getEncoded()) };
        KeyStore.PrivateKeyEntry pKey = new KeyStore.PrivateKeyEntry(tkp
                .getPrivate(), certs);
        char[] pwd = { 'p', 'a', 's', 's', 'w', 'd' };
        KeyStore.PasswordProtection pp = new KeyStore.PasswordProtection(pwd);

        String[] aliases = { "Alias1", "Alias2", "Alias3", "Alias4", "Alias5" };

        KeyStore[] kss = createKS();
        assertNotNull("KeyStore objects were not created", kss);

        for (int i = 0; i < kss.length; i++) {
            kss[i].load(null, null);
            kss[i].setEntry(aliases[0], tCert, null);
            kss[i].setEntry(aliases[1], pKey, pp);
            kss[i].setEntry(aliases[2], pKey, pp);

            kss[i].setKeyEntry(aliases[3], tkp.getPrivate(), pwd, certs);

            kss[i].setCertificateEntry(aliases[4], certs[0]);

            assertEquals("Incorrect size", kss[i].size(), 5);
            try {
View Full Code Here

Examples of org.apache.harmony.security.tests.support.TestKeyPair

     * KeyStore.PrivateKeyEntry is used.
     *
     */   
    public void testEntry07() throws Exception
        assertTrue(NotSupportMsg, JKSSupported);
        TestKeyPair tkp = new TestKeyPair("DSA");
        KeyStoreTestSupport.MCertificate certs[] = {
                new KeyStoreTestSupport.MCertificate("DSA", tkp.getPrivate()
                        .getEncoded()),
                new KeyStoreTestSupport.MCertificate("DSA", tkp.getPrivate()
                        .getEncoded()) };
        PrivateKey privKey = tkp.getPrivate();
        KeyStore.PrivateKeyEntry pKey = new KeyStore.PrivateKeyEntry(privKey, certs);       
        char [] pwd = {'p', 'a', 's', 's', 'w', 'd'};
        String aliasKE = "KeyAlias";
        KeyStore.PasswordProtection pp = new KeyStore.PasswordProtection(pwd);
        new KeyStore.PasswordProtection(new char[0]);
View Full Code Here

Examples of org.apache.harmony.security.tests.support.TestKeyPair

        KeyStore.PasswordProtection protPass1 = new KeyStore.PasswordProtection(
                pass);
        KeyStore.ProtectionParameter [] pp = { protPass, protPass1,
                callbackHand, myProtParam };
        TestKeyPair tkp = new TestKeyPair("DSA");
        Certificate certs[] = {
                new MCertificate("DSA", tkp.getPrivate()
                        .getEncoded()),
                new MCertificate("DSA", tkp.getPrivate()
                        .getEncoded()) };
        PrivateKey privKey = tkp.getPrivate();

        KeyStore.PrivateKeyEntry pKey = new KeyStore.PrivateKeyEntry(privKey,
                certs);
        for (int i = 0; i < pp.length; i++) {
            ks = KeyStore.getInstance(defaultType);
View Full Code Here

Examples of org.apache.harmony.security.tests.support.TestKeyPair

                (X509Certificate)ks.getCertificate(certAlias),
                getFullEncoding());

        assertNotNull("#1", ta.toString());

        PublicKey pk = new TestKeyPair(keyAlg).getPublic();


        // sub testcase 2
        ta = new TrustAnchor(validCaNameRfc2253, pk, getEncodingESOnly());
View Full Code Here

Examples of org.apache.harmony.security.tests.support.TestKeyPair

          sig = Signature.getInstance("SHA1withDSA");   
      } catch (NoSuchAlgorithmException e) {
        fail(e.toString());
      }
      try {
      tkp = new TestKeyPair("DSA");
    } catch (NoSuchAlgorithmException e1) {
      fail(e1.toString());
    }
      prop = new Properties();
      prop.put("aaa", "bbb");
View Full Code Here

Examples of org.apache.harmony.security.tests.support.TestKeyPair

*/
public class SecurityTest extends TestCase {

    public final void testMixed() {

        TestKeyPair tkp = null;
        try {
            tkp = new TestKeyPair("DSA");
        } catch (NoSuchAlgorithmException e1) {
            e1.printStackTrace();
            return;
        }

        try {
            MessageDigest.getInstance("SHA-1");
            KeyFactory.getInstance("DSA");
            Signature ss =Signature.getInstance("DSA");
            ss.initSign(tkp.getPrivate());
            Signature.getInstance("aaaaaaaaaaaa");
        } catch (Exception e) {
            // ignore
        }   

View Full Code Here

Examples of org.apache.harmony.security.tests.support.TestKeyPair

* Tests for <code>SignedObject</code> constructor and methods
*/
public class SignedObjectTest extends TestCase {

    public void testSignedObject() throws Exception {
        TestKeyPair tkp = null;
        Properties prop;

        Signature sig = Signature.getInstance("SHA1withDSA");

        try {
            tkp = new TestKeyPair("DSA");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return;
        }
        prop = new Properties();
        prop.put("aaa", "bbb");

        SignedObject so = new SignedObject(prop, tkp.getPrivate(), sig);

        assertEquals("SHA1withDSA", so.getAlgorithm());
        assertEquals(prop, so.getObject());

        assertTrue("verify() failed", so.verify(tkp.getPublic(), sig));

        assertNotNull("signature is null", so.getSignature());
    }
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.