Package org.cyclos.impl.access
Class SystemSessionData
- java.lang.Object
-
- org.cyclos.impl.access.AbstractSessionData
-
- org.cyclos.impl.access.SystemSessionData
-
- All Implemented Interfaces:
ProcessableForProxying,DelegatingUserPrincipal,RoleContainer,UserPrincipal,SessionData
public class SystemSessionData extends AbstractSessionData
A session data for running a piece of code as system.
IMPORTANT: System doesn't have any role, that is why all those methods defined inRoleContainerreturn false.
E.g:AbstractSessionData.isManagerOf(BasicUser)returns false due to System is not an admin nor a broker (i.e doesn't have any of the required roles). On the other hand, the methodmanages(BasicUser)return true because a System session can manage all users.
This also implies that when implementing business logic in a method, we must treat System as a special case and not rely only in role-based methods to do the stuff.
For example we should code in this way:if (sessionData.isSystem()) { // code for system... } else if (sessionData.isManagerOf(user)) { // code for admin/brokers... }
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.cyclos.impl.access.AbstractSessionData
AbstractSessionData.SessionDataChannelAccessAccessor
-
-
Field Summary
-
Fields inherited from class org.cyclos.impl.access.AbstractSessionData
requestData
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected LongdoGetConfigurationId()protected ProductsAccessordoGetProducts()Must be implemented to return a a validProductsAccessorprotected SessionDataSubjectIddoGetSubjectId()protected booleandoHasPermission(Permission permission)StringgetAccessChannelName()Returns the internal name of the original channel (i.e the channel used to access Cyclos) .Set<BasicGroup>getAccessibleBasicGroups()Returns the basic groups accessible by the current sessionUserAuthVOgetAuthenticatedUser()Returns the user authentication data, or null if noneStringgetChannelName()Returns the internal name of the current channel.GroupgetGroup()Returns the group of the authenticated user, if anyBasicUsergetLoggedBasicUser()Returns the authenticated basic user, or null if nonePrincipalTypegetPrincipalType()booleanhasRequiredValue(Permission permission, Object value)Returns whether the current user has access to the given required value for the given permissionbooleanisSystem()Returns whether the current session represents a system taskbooleanisVisible(EntityCheck<SimpleEntity> entityCheck, SimpleEntity entity)Returns whether the given entity is visible under the given entity checkbooleanmanages(BasicUser user)Returns whether the current user manages the given user.booleanrelatesTo(BasicUser user)Returns whether the current user is related to (is allowed to view) the given userStringtoString()-
Methods inherited from class org.cyclos.impl.access.AbstractSessionData
bean, checkConsistency, doGetConfigurationAccessor, doGetPreferredLocales, getAccessChannel, getAccessClient, getAccessToken, getAccountType, getApplicationContext, getBasicUser, getChannel, getChannelAccessAccessor, getChannelConfiguration, getChannelSettingsAccessor, getConfiguration, getConfigurationEntity, getCustomFieldValue, getIdentityProvider, getIpAddressService, getLoggedOperator, getLoggedUser, getMobilePhone, getNetwork, getPin, getPrincipal, getProducts, getRawEntityManagerHandler, getRemoteAddress, getRequestData, getSession, getSubjectId, getToken, getTrustedDevice, hasPermission, isAdmin, isAdminOf, isAliasOperator, isBroker, isBrokerOf, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isManagerOf, isMember, isMemberOnly, isMultiNetworkAdminInGlobalMode, isNetworkAdmin, isOperator, isOwnerOf, isRestrictedOperator, isScript, isSelf, isTrusted, isUserManager, runAsSystem, runAsSystem, shouldCheckRemoteAddress, unwrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.cyclos.entities.users.DelegatingUserPrincipal
getDelegate
-
Methods inherited from interface org.cyclos.impl.access.SessionData
getProxyClass, hasPermission, ifWraps, isRest
-
-
-
-
Method Detail
-
getAccessChannelName
public String getAccessChannelName()
Description copied from interface:SessionDataReturns the internal name of the original channel (i.e the channel used to access Cyclos) . Must be accessible outside transactions.
-
getAccessibleBasicGroups
public Set<BasicGroup> getAccessibleBasicGroups()
Description copied from interface:SessionDataReturns the basic groups accessible by the current session
-
getAuthenticatedUser
public UserAuthVO getAuthenticatedUser()
Description copied from interface:SessionDataReturns the user authentication data, or null if none
-
getChannelName
public String getChannelName()
Description copied from interface:SessionDataReturns the internal name of the current channel. Must be accessible outside transactions.
-
getGroup
public Group getGroup()
Description copied from interface:SessionDataReturns the group of the authenticated user, if any
-
getLoggedBasicUser
public BasicUser getLoggedBasicUser()
Description copied from interface:SessionDataReturns the authenticated basic user, or null if none
-
getPrincipalType
public PrincipalType getPrincipalType()
- Specified by:
getPrincipalTypein interfaceUserPrincipal- Overrides:
getPrincipalTypein classAbstractSessionData
-
hasRequiredValue
public boolean hasRequiredValue(Permission permission, Object value)
Description copied from interface:SessionDataReturns whether the current user has access to the given required value for the given permission
-
isSystem
public boolean isSystem()
Description copied from interface:SessionDataReturns whether the current session represents a system task- Specified by:
isSystemin interfaceSessionData- Overrides:
isSystemin classAbstractSessionData
-
isVisible
public boolean isVisible(EntityCheck<SimpleEntity> entityCheck, SimpleEntity entity)
Description copied from interface:SessionDataReturns whether the given entity is visible under the given entity check
-
manages
public boolean manages(BasicUser user)
Description copied from interface:SessionDataReturns whether the current user manages the given user. If the logged user and the given one are the same user then it returns true.
-
relatesTo
public boolean relatesTo(BasicUser user)
Description copied from interface:SessionDataReturns whether the current user is related to (is allowed to view) the given user
-
doGetConfigurationId
protected Long doGetConfigurationId()
- Specified by:
doGetConfigurationIdin classAbstractSessionData
-
doGetProducts
protected ProductsAccessor doGetProducts()
Description copied from class:AbstractSessionDataMust be implemented to return a a validProductsAccessor- Specified by:
doGetProductsin classAbstractSessionData
-
doGetSubjectId
protected SessionDataSubjectId doGetSubjectId()
- Specified by:
doGetSubjectIdin classAbstractSessionData
-
doHasPermission
protected boolean doHasPermission(Permission permission)
- Specified by:
doHasPermissionin classAbstractSessionData
-
-