Skip to content

Commit a49f833

Browse files
committed
8346045: Cleanup of security library tests calling Security Manager APIs
Reviewed-by: rriggs
1 parent 56c7800 commit a49f833

File tree

6 files changed

+14
-85
lines changed

6 files changed

+14
-85
lines changed

test/jdk/java/security/AccessControlContext/FailureDebugOption.java

Lines changed: 0 additions & 49 deletions
This file was deleted.

test/jdk/java/security/cert/CertPathBuilder/GetInstance.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,11 +30,7 @@
3030
* The test passes if it returns.
3131
* The test fails if an exception is thrown.
3232
*/
33-
import java.security.cert.CertPathParameters;
34-
import java.security.cert.CertPathBuilderResult;
35-
import java.security.cert.CertPathBuilderSpi;
3633
import java.security.Provider;
37-
import java.security.AccessController;
3834
import java.security.cert.CertPathBuilder;
3935
import java.security.NoSuchAlgorithmException;
4036

test/jdk/sun/security/pkcs11/PKCS11Test.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,6 @@
3737
import java.security.InvalidAlgorithmParameterException;
3838
import java.security.KeyPairGenerator;
3939
import java.security.NoSuchProviderException;
40-
import java.security.Policy;
4140
import java.security.Provider;
4241
import java.security.ProviderException;
4342
import java.security.SecureRandom;

test/jdk/sun/security/tools/jarsigner/CertChainUnclosed.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -32,15 +32,12 @@
3232

3333
import java.nio.file.Files;
3434
import java.nio.file.Paths;
35-
import java.security.AccessController;
36-
import java.security.PrivilegedAction;
3735
import java.util.Locale;
3836

3937
public class CertChainUnclosed {
4038

4139
public static void main(String[] args) throws Exception {
42-
String os = AccessController.doPrivileged(
43-
(PrivilegedAction<String>)() -> System.getProperty("os.name"));
40+
String os = System.getProperty("os.name");
4441
if (!os.toUpperCase(Locale.US).contains("WINDOWS")) {
4542
System.out.println("Not Windows. Skip test.");
4643
return;

test/jdk/sun/security/x509/AVA/AVAEqualsHashCode.java

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -49,9 +49,7 @@ public static void main(String[] args) throws Exception {
4949
byte[] ba = deros.toByteArray();
5050
DerValue dv = new DerValue(ba);
5151

52-
GetAVAConstructor a = new GetAVAConstructor();
53-
java.security.AccessController.doPrivileged(a);
54-
Constructor c = a.getCons();
52+
Constructor c = getAVAConstructor();
5553

5654
Object[] objs = new Object[2];
5755
objs[0] = oid;
@@ -72,16 +70,10 @@ public static void main(String[] args) throws Exception {
7270
else
7371
throw new Exception("FAILED equals()/hashCode() contract");
7472
}
75-
}
76-
77-
class GetAVAConstructor implements java.security.PrivilegedExceptionAction {
7873

79-
private Class avaClass = null;
80-
private Constructor avaCons = null;
81-
82-
public Object run() throws Exception {
74+
static Constructor getAVAConstructor() throws Exception {
8375
try {
84-
avaClass = Class.forName("sun.security.x509.AVA");
76+
Class avaClass = Class.forName("sun.security.x509.AVA");
8577
Constructor[] cons = avaClass.getDeclaredConstructors();
8678

8779
int i;
@@ -90,22 +82,16 @@ public Object run() throws Exception {
9082
if (parms.length == 2) {
9183
if (parms[0].getName().equalsIgnoreCase("sun.security.util.ObjectIdentifier") &&
9284
parms[1].getName().equalsIgnoreCase("sun.security.util.DerValue")) {
93-
avaCons = cons[i];
85+
Constructor avaCons = cons[i];
9486
avaCons.setAccessible(true);
95-
break;
87+
return avaCons;
9688
}
9789
}
9890
}
99-
91+
return null;
10092
} catch (Exception e) {
10193
System.out.println("Caught unexpected exception " + e);
10294
throw e;
10395
}
104-
return avaCons;
10596
}
106-
107-
public Constructor getCons(){
108-
return avaCons;
109-
}
110-
11197
}

test/lib/jdk/test/lib/net/SimpleSSLContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -48,8 +48,7 @@ public SimpleSSLContext() throws IOException {
4848
}
4949

5050
private SimpleSSLContext(Supplier<String> protocols) throws IOException {
51-
final String proto = protocols.get();
52-
51+
String proto = protocols.get();
5352
String paths = System.getProperty("test.src.path");
5453
StringTokenizer st = new StringTokenizer(paths, File.pathSeparator);
5554
while (st.hasMoreTokens()) {
@@ -58,6 +57,7 @@ private SimpleSSLContext(Supplier<String> protocols) throws IOException {
5857
if (f.exists()) {
5958
try (FileInputStream fis = new FileInputStream(f)) {
6059
init(fis, proto);
60+
break;
6161
}
6262
}
6363
}

0 commit comments

Comments
 (0)