Skip to content

Commit

Permalink
update according to code review
Browse files Browse the repository at this point in the history
  • Loading branch information
taoliult committed Sep 23, 2024
1 parent 4f7e6ea commit da716ff
Showing 1 changed file with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -995,8 +994,8 @@ private static final class ProfileParser {
// The java.security properties.
private final Properties securityProps;

private LinkedList<String> profileCheckPropertyNames;
private LinkedList<String> profileCheckProviderNames;
private final Set<String> profileCheckPropertyNames;
private final Set<String> profileCheckProviderNames;

/**
*
Expand All @@ -1020,8 +1019,8 @@ private ProfileParser(String id, Properties props) {

parsedProfiles = new HashSet<>();

profileCheckPropertyNames = new LinkedList<>();
profileCheckProviderNames = new LinkedList<>();
profileCheckPropertyNames = new HashSet<>();
profileCheckProviderNames = new HashSet<>();

// Initialize the properties.
init(profileID);
Expand Down Expand Up @@ -1051,13 +1050,14 @@ private void init(String profileID) {

loadProfileCheck(profileID);

String potentialExtendsProfileID = parseProperty(securityProps.getProperty(profileID + ".extends"));
String profileExtendsKeyword = profileID + ".extends";
String potentialExtendsProfileID = parseProperty(securityProps.getProperty(profileExtendsKeyword));
if (potentialExtendsProfileID != null) { // If profile extends another profile.
if (debug != null) {
debug.println("\t'" + profileID + "' extends '" + potentialExtendsProfileID + "'.");
}

profileCheckPropertyNames.remove(profileID + ".extends");
profileCheckPropertyNames.remove(profileExtendsKeyword);

// Check if extended profile exists.
String extendsProfileID = null;
Expand Down Expand Up @@ -1730,25 +1730,27 @@ private void loadProfileCheck(String profileID) {
Enumeration<?> pNames = securityProps.propertyNames();
while (pNames.hasMoreElements()) {
String name = (String) pNames.nextElement();
if (name.startsWith(profileID + '.') && name.contains(".jce.provider.")) {
profileCheckProviderNames.add(name);
} else if (name.startsWith(profileID + '.')) {
profileCheckPropertyNames.add(name);
if (name.startsWith(profileID + '.')) {
if (name.contains(".jce.provider.")) {
profileCheckProviderNames.add(name);
} else {
profileCheckPropertyNames.add(name);
}
}
}
}

private void checkProfileCheck(String profileID) {
if (!profileCheckProviderNames.isEmpty()) {
printStackTraceAndExit(
"The order of providers in profile " + profileID
+ " (or its base profile) is incorrect.");
"The order numbers of providers in profile " + profileID
+ " (or its base profile) are not consecutive.");
}
if (!profileCheckPropertyNames.isEmpty()) {
printStackTraceAndExit(
"The property name: " + profileCheckPropertyNames.toString()
"One or more property names: " + profileCheckPropertyNames.toString()
+ " in profile " + profileID
+ " may be misspelled.");
+ " are misspelled.");
}
}
}
Expand Down

0 comments on commit da716ff

Please sign in to comment.