< prev index next >
test/jdk/java/security/KeyStore/TestKeyStoreEntry.java
Print this page
rev 59383 : [mq]: final
*** 1,7 ****
/*
! * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 34,44 ****
/*
* @test
* @bug 8048621
* @summary Test the basic operations of KeyStore entry, provided by SunJCE
! * (jceks), and SunPKCS11-Solaris(PKCS11KeyStore)
* @author Yu-Ching Valerie PENG
*/
public class TestKeyStoreEntry {
private static final char[] PASSWDK = new char[] {
--- 34,44 ----
/*
* @test
* @bug 8048621
* @summary Test the basic operations of KeyStore entry, provided by SunJCE
! * (jceks)
* @author Yu-Ching Valerie PENG
*/
public class TestKeyStoreEntry {
private static final char[] PASSWDK = new char[] {
*** 49,65 ****
private static final String[] KS_ALGOS = {
"DES", "DESede", "Blowfish"
};
private static final int NUM_ALGOS = KS_ALGOS.length;
- private static final String[] KS_TYPE = {
- "jks", "jceks", "pkcs12", "PKCS11KeyStore"
- };
- private static final String[] PRO_TYPE = {
- "SUN", "SunJCE", "SunJSSE", "SunPKCS11-Solaris"
- };
-
private final SecretKey[] sks = new SecretKey[NUM_ALGOS];
TestKeyStoreEntry() throws Exception {
// generate secret keys which are to be stored in the jce
// key store object
--- 49,58 ----
*** 75,113 ****
TestKeyStoreEntry jstest = new TestKeyStoreEntry();
jstest.run();
}
public void run() throws Exception {
-
- Provider[] providers = Security.getProviders();
- for (Provider p: providers) {
- String prvName = p.getName();
- if (prvName.startsWith("SunJCE")
- || prvName.startsWith("SunPKCS11-Solaris")) {
- try {
- runTest(p);
- out.println("Test with provider " + p.getName() + ""
- + " passed");
-
- } catch (java.security.KeyStoreException e) {
- if (prvName.startsWith("SunPKCS11-Solaris")) {
- out.println("KeyStoreException is expected because "
- + "PKCS11KeyStore is invalid keystore type.");
- e.printStackTrace();
- } else {
- throw e;
- }
- }
- }
- }
- }
-
- public void runTest(Provider p) throws Exception {
try (FileOutputStream fos = new FileOutputStream("jceks");
FileInputStream fis = new FileInputStream("jceks");) {
! KeyStore ks = KeyStore.getInstance("jceks", p);
// create an empty key store
ks.load(null, null);
// store the secret keys
String aliasHead = new String("secretKey");
--- 68,81 ----
TestKeyStoreEntry jstest = new TestKeyStoreEntry();
jstest.run();
}
public void run() throws Exception {
try (FileOutputStream fos = new FileOutputStream("jceks");
FileInputStream fis = new FileInputStream("jceks");) {
! KeyStore ks = KeyStore.getInstance("jceks");
// create an empty key store
ks.load(null, null);
// store the secret keys
String aliasHead = new String("secretKey");
< prev index next >