1 /* 2 * Copyright �, Aegeus Technology Limited. All rights reserved. 3 */ 4 package jsdsi.util; 5 6 import java.net.URI; 7 import java.security.KeyPair; 8 import jsdsi.Provider; 9 import jsdsi.RSAPublicKey; 10 import junit.framework.TestCase; 11 12 /*** 13 * @author Sean Radford 14 */ 15 public class KeyPairFactoryTest extends TestCase { 16 17 /*** 18 * 19 */ 20 public KeyPairFactoryTest() { 21 super("KeyPairFactoryTest"); 22 } 23 24 /*** 25 * @see TestCase#setUp() 26 */ 27 protected void setUp() throws Exception { 28 super.setUp(); 29 Provider.install(); 30 } 31 32 /*** 33 * @see TestCase#tearDown() 34 */ 35 protected void tearDown() throws Exception { 36 super.tearDown(); 37 } 38 39 /*** 40 * Test generation of jsdsi compatible RSA key 41 * 42 * @throws Exception 43 */ 44 public void testRSA() throws Exception { 45 KeyPair kp = KeyPairFactory.create(KeyEnum.RSA); 46 java.security.PublicKey javaPubKey = kp.getPublic(); 47 assertTrue((javaPubKey instanceof RSAPublicKey)); 48 } 49 50 /*** 51 * Test generation of jsdsi compatible RSA key with a URI 52 * 53 * @throws Exception 54 */ 55 public void testRSAwithURI() throws Exception { 56 URI uri = new URI("test://jsdsi.sf.net"); 57 KeyPair kp = KeyPairFactory.create(KeyEnum.RSA,new URI[] {uri}); 58 java.security.PublicKey pubKey = kp.getPublic(); 59 assertTrue((pubKey instanceof RSAPublicKey)); 60 assertNotNull( ((RSAPublicKey)pubKey).getURIs()); 61 } 62 63 }

This page was automatically generated by Maven