public class PublicUserManager extends GenericUserManager
Essentially this user manager makes all functionality public accessible by always returning a user which has a defined set of roles (therefore one can of course disable some functions entirely).
This roles granted can be controlled by two config entries. One is security.publicRoles which also affects all other user managers. The other is defaultRoles which has to be defined within the scope.
Note that also trustedRoles can be defined to control roles which are only added to a trusted user (i.e. from the local network).
Modifier and Type | Class and Description |
---|---|
static class |
PublicUserManager.Factory
Used to create public user managers.
|
config, defaultRoles, defaultUser, hashFunction, keepLoginEnabled, loginCookieTTL, publicRoles, scope, ssoEnabled, ssoGraceInterval, ssoSecret, trustedRoles
Modifier | Constructor and Description |
---|---|
protected |
PublicUserManager(ScopeInfo scope,
sirius.kernel.settings.Extension config) |
Modifier and Type | Method and Description |
---|---|
void |
attachToSession(UserInfo user,
WebContext ctx)
Attaches the given user to the current session.
|
UserInfo |
bindToRequest(WebContext ctx)
Tries to find the current user in the current session or by checking the request for valid credentials
|
protected String |
computeLang(WebContext ctx,
String userId)
Compues the langange code of the given user and request.
|
protected Set<String> |
computeRoles(WebContext ctx,
String userId)
Tries to compute the roles for the given user and request.
|
protected String |
computeTenantname(WebContext ctx,
String tenantId)
Compues the name of the given tenant and request.
|
protected String |
computeUsername(WebContext ctx,
String userId)
Compues the name of the given user and request.
|
void |
detachFromSession(UserInfo user,
WebContext ctx)
Removes all stored user information from the current session.
|
UserInfo |
findUserByCredentials(WebContext ctx,
String user,
String password)
Tries to find a user with the given credentials.
|
UserInfo |
findUserByName(WebContext ctx,
String user)
Tries to find a user with the given username.
|
protected Object |
getUserObject(UserInfo u)
Resolves the given user info back into the original (underlying) user object.
|
boolean |
isLoginSupported()
Determines if a login via username and password is possible.
|
buildDefaultUser, computeSSOHashInput, computeSSOToken, determineRolesOfDefaultUser, extractChallengeAndResponse, findUserForRequest, findUserInSession, getScopeSettings, getSSOHashFunction, getUserSettings, isKeepLoginSupported, isUserStillValid, log, recordUserLogin, transformRoles, updateLoginCookie
protected PublicUserManager(ScopeInfo scope, sirius.kernel.settings.Extension config)
@Nonnull public UserInfo bindToRequest(@Nonnull WebContext ctx)
UserManager
bindToRequest
in interface UserManager
bindToRequest
in class GenericUserManager
ctx
- the request to attach toUserInfo.NOBODY
can be used.public UserInfo findUserByName(@Nullable WebContext ctx, String user)
UserManager
ctx
- the current HTTP request if one is presentuser
- the login name of the user to findpublic UserInfo findUserByCredentials(@Nullable WebContext ctx, String user, String password)
UserManager
ctx
- the current HTTP request if one is presentuser
- the login name of the user to findpassword
- the password of the user to findprotected Object getUserObject(UserInfo u)
GenericUserManager
getUserObject
in class GenericUserManager
u
- the user info which was passed to the outside world.@Nullable protected Set<String> computeRoles(@Nullable WebContext ctx, String userId)
GenericUserManager
If a server session is available, we try to load the roles from there.
computeRoles
in class GenericUserManager
ctx
- the current requestuserId
- the id of the user to fetch roles for@Nonnull protected String computeUsername(@Nullable WebContext ctx, String userId)
GenericUserManager
computeUsername
in class GenericUserManager
ctx
- the current requestuserId
- the id of the user to fetch the name for@Nonnull protected String computeTenantname(@Nullable WebContext ctx, String tenantId)
GenericUserManager
computeTenantname
in class GenericUserManager
ctx
- the current requesttenantId
- the id of the tenant to fetch the name for@Nonnull protected String computeLang(WebContext ctx, String userId)
GenericUserManager
computeLang
in class GenericUserManager
ctx
- the current requestuserId
- the id of the user to fetch the language forpublic void attachToSession(@Nonnull UserInfo user, @Nonnull WebContext ctx)
GenericUserManager
This will make the login persistent across requests (if session management is enabled).
attachToSession
in interface UserManager
attachToSession
in class GenericUserManager
user
- the user to attach to the sessionctx
- the current request to attach the user topublic void detachFromSession(@Nonnull UserInfo user, @Nonnull WebContext ctx)
GenericUserManager
detachFromSession
in interface UserManager
detachFromSession
in class GenericUserManager
user
- the current user - passed in, in case a cache etc. has to be clearedctx
- the request to remove all data frompublic boolean isLoginSupported()
UserManager
isLoginSupported
in interface UserManager
isLoginSupported
in class GenericUserManager
Copyright © 2018. All rights reserved.