Package org.cyclos.impl.access
Class SessionHandlerImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractGlobalServerComponent
-
- org.cyclos.impl.BaseGlobalHandlerImpl
-
- org.cyclos.impl.access.SessionHandlerImpl
-
- All Implemented Interfaces:
SessionHandler,ApplicationInitializationListener
@Component public class SessionHandlerImpl extends BaseGlobalHandlerImpl implements SessionHandler, ApplicationInitializationListener
Implementation forSessionHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSessionHandlerImpl.SessionDescriptor-
Nested classes/interfaces inherited from interface org.cyclos.impl.access.SessionHandler
SessionHandler.CreateSessionParameters, SessionHandler.UserCheckResult
-
-
Field Summary
-
Fields inherited from class org.cyclos.impl.AbstractGlobalServerComponent
rawEntityManagerHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
Fields inherited from interface org.cyclos.impl.ApplicationInitializationListener
MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY
-
Fields inherited from interface org.cyclos.impl.access.SessionHandler
ATTR_CHANNEL, ATTR_PRINCIPAL, ATTR_QUERY, ATTR_REMOTE_ADDRESS, ATTR_SESSION_PROPERTIES, ATTR_SESSION_TIMEOUT, ATTR_SESSION_TOKEN, ATTR_TRUSTED, ATTR_USER
-
-
Constructor Summary
Constructors Constructor Description SessionHandlerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AccessClientcheckAccessClientAccess(boolean forLogin, Network network, String channelName, String remoteAddress, String accessClientToken)Checks the access for a user for a channel / network using the specified access client token.OidcAccessTokencheckOidcAccessToken(Network network, String remoteAddress, String accessToken)Checks the access for a user for a network using the specified OAuth2 / OpenID Connect access token.voidcheckSecondaryPassword(String password)Validate the pending secondary access password for the logged user.SessionHandler.UserCheckResultcheckUserAccess(boolean forLogin, boolean allowIfPasswordExpired, Network network, String channelName, String remoteAddress, UserLocatorVO locator, String password, Set<Group> allowedGroups)Checks the access for a user for a channel / networkvoidclearPinCreationToken(Session session)Removes the PIN creation token for the given session, if anySessioncreate(SessionHandler.CreateSessionParameters params)Creates a new session according to the given session data and timeout.
See the Javadoc forLoginServiceLocal#doLogin(TimeInterval, Long, Long, String, String).SessiongetIfValid(String remoteAddress, String token)Returns an active session by remote address and session token.StringgetPinCreationToken(Session session)Returns the token that can be used to create a device PIN without informing the current password / PIN.TimeIntervalgetSessionTimeout(Session session)Returns the timeout for a given sessionvoidinitialize()booleaninvalidate(String remoteAddress, String token)Invalidates the session with the given token, under the given remote address, returning whether the sessions was actually invalidated.Sessionlogin(String channelName, String remoteAddress, TimeInterval customSessionTimeout, UserLocatorVO locator, String password, Set<Group> allowedGroups)Performs a login.voidonApplicationInitialization()Invoked when the application service is initializedintpurgeExpired()Purges all expired sessions.intremove(Collection<String> tokens)Removes (both from the shared map and from the database) sessions with the given tokens, returning the number of actually deleted sessionsbooleanremove(Session session)Removes (both from the shared map and from the database) the given session, returning true if was actually removedStringreplace(Session session)Replaces an existing session tokenvoidsetProperties(Session session, SessionProperties newProperties)Updates the properties of the given sessionvoidupdateTimeout(String token, TimeInterval interval)Updates the expiration time of the session with the given token-
Methods inherited from class org.cyclos.impl.AbstractGlobalServerComponent
getBaseEntityManagerHandler, getEntityManager
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, delete, detach, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.cyclos.impl.ApplicationInitializationListener
applicationInitializationPriority, getInitializationId
-
-
-
-
Method Detail
-
checkAccessClientAccess
public AccessClient checkAccessClientAccess(boolean forLogin, Network network, String channelName, String remoteAddress, String accessClientToken)
Description copied from interface:SessionHandlerChecks the access for a user for a channel / network using the specified access client token.- Specified by:
checkAccessClientAccessin interfaceSessionHandler
-
checkOidcAccessToken
public OidcAccessToken checkOidcAccessToken(Network network, String remoteAddress, String accessToken)
Description copied from interface:SessionHandlerChecks the access for a user for a network using the specified OAuth2 / OpenID Connect access token. The channel is alwaysBuiltInChannel.OIDC.- Specified by:
checkOidcAccessTokenin interfaceSessionHandler
-
checkSecondaryPassword
public void checkSecondaryPassword(String password)
Description copied from interface:SessionHandlerValidate the pending secondary access password for the logged user.- Specified by:
checkSecondaryPasswordin interfaceSessionHandler
-
checkUserAccess
public SessionHandler.UserCheckResult checkUserAccess(boolean forLogin, boolean allowIfPasswordExpired, Network network, String channelName, String remoteAddress, UserLocatorVO locator, String password, Set<Group> allowedGroups)
Description copied from interface:SessionHandlerChecks the access for a user for a channel / network- Specified by:
checkUserAccessin interfaceSessionHandler
-
clearPinCreationToken
public void clearPinCreationToken(Session session)
Description copied from interface:SessionHandlerRemoves the PIN creation token for the given session, if any- Specified by:
clearPinCreationTokenin interfaceSessionHandler
-
create
public Session create(SessionHandler.CreateSessionParameters params)
Description copied from interface:SessionHandlerCreates a new session according to the given session data and timeout.
See the Javadoc forLoginServiceLocal#doLogin(TimeInterval, Long, Long, String, String).- Specified by:
createin interfaceSessionHandler- See Also:
LoginServiceLocal#doLogin(TimeInterval, Long, Long, String, String)
-
getIfValid
public Session getIfValid(String remoteAddress, String token)
Description copied from interface:SessionHandlerReturns an active session by remote address and session token. If the session has expired or doesn't match the remote address, returns null- Specified by:
getIfValidin interfaceSessionHandler
-
getPinCreationToken
public String getPinCreationToken(Session session)
Description copied from interface:SessionHandlerReturns the token that can be used to create a device PIN without informing the current password / PIN. The token is valid for 6 hours since the session is created.- Specified by:
getPinCreationTokenin interfaceSessionHandler
-
getSessionTimeout
public TimeInterval getSessionTimeout(Session session)
Description copied from interface:SessionHandlerReturns the timeout for a given session- Specified by:
getSessionTimeoutin interfaceSessionHandler
-
initialize
@PostConstruct public void initialize()
-
invalidate
public boolean invalidate(String remoteAddress, String token)
Description copied from interface:SessionHandlerInvalidates the session with the given token, under the given remote address, returning whether the sessions was actually invalidated.- Specified by:
invalidatein interfaceSessionHandler
-
login
public Session login(String channelName, String remoteAddress, TimeInterval customSessionTimeout, UserLocatorVO locator, String password, Set<Group> allowedGroups) throws FrameworkException, LoginException, RemoteAddressBlockedException
Description copied from interface:SessionHandlerPerforms a login. Checks the remote address blocking by exceeding invalid username attempts, and creates a session. When allowedGroups is null, allows any group to login. Otherwise, retrict login to users of these groups.- Specified by:
loginin interfaceSessionHandler- Throws:
FrameworkExceptionLoginExceptionRemoteAddressBlockedException
-
onApplicationInitialization
public void onApplicationInitialization()
Description copied from interface:ApplicationInitializationListenerInvoked when the application service is initialized- Specified by:
onApplicationInitializationin interfaceApplicationInitializationListener
-
purgeExpired
public int purgeExpired()
Description copied from interface:SessionHandlerPurges all expired sessions. Should run outside a transaction.- Specified by:
purgeExpiredin interfaceSessionHandler
-
remove
public int remove(Collection<String> tokens)
Description copied from interface:SessionHandlerRemoves (both from the shared map and from the database) sessions with the given tokens, returning the number of actually deleted sessions- Specified by:
removein interfaceSessionHandler
-
remove
public boolean remove(Session session)
Description copied from interface:SessionHandlerRemoves (both from the shared map and from the database) the given session, returning true if was actually removed- Specified by:
removein interfaceSessionHandler
-
replace
public String replace(Session session)
Description copied from interface:SessionHandlerReplaces an existing session token- Specified by:
replacein interfaceSessionHandler
-
setProperties
public void setProperties(Session session, SessionProperties newProperties)
Description copied from interface:SessionHandlerUpdates the properties of the given session- Specified by:
setPropertiesin interfaceSessionHandler
-
updateTimeout
public void updateTimeout(String token, TimeInterval interval)
Description copied from interface:SessionHandlerUpdates the expiration time of the session with the given token- Specified by:
updateTimeoutin interfaceSessionHandler
-
-