Package io.datarouter.auth.session
Interface CurrentSessionInfo
- All Known Implementing Classes:
CurrentSessionInfo.NoOpCurrentSessionInfo
public interface CurrentSessionInfo
Simple interface for reading information about the current user, session, and roles.
Implementations should depend on as few Daos, Services, etc., as possible to minimize risk of circular
dependencies. Only
getSession(ServletRequest), and
getRoles(ServletRequest) need to be implemented.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionfindNonEmptyUsername(javax.servlet.ServletRequest request) find the usernamedefault StringgetNonEmptyUsernameOrElse(javax.servlet.ServletRequest request, String other) Gets the username or an alternate valuedefault SessiongetRequiredSession(javax.servlet.ServletRequest request) getRoles(javax.servlet.ServletRequest request) returns the Roles associated with the current user/session, an empty set if there is no current sessiongetSession(javax.servlet.ServletRequest request) default booleanhasAnyRole(javax.servlet.ServletRequest request, Collection<Role> targetRoles) default booleanhasAnyRoleEnum(javax.servlet.ServletRequest request, Collection<RoleEnum<?>> targetRoles) default booleanreturns whether the current user/session is associated with the given Role, false if there is no current sessiondefault booleanreturns whether the current user/session is associated with the given Role, false if there is no current session
-
Method Details
-
findNonEmptyUsername
find the username -
getNonEmptyUsernameOrElse
Gets the username or an alternate value -
getSession
-
getRequiredSession
-
getRoles
returns the Roles associated with the current user/session, an empty set if there is no current session -
hasRole
returns whether the current user/session is associated with the given Role, false if there is no current session -
hasRole
returns whether the current user/session is associated with the given Role, false if there is no current session -
hasAnyRole
-
hasAnyRoleEnum
default boolean hasAnyRoleEnum(javax.servlet.ServletRequest request, Collection<RoleEnum<?>> targetRoles)
-