Skip to content

Commit 5a9311c

Browse files
Allow multiple constraints for each algorithm
If a constraint for an algorithm is found and the attributes don't match or the class attempting to utilize it doesn't match the accepted uses, the algorithm is considered not allowed and loading it does not succeed. Instead, we want to check all available constraints for an algorithm before deciding if it is allowed to be used or not. Signed-off-by: Kostas Tsiounis <[email protected]>
1 parent 1a0cc53 commit 5a9311c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Diff for: closed/src/java.base/share/classes/openj9/internal/security/RestrictedSecurity.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ boolean isRestrictedServiceAllowed(Service service, boolean checkUse) {
789789
if (debug != null) {
790790
debug.println("Security constraints check of provider.");
791791
}
792+
constraints:
792793
for (Constraint constraint : constraints) {
793794
String cType = constraint.type;
794795
String cAlgorithm = constraint.algorithm;
@@ -807,14 +808,14 @@ boolean isRestrictedServiceAllowed(Service service, boolean checkUse) {
807808
if (debug != null) {
808809
debug.println("The constraint doesn't apply to the service type.");
809810
}
810-
continue;
811+
continue constraints;
811812
}
812813
if (!isAsterisk(cAlgorithm) && !algorithm.equalsIgnoreCase(cAlgorithm)) {
813814
// The constraint doesn't apply to the service algorithm.
814815
if (debug != null) {
815816
debug.println("The constraint doesn't apply to the service algorithm.");
816817
}
817-
continue;
818+
continue constraints;
818819
}
819820

820821
// For type and algorithm match, and attribute is not *.
@@ -836,7 +837,8 @@ boolean isRestrictedServiceAllowed(Service service, boolean checkUse) {
836837
+ "\nagainst the service attribute value: " + sValue);
837838
}
838839
if ((sValue == null) || !cValue.equalsIgnoreCase(sValue)) {
839-
// If any attribute doesn't match, return service is not allowed.
840+
// If any of the attributes don't match,
841+
// then this constraint doesn't match so move on.
840842
if (debug != null) {
841843
debug.println("Attributes don't match!");
842844
debug.println("The following service:"
@@ -845,7 +847,7 @@ boolean isRestrictedServiceAllowed(Service service, boolean checkUse) {
845847
+ "\n\tAttribute: " + cAttribute
846848
+ "\nis NOT allowed in provider: " + providerClassName);
847849
}
848-
return false;
850+
continue constraints;
849851
}
850852
if (debug != null) {
851853
debug.println("Attributes match!");
@@ -903,7 +905,7 @@ boolean isRestrictedServiceAllowed(Service service, boolean checkUse) {
903905
}
904906

905907
// If nothing matching the accepted uses is found in the call stack,
906-
// this service is not allowed.
908+
// then this constraint doesn't match so move on.
907909
if (!found) {
908910
if (debug != null) {
909911
debug.println("Classes in call stack are not part of accepted uses!");
@@ -914,7 +916,7 @@ boolean isRestrictedServiceAllowed(Service service, boolean checkUse) {
914916
+ "\n\tAccepted uses: " + cAcceptedUses
915917
+ "\nis NOT allowed in provider: " + providerClassName);
916918
}
917-
return false;
919+
continue constraints;
918920
}
919921
}
920922

0 commit comments

Comments
 (0)