mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8292177: InitialSecurityProperty JFR event
Reviewed-by: mullan
This commit is contained in:
parent
e7a964b4db
commit
8c40b7dc8c
12 changed files with 393 additions and 145 deletions
|
@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.io.*;
|
||||
import java.net.URL;
|
||||
|
||||
import jdk.internal.access.JavaSecurityPropertiesAccess;
|
||||
import jdk.internal.event.EventHelper;
|
||||
import jdk.internal.event.SecurityPropertyModificationEvent;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
|
@ -63,6 +64,9 @@ public final class Security {
|
|||
/* The java.security properties */
|
||||
private static Properties props;
|
||||
|
||||
/* cache a copy for recording purposes */
|
||||
private static Properties initialSecurityProperties;
|
||||
|
||||
// An element in the cache
|
||||
private static class ProviderProperty {
|
||||
String className;
|
||||
|
@ -79,6 +83,13 @@ public final class Security {
|
|||
initialize();
|
||||
return null;
|
||||
});
|
||||
// Set up JavaSecurityPropertiesAccess in SharedSecrets
|
||||
SharedSecrets.setJavaSecurityPropertiesAccess(new JavaSecurityPropertiesAccess() {
|
||||
@Override
|
||||
public Properties getInitialProperties() {
|
||||
return initialSecurityProperties;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void initialize() {
|
||||
|
@ -104,6 +115,14 @@ public final class Security {
|
|||
}
|
||||
loadProps(null, extraPropFile, overrideAll);
|
||||
}
|
||||
initialSecurityProperties = (Properties) props.clone();
|
||||
if (sdebug != null) {
|
||||
for (String key : props.stringPropertyNames()) {
|
||||
sdebug.println("Initial security property: " + key + "=" +
|
||||
props.getProperty(key));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static boolean loadProps(File masterFile, String extraPropFile, boolean overrideAll) {
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk.internal.access;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public interface JavaSecurityPropertiesAccess {
|
||||
Properties getInitialProperties();
|
||||
}
|
|
@ -30,6 +30,7 @@ import javax.crypto.spec.SecretKeySpec;
|
|||
import java.io.ObjectInputFilter;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.module.ModuleDescriptor;
|
||||
import java.security.Security;
|
||||
import java.security.spec.EncodedKeySpec;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
|
@ -83,6 +84,7 @@ public class SharedSecrets {
|
|||
private static JavaUtilZipFileAccess javaUtilZipFileAccess;
|
||||
private static JavaUtilResourceBundleAccess javaUtilResourceBundleAccess;
|
||||
private static JavaSecurityAccess javaSecurityAccess;
|
||||
private static JavaSecurityPropertiesAccess javaSecurityPropertiesAccess;
|
||||
private static JavaSecuritySignatureAccess javaSecuritySignatureAccess;
|
||||
private static JavaSecuritySpecAccess javaSecuritySpecAccess;
|
||||
private static JavaxCryptoSealedObjectAccess javaxCryptoSealedObjectAccess;
|
||||
|
@ -343,6 +345,19 @@ public class SharedSecrets {
|
|||
return access;
|
||||
}
|
||||
|
||||
public static void setJavaSecurityPropertiesAccess(JavaSecurityPropertiesAccess jspa) {
|
||||
javaSecurityPropertiesAccess = jspa;
|
||||
}
|
||||
|
||||
public static JavaSecurityPropertiesAccess getJavaSecurityPropertiesAccess() {
|
||||
var access = javaSecurityPropertiesAccess;
|
||||
if (access == null) {
|
||||
ensureClassInitialized(Security.class);
|
||||
access = javaSecurityPropertiesAccess;
|
||||
}
|
||||
return access;
|
||||
}
|
||||
|
||||
public static JavaUtilZipFileAccess getJavaUtilZipFileAccess() {
|
||||
var access = javaUtilZipFileAccess;
|
||||
if (access == null) {
|
||||
|
|
|
@ -165,6 +165,7 @@ module java.base {
|
|||
jdk.charsets,
|
||||
jdk.jartool,
|
||||
jdk.jlink,
|
||||
jdk.jfr,
|
||||
jdk.net;
|
||||
exports jdk.internal.foreign to
|
||||
jdk.incubator.vector;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue