public static boolean hasRole(String role) { return roles().contains(role); }
public static boolean isLoggedInAs(String username) { return username != null && username.equals(username()); }
public static Set<String> scope() { return user().scope; }
private void addExtraRequestHeaders(Req req, Map<String, String> headers) { String clientIpAddress = req.clientIpAddress(); if (setXUsernameHeader()) headers.put("X-Username", U.safe(Current.username())); if (setXRolesHeader()) headers.put("X-Roles", U.join(", ", Current.roles())); if (setXClientIPHeader()) headers.put("X-Client-IP", clientIpAddress); if (setXRealIPHeader()) headers.put("X-Real-IP", req.realIpAddress()); if (setXForwardedForHeader()) { String forwardedFor = headers.get("X-Forwarded-For"); if (U.notEmpty(forwardedFor)) { forwardedFor += ", " + clientIpAddress; } else { forwardedFor = clientIpAddress; } headers.put("X-Forwarded-For", forwardedFor); } }
protected Req req() { return Current.request(); }
private void addExtraRequestHeaders(Req req, Map<String, String> headers) { String clientIpAddress = req.clientIpAddress(); if (setXUsernameHeader()) headers.put("X-Username", U.safe(Current.username())); if (setXRolesHeader()) headers.put("X-Roles", U.join(", ", Current.roles())); if (setXClientIPHeader()) headers.put("X-Client-IP", clientIpAddress); if (setXRealIPHeader()) headers.put("X-Real-IP", req.realIpAddress()); if (setXForwardedForHeader()) { String forwardedFor = headers.get("X-Forwarded-For"); if (U.notEmpty(forwardedFor)) { forwardedFor += ", " + clientIpAddress; } else { forwardedFor = clientIpAddress; } headers.put("X-Forwarded-For", forwardedFor); } }
public static boolean isLoggedIn() { return user().username != null; }
public static boolean isLoggedInAs(String username) { return username != null && username.equals(username()); }
public static boolean hasRole(String role) { return roles().contains(role); }
public static String username() { return user().username; }
public static Set<String> roles() { return user().roles; }
public static boolean isLoggedIn() { return user().username != null; }
public static Set<String> roles() { return user().roles; }
public static String username() { return user().username; }
public static Set<String> scope() { return user().scope; }