Package org.cyclos.impl.access
Class AbstractSessionData
- java.lang.Object
-
- org.cyclos.impl.access.AbstractSessionData
-
- All Implemented Interfaces:
RoleContainer,DelegatingUserPrincipal,SessionData,UserPrincipal
- Direct Known Subclasses:
GuestSessionData,ScriptSessionData,SystemSessionData,UserSessionData
public abstract class AbstractSessionData extends Object implements SessionData
Base class for SessionData's implementations, containing logic that counts for any type of SessionData.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classAbstractSessionData.SessionDataChannelAccessAccessor
-
Field Summary
Fields Modifier and Type Field Description protected RequestDatarequestData
-
Constructor Summary
Constructors Constructor Description AbstractSessionData(RequestData requestData)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected <T> Tbean(Class<T> beanClass)voidcheckConsistency()Checks for consistency.protected ConfigurationAccessordoGetConfigurationAccessor()protected abstract LongdoGetConfigurationId()protected List<String>doGetPreferredLocales()protected abstract ProductsAccessordoGetProducts()Must be implemented to return a a validProductsAccessorprotected abstract SessionDataSubjectIddoGetSubjectId()protected abstract booleandoHasPermission(Permission permission)ChannelgetAccessChannel()Returns the original channel (i.e the channel used to access Cyclos) this session is usingAccessClientgetAccessClient()OidcAccessTokengetAccessToken()Returns the OpenID Connect / OAuth2 access token for this sessionUserAccountTypegetAccountType()protected ApplicationContextgetApplicationContext()BasicUsergetBasicUser()ChannelgetChannel()Returns the current channel this session is usingChannelAccessAccessorgetChannelAccessAccessor()Returns the accessor for the access channel (i.e the original channel used to access Cyclos) access settings.ChannelConfigurationgetChannelConfiguration()This method is here, but not in the interface.ChannelSettingsAccessorgetChannelSettingsAccessor()Returns the accessor for the current channel (i.e the channel used to run the service method) general settings.ConfigurationAccessorgetConfiguration()Returns the configuration accessorprotected ConfigurationgetConfigurationEntity()UserCustomFieldValuegetCustomFieldValue()FailedActionHandlergetFailedActionHandler()IdentityProvidergetIdentityProvider()Returns theIdentityProviderused for this session only if the user was authenticated using such mechanism.OperatorgetLoggedOperator()Returns the authenticated operator, or null if none or the logged is not an operatorUsergetLoggedUser()Returns the authenticated user, or null if noneMobilePhonegetMobilePhone()NetworkgetNetwork()Returns the network this session is using, or null if as global system or administratorPingetPin()Returns thePinused for this session only if the user was authenticated using such mechanism.StringgetPrincipal()Should return a value that can be used to identify the user.PrincipalTypegetPrincipalType()ProductsAccessorgetProducts()Returns the products accessorprotected RawEntityManagerHandlergetRawEntityManagerHandler()StringgetRemoteAddress()Returns the remote address, of the client accessing the applicationRequestDatagetRequestData()Returns data about the calling request.SessiongetSession()Returns the session in case this session data performed a loginSessionDataSubjectIdgetSubjectId()Returns the subject idTokengetToken()TrustedDevicegetTrustedDevice()booleanhasPermission(Permission permission)Returns whether the current user has the given permissionbooleanisAdmin()Returns whether theRole.ADMINis grantedbooleanisAdminOf(BasicUser user)Returns whether the current user is an administrator of the given userbooleanisAliasOperator()Returns whether theRole.ALIAS_OPERATORis grantedbooleanisBroker()Returns whether theRole.BROKERis grantedbooleanisBrokerOf(BasicUser user)Returns whether the current user is a broker of the given userbooleanisGlobalAdmin()Returns whether theRole.GLOBAL_ADMINis granted Returns true if the user is the "root" user.booleanisGlobalAdminInNetwork()Returns whether a global admin OR a global restricted has switched to a network.booleanisGuest()Returns whether the current session represents a guestbooleanisLoggedIn()Returns whether the current session represents a userbooleanisManagerOf(BasicUser user)Returns whether the current user is a manager of the given user and is not the given user.booleanisMember()Returns whether theRole.MEMBERis grantedbooleanisMemberOnly()Returns true if the logged user has onlyRolemember.booleanisMultiNetworkAdminInGlobalMode()Returns whether a global restricted has not switched to a network.booleanisNetworkAdmin()Returns whether theRole.NETWORK_ADMINis grantedbooleanisOperator()Returns whether theRole.OPERATORis grantedbooleanisOwnerOf(BasicUser operator)Returns whether current user is either the owner member of a given operator or as another alias operatorbooleanisRestrictedOperator()Returns whether theRole.RESTRICTED_OPERATORis grantedbooleanisScript()Returns whether this session is running under a scriptbooleanisSelf(BasicUser user)booleanisSystem()Returns whether the current session represents a system taskbooleanisTrusted()Returns whether this session should be considered trustedbooleanisUserManager()Returns whether theRole.ADMINorRole.BROKERroles are grantedprotected LongresolveNetworkId()protected <T> TrunAsSystem(Callable<T> callable)Runs the given callable as system, with the same request data and channel as this session dataprotected <T> TrunAsSystem(Callable<T> callable, boolean useCurrentChannelName)protected booleanshouldCheckRemoteAddress()-
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.access.DelegatingUserPrincipal
getDelegate
-
Methods inherited from interface org.cyclos.impl.access.SessionData
getAccessChannelName, getAccessibleBasicGroups, getAuthenticatedUser, getChannelName, getGroup, getLoggedBasicUser, hasPermission, hasRequiredValue, isRest, isVisible, manages, relatesTo
-
-
-
-
Field Detail
-
requestData
protected final RequestData requestData
-
-
Constructor Detail
-
AbstractSessionData
public AbstractSessionData(RequestData requestData)
-
-
Method Detail
-
checkConsistency
public void checkConsistency() throws InvalidSessionDataExceptionDescription copied from interface:SessionDataChecks for consistency. Called before invoking a service method, as system- Specified by:
checkConsistencyin interfaceSessionData- Throws:
InvalidSessionDataException
-
getAccessChannel
public final Channel getAccessChannel()
Description copied from interface:SessionDataReturns the original channel (i.e the channel used to access Cyclos) this session is using- Specified by:
getAccessChannelin interfaceSessionData
-
getAccessClient
public AccessClient getAccessClient()
- Specified by:
getAccessClientin interfaceUserPrincipal
-
getAccessToken
public OidcAccessToken getAccessToken()
Description copied from interface:SessionDataReturns the OpenID Connect / OAuth2 access token for this session- Specified by:
getAccessTokenin interfaceSessionData
-
getAccountType
public UserAccountType getAccountType()
- Specified by:
getAccountTypein interfaceUserPrincipal
-
getBasicUser
public BasicUser getBasicUser()
- Specified by:
getBasicUserin interfaceUserPrincipal
-
getChannel
public final Channel getChannel()
Description copied from interface:SessionDataReturns the current channel this session is using- Specified by:
getChannelin interfaceSessionData
-
getChannelAccessAccessor
public ChannelAccessAccessor getChannelAccessAccessor()
Description copied from interface:SessionDataReturns the accessor for the access channel (i.e the original channel used to access Cyclos) access settings. Always uses the user's own settings. For example, if a global administrator is switched to a network, will get his settings, from global mode.- Specified by:
getChannelAccessAccessorin interfaceSessionData
-
getChannelConfiguration
public ChannelConfiguration getChannelConfiguration()
This method is here, but not in the interface. Session data for guests / system has a single channel configuration. Also, scripts might be using this method, so it keeps them working.
-
getChannelSettingsAccessor
public ChannelSettingsAccessor getChannelSettingsAccessor()
Description copied from interface:SessionDataReturns the accessor for the current channel (i.e the channel used to run the service method) general settings. Always uses the current configuration settings. For example, if a global administrator is switched to a network, will get the settings for the network administrators.- Specified by:
getChannelSettingsAccessorin interfaceSessionData
-
getConfiguration
public final ConfigurationAccessor getConfiguration()
Description copied from interface:SessionDataReturns the configuration accessor- Specified by:
getConfigurationin interfaceSessionData
-
getCustomFieldValue
public UserCustomFieldValue getCustomFieldValue()
- Specified by:
getCustomFieldValuein interfaceUserPrincipal
-
getFailedActionHandler
public FailedActionHandler getFailedActionHandler()
-
getIdentityProvider
public IdentityProvider getIdentityProvider()
Description copied from interface:SessionDataReturns theIdentityProviderused for this session only if the user was authenticated using such mechanism.- Specified by:
getIdentityProviderin interfaceSessionData
-
getLoggedOperator
public final Operator getLoggedOperator()
Description copied from interface:SessionDataReturns the authenticated operator, or null if none or the logged is not an operator- Specified by:
getLoggedOperatorin interfaceSessionData
-
getLoggedUser
public final User getLoggedUser()
Description copied from interface:SessionDataReturns the authenticated user, or null if none- Specified by:
getLoggedUserin interfaceSessionData
-
getMobilePhone
public MobilePhone getMobilePhone()
- Specified by:
getMobilePhonein interfaceUserPrincipal
-
getNetwork
public final Network getNetwork()
Description copied from interface:SessionDataReturns the network this session is using, or null if as global system or administrator- Specified by:
getNetworkin interfaceSessionData
-
getPin
public Pin getPin()
Description copied from interface:SessionDataReturns thePinused for this session only if the user was authenticated using such mechanism.- Specified by:
getPinin interfaceSessionData
-
getPrincipal
public String getPrincipal()
Description copied from interface:UserPrincipalShould return a value that can be used to identify the user. In case the value should be hidden, implementors should return null.- Specified by:
getPrincipalin interfaceDelegatingUserPrincipal- Specified by:
getPrincipalin interfaceUserPrincipal
-
getPrincipalType
public PrincipalType getPrincipalType()
- Specified by:
getPrincipalTypein interfaceUserPrincipal
-
getProducts
public final ProductsAccessor getProducts()
Description copied from interface:SessionDataReturns the products accessor- Specified by:
getProductsin interfaceSessionData
-
getRemoteAddress
public String getRemoteAddress()
Description copied from interface:SessionDataReturns the remote address, of the client accessing the application- Specified by:
getRemoteAddressin interfaceSessionData
-
getRequestData
public final RequestData getRequestData()
Description copied from interface:SessionDataReturns data about the calling request. Must be accessible outside transactions.- Specified by:
getRequestDatain interfaceSessionData
-
getSession
public Session getSession()
Description copied from interface:SessionDataReturns the session in case this session data performed a login- Specified by:
getSessionin interfaceSessionData
-
getSubjectId
public SessionDataSubjectId getSubjectId()
Description copied from interface:SessionDataReturns the subject id- Specified by:
getSubjectIdin interfaceSessionData
-
getToken
public Token getToken()
- Specified by:
getTokenin interfaceUserPrincipal
-
getTrustedDevice
public TrustedDevice getTrustedDevice()
- Specified by:
getTrustedDevicein interfaceUserPrincipal
-
hasPermission
public final boolean hasPermission(Permission permission)
Description copied from interface:SessionDataReturns whether the current user has the given permission- Specified by:
hasPermissionin interfaceSessionData
-
isAdmin
public boolean isAdmin()
Description copied from interface:RoleContainerReturns whether theRole.ADMINis granted- Specified by:
isAdminin interfaceRoleContainer
-
isAdminOf
public boolean isAdminOf(BasicUser user)
Description copied from interface:SessionDataReturns whether the current user is an administrator of the given user- Specified by:
isAdminOfin interfaceSessionData
-
isAliasOperator
public boolean isAliasOperator()
Description copied from interface:RoleContainerReturns whether theRole.ALIAS_OPERATORis granted- Specified by:
isAliasOperatorin interfaceRoleContainer
-
isBroker
public boolean isBroker()
Description copied from interface:RoleContainerReturns whether theRole.BROKERis granted- Specified by:
isBrokerin interfaceRoleContainer
-
isBrokerOf
public boolean isBrokerOf(BasicUser user)
Description copied from interface:SessionDataReturns whether the current user is a broker of the given user- Specified by:
isBrokerOfin interfaceSessionData
-
isGlobalAdmin
public boolean isGlobalAdmin()
Description copied from interface:RoleContainerReturns whether theRole.GLOBAL_ADMINis granted Returns true if the user is the "root" user. For multi-networks administrators it returns false- Specified by:
isGlobalAdminin interfaceRoleContainer- See Also:
RoleContainer.isGlobalAdmin()
-
isGlobalAdminInNetwork
public boolean isGlobalAdminInNetwork()
Returns whether a global admin OR a global restricted has switched to a network.- Specified by:
isGlobalAdminInNetworkin interfaceSessionData
-
isGuest
public boolean isGuest()
Description copied from interface:SessionDataReturns whether the current session represents a guest- Specified by:
isGuestin interfaceSessionData
-
isLoggedIn
public boolean isLoggedIn()
Description copied from interface:SessionDataReturns whether the current session represents a user- Specified by:
isLoggedInin interfaceSessionData
-
isManagerOf
public boolean isManagerOf(BasicUser user)
Description copied from interface:SessionDataReturns whether the current user is a manager of the given user and is not the given user.- Specified by:
isManagerOfin interfaceSessionData
-
isMember
public boolean isMember()
Description copied from interface:RoleContainerReturns whether theRole.MEMBERis granted- Specified by:
isMemberin interfaceRoleContainer
-
isMemberOnly
public boolean isMemberOnly()
Description copied from interface:SessionDataReturns true if the logged user has onlyRolemember.- Specified by:
isMemberOnlyin interfaceSessionData
-
isMultiNetworkAdminInGlobalMode
public boolean isMultiNetworkAdminInGlobalMode()
Returns whether a global restricted has not switched to a network.- Specified by:
isMultiNetworkAdminInGlobalModein interfaceSessionData
-
isNetworkAdmin
public boolean isNetworkAdmin()
Description copied from interface:RoleContainerReturns whether theRole.NETWORK_ADMINis granted- Specified by:
isNetworkAdminin interfaceRoleContainer
-
isOperator
public boolean isOperator()
Description copied from interface:RoleContainerReturns whether theRole.OPERATORis granted- Specified by:
isOperatorin interfaceRoleContainer
-
isOwnerOf
public boolean isOwnerOf(BasicUser operator)
Description copied from interface:SessionDataReturns whether current user is either the owner member of a given operator or as another alias operator- Specified by:
isOwnerOfin interfaceSessionData
-
isRestrictedOperator
public boolean isRestrictedOperator()
Description copied from interface:RoleContainerReturns whether theRole.RESTRICTED_OPERATORis granted- Specified by:
isRestrictedOperatorin interfaceRoleContainer
-
isScript
public boolean isScript()
Description copied from interface:SessionDataReturns whether this session is running under a script- Specified by:
isScriptin interfaceSessionData
-
isSelf
public boolean isSelf(BasicUser user)
Description copied from interface:SessionData- Specified by:
isSelfin interfaceSessionData
-
isSystem
public boolean isSystem()
Description copied from interface:SessionDataReturns whether the current session represents a system task- Specified by:
isSystemin interfaceSessionData
-
isTrusted
public boolean isTrusted()
Description copied from interface:SessionDataReturns whether this session should be considered trusted- Specified by:
isTrustedin interfaceSessionData
-
isUserManager
public boolean isUserManager()
Description copied from interface:RoleContainerReturns whether theRole.ADMINorRole.BROKERroles are granted- Specified by:
isUserManagerin interfaceRoleContainer
-
bean
protected <T> T bean(Class<T> beanClass)
-
doGetConfigurationAccessor
protected ConfigurationAccessor doGetConfigurationAccessor()
-
doGetConfigurationId
protected abstract Long doGetConfigurationId()
-
doGetProducts
protected abstract ProductsAccessor doGetProducts()
Must be implemented to return a a validProductsAccessor
-
doGetSubjectId
protected abstract SessionDataSubjectId doGetSubjectId()
-
doHasPermission
protected abstract boolean doHasPermission(Permission permission)
-
getApplicationContext
protected ApplicationContext getApplicationContext()
-
getConfigurationEntity
protected final Configuration getConfigurationEntity()
-
getRawEntityManagerHandler
protected RawEntityManagerHandler getRawEntityManagerHandler()
-
resolveNetworkId
protected Long resolveNetworkId()
-
runAsSystem
protected <T> T runAsSystem(Callable<T> callable)
Runs the given callable as system, with the same request data and channel as this session data
-
runAsSystem
protected <T> T runAsSystem(Callable<T> callable, boolean useCurrentChannelName)
-
shouldCheckRemoteAddress
protected boolean shouldCheckRemoteAddress()
-
-