@@ -1332,6 +1332,48 @@ private void updateProviders(String profileExtensionId, List<String> allInfo) {
1332
1332
}
1333
1333
}
1334
1334
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
+
1335
1377
/**
1336
1378
* Load restricted security properties.
1337
1379
*/
@@ -1603,7 +1645,7 @@ private boolean setProperty(String property, String propertyKey, List<String> al
1603
1645
allInfo .add (propertyKey + "=" + value );
1604
1646
1605
1647
// Check if property overrides, adds to or removes from previous value.
1606
- String existingValue = profileProperties . get (property );
1648
+ String existingValue = getExistingValue (property );
1607
1649
if (value .startsWith ("+" )) {
1608
1650
if (!isPropertyAppendable (property )) {
1609
1651
printStackTraceAndExit ("Property '" + property + "' is not appendable." );
@@ -1613,7 +1655,8 @@ private boolean setProperty(String property, String propertyKey, List<String> al
1613
1655
1614
1656
// Take existing value of property into account, if applicable.
1615
1657
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." );
1617
1660
} else if (existingValue .isBlank ()) {
1618
1661
newValue = value ;
1619
1662
} else {
@@ -1627,6 +1670,10 @@ private boolean setProperty(String property, String propertyKey, List<String> al
1627
1670
// Remove values from property.
1628
1671
value = value .substring (1 ).trim ();
1629
1672
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
+ }
1630
1677
List <String > existingValues = Stream .of (existingValue .split ("," ))
1631
1678
.map (v -> v .trim ())
1632
1679
.collect (Collectors .toList ());
@@ -1640,7 +1687,8 @@ private boolean setProperty(String property, String propertyKey, List<String> al
1640
1687
} else {
1641
1688
// Nothing to do. Use existing value of property into account, if available.
1642
1689
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." );
1644
1692
} else if (existingValue .isBlank ()) {
1645
1693
newValue = value ;
1646
1694
} else {
0 commit comments