Skip to content

Commit

Permalink
Error message update when profile name without version is not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
taoliult committed Nov 10, 2024
1 parent 052270e commit df71fc4
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,23 +344,29 @@ private static void getProfileID(Properties props) {
+ selectedProfile);
}
String defaultMatch = null;
Boolean profileExist = false;
for (Object keyObject : props.keySet()) {
if (keyObject instanceof String key) {
if (key.startsWith(potentialProfileID) && key.endsWith(".desc.default")) {
// Check if property is set to true.
if (Boolean.parseBoolean(props.getProperty(key))) {
// Check if multiple defaults exist and act accordingly.
if (defaultMatch == null) {
defaultMatch = key.split("\\.desc")[0];
} else {
printStackTraceAndExit("Multiple default RestrictedSecurity"
+ " profiles for " + selectedProfile);
if (key.startsWith(potentialProfileID)) {
profileExist = true;
if (key.endsWith(".desc.default")) {
// Check if property is set to true.
if (Boolean.parseBoolean(props.getProperty(key))) {
// Check if multiple defaults exist and act accordingly.
if (defaultMatch == null) {
defaultMatch = key.split("\\.desc")[0];
} else {
printStackTraceAndExit("Multiple default RestrictedSecurity"
+ " profiles for " + selectedProfile);
}
}
}
}
}
}
if (defaultMatch == null) {
if (!profileExist) {
printStackTraceAndExit(selectedProfile + " is not present in the java.security file.");
} else if (defaultMatch == null) {
printStackTraceAndExit("No default RestrictedSecurity profile was found for "
+ selectedProfile);
} else {
Expand Down

0 comments on commit df71fc4

Please sign in to comment.