diff options
author | (no author) <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2003-12-22 17:51:40 +0000 |
---|---|---|
committer | (no author) <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2003-12-22 17:51:40 +0000 |
commit | b9e7df0cbe67b486ce3a1a2177bd08c0ced9e005 (patch) | |
tree | 7c3ebc612f89ce28ce75c8e7c06f92aca3ad5501 /common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java | |
parent | 296f2afedb9bef1bc71aeaa3407128094de7a523 (diff) | |
download | moa-id-spss-b9e7df0cbe67b486ce3a1a2177bd08c0ced9e005.tar.gz moa-id-spss-b9e7df0cbe67b486ce3a1a2177bd08c0ced9e005.tar.bz2 moa-id-spss-b9e7df0cbe67b486ce3a1a2177bd08c0ced9e005.zip |
This commit was manufactured by cvs2svn to create tag 'Build_002'.tags/Build_002
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/tags/Build_002@88 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java')
-rw-r--r-- | common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java b/common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java deleted file mode 100644 index 06a72c570..000000000 --- a/common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package test.at.gv.egovernment.moa.util; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.math.BigInteger; -import java.security.KeyStore; -import java.security.Security; -import java.security.cert.X509Certificate; -import java.util.Enumeration; - -import at.gv.egovernment.moa.util.KeyStoreUtils; - -import junit.framework.TestCase; - -/** - * @author Paul Ivancsics - * @version $Id$ - */ -public class KeyStoreUtilsTest extends TestCase { - private String tmpDir = "tmp/KeyStoreUtilsTest"; - private String tmpDirURL = "file:" + tmpDir; - - public KeyStoreUtilsTest(String arg0) { - super(arg0); - } - - protected void setUp() throws Exception { - Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); - new File(tmpDir).mkdirs(); - } - protected void tearDown() throws Exception { - new File(tmpDir).delete(); - } - public void testCreateKeyStoreJKS() throws Exception { - String[] certFilenames = new String[] { - "data/test/security/server-certs/baltimore.cer" - }; - KeyStore ks = KeyStoreUtils.createKeyStore("jks", certFilenames); - assertEquals(1, ks.size()); - X509Certificate cert = (X509Certificate)ks.getCertificate("0"); - assertEquals(3424, cert.getSerialNumber().intValue()); - } - public void testCreateKeyStorePKCS12() throws Exception { - String[] certFilenames = new String[] { - "data/test/security/server-certs/baltimore.cer" - }; - KeyStore ks = KeyStoreUtils.createKeyStore("pkcs12", certFilenames); - assertEquals(1, ks.size()); - X509Certificate cert = (X509Certificate)ks.getCertificate("0"); - assertEquals(3424, cert.getSerialNumber().intValue()); - } - public void testCreateKeyStoreFromCertificateDirectory() throws Exception { - // copy certificate files to a temporary directory, - // omitting the "CVS" directory in the source directory - copyCertificates("data/test/security/server-certs", tmpDir); - KeyStore ks = KeyStoreUtils.createKeyStoreFromCertificateDirectory("jks", tmpDirURL); - assertEquals(2, ks.size()); - X509Certificate cert0 = (X509Certificate)ks.getCertificate("0"); - X509Certificate cert1 = (X509Certificate)ks.getCertificate("1"); - assertTrue(3424 == cert0.getSerialNumber().intValue() || 3424 == cert1.getSerialNumber().intValue()); - } - private void copyCertificates(String from, String to) throws IOException { - String[] fromList = new File(from).list(); - for (int i = 0; i < fromList.length; i++) { - File fromFile = new File(from + File.separator + fromList[i]); - if (fromFile.isFile()) { - String toFile = to + "/" + fromList[i]; - FileInputStream in = new FileInputStream(fromFile); - FileOutputStream out = new FileOutputStream(toFile); - for (int ch = in.read(); ch >= 0; ch = in.read()) - out.write(ch); - out.close(); - in.close(); - } - } - - } - public void testLoadKeyStore() throws Exception { - String keyStoreURL = "file:data/test/security/client-certs/sicher-demo(buergerkarte).p12"; - KeyStore ks = KeyStoreUtils.loadKeyStore("pkcs12", keyStoreURL, "buergerkarte"); - assertEquals(1, ks.size()); - Enumeration enum = ks.aliases(); - String alias = (String)enum.nextElement(); - X509Certificate cert = (X509Certificate)ks.getCertificate(alias); - assertEquals(new BigInteger("1044289238331").intValue(), cert.getSerialNumber().intValue()); - } - -} |