@@ -1332,6 +1332,48 @@ private void updateProviders(String profileExtensionId, List<String> allInfo) {
13321332 }
13331333 }
13341334
1335+ private String getExistingValue (String property ) {
1336+ if (debug != null ) {
1337+ debug .println ("\t Getting previous value of property: " + property );
1338+ }
1339+
1340+ // Look for values from profiles that this one extends.
1341+ String existingValue = profileProperties .get (property );
1342+ String debugMessage = "\t \t Previous value from extended profile: " ;
1343+
1344+ // If there is no value, look for non-profile values in java.security file.
1345+ if (existingValue == null ) {
1346+ debugMessage = "\t \t Previous value from java.security file: " ;
1347+ String propertyKey ;
1348+ switch (property ) {
1349+ case "jdkCertpathDisabledAlgorithms" :
1350+ propertyKey = "jdk.certpath.disabledAlgorithms" ;
1351+ break ;
1352+ case "jdkSecurityLegacyAlgorithms" :
1353+ propertyKey = "jdk.security.legacyAlgorithms" ;
1354+ break ;
1355+ case "jdkTlsDisabledAlgorithms" :
1356+ propertyKey = "jdk.tls.disabledAlgorithms" ;
1357+ break ;
1358+ case "jdkTlsDisabledNamedCurves" :
1359+ propertyKey = "jdk.tls.disabledNamedCurves" ;
1360+ break ;
1361+ case "jdkTlsLegacyAlgorithms" :
1362+ propertyKey = "jdk.tls.legacyAlgorithms" ;
1363+ break ;
1364+ default :
1365+ return null ;
1366+ }
1367+ existingValue = securityProps .getProperty (propertyKey );
1368+ }
1369+
1370+ if ((debug != null ) && (existingValue != null )) {
1371+ debug .println (debugMessage + existingValue );
1372+ }
1373+
1374+ return existingValue ;
1375+ }
1376+
13351377 /**
13361378 * Load restricted security properties.
13371379 */
@@ -1603,7 +1645,7 @@ private boolean setProperty(String property, String propertyKey, List<String> al
16031645 allInfo .add (propertyKey + "=" + value );
16041646
16051647 // Check if property overrides, adds to or removes from previous value.
1606- String existingValue = profileProperties . get (property );
1648+ String existingValue = getExistingValue (property );
16071649 if (value .startsWith ("+" )) {
16081650 if (!isPropertyAppendable (property )) {
16091651 printStackTraceAndExit ("Property '" + property + "' is not appendable." );
@@ -1613,7 +1655,8 @@ private boolean setProperty(String property, String propertyKey, List<String> al
16131655
16141656 // Take existing value of property into account, if applicable.
16151657 if (existingValue == null ) {
1616- printStackTraceAndExit ("Property '" + property + "' does not exist in parent profile. Cannot append." );
1658+ printStackTraceAndExit ("Property '" + property + "' does not exist in"
1659+ + " parent profile or java.security file. Cannot append." );
16171660 } else if (existingValue .isBlank ()) {
16181661 newValue = value ;
16191662 } else {
@@ -1627,6 +1670,10 @@ private boolean setProperty(String property, String propertyKey, List<String> al
16271670 // Remove values from property.
16281671 value = value .substring (1 ).trim ();
16291672 if (!value .isBlank ()) {
1673+ if (existingValue == null ) {
1674+ printStackTraceAndExit ("Property '" + property + "' does not exist in"
1675+ + " parent profile or java.security file. Cannot remove." );
1676+ }
16301677 List <String > existingValues = Stream .of (existingValue .split ("," ))
16311678 .map (v -> v .trim ())
16321679 .collect (Collectors .toList ());
@@ -1640,7 +1687,8 @@ private boolean setProperty(String property, String propertyKey, List<String> al
16401687 } else {
16411688 // Nothing to do. Use existing value of property into account, if available.
16421689 if (existingValue == null ) {
1643- printStackTraceAndExit ("Property '" + property + "' does not exist in parent profile. Cannot remove." );
1690+ printStackTraceAndExit ("Property '" + property + "' does not exist in"
1691+ + " parent profile or java.security file. Cannot remove." );
16441692 } else if (existingValue .isBlank ()) {
16451693 newValue = value ;
16461694 } else {
0 commit comments