Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/jdk/sun/security/pkcs11/Config/ReadConfInUTF16Env.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, 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
Expand Down Expand Up @@ -29,6 +29,7 @@
*/

import jdk.test.lib.process.ProcessTools;
import jtreg.SkippedException;
import org.testng.annotations.Test;

import java.security.Provider;
Expand All @@ -47,8 +48,7 @@ static class TestSunPKCS11Provider {
public static void main(String[] args) throws Exception {
Provider p = Security.getProvider("SunPKCS11");
if (p == null) {
System.out.println("Skipping test - no PKCS11 provider available");
return;
throw new SkippedException("No PKCS11 provider available");
}
System.out.println(p.getName());
}
Expand Down
2 changes: 1 addition & 1 deletion test/jdk/sun/security/pkcs11/PKCS11Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ protected boolean skipTest(Provider p) {

private void premain(Provider p) throws Exception {
if (skipTest(p)) {
return;
throw new SkippedException("See logs for details");
}

long start = System.currentTimeMillis();
Expand Down
6 changes: 2 additions & 4 deletions test/jdk/sun/security/pkcs11/Secmod/AddPrivateKey.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2025, 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
Expand Down Expand Up @@ -62,9 +62,7 @@ public class AddPrivateKey extends SecmodTest {
private static final byte[] DATA = generateData(DATA_LENGTH);

public static void main(String[] args) throws Exception {
if (initSecmod() == false) {
return;
}
initSecmod();

String configName = BASE + SEP + "nss.cfg";
Provider p = getSunPKCS11(configName);
Expand Down
5 changes: 1 addition & 4 deletions test/jdk/sun/security/pkcs11/Secmod/AddTrustedCert.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
* @run main/othervm AddTrustedCert
*/

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.KeyStore;
Expand All @@ -47,9 +46,7 @@
public class AddTrustedCert extends SecmodTest {

public static void main(String[] args) throws Exception {
if (initSecmod() == false) {
return;
}
initSecmod();

X509Certificate cert;
try (InputStream in = new FileInputStream(BASE + SEP + "anchor.cer")) {
Expand Down
7 changes: 2 additions & 5 deletions test/jdk/sun/security/pkcs11/Secmod/Crypto.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2025, 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
Expand Down Expand Up @@ -31,7 +31,6 @@
* @run main/othervm Crypto
*/

import java.io.File;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.Provider;
Expand All @@ -40,9 +39,7 @@
public class Crypto extends SecmodTest {

public static void main(String[] args) throws Exception {
if (initSecmod() == false) {
return;
}
initSecmod();

String configName = BASE + SEP + "nsscrypto.cfg";
Provider p = getSunPKCS11(configName);
Expand Down
7 changes: 2 additions & 5 deletions test/jdk/sun/security/pkcs11/Secmod/GetPrivateKey.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2025, 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
Expand Down Expand Up @@ -32,7 +32,6 @@
* @run main/othervm GetPrivateKey
*/

import java.io.File;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.Provider;
Expand All @@ -46,9 +45,7 @@
public class GetPrivateKey extends SecmodTest {

public static void main(String[] args) throws Exception {
if (initSecmod() == false) {
return;
}
initSecmod();

String configName = BASE + SEP + "nss.cfg";
Provider p = getSunPKCS11(configName);
Expand Down
7 changes: 2 additions & 5 deletions test/jdk/sun/security/pkcs11/Secmod/JksSetPrivateKey.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2025, 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
Expand Down Expand Up @@ -31,7 +31,6 @@
* @run main/othervm JksSetPrivateKey
*/

import java.io.File;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.PrivateKey;
Expand All @@ -45,9 +44,7 @@
public class JksSetPrivateKey extends SecmodTest {

public static void main(String[] args) throws Exception {
if (initSecmod() == false) {
return;
}
initSecmod();

String configName = BASE + SEP + "nss.cfg";
Provider p = getSunPKCS11(configName);
Expand Down
7 changes: 2 additions & 5 deletions test/jdk/sun/security/pkcs11/Secmod/LoadKeystore.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2025, 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
Expand Down Expand Up @@ -30,7 +30,6 @@
* @run main/othervm LoadKeystore
*/

import java.io.File;
import java.io.IOException;
import java.security.KeyStore;
import java.security.KeyStoreException;
Expand All @@ -42,9 +41,7 @@
public class LoadKeystore extends SecmodTest {

public static void main(String[] args) throws Exception {
if (!initSecmod()) {
return;
}
initSecmod();

String configName = BASE + SEP + "nss.cfg";
Provider p = getSunPKCS11(configName);
Expand Down
20 changes: 5 additions & 15 deletions test/jdk/sun/security/pkcs11/Secmod/TestNssDbSqlite.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Red Hat, Inc. and/or its affiliates.
* Copyright (c) 2017, 2025, Red Hat, Inc. and/or its affiliates.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -46,6 +46,7 @@
import java.security.Provider;
import java.security.Signature;

import jtreg.SkippedException;
import sun.security.rsa.SunRsaSign;
import sun.security.jca.ProviderList;
import sun.security.jca.Providers;
Expand All @@ -66,9 +67,7 @@ public final class TestNssDbSqlite extends SecmodTest {

public static void main(String[] args) throws Exception {

if (!initialize()) {
return;
}
initializeProvider();

if (enableDebug) {
System.out.println("SunPKCS11 provider: " +
Expand Down Expand Up @@ -110,16 +109,9 @@ private static void testRetrieveKeysFromKeystore() throws Exception {
}
}

private static boolean initialize() throws Exception {
return initializeProvider();
}

private static boolean initializeProvider() throws Exception {
private static void initializeProvider() throws Exception {
useSqlite(true);
if (!initSecmod()) {
System.out.println("Cannot init security module database, skipping");
return false;
}
initSecmod();

sunPKCS11NSSProvider = getSunPKCS11(BASE + SEP + "nss-sqlite.cfg");
sunJCEProvider = new com.sun.crypto.provider.SunJCE();
Expand All @@ -135,7 +127,5 @@ private static boolean initializeProvider() throws Exception {
gen.generate(2048);
privateKey = gen.getPrivateKey();
certificate = gen.getSelfCertificate(new X500Name("CN=Me"), 365);

return true;
}
}
7 changes: 2 additions & 5 deletions test/jdk/sun/security/pkcs11/Secmod/TrustAnchors.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2025, 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
Expand Down Expand Up @@ -31,7 +31,6 @@
* @run main/othervm TrustAnchors
*/

import java.io.File;
import java.security.KeyStore;
import java.security.Provider;
import java.security.Security;
Expand All @@ -43,9 +42,7 @@
public class TrustAnchors extends SecmodTest {

public static void main(String[] args) throws Exception {
if (initSecmod() == false) {
return;
}
initSecmod();

// our secmod.db file says nssckbi.*so*, so NSS does not find the
// *DLL* on Windows nor the *DYLIB* on Mac OSX.
Expand Down
5 changes: 2 additions & 3 deletions test/jdk/sun/security/pkcs11/SecmodTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static void useSqlite(boolean b) {
useSqlite = b;
}

static boolean initSecmod() throws Exception {
static void initSecmod() throws Exception {
useNSS();
LIBPATH = getNSSLibDir();
// load all the libraries except libnss3 into memory
Expand All @@ -60,7 +60,7 @@ static boolean initSecmod() throws Exception {
System.setProperty("pkcs11test.nss.db", DBDIR);
}
File dbdirFile = new File(DBDIR);
if (dbdirFile.exists() == false) {
if (!dbdirFile.exists()) {
dbdirFile.mkdir();
}

Expand All @@ -73,7 +73,6 @@ static boolean initSecmod() throws Exception {
copyFile("key3.db", BASE, DBDIR);
copyFile("cert8.db", BASE, DBDIR);
}
return true;
}

private static void copyFile(String name, String srcDir, String dstDir) throws IOException {
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/sun/security/pkcs11/ec/ReadCertificates.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import java.util.Map;
import javax.security.auth.x500.X500Principal;
import jdk.test.lib.security.Providers;
import jtreg.SkippedException;

public class ReadCertificates extends PKCS11Test {

Expand All @@ -78,8 +79,7 @@ public static void main(String[] args) throws Exception {
@Override
public void main(Provider p) throws Exception {
if (p.getService("Signature", "SHA1withECDSA") == null) {
System.out.println("Provider does not support ECDSA, skipping...");
return;
throw new SkippedException("Provider does not support ECDSA");
}

/*
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/sun/security/pkcs11/ec/ReadPKCS12.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import java.util.Map;
import java.util.Random;
import jdk.test.lib.security.Providers;
import jtreg.SkippedException;

public class ReadPKCS12 extends PKCS11Test {

Expand All @@ -66,8 +67,7 @@ public static void main(String[] args) throws Exception {
@Override
public void main(Provider p) throws Exception {
if (p.getService("Signature", "SHA1withECDSA") == null) {
System.out.println("Provider does not support ECDSA, skipping...");
return;
throw new SkippedException("Provider does not support ECDSA");
}

/*
Expand Down
7 changes: 4 additions & 3 deletions test/jdk/sun/security/pkcs11/ec/TestKeyFactory.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2025, 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
Expand Down Expand Up @@ -31,6 +31,8 @@
* @run main/othervm TestKeyFactory
*/

import jtreg.SkippedException;

import java.security.Key;
import java.security.KeyFactory;
import java.security.KeyPair;
Expand Down Expand Up @@ -126,8 +128,7 @@ public static void main(String[] args) throws Exception {
@Override
public void main(Provider p) throws Exception {
if (p.getService("KeyFactory", "EC") == null) {
System.out.println("Provider does not support EC, skipping");
return;
throw new SkippedException("Provider does not support EC, skipping");
}
int[] keyLengths = {256, 521};
KeyFactory kf = KeyFactory.getInstance("EC", p);
Expand Down
10 changes: 5 additions & 5 deletions test/jdk/sun/security/pkcs11/rsa/KeyWrap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2025, 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
Expand Down Expand Up @@ -32,6 +32,8 @@
* @run main/othervm KeyWrap
*/

import jtreg.SkippedException;

import java.security.GeneralSecurityException;
import java.security.InvalidKeyException;
import java.security.Key;
Expand All @@ -54,8 +56,7 @@ public void main(Provider p) throws Exception {
try {
Cipher.getInstance("RSA/ECB/PKCS1Padding", p);
} catch (GeneralSecurityException e) {
System.out.println("Not supported by provider, skipping");
return;
throw new SkippedException("Not supported by provider, skipping");
}
KeyPair kp;
try {
Expand All @@ -74,8 +75,7 @@ public void main(Provider p) throws Exception {
kp = new KeyPair(pub, priv);
} catch (NoSuchAlgorithmException | InvalidKeyException ee) {
ee.printStackTrace();
System.out.println("Provider does not support RSA, skipping");
return;
throw new SkippedException("Provider does not support RSA, skipping");
}
}
System.out.println(kp);
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.security.Provider;
import java.security.Security;
import jdk.test.lib.security.Providers;
import jtreg.SkippedException;

public class ClientJSSEServerJSSE extends PKCS11Test {

Expand All @@ -58,8 +59,7 @@ public static void main(String[] args) throws Exception {
@Override
public void main(Provider p) throws Exception {
if (p.getService("KeyFactory", "EC") == null) {
System.out.println("Provider does not support EC, skipping");
return;
throw new SkippedException("Provider does not support EC, skipping");
}
Providers.setAt(p, 1);
CipherTest.main(new JSSEFactory(), cmdArgs);
Expand Down
Loading