1   package test.base.jdbs.cryptography.asymmetric;
2   
3   import java.security.InvalidKeyException;
4   import java.security.NoSuchAlgorithmException;
5   import java.security.NoSuchProviderException;
6   import java.security.SignatureException;
7   
8   import org.apache.log4j.Logger;
9   
10  import test.base.jdbs.AllTests;
11  import base.jdbs.cryptography.asymmetric.AsymmetricKeyRing;
12  import base.jdbs.cryptography.asymmetric.KeyPair;
13  import junit.framework.TestCase;
14  
15  public class RSAKeyPairFactoryTest extends TestCase {
16  
17  	private static final transient Logger logger = Logger.getLogger(RSAKeyPairFactoryTest.class.getName());
18  
19  	/*
20  	 * Test method for 'base.jdbs.cryptography.asymmetric.RSAKeyPairFactory.newKeyPair(AsymmetricKeyRing, String)'
21  	 */
22  	public void testNewKeyPair() throws InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException, SecurityException, SignatureException {
23  		AsymmetricKeyRing akr = new AsymmetricKeyRing(AllTests.getUser());
24  		KeyPair kp = base.jdbs.cryptography.asymmetric.RSAKeyPairFactory.newKeyPair(akr,"Test Key Pair");
25  		logger.debug("Before add, Key Pair length: "+akr.getAllKeyPair().length);
26  		assertTrue(akr.getAllKeyPair().length == 0);
27  		akr.addKeyPair(kp);
28  		logger.debug("After add, Key Pair length: "+akr.getAllKeyPair().length);
29  		assertTrue(akr.getAllKeyPair().length == 1);
30  		
31  		assertEquals(AllTests.getUser(),akr.getOwner());
32  	}
33  
34  }