diff --git a/closed/src/java.base/share/classes/openj9/internal/security/RestrictedSecurity.java b/closed/src/java.base/share/classes/openj9/internal/security/RestrictedSecurity.java index eda8eb2b476..7c104df2410 100644 --- a/closed/src/java.base/share/classes/openj9/internal/security/RestrictedSecurity.java +++ b/closed/src/java.base/share/classes/openj9/internal/security/RestrictedSecurity.java @@ -347,7 +347,7 @@ private static void getProfileID(Properties props) { boolean profileExists = false; for (Object keyObject : props.keySet()) { if (keyObject instanceof String key) { - if (key.startsWith(potentialProfileID)) { + if (key.startsWith(potentialProfileID + '.')) { profileExists = true; if (key.endsWith(".desc.default")) { // Check if property is set to true. diff --git a/closed/test/jdk/openj9/internal/security/TestProperties.java b/closed/test/jdk/openj9/internal/security/TestProperties.java index c3bfc89e88b..9e16f1b78d4 100644 --- a/closed/test/jdk/openj9/internal/security/TestProperties.java +++ b/closed/test/jdk/openj9/internal/security/TestProperties.java @@ -43,6 +43,15 @@ public class TestProperties { + private static Stream patternMatches_expectedExitValue0() { + return Stream.of( + // 1 - Test property - Same beginnings of the profile name without version + Arguments.of("Test-Profile-SameStartWithoutVersion", + System.getProperty("test.src") + "/property-java.security", + "(?s)(?=.*Sun)(?=.*\\bSunJCE\\b)(?=.*SunJSSE)") + ); + } + private static Stream patternMatches_expectedExitValue1() { return Stream.of( // 1 - Test profile - base profile misspell properties. @@ -155,6 +164,19 @@ private static Stream patternMatches_expectedExitValue1() { ); } + @ParameterizedTest + @MethodSource("patternMatches_expectedExitValue0") + public void shouldContain_expectedExitValue0(String customprofile, String securityPropertyFile, String expected) throws Exception { + OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava( + "-Dsemeru.fips=true", + "-Dsemeru.customprofile=" + customprofile, + "-Djava.security.properties=" + securityPropertyFile, + "TestProviders" + ); + outputAnalyzer.reportDiagnosticSummary(); + outputAnalyzer.shouldHaveExitValue(0).shouldMatch(expected); + } + @ParameterizedTest @MethodSource("patternMatches_expectedExitValue1") public void shouldContain_expectedExitValue1(String customprofile, String securityPropertyFile, String expected) throws Exception { diff --git a/closed/test/jdk/openj9/internal/security/property-java.security b/closed/test/jdk/openj9/internal/security/property-java.security index 490d33e1594..4e84d4299af 100644 --- a/closed/test/jdk/openj9/internal/security/property-java.security +++ b/closed/test/jdk/openj9/internal/security/property-java.security @@ -525,3 +525,39 @@ RestrictedSecurity.Test-Profile-ConstraintChanged_3.Base.jce.provider.1 = com.s RestrictedSecurity.Test-Profile-ConstraintChanged_3.Base.securerandom.provider = OpenJCEPlusFIPS RestrictedSecurity.Test-Profile-ConstraintChanged_3.Base.securerandom.algorithm = SHA512DRBG + +# +# Test-Profile-SameStartWithoutVersion +# Test property - Same beginnings of the profile name without version +# +RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.name = Test-Profile-SameStartWithoutVersion +RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.default = true +RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.fips = true +RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.hash = SHA256:2c893d75043da09c3dba8d8b24cb71dc1c7ceac5fb8bf362a35847418a933a06 +RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.number = Certificate #XXX +RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.policy = https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/ +RestrictedSecurity.Test-Profile-SameStartWithoutVersion.desc.sunsetDate = 2026-09-21 +RestrictedSecurity.Test-Profile-SameStartWithoutVersion.fips.mode = 140-3 + +RestrictedSecurity.Test-Profile-SameStartWithoutVersion.jce.provider.1 = sun.security.provider.Sun +RestrictedSecurity.Test-Profile-SameStartWithoutVersion.jce.provider.2 = com.sun.crypto.provider.SunJCE +RestrictedSecurity.Test-Profile-SameStartWithoutVersion.jce.provider.3 = sun.security.ssl.SunJSSE + +RestrictedSecurity.Test-Profile-SameStartWithoutVersion.securerandom.provider = OpenJCEPlusFIPS +RestrictedSecurity.Test-Profile-SameStartWithoutVersion.securerandom.algorithm = SHA512DRBG + +RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.desc.name = Test-Profile-SameStartWithoutVersionPart +RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.desc.default = true +RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.desc.fips = true +RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.desc.hash = SHA256:2c893d75043da09c3dba8d8b24cb71dc1c7ceac5fb8bf362a35847418a933a06 +RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.desc.number = Certificate #XXX +RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.desc.policy = https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/ +RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.desc.sunsetDate = 2026-09-21 +RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.fips.mode = 140-3 + +RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.jce.provider.1 = sun.security.provider.Sun +RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.jce.provider.2 = com.sun.crypto.provider.SunJCE +RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.jce.provider.3 = sun.security.ssl.SunJSSE + +RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.securerandom.provider = OpenJCEPlusFIPS +RestrictedSecurity.Test-Profile-SameStartWithoutVersionPart.securerandom.algorithm = SHA512DRBG