1 /* 2 * Copyright �, Aegeus Technology Limited. All rights reserved. 3 */ 4 package jsdsi.util; 5 6 import java.math.BigInteger; 7 import java.net.URI; 8 import java.security.KeyPair; 9 import java.security.KeyPairGenerator; 10 11 import jsdsi.Principal; 12 import jsdsi.Provider; 13 import junit.framework.TestCase; 14 15 /*** 16 * @author Sean Radford 17 * @version $Revision: 1.2 $ $Date: 2004/11/11 19:31:47 $ 18 */ 19 public class RSAKeyPairGeneratorSpiTest extends TestCase { 20 21 private static final String ALGO_RSA = "SPKI/RSA"; 22 23 /*** 24 * @see TestCase#setUp() 25 */ 26 protected void setUp() throws Exception { 27 super.setUp(); 28 Provider.install(); 29 } 30 31 /*** 32 * @see TestCase#tearDown() 33 */ 34 protected void tearDown() throws Exception { 35 super.tearDown(); 36 } 37 38 public void testDefaults() throws Exception { 39 KeyPairGenerator kpg = KeyPairGenerator.getInstance(ALGO_RSA); 40 KeyPair kp = kpg.generateKeyPair(); 41 assertTrue(kp.getPublic() instanceof Principal); 42 assertNull(((Principal) kp.getPublic()).getURIs()); 43 } 44 45 public void testURI() throws Exception { 46 RSAKeyGenParameterSpec spec = new RSAKeyGenParameterSpec(512, 47 BigInteger.ONE, 48 new URI[] { new URI("test://jsdsi.sf.net") }); 49 KeyPairGenerator kpg = KeyPairGenerator.getInstance(ALGO_RSA); 50 kpg.initialize(spec); 51 KeyPair kp = kpg.generateKeyPair(); 52 assertTrue(kp.getPublic() instanceof Principal); 53 assertNotNull(((Principal) kp.getPublic()).getURIs()); 54 } 55 56 }

This page was automatically generated by Maven