Skip to content

Commit

Permalink
Initial changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
seanjmullan committed Jan 13, 2025
1 parent 27646e5 commit afd0bcb
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 129 deletions.

This file was deleted.

6 changes: 1 addition & 5 deletions test/jdk/java/security/cert/CertPathBuilder/GetInstance.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 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,11 +30,7 @@
* The test passes if it returns.
* The test fails if an exception is thrown.
*/
import java.security.cert.CertPathParameters;
import java.security.cert.CertPathBuilderResult;
import java.security.cert.CertPathBuilderSpi;
import java.security.Provider;
import java.security.AccessController;
import java.security.cert.CertPathBuilder;
import java.security.NoSuchAlgorithmException;

Expand Down
3 changes: 1 addition & 2 deletions test/jdk/sun/security/pkcs11/PKCS11Test.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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 @@ -37,7 +37,6 @@
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyPairGenerator;
import java.security.NoSuchProviderException;
import java.security.Policy;
import java.security.Provider;
import java.security.ProviderException;
import java.security.SecureRandom;
Expand Down
7 changes: 2 additions & 5 deletions test/jdk/sun/security/tools/jarsigner/CertChainUnclosed.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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,15 +32,12 @@

import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Locale;

public class CertChainUnclosed {

public static void main(String[] args) throws Exception {
String os = AccessController.doPrivileged(
(PrivilegedAction<String>)() -> System.getProperty("os.name"));
String os = System.getProperty("os.name");
if (!os.toUpperCase(Locale.US).contains("WINDOWS")) {
System.out.println("Not Windows. Skip test.");
return;
Expand Down
28 changes: 7 additions & 21 deletions test/jdk/sun/security/x509/AVA/AVAEqualsHashCode.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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 @@ -49,9 +49,7 @@ public static void main(String[] args) throws Exception {
byte[] ba = deros.toByteArray();
DerValue dv = new DerValue(ba);

GetAVAConstructor a = new GetAVAConstructor();
java.security.AccessController.doPrivileged(a);
Constructor c = a.getCons();
Constructor c = getAVAConstructor();

Object[] objs = new Object[2];
objs[0] = oid;
Expand All @@ -72,16 +70,10 @@ public static void main(String[] args) throws Exception {
else
throw new Exception("FAILED equals()/hashCode() contract");
}
}

class GetAVAConstructor implements java.security.PrivilegedExceptionAction {

private Class avaClass = null;
private Constructor avaCons = null;

public Object run() throws Exception {
static Constructor getAVAConstructor() throws Exception {
try {
avaClass = Class.forName("sun.security.x509.AVA");
Class avaClass = Class.forName("sun.security.x509.AVA");
Constructor[] cons = avaClass.getDeclaredConstructors();

int i;
Expand All @@ -90,22 +82,16 @@ public Object run() throws Exception {
if (parms.length == 2) {
if (parms[0].getName().equalsIgnoreCase("sun.security.util.ObjectIdentifier") &&
parms[1].getName().equalsIgnoreCase("sun.security.util.DerValue")) {
avaCons = cons[i];
Constructor avaCons = cons[i];
avaCons.setAccessible(true);
break;
return avaCons;
}
}
}

return null;
} catch (Exception e) {
System.out.println("Caught unexpected exception " + e);
throw e;
}
return avaCons;
}

public Constructor getCons(){
return avaCons;
}

}
59 changes: 12 additions & 47 deletions test/lib/jdk/test/lib/net/SimpleSSLContext.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, 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 @@ -34,13 +34,6 @@
* Creates a simple usable SSLContext for SSLSocketFactory
* or a HttpsServer using either a given keystore or a default
* one in the test tree.
*
* Using this class with a security manager requires the following
* permissions to be granted:
*
* permission "java.util.PropertyPermission" "test.src.path", "read";
* permission java.io.FilePermission "/path/to/test/lib/jdk/test/lib/testkeys", "read";
* The exact path above depends on the location of the test.
*/
public class SimpleSSLContext {

Expand All @@ -54,47 +47,19 @@ public SimpleSSLContext() throws IOException {
this(() -> "TLS");
}

@SuppressWarnings("removal")
private SimpleSSLContext(Supplier<String> protocols) throws IOException {
try {
final String proto = protocols.get();
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
String paths = System.getProperty("test.src.path");
StringTokenizer st = new StringTokenizer(paths, File.pathSeparator);
boolean securityExceptions = false;
while (st.hasMoreTokens()) {
String path = st.nextToken();
try {
File f = new File(path, "jdk/test/lib/net/testkeys");
if (f.exists()) {
try (FileInputStream fis = new FileInputStream(f)) {
init(fis, proto);
return null;
}
}
} catch (SecurityException e) {
// catch and ignore because permission only required
// for one entry on path (at most)
securityExceptions = true;
}
}
if (securityExceptions) {
System.err.println("SecurityExceptions thrown on loading testkeys");
}
return null;
String proto = protocols.get();
String paths = System.getProperty("test.src.path");
StringTokenizer st = new StringTokenizer(paths, File.pathSeparator);
while (st.hasMoreTokens()) {
String path = st.nextToken();
File f = new File(path, "jdk/test/lib/net/testkeys");
if (f.exists()) {
try (FileInputStream fis = new FileInputStream(f)) {
init(fis, proto);
break;
}
});
} catch (PrivilegedActionException pae) {
Throwable t = pae.getCause() != null ? pae.getCause() : pae;
if (t instanceof IOException)
throw (IOException)t;
if (t instanceof RuntimeException)
throw (RuntimeException)t;
if (t instanceof Error)
throw (Error)t;
throw new RuntimeException(t);
}
}
}

Expand Down

0 comments on commit afd0bcb

Please sign in to comment.