fix bad debugv({}) in favor of more tolerant debugf(%s)

Closes #31368

Signed-off-by: Diego Ramp <diego.ramp@mobi.ch>
This commit is contained in:
Diego Ramp 2024-07-17 08:04:54 +02:00 committed by Marek Posolda
parent 3110bb8989
commit ae74d923d2
14 changed files with 28 additions and 28 deletions

View file

@ -39,7 +39,7 @@ public class AggregatePolicyProvider implements PolicyProvider {
@Override
public void evaluate(Evaluation evaluation) {
logger.debugv("Aggregate policy {} evaluating using parent class", evaluation.getPolicy().getName());
logger.debugf("Aggregate policy %s evaluating using parent class", evaluation.getPolicy().getName());
DecisionResultCollector decision = new DecisionResultCollector() {
@Override
protected void onComplete(Result result) {

View file

@ -33,7 +33,7 @@ public class ClientPolicyProvider implements PolicyProvider {
if (context.getAttributes().containsValue("kc.client.id", clientModel.getClientId())) {
evaluation.grant();
logger.debugv("Client policy {} matched with client {} and was granted", evaluation.getPolicy().getName(), clientModel.getClientId());
logger.debugf("Client policy %s matched with client %s and was granted", evaluation.getPolicy().getName(), clientModel.getClientId());
return;
}
}

View file

@ -70,7 +70,7 @@ public class ClientScopePolicyProvider implements PolicyProvider {
}
}
}
logger.debugv("Client Scope Policy {} evaluated to {}", policy.getName(), evaluation.getEffect());
logger.debugf("Client Scope Policy %s evaluated to %s", policy.getName(), evaluation.getEffect());
}
private boolean hasClientScope(Identity identity, ClientScopeModel clientScope) {

View file

@ -81,7 +81,7 @@ public class GroupPolicyProvider implements PolicyProvider {
}
}
}
logger.debugv("Groups policy {} evaluated to {} with identity groups {}", policy.getName(), evaluation.getEffect(), groupsClaim);
logger.debugf("Groups policy %s evaluated to %s with identity groups %s", policy.getName(), evaluation.getEffect(), groupsClaim);
}
@Override

View file

