From 5d843f47256ca1dc1e0b9630ca9c3e1e32dd5700 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Sat, 27 Apr 2019 10:28:16 +0200 Subject: [PATCH] org.hostsharing.hsadminng logging on INFO level and logging in SecurityUtils --- .../org/hostsharing/hsadminng/security/SecurityUtils.java | 8 +++++++- src/main/resources/logback-spring.xml | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/hostsharing/hsadminng/security/SecurityUtils.java b/src/main/java/org/hostsharing/hsadminng/security/SecurityUtils.java index f5a4a1cb..c4268160 100644 --- a/src/main/java/org/hostsharing/hsadminng/security/SecurityUtils.java +++ b/src/main/java/org/hostsharing/hsadminng/security/SecurityUtils.java @@ -1,6 +1,8 @@ package org.hostsharing.hsadminng.security; import org.hostsharing.hsadminng.service.accessfilter.Role; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; @@ -14,6 +16,8 @@ import java.util.Optional; */ public final class SecurityUtils { + private static final Logger log = LoggerFactory.getLogger(SecurityUtils.class); + private static List userRoleAssignments = new ArrayList<>(); private SecurityUtils() { @@ -86,16 +90,18 @@ public final class SecurityUtils { ? ura.role : Role.ANYBODY). reduce(Role.ANYBODY, (r1, r2) -> r1.covers(r2) ? r1 : r2); + log.info("getLoginUserRoleFor({}, {}) returned {}", onDtoClass, onId, highestRole); return highestRole; } private static boolean matches(Class onDtoClass, Long onId, UserRoleAssignment ura) { - final boolean matches = (ura.onClass == null || onDtoClass == ura.onClass) && (ura.onId == null || ura.onId.equals(onId)); + final boolean matches = (ura.onClass == null || onDtoClass == ura.onClass) && (ura.onId == null || ura.onId.equals(onId)); return matches; } // TODO: depends on https://plan.hostsharing.net/project/hsadmin/us/67?milestone=34 public static void addUserRole(final Class onClass, final Long onId, final Role role) { + log.info("addUserRole({}, {}, {})", onClass, onId, role); userRoleAssignments.add(new UserRoleAssignment(onClass, onId, role)); } diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 0b9cc1fd..2d182c88 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -26,6 +26,7 @@ --> +