Skip to content

Commit

Permalink
Simplify logic of getting value of OIDC field
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-walkiewicz authored and kokosing committed Aug 11, 2022
1 parent 4a1db4e commit 3fdb2ae
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,23 @@ private static URI getRequiredField(String metadataField, URI metadataValue, Str

private static Optional<String> getOptionalField(String metadataField, Optional<String> metadataValue, String configurationField, Optional<String> configurationValue)
{
if (configurationValue.isPresent()) {
if (!configurationValue.equals(metadataValue)) {
LOG.warn("Overriding \"%s=%s\" from OpenID metadata document with value \"%s=%s\" defined in configuration",
metadataField, metadataValue.orElse(""), configurationField, configurationValue.orElse(""));
} else {
LOG.warn("Provided redundant configuration property \"%s\" with the same value as \"%s\" field in OpenID metadata document");
}
if (configurationValue.isEmpty()) {
return metadataValue;
}

if (metadataValue.isEmpty()) {
return configurationValue;
}
return metadataValue;

if (!configurationValue.equals(metadataValue)) {
LOG.warn("Overriding \"%s=%s\" from OpenID metadata document with value \"%s=%s\" defined in configuration",
metadataField, metadataValue.orElse(""), configurationField, configurationValue.orElse(""));
}
else {
LOG.warn("Provided redundant configuration property \"%s\" with the same value as \"%s\" field in OpenID metadata document",
configurationField, metadataField);
}
return configurationValue;
}

private static void checkMetadataState(boolean expression, String additionalMessage, String... additionalMessageArgs)
Expand Down

0 comments on commit 3fdb2ae

Please sign in to comment.