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:
parent
3110bb8989
commit
ae74d923d2
14 changed files with 28 additions and 28 deletions
|
@ -39,7 +39,7 @@ public class AggregatePolicyProvider implements PolicyProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(Evaluation evaluation) {
|
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() {
|
DecisionResultCollector decision = new DecisionResultCollector() {
|
||||||
@Override
|
@Override
|
||||||
protected void onComplete(Result result) {
|
protected void onComplete(Result result) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class ClientPolicyProvider implements PolicyProvider {
|
||||||
|
|
||||||
if (context.getAttributes().containsValue("kc.client.id", clientModel.getClientId())) {
|
if (context.getAttributes().containsValue("kc.client.id", clientModel.getClientId())) {
|
||||||
evaluation.grant();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
private boolean hasClientScope(Identity identity, ClientScopeModel clientScope) {
|
||||||
|
|
|
@ -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
|
@Override
|
||||||
|
|
|
@ -54,7 +54,7 @@ class JSPolicyProvider implements PolicyProvider {
|
||||||
context.setAttribute("$evaluation", evaluation, ScriptContext.ENGINE_SCOPE);
|
context.setAttribute("$evaluation", evaluation, ScriptContext.ENGINE_SCOPE);
|
||||||
|
|
||||||
adapter.eval(context);
|
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) {
|
catch (Exception e) {
|
||||||
throw new RuntimeException("Error evaluating JS Policy [" + policy.getName() + "].", e);
|
throw new RuntimeException("Error evaluating JS Policy [" + policy.getName() + "].", e);
|
||||||
|
|
|
@ -54,11 +54,11 @@ public abstract class AbstractPermissionProvider implements PolicyProvider {
|
||||||
|
|
||||||
if (effect == null) {
|
if (effect == null) {
|
||||||
PolicyProvider policyProvider = authorization.getProvider(associatedPolicy.getType());
|
PolicyProvider policyProvider = authorization.getProvider(associatedPolicy.getType());
|
||||||
|
|
||||||
if (policyProvider == null) {
|
if (policyProvider == null) {
|
||||||
throw new RuntimeException("No policy provider found for policy [" + associatedPolicy.getType() + "]");
|
throw new RuntimeException("No policy provider found for policy [" + associatedPolicy.getType() + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
policyProvider.evaluate(defaultEvaluation);
|
policyProvider.evaluate(defaultEvaluation);
|
||||||
evaluation.denyIfNoEffect();
|
evaluation.denyIfNoEffect();
|
||||||
decisions.put(permission, defaultEvaluation.getEffect());
|
decisions.put(permission, defaultEvaluation.getEffect());
|
||||||
|
@ -66,7 +66,7 @@ public abstract class AbstractPermissionProvider implements PolicyProvider {
|
||||||
defaultEvaluation.setEffect(effect);
|
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
|
@Override
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class ResourcePolicyProvider extends AbstractPermissionProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(Evaluation evaluation) {
|
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);
|
DefaultEvaluation defaultEvaluation = DefaultEvaluation.class.cast(evaluation);
|
||||||
Map<Policy, Map<Object, Decision.Effect>> decisionCache = defaultEvaluation.getDecisionCache();
|
Map<Policy, Map<Object, Decision.Effect>> decisionCache = defaultEvaluation.getDecisionCache();
|
||||||
Policy policy = defaultEvaluation.getParentPolicy();
|
Policy policy = defaultEvaluation.getParentPolicy();
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class ScopePolicyProvider extends AbstractPermissionProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(Evaluation evaluation) {
|
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);
|
DefaultEvaluation defaultEvaluation = DefaultEvaluation.class.cast(evaluation);
|
||||||
Map<Policy, Map<Object, Decision.Effect>> decisionCache = defaultEvaluation.getDecisionCache();
|
Map<Policy, Map<Object, Decision.Effect>> decisionCache = defaultEvaluation.getDecisionCache();
|
||||||
Policy policy = defaultEvaluation.getParentPolicy();
|
Policy policy = defaultEvaluation.getParentPolicy();
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class UMAPolicyProvider extends AbstractPermissionProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(Evaluation evaluation) {
|
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();
|
ResourcePermission permission = evaluation.getPermission();
|
||||||
Resource resource = permission.getResource();
|
Resource resource = permission.getResource();
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class RegexPolicyProvider implements PolicyProvider {
|
||||||
Matcher matcher = pattern.matcher(value);
|
Matcher matcher = pattern.matcher(value);
|
||||||
if (matcher.matches()) {
|
if (matcher.matches()) {
|
||||||
evaluation.grant();
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
private boolean hasRole(Identity identity, RoleModel role, RealmModel realm, AuthorizationProvider authorizationProvider, boolean fetchRoles) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class TimePolicyProvider implements PolicyProvider {
|
||||||
public void evaluate(Evaluation evaluation) {
|
public void evaluate(Evaluation evaluation) {
|
||||||
Policy policy = evaluation.getPolicy();
|
Policy policy = evaluation.getPolicy();
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_PATTERN);
|
SimpleDateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_PATTERN);
|
||||||
logger.debugv("Time policy {} evaluating", policy.getName());
|
logger.debugf("Time policy %s evaluating", policy.getName());
|
||||||
try {
|
try {
|
||||||
String contextTime = null;
|
String contextTime = null;
|
||||||
EvaluationContext context = evaluation.getContext();
|
EvaluationContext context = evaluation.getContext();
|
||||||
|
@ -67,7 +67,7 @@ public class TimePolicyProvider implements PolicyProvider {
|
||||||
String notOnOrAfter = policy.getConfig().get("noa");
|
String notOnOrAfter = policy.getConfig().get("noa");
|
||||||
if (notOnOrAfter != null && !"".equals(notOnOrAfter)) {
|
if (notOnOrAfter != null && !"".equals(notOnOrAfter)) {
|
||||||
if (actualDate.after(dateFormat.parse(format(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();
|
evaluation.deny();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public class TimePolicyProvider implements PolicyProvider {
|
||||||
|| isInvalid(actualDate, Calendar.YEAR, "year", policy)
|
|| isInvalid(actualDate, Calendar.YEAR, "year", policy)
|
||||||
|| isInvalid(actualDate, Calendar.HOUR_OF_DAY, "hour", policy)
|
|| isInvalid(actualDate, Calendar.HOUR_OF_DAY, "hour", policy)
|
||||||
|| isInvalid(actualDate, Calendar.MINUTE, "minute", 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();
|
evaluation.deny();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class UserPolicyProvider implements PolicyProvider {
|
||||||
break;
|
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
|
@Override
|
||||||
|
|
|
@ -253,12 +253,12 @@ public class AuthenticationManagementResource {
|
||||||
if (realm.getFlowByAlias(flow.getAlias()) != null) {
|
if (realm.getFlowByAlias(flow.getAlias()) != null) {
|
||||||
throw ErrorResponse.exists("Flow " + flow.getAlias() + " already exists");
|
throw ErrorResponse.exists("Flow " + flow.getAlias() + " already exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
//adding an empty string to avoid NPE
|
//adding an empty string to avoid NPE
|
||||||
if(Objects.isNull(flow.getDescription())) {
|
if(Objects.isNull(flow.getDescription())) {
|
||||||
flow.setDescription("");
|
flow.setDescription("");
|
||||||
}
|
}
|
||||||
|
|
||||||
ReservedCharValidator.validate(flow.getAlias());
|
ReservedCharValidator.validate(flow.getAlias());
|
||||||
|
|
||||||
AuthenticationFlowModel createdModel = realm.addAuthenticationFlow(RepresentationToModel.toModel(flow));
|
AuthenticationFlowModel createdModel = realm.addAuthenticationFlow(RepresentationToModel.toModel(flow));
|
||||||
|
@ -503,7 +503,7 @@ public class AuthenticationManagementResource {
|
||||||
String type = (String) data.get("type");
|
String type = (String) data.get("type");
|
||||||
String provider = (String) data.get("provider");
|
String provider = (String) data.get("provider");
|
||||||
int priority = data.containsKey("priority") ? (Integer) data.get("priority") : getNextPriority(parentFlow);
|
int priority = data.containsKey("priority") ? (Integer) data.get("priority") : getNextPriority(parentFlow);
|
||||||
|
|
||||||
//Make sure that the description to avoid NullPointerException
|
//Make sure that the description to avoid NullPointerException
|
||||||
String description = Objects.isNull(data.get("description")) ? "" : (String) data.get("description");
|
String description = Objects.isNull(data.get("description")) ? "" : (String) data.get("description");
|
||||||
|
|
||||||
|
@ -795,17 +795,17 @@ public class AuthenticationManagementResource {
|
||||||
if (!checkFlow.getAlias().equals(rep.getDisplayName())) {
|
if (!checkFlow.getAlias().equals(rep.getDisplayName())) {
|
||||||
checkFlow.setAlias(rep.getDisplayName());
|
checkFlow.setAlias(rep.getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if description is null and set an empty String to avoid NPE
|
// check if description is null and set an empty String to avoid NPE
|
||||||
if (Objects.isNull(checkFlow.getDescription())) {
|
if (Objects.isNull(checkFlow.getDescription())) {
|
||||||
checkFlow.setDescription("");
|
checkFlow.setDescription("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the description changed
|
// check if the description changed
|
||||||
if (!checkFlow.getDescription().equals(rep.getDescription())) {
|
if (!checkFlow.getDescription().equals(rep.getDescription())) {
|
||||||
checkFlow.setDescription(rep.getDescription());
|
checkFlow.setDescription(rep.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
//update the flow
|
//update the flow
|
||||||
realm.updateAuthenticationFlow(checkFlow);
|
realm.updateAuthenticationFlow(checkFlow);
|
||||||
adminEvent.operation(OperationType.UPDATE).resource(ResourceType.AUTH_EXECUTION).resourcePath(session.getContext().getUri()).representation(rep).success();
|
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));
|
final Optional<AuthenticationExecutionModel> model = Optional.ofNullable(realm.getAuthenticationExecutionById(executionId));
|
||||||
if (!model.isPresent()) {
|
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");
|
throw new NotFoundException("Illegal execution");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1020,7 +1020,7 @@ public class AuthenticationManagementResource {
|
||||||
@APIResponse(responseCode = "201", description = "Created")
|
@APIResponse(responseCode = "201", description = "Created")
|
||||||
public Response newExecutionConfig(@Parameter(description = "Execution id") @PathParam("executionId") String execution, @Parameter(description = "JSON with new configuration") AuthenticatorConfigRepresentation json) {
|
public Response newExecutionConfig(@Parameter(description = "Execution id") @PathParam("executionId") String execution, @Parameter(description = "JSON with new configuration") AuthenticatorConfigRepresentation json) {
|
||||||
auth.realm().requireManageRealm();
|
auth.realm().requireManageRealm();
|
||||||
|
|
||||||
ReservedCharValidator.validate(json.getAlias());
|
ReservedCharValidator.validate(json.getAlias());
|
||||||
|
|
||||||
AuthenticationExecutionModel model = realm.getAuthenticationExecutionById(execution);
|
AuthenticationExecutionModel model = realm.getAuthenticationExecutionById(execution);
|
||||||
|
@ -1137,7 +1137,7 @@ public class AuthenticationManagementResource {
|
||||||
return actions.isEmpty() ? 0 : actions.get(actions.size() - 1).getPriority() + 1;
|
return actions.isEmpty() ? 0 : actions.get(actions.size() - 1).getPriority() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get required actions
|
* Get required actions
|
||||||
*
|
*
|
||||||
|
@ -1526,7 +1526,7 @@ public class AuthenticationManagementResource {
|
||||||
auth.realm().requireManageRealm();
|
auth.realm().requireManageRealm();
|
||||||
|
|
||||||
ReservedCharValidator.validate(rep.getAlias());
|
ReservedCharValidator.validate(rep.getAlias());
|
||||||
|
|
||||||
AuthenticatorConfigModel config = realm.addAuthenticatorConfig(RepresentationToModel.toModel(rep));
|
AuthenticatorConfigModel config = realm.addAuthenticatorConfig(RepresentationToModel.toModel(rep));
|
||||||
adminEvent.operation(OperationType.CREATE).resource(ResourceType.AUTHENTICATOR_CONFIG).resourcePath(session.getContext().getUri(), config.getId()).representation(rep).success();
|
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();
|
return Response.created(session.getContext().getUri().getAbsolutePathBuilder().path(config.getId()).build()).build();
|
||||||
|
@ -1608,7 +1608,7 @@ public class AuthenticationManagementResource {
|
||||||
if (exists == null) {
|
if (exists == null) {
|
||||||
throw new NotFoundException("Could not find authenticator config");
|
throw new NotFoundException("Could not find authenticator config");
|
||||||
}
|
}
|
||||||
|
|
||||||
exists.setAlias(rep.getAlias());
|
exists.setAlias(rep.getAlias());
|
||||||
exists.setConfig(RepresentationToModel.removeEmptyString(rep.getConfig()));
|
exists.setConfig(RepresentationToModel.removeEmptyString(rep.getConfig()));
|
||||||
realm.updateAuthenticatorConfig(exists);
|
realm.updateAuthenticatorConfig(exists);
|
||||||
|
|
Loading…
Reference in a new issue