Package org.cyclos.security.users
Class UserServiceSecurity
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.security.BaseServiceSecurity
-
- org.cyclos.security.CRUDServiceSecurity<UserDTO,User,UserData,UserDataParams>
-
- org.cyclos.security.users.UserServiceSecurity
-
- All Implemented Interfaces:
CRUDService<UserDTO,UserData,UserDataParams>,CRUDWithConfirmationPasswordService<UserDTO,UserData,UserDataParams>,Service,UserService
@Security public class UserServiceSecurity extends CRUDServiceSecurity<UserDTO,User,UserData,UserDataParams> implements UserService
Security layer forUserService
-
-
Field Summary
-
Fields inherited from class org.cyclos.security.CRUDServiceSecurity
entityClass
-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
Fields inherited from interface org.cyclos.services.users.UserService
ANY_PRINCIPAL_TYPE, PIN_PRINCIPAL_TYPE, SELF
-
-
Constructor Summary
Constructors Constructor Description UserServiceSecurity()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanPerformOperation(User user, CRUDOperation operation)Returns whether the logged user can perform the given operation over the given entitybooleancanViewData(User user)Should be implemented in order to return whether the caller is allowed to call getData on the given entity.protected voidcheckCreateNew(UserDataParams params)Checks whether creating new entities with the given context parameters is allowed, throwingPermissionDeniedExceptionif notbooleancheckQuery(AbstractUserQuery query)booleandoHasManageAccess(User user)Should be implemented in order to return whether the caller is allowed to manage the given entity, for the given operationbooleandoHasViewAccess(User user)Should be implemented in order to return whether the caller is allowed to view the given entity.FileInfoexportUsers(ExportFormatVO format, UserQuery params)Exports the user search results to a fileActiveConfigurationDatagetActiveConfiguration(UserLocatorVO locator)Returns theActiveConfigurationData, containing all the actual configuration for the user matching the given locatorUserWithRolesVOgetCurrentUser()Returns the current user logged inprotected UserServiceLocalgetImplementation()Should be implemented in order to return the actual implementation of the servicePublicRegistrationDatagetPublicRegistrationData(InitialGroupVO group, String inviteToken)Returns data for registering a user from the public registrationList<InitialGroupVO>getPublicRegistrationGroups()Return the list of groups guests user can registerUserSearchDatagetSearchData(UserSearchContext context, UserLocatorVO brokerVO)Gets data used on the search page, according to the given search typeList<InitialGroupVO>getUserRegistrationGroups(boolean asMember)Return the list of groups the logged user can register new users.ViewProfileDatagetViewProfileData(UserLocatorVO locator)Return aViewProfileDatafor the user matching the given locatorbooleanisAccessible(SessionData sessionData, User entity)Must be implemented in order to determine whether the given entity is accessible for the given session data.UserVOlocate(UserLocatorVO locator)Locates a user by a customizable key.protected voidonBeforeSave(UserDTO dto, User user)UserRegistrationResultpublicRegister(PublicRegistrationDTO dto)Registers a user from a public registrationUserRegistrationResultregister(UserRegistrationDTO dto)Registers a userUserRegistrationResultregisterByMember(UserRegistrationByMemberDTO dto)Registers a user by a regular member.Page<UserWithFieldsVO>search(UserQuery query)Search users according to the specified query parameters.StringvalidateRegistrationField(ValidateRegistrationFieldParams params)Validates a field for user registration.-
Methods inherited from class org.cyclos.security.CRUDServiceSecurity
checkManageAccess, checkOperation, checkSave, checkViewAccess, customizeData, find, getConfirmationPasswordInputForRemove, getData, getDataForNew, getEntityClass, hasManageAccess, hasViewAccess, load, remove, removeAll, removeAllWithConfirmationPassword, removeWithConfirmationPassword, resolveEntityCheck, save, saveWithConfirmationPassword
-
Methods inherited from class org.cyclos.security.BaseServiceSecurity
checkGuest, checkId, checkIds, checkInternalName, checkLoggedIn, checkManagesUser, checkRelatesToUser, checkScope, checkVO, checkVOs, doInitialize, getEntityCheckRegistry, getUser, initialize
-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, toDate, toDateTime, validate
-
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.services.CRUDService
getData, getDataForNew, load, remove, removeAll, save
-
Methods inherited from interface org.cyclos.services.CRUDWithConfirmationPasswordService
getConfirmationPasswordInputForRemove, removeAllWithConfirmationPassword, removeWithConfirmationPassword, saveWithConfirmationPassword
-
-
-
-
Method Detail
-
canPerformOperation
public boolean canPerformOperation(User user, CRUDOperation operation)
Description copied from class:CRUDServiceSecurityReturns whether the logged user can perform the given operation over the given entity- Overrides:
canPerformOperationin classCRUDServiceSecurity<UserDTO,User,UserData,UserDataParams>
-
canViewData
public boolean canViewData(User user)
Description copied from class:CRUDServiceSecurityShould be implemented in order to return whether the caller is allowed to call getData on the given entity.- Overrides:
canViewDatain classCRUDServiceSecurity<UserDTO,User,UserData,UserDataParams>
-
checkQuery
public boolean checkQuery(AbstractUserQuery query)
-
doHasManageAccess
public boolean doHasManageAccess(User user)
Description copied from class:CRUDServiceSecurityShould be implemented in order to return whether the caller is allowed to manage the given entity, for the given operation- Specified by:
doHasManageAccessin classCRUDServiceSecurity<UserDTO,User,UserData,UserDataParams>
-
doHasViewAccess
public boolean doHasViewAccess(User user)
Description copied from class:CRUDServiceSecurityShould be implemented in order to return whether the caller is allowed to view the given entity.- Specified by:
doHasViewAccessin classCRUDServiceSecurity<UserDTO,User,UserData,UserDataParams>
-
exportUsers
public FileInfo exportUsers(ExportFormatVO format, UserQuery params) throws FrameworkException
Description copied from interface:UserServiceExports the user search results to a file- Specified by:
exportUsersin interfaceUserService- Throws:
FrameworkException
-
getActiveConfiguration
public ActiveConfigurationData getActiveConfiguration(UserLocatorVO locator) throws EntityNotFoundException
Description copied from interface:UserServiceReturns theActiveConfigurationData, containing all the actual configuration for the user matching the given locator- Specified by:
getActiveConfigurationin interfaceUserService- Throws:
EntityNotFoundException
-
getCurrentUser
public UserWithRolesVO getCurrentUser() throws FrameworkException
Description copied from interface:UserServiceReturns the current user logged in- Specified by:
getCurrentUserin interfaceUserService- Throws:
FrameworkException
-
getPublicRegistrationData
public PublicRegistrationData getPublicRegistrationData(InitialGroupVO group, String inviteToken) throws FrameworkException
Description copied from interface:UserServiceReturns data for registering a user from the public registration- Specified by:
getPublicRegistrationDatain interfaceUserService- Throws:
FrameworkException
-
getPublicRegistrationGroups
public List<InitialGroupVO> getPublicRegistrationGroups() throws FrameworkException
Description copied from interface:UserServiceReturn the list of groups guests user can register- Specified by:
getPublicRegistrationGroupsin interfaceUserService- Throws:
FrameworkException
-
getSearchData
public UserSearchData getSearchData(UserSearchContext context, UserLocatorVO brokerVO) throws FrameworkException
Description copied from interface:UserServiceGets data used on the search page, according to the given search type- Specified by:
getSearchDatain interfaceUserService- Throws:
FrameworkException
-
getUserRegistrationGroups
public List<InitialGroupVO> getUserRegistrationGroups(boolean asMember) throws FrameworkException
Description copied from interface:UserServiceReturn the list of groups the logged user can register new users.- Specified by:
getUserRegistrationGroupsin interfaceUserService- Parameters:
asMember- flag used only in case the logged user is a broker to distinguish between registering as member/broker.- Throws:
FrameworkException
-
getViewProfileData
public ViewProfileData getViewProfileData(UserLocatorVO locator)
Description copied from interface:UserServiceReturn aViewProfileDatafor the user matching the given locator- Specified by:
getViewProfileDatain interfaceUserService
-
isAccessible
public boolean isAccessible(SessionData sessionData, User entity)
Description copied from class:CRUDServiceSecurityMust be implemented in order to determine whether the given entity is accessible for the given session data. This method shouldn't check the same condition asCRUDServiceSecurity.hasViewAccess(BaseEntity). If the only condition for an entity isCRUDServiceSecurity.hasViewAccess(BaseEntity), this method should return false.- Specified by:
isAccessiblein classCRUDServiceSecurity<UserDTO,User,UserData,UserDataParams>
-
locate
public UserVO locate(UserLocatorVO locator) throws FrameworkException
Description copied from interface:UserServiceLocates a user by a customizable key. Fields are attempted in the following order (only the first non-blank field will be used for the search):- Id
- Username
- Field value with field's id
- Field value with field's internal name
- Mobile phone
- Specified by:
locatein interfaceUserService- Throws:
ValidationException- if the locator is invalid (there is no fields non null).EntityNotFoundException- if the user was not found or more than one user was found with the specified locator.FrameworkException
-
publicRegister
public UserRegistrationResult publicRegister(PublicRegistrationDTO dto) throws FrameworkException
Description copied from interface:UserServiceRegisters a user from a public registration- Specified by:
publicRegisterin interfaceUserService- Throws:
FrameworkException
-
register
public UserRegistrationResult register(UserRegistrationDTO dto) throws ValidationException, PasswordException
Description copied from interface:UserServiceRegisters a user- Specified by:
registerin interfaceUserService- Throws:
ValidationExceptionPasswordException
-
registerByMember
public UserRegistrationResult registerByMember(UserRegistrationByMemberDTO dto) throws FrameworkException
Description copied from interface:UserServiceRegisters a user by a regular member.- Specified by:
registerByMemberin interfaceUserService- Throws:
FrameworkException
-
search
public Page<UserWithFieldsVO> search(UserQuery query) throws QueryParseException
Description copied from interface:UserServiceSearch users according to the specified query parameters. The returned objects will either contain theBasicUserVO.DISPLAYandBasicUserVO.SHORT_DISPLAYproperties filled in or specific profile fields, depending on the products (permissions) of the viewing user. If there are profile fields marked to be returned, display and short display are not returned, as in most cases it would mean repeated information.- Specified by:
searchin interfaceUserService- Throws:
QueryParseException
-
validateRegistrationField
public String validateRegistrationField(ValidateRegistrationFieldParams params) throws FrameworkException
Description copied from interface:UserServiceValidates a field for user registration. The group must be a group allowed for registration. The field should be either an alias of aBasicProfileField.getByAlias(String)or the internal name of a custom field, and must be valid for the given group. The value should be a valid reference value, just as accepted byCustomFieldValueDTO.setReferenceValue(String)- Specified by:
validateRegistrationFieldin interfaceUserService- Throws:
FrameworkException
-
checkCreateNew
protected void checkCreateNew(UserDataParams params)
Description copied from class:CRUDServiceSecurityChecks whether creating new entities with the given context parameters is allowed, throwingPermissionDeniedExceptionif not- Specified by:
checkCreateNewin classCRUDServiceSecurity<UserDTO,User,UserData,UserDataParams>
-
getImplementation
protected UserServiceLocal getImplementation()
Description copied from class:CRUDServiceSecurityShould be implemented in order to return the actual implementation of the service- Specified by:
getImplementationin classCRUDServiceSecurity<UserDTO,User,UserData,UserDataParams>
-
onBeforeSave
protected void onBeforeSave(UserDTO dto, User user)
- Overrides:
onBeforeSavein classCRUDServiceSecurity<UserDTO,User,UserData,UserDataParams>
-
-