org.hostsharing.hsadminng logging on INFO level and logging in SecurityUtils

This commit is contained in:
Michael Hoennig 2019-04-27 10:28:16 +02:00
parent 53382beb88
commit 5d843f4725
2 changed files with 8 additions and 1 deletions

View File

@ -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<UserRoleAssignment> 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));
}

View File

@ -26,6 +26,7 @@
<appender-ref ref="ASYNC"/>
</root>
-->
<logger name="org.hostsharing.hsadminng" level="INFO"/>
<logger name="javax.activation" level="WARN"/>
<logger name="javax.mail" level="WARN"/>