@ -54,7 +54,7 @@ class JSPolicyProvider implements PolicyProvider {
context.setAttribute("$evaluation", evaluation, ScriptContext.ENGINE_SCOPE);
adapter.eval(context);
logger.debugv("JS Policy {} evaluated to status {}", policy.getName(), evaluation.getEffect());
logger.debugf("JS Policy %s evaluated to status %s", policy.getName(), evaluation.getEffect());
}
catch (Exception e) {
throw new RuntimeException("Error evaluating JS Policy [" + policy.getName() + "].", e);

View file

@ -54,11 +54,11 @@ public abstract class AbstractPermissionProvider implements PolicyProvider {
if (effect == null) {
PolicyProvider policyProvider = authorization.getProvider(associatedPolicy.getType());
if (policyProvider == null) {
throw new RuntimeException("No policy provider found for policy [" + associatedPolicy.getType() + "]");
}
policyProvider.evaluate(defaultEvaluation);
evaluation.denyIfNoEffect();
decisions.put(permission, defaultEvaluation.getEffect());
@ -66,7 +66,7 @@ public abstract class AbstractPermissionProvider implements PolicyProvider {
defaultEvaluation.setEffect(effect);
}
}
logger.debugv("Policy {} was evaluated with status {} in {} mode after processing {} associated policies: {}", policy.getName(), evaluation.getEffect(), policy.getDecisionStrategy(), policy.getAssociatedPolicies().size(), policy.getAssociatedPolicies());
logger.debugf("Policy %s was evaluated with status %s in %s mode after processing %s associated policies: %s", policy.getName(), evaluation.getEffect(), policy.getDecisionStrategy(), policy.getAssociatedPolicies().size(), policy.getAssociatedPolicies());
}
@Override

View file

@ -35,7 +35,7 @@ public class ResourcePolicyProvider extends AbstractPermissionProvider {
@Override
public void evaluate(Evaluation evaluation) {
logger.debugv("Resource policy {} evaluating using parent class", evaluation.getPolicy().getName());
logger.debugf("Resource policy %s evaluating using parent class", evaluation.getPolicy().getName());
DefaultEvaluation defaultEvaluation = DefaultEvaluation.class.cast(evaluation);
Map<Policy, Map<Object, Decision.Effect>> decisionCache = defaultEvaluation.getDecisionCache();
Policy policy = defaultEvaluation.getParentPolicy();

View file

@ -35,7 +35,7 @@ public class ScopePolicyProvider extends AbstractPermissionProvider {
@Override
public void evaluate(Evaluation evaluation) {
logger.debugv("Scope policy {} evaluating using parent class", evaluation.getPolicy().getName());
logger.debugf("Scope policy %s evaluating using parent class", evaluation.getPolicy().getName());
DefaultEvaluation defaultEvaluation = DefaultEvaluation.class.cast(evaluation);
Map<Policy, Map<Object, Decision.Effect>> decisionCache = defaultEvaluation.getDecisionCache();
Policy policy = defaultEvaluation.getParentPolicy();

View file

@ -31,7 +31,7 @@ public class UMAPolicyProvider extends AbstractPermissionProvider {
@Override
public void evaluate(Evaluation evaluation) {
logger.debugv("UMA policy {} evaluating using parent class", evaluation.getPolicy().getName());
logger.debugf("UMA policy %s evaluating using parent class", evaluation.getPolicy().getName());
ResourcePermission permission = evaluation.getPermission();
Resource resource = permission.getResource();

View file

@ -68,7 +68,7 @@ public class RegexPolicyProvider implements PolicyProvider {
Matcher matcher = pattern.matcher(value);
if (matcher.matches()) {
evaluation.grant();
logger.debugv("policy {} evaluated with status {} on identity {} and claim value {}", policy.getName(), evaluation.getEffect(), evaluation.getContext().getIdentity().getId(), getClaimValue(evaluation, policy));
logger.debugf("policy %s evaluated with status %s on identity %s and claim value %s", policy.getName(), evaluation.getEffect(), evaluation.getContext().getIdentity().getId(), getClaimValue(evaluation, policy));
}
}

View file

@ -72,7 +72,7 @@ public class RolePolicyProvider implements PolicyProvider {
}
}
}
logger.debugv("policy {} evaluated with status {} on identity {}", policy.getName(), evaluation.getEffect(), identity.getId());
logger.debugf("policy %s evaluated with status %s on identity %s", policy.getName(), evaluation.getEffect(), identity.getId());
}
private boolean hasRole(Identity identity, RoleModel role, RealmModel realm, AuthorizationProvider authorizationProvider, boolean fetchRoles) {

View file

@ -43,7 +43,7 @@ public class TimePolicyProvider implements PolicyProvider {
public void evaluate(Evaluation evaluation) {
Policy policy = evaluation.getPolicy();
SimpleDateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_PATTERN);
logger.debugv("Time policy {} evaluating", policy.getName());
logger.debugf("Time policy %s evaluating", policy.getName());
try {
String contextTime = null;
EvaluationContext context = evaluation.getContext();
@ -67,7 +67,7 @@ public class TimePolicyProvider implements PolicyProvider {
String notOnOrAfter = policy.getConfig().get("noa");
if (notOnOrAfter != null && !"".equals(notOnOrAfter)) {
if (actualDate.after(dateFormat.parse(format(notOnOrAfter)))) {
logger.debugv("Provided date is after the accepted date: (noa) {}", notOnOrAfter);
logger.debugf("Provided date is after the accepted date: (noa) %s", notOnOrAfter);
evaluation.deny();
return;
}
@ -78,7 +78,7 @@ public class TimePolicyProvider implements PolicyProvider {
|| isInvalid(actualDate, Calendar.YEAR, "year", policy)
|| isInvalid(actualDate, Calendar.HOUR_OF_DAY, "hour", policy)
|| isInvalid(actualDate, Calendar.MINUTE, "minute", policy)) {
logger.debugv("Invalid date provided to time policy {}", policy.getName());
logger.debugf("Invalid date provided to time policy %s", policy.getName());
evaluation.deny();
return;
}

View file

@ -51,7 +51,7 @@ public class UserPolicyProvider implements PolicyProvider {
break;
}
}
logger.debugv("User policy {} evaluated to status {} on identity {} with accepted users: {}", evaluation.getPolicy().getName(), evaluation.getEffect(), evaluation.getContext().getIdentity().getId(), representation.getUsers());
logger.debugf("User policy %s evaluated to status %s on identity %s with accepted users: %s", evaluation.getPolicy().getName(), evaluation.getEffect(), evaluation.getContext().getIdentity().getId(), representation.getUsers());
}
@Override

View file

@ -253,12 +253,12 @@ public class AuthenticationManagementResource {
if (realm.getFlowByAlias(flow.getAlias()) != null) {
throw ErrorResponse.exists("Flow " + flow.getAlias() + " already exists");
}
//adding an empty string to avoid NPE
if(Objects.isNull(flow.getDescription())) {
flow.setDescription("");
}
ReservedCharValidator.validate(flow.getAlias());
AuthenticationFlowModel createdModel = realm.addAuthenticationFlow(RepresentationToModel.toModel(flow));
@ -503,7 +503,7 @@ public class AuthenticationManagementResource {
String type = (String) data.get("type");
String provider = (String) data.get("provider");
int priority = data.containsKey("priority") ? (Integer) data.get("priority") : getNextPriority(parentFlow);
//Make sure that the description to avoid NullPointerException
String description = Objects.isNull(data.get("description")) ? "" : (String) data.get("description");
@ -795,17 +795,17 @@ public class AuthenticationManagementResource {
if (!checkFlow.getAlias().equals(rep.getDisplayName())) {
checkFlow.setAlias(rep.getDisplayName());
}
// check if description is null and set an empty String to avoid NPE
if (Objects.isNull(checkFlow.getDescription())) {
checkFlow.setDescription("");
}
// check if the description changed
if (!checkFlow.getDescription().equals(rep.getDescription())) {
checkFlow.setDescription(rep.getDescription());
}
//update the flow
realm.updateAuthenticationFlow(checkFlow);
adminEvent.operation(OperationType.UPDATE).resource(ResourceType.AUTH_EXECUTION).resourcePath(session.getContext().getUri()).representation(rep).success();
@ -828,7 +828,7 @@ public class AuthenticationManagementResource {
final Optional<AuthenticationExecutionModel> model = Optional.ofNullable(realm.getAuthenticationExecutionById(executionId));
if (!model.isPresent()) {
logger.debugv("Could not find execution by Id: {}", executionId);
logger.debugf("Could not find execution by Id: %s", executionId);
throw new NotFoundException("Illegal execution");
}
@ -1020,7 +1020,7 @@ public class AuthenticationManagementResource {
@APIResponse(responseCode = "201", description = "Created")
public Response newExecutionConfig(@Parameter(description = "Execution id") @PathParam("executionId") String execution, @Parameter(description = "JSON with new configuration") AuthenticatorConfigRepresentation json) {
auth.realm().requireManageRealm();
ReservedCharValidator.validate(json.getAlias());
AuthenticationExecutionModel model = realm.getAuthenticationExecutionById(execution);
@ -1137,7 +1137,7 @@ public class AuthenticationManagementResource {
return actions.isEmpty() ? 0 : actions.get(actions.size() - 1).getPriority() + 1;
}
/**
* Get required actions
*
@ -1526,7 +1526,7 @@ public class AuthenticationManagementResource {
auth.realm().requireManageRealm();
ReservedCharValidator.validate(rep.getAlias());
AuthenticatorConfigModel config = realm.addAuthenticatorConfig(RepresentationToModel.toModel(rep));
adminEvent.operation(OperationType.CREATE).resource(ResourceType.AUTHENTICATOR_CONFIG).resourcePath(session.getContext().getUri(), config.getId()).representation(rep).success();
return Response.created(session.getContext().getUri().getAbsolutePathBuilder().path(config.getId()).build()).build();
@ -1608,7 +1608,7 @@ public class AuthenticationManagementResource {
if (exists == null) {
throw new NotFoundException("Could not find authenticator config");
}
exists.setAlias(rep.getAlias());
exists.setConfig(RepresentationToModel.removeEmptyString(rep.getConfig()));
realm.updateAuthenticatorConfig(exists);