Examples of TestKeyPair


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

*/
public class SignedObjectTest extends TestCase {

  public void testSignedObject() {
    Signature sig = null;
    TestKeyPair tkp = null;
      Properties prop;
     
      try {
          sig = Signature.getInstance("SHA1withDSA");   
      } catch (NoSuchAlgorithmException e) {
        fail(e.toString());
      }
     
      try {
      tkp = new TestKeyPair("DSA");
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
        return;
    }
      prop = new Properties();
      prop.put("aaa", "bbb");
      SignedObject so = null;
      try {
        so = new SignedObject(prop, tkp.getPrivate(), sig);
      } catch (IOException e) {
             fail(e.toString())
      } catch (SignatureException e) {  
             fail(e.toString())
      } catch (InvalidKeyException e) {
             fail(e.toString())
      } catch (InvalidKeySpecException e) {
            fail(e.toString());
    }

      assertEquals("SHA1withDSA", so.getAlgorithm());
        try {
            assertEquals(so.getObject(), prop);       
        } catch (ClassNotFoundException e) {
             fail(e.toString())
        } catch (IOException e) {
             fail(e.toString())
        }
        try {
          if (!so.verify(tkp.getPublic(), sig)) {
              fail("verify() failed");
           
        } catch (SignatureException e) {
          fail(e.toString());       
        } catch (InvalidKeyException e) {
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

     * @throws InvalidKeySpecException
     */
    public final void testTrustAnchorStringPublicKeybyteArray01()
            throws Exception {

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

        // sub testcase 1
        new TrustAnchor(validCaNameRfc2253, pk, getFullEncoding());
        // sub testcase 2
        new TrustAnchor(validCaNameRfc2253, pk, getEncodingPSOnly());       
View Full Code Here

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

     * @throws InvalidKeySpecException
     */
    public final void testTrustAnchorStringPublicKeybyteArray02()
            throws Exception {

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

        new TrustAnchor(validCaNameRfc2253, pk, null);
    }
View Full Code Here

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

     * @throws InvalidKeySpecException
     */
    public final void testTrustAnchorStringPublicKeybyteArray03()
            throws Exception {

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

        byte[] nc = getEncodingPSOnly();
        byte[] ncCopy = nc.clone();
        // sub testcase 5 - nameConstraints can be null
        TrustAnchor ta = new TrustAnchor(validCaNameRfc2253, pk, ncCopy);
View Full Code Here

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

     * Expected: NullPointerException
     */
    public final void testTrustAnchorStringPublicKeybyteArray04()
            throws Exception {

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

        // sub testcase 1: 'caName' param is null
        try {
            new TrustAnchor((String)null, pk, getEncodingPSOnly());
            fail("NullPointerException has not been thrown");
View Full Code Here

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

     * @throws InvalidKeySpecException
     */
    public final void testTrustAnchorX500PrincipalPublicKeybyteArray01()
            throws Exception {

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

        X500Principal x500p = new X500Principal(validCaNameRfc2253);
        // sub testcase 1
        new TrustAnchor(x500p, pk, getFullEncoding());
        // sub testcase 2
View Full Code Here

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

     * @throws InvalidKeySpecException
     */
    public final void testTrustAnchorX500PrincipalPublicKeybyteArray02()
            throws Exception {

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

        X500Principal x500p = new X500Principal(validCaNameRfc2253);

        new TrustAnchor(x500p, pk, null);
    }
View Full Code Here

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

     * @throws InvalidKeySpecException
     */
    public final void testTrustAnchorX500PrincipalPublicKeybyteArray03()
            throws Exception {

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

        byte[] nc = getEncodingPSOnly();
        byte[] ncCopy = nc.clone();
        // sub testcase 5 - nameConstraints can be null
        TrustAnchor ta = new TrustAnchor(new X500Principal(validCaNameRfc2253),
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.