KEYCLOAK-10022 Fixing few admin events not raised bug

This commit is contained in:
Shiva Prasad Thagadur Prakash 2019-07-16 14:25:12 +03:00 committed by Pedro Igor
parent 9c37da0ee9
commit ff8b790549
4 changed files with 16 additions and 30 deletions

View File

@ -113,9 +113,7 @@ public class PolicyResourceService {
policyStore.delete(policy.getId());
if (authorization.getRealm().isAdminEventsEnabled()) {
audit(toRepresentation(policy, authorization), OperationType.DELETE);
}
audit(toRepresentation(policy, authorization), OperationType.DELETE);
return Response.noContent().build();
}
@ -257,8 +255,6 @@ public class PolicyResourceService {
}
private void audit(AbstractPolicyRepresentation policy, OperationType operation) {
if (authorization.getRealm().isAdminEventsEnabled()) {
adminEvent.operation(operation).resourcePath(authorization.getKeycloakSession().getContext().getUri()).representation(policy).success();
}
adminEvent.operation(operation).resourcePath(authorization.getKeycloakSession().getContext().getUri()).representation(policy).success();
}
}

View File

@ -320,12 +320,10 @@ public class PolicyService {
}
private void audit(AbstractPolicyRepresentation resource, String id, OperationType operation, KeycloakSession session) {
if (authorization.getRealm().isAdminEventsEnabled()) {
if (id != null) {
adminEvent.operation(operation).resourcePath(session.getContext().getUri(), id).representation(resource).success();
} else {
adminEvent.operation(operation).resourcePath(session.getContext().getUri()).representation(resource).success();
}
if (id != null) {
adminEvent.operation(operation).resourcePath(session.getContext().getUri(), id).representation(resource).success();
} else {
adminEvent.operation(operation).resourcePath(session.getContext().getUri()).representation(resource).success();
}
}
}

View File

@ -166,9 +166,7 @@ public class ResourceSetService {
storeFactory.getResourceStore().delete(id);
if (authorization.getRealm().isAdminEventsEnabled()) {
audit(toRepresentation(resource, resourceServer, authorization), OperationType.DELETE);
}
audit(toRepresentation(resource, resourceServer, authorization), OperationType.DELETE);
return Response.noContent().build();
}
@ -471,12 +469,10 @@ public class ResourceSetService {
}
public void audit(ResourceRepresentation resource, String id, OperationType operation) {
if (authorization.getRealm().isAdminEventsEnabled()) {
if (id != null) {
adminEvent.operation(operation).resourcePath(session.getContext().getUri(), id).representation(resource).success();
} else {
adminEvent.operation(operation).resourcePath(session.getContext().getUri()).representation(resource).success();
}
if (id != null) {
adminEvent.operation(operation).resourcePath(session.getContext().getUri(), id).representation(resource).success();
} else {
adminEvent.operation(operation).resourcePath(session.getContext().getUri()).representation(resource).success();
}
}
}

View File

@ -143,9 +143,7 @@ public class ScopeService {
storeFactory.getScopeStore().delete(id);
if (authorization.getRealm().isAdminEventsEnabled()) {
audit(toRepresentation(scope), OperationType.DELETE);
}
audit(toRepresentation(scope), OperationType.DELETE);
return Response.noContent().build();
}
@ -266,12 +264,10 @@ public class ScopeService {
}
private void audit(ScopeRepresentation resource, String id, OperationType operation) {
if (authorization.getRealm().isAdminEventsEnabled()) {
if (id != null) {
adminEvent.operation(operation).resourcePath(session.getContext().getUri(), id).representation(resource).success();
} else {
adminEvent.operation(operation).resourcePath(session.getContext().getUri()).representation(resource).success();
}
if (id != null) {
adminEvent.operation(operation).resourcePath(session.getContext().getUri(), id).representation(resource).success();
} else {
adminEvent.operation(operation).resourcePath(session.getContext().getUri()).representation(resource).success();
}
}
}