Package org.cyclos.impl.access
Class AccessClientServiceImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseServiceImpl
-
- org.cyclos.impl.CRUDServiceImpl<AccessClient,QAccessClient,AccessClientDTO,AccessClientData,AccessClientDataParams>
-
- org.cyclos.impl.access.AccessClientServiceImpl
-
- All Implemented Interfaces:
AccessClientServiceLocal,CRUDServiceLocal<AccessClient,AccessClientDTO,AccessClientData,AccessClientDataParams>,AccessClientService,CRUDService<AccessClientDTO,AccessClientData,AccessClientDataParams>,CRUDWithConfirmationPasswordService<AccessClientDTO,AccessClientData,AccessClientDataParams>,Service
@Service public class AccessClientServiceImpl extends CRUDServiceImpl<AccessClient,QAccessClient,AccessClientDTO,AccessClientData,AccessClientDataParams> implements AccessClientServiceLocal
Implementation forAccessClientService
-
-
Field Summary
-
Fields inherited from class org.cyclos.impl.CRUDServiceImpl
$, ATTR_CURRENT_COPY, cacheHandler, dtoClass, entityClass, extensionPointService, idPath, internalNamePath, namePath, ownerEntityIdPath, ownerEntityPath, ownerEntityPropertyName, richTextHandler, withConfirmationPassword
-
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
-
-
Constructor Summary
Constructors Constructor Description AccessClientServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ActivateAccessClientDTOactivate(String activationCode, String prefix)Activates an access client for the current user, using the given activation code.voidblock(AccessClientActionParams params)Blocks the given an access clientbooleancanActivateAccessClient(AccessClientPrincipalType type, User user)Returns if the given user can activate an access client of the given type by checking if there are unassigned access clients or if it is possible to create a new one.protected voiddoRemove(AccessClient accessClient, boolean flush)May be overridden in order to perform logical removing, instead of physical removing, or to remove some extra relationships as wellprotected <VO> Page<VO>doSearch(Class<VO> resultType, AccessClientQuery params)AccessClientfindByToken(Network network, String token)Finds an access client by token in the given networkAccessClientfindForAccess(Network network, String remoteAddress, String token)Returns an access client by tokenAccessClientfindForActivation(User user, String activationCode)Finds an access client for the given user for activation - needs to be in unassigned statusStringgetActivationCode(AccessClientActionParams params)Returns the code which can be used to activate the access client, connecting an applicationprotected AccessClientDatagetData(AccessClient accessClient)Returns details data for the given entityAccessClientsListDatagetListData(PrincipalTypeVO principalTypeVO, UserLocatorVO locator)Returns data for listing access clients of a given type and userAccessClientsSearchDatagetSearchData()Returns data for searching access clientsList<AccessClientTypeData>getTypeData(UserLocatorVO locator, ChannelVO channelVO)Returns data each access client type the authenticated user can see for the given user.booleanisVisible(AccessClient accessClient)Returns whether the given access client is visible to the logged userList<AccessClient>listVisible(User user, AccessClientStatus... status)Returns all visible access clients, ordered by type and then client namesAccessClientVOlocate(AccessClientLocatorVO locator)Returns an access client by either id or token, but only if it belongs (or is managed by) the authenticated userAccessClientlocateAccessClient(AccessClientLocatorVO locator)Locates an access client, either by id or tokenAccessClientnewEntity(AccessClientDataParams params)Should be implemented in order to instantiate a new entity based on the given context parametersprotected voidonAfterSave(AccessClient accessClient, AccessClient currentCopy, Object dataFromOnBeforeSave)May be overridden in order to perform custom logic after saving an entityprotected ObjectonBeforeSave(AccessClient entity, AccessClient currentCopy)May be overridden in order to perform custom logic before saving an entity.protected voidregisterNetworkMappings(NetworkPathRegistry networkPathRegistry)Needs to be overridden by subclasses to register the path up to the networkvoidremoveAll(User user)Removes all access clients of the given userprotected ValidatorresolveValidator(AccessClientDTO dto)Page<AccessClientDetailedVO>search(AccessClientQuery params)Searches for access clients according to the given criteriaAccessClienttoEntity(AccessClientDTO dto)Converts the given DTO in an entity, handling theCRUDServiceImpl.subClassMappings()mappings for subclassesvoidunassign(AccessClientActionParams params)Unassigns the given access client from its connected applicationbooleanunassignCurrent(ActionWithConfirmationPassword params)Unassigns the access client in the current authorization.voidunblock(AccessClientActionParams params)Unblocks the given access client-
Methods inherited from class org.cyclos.impl.CRUDServiceImpl
addCustomInternalNameValidations, addCustomNameValidations, checkConfirmationPassword, find, findAll, from, getConfirmationPasswordInput, getConfirmationPasswordInputForRemove, getData, getDataForNew, getDeviceConfirmationParams, getEntityClass, getEntityInternalNameKey, getExcludedPropertiesToDTO, getExcludedPropertiesToEntity, getNameLabel, getUniqueInternalNameQuery, getUniqueNameQuery, isEntityInternalNameRequired, isNameRequired, load, logEntity, onAfterRemove, onBeforeRemove, preProcessCurrentCopy, remove, remove, removeAll, removeAll, removeAllWithConfirmationPassword, removeWithConfirmationPassword, resolveDTOType, resolveEntityType, resolveExtensionPointAccessor, save, saveOrder, saveSkippingEntityLog, saveWithConfirmationPassword, shouldCheckConfirmationPassword, subClassMappings, toDTO, validate
-
Methods inherited from class org.cyclos.impl.BaseServiceImpl
initializeNetworkMappings
-
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, setAlreadyValidated, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, dataTranslationProxy, delete, detach, doDataTranslationProxy, 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.impl.CRUDServiceLocal
find, findAll, getEntityClass, remove, removeAll, saveEntity, saveSkippingEntityLog, toDTO, validate
-
-
-
-
Method Detail
-
activate
public ActivateAccessClientDTO activate(String activationCode, String prefix) throws FrameworkException
Description copied from interface:AccessClientServiceActivates an access client for the current user, using the given activation code. It is possible to pass in a prefix (optional) to have it appended before the activation code itself. Returns a dto containing the principal type and a token which is then used to identify the remote application. The prefix is not returned. So, if for example, "123" is passed as prefix, and "ABCDEF", the token needed to be used on web service requests will be "123ABCDEF", but only "ABCDEF" is returned. If the prefix is null, no prefix is used.- Specified by:
activatein interfaceAccessClientService- Throws:
FrameworkException
-
block
public void block(AccessClientActionParams params) throws FrameworkException
Description copied from interface:AccessClientServiceBlocks the given an access client- Specified by:
blockin interfaceAccessClientService- Throws:
IllegalActionException- When the status is not activeFrameworkException
-
canActivateAccessClient
public boolean canActivateAccessClient(AccessClientPrincipalType type, User user)
Description copied from interface:AccessClientServiceLocalReturns if the given user can activate an access client of the given type by checking if there are unassigned access clients or if it is possible to create a new one.- Specified by:
canActivateAccessClientin interfaceAccessClientServiceLocal
-
findByToken
public AccessClient findByToken(Network network, String token) throws FrameworkException
Description copied from interface:AccessClientServiceLocalFinds an access client by token in the given network- Specified by:
findByTokenin interfaceAccessClientServiceLocal- Throws:
FrameworkException
-
findForAccess
public AccessClient findForAccess(Network network, String remoteAddress, String token) throws FrameworkException
Description copied from interface:AccessClientServiceLocalReturns an access client by token- Specified by:
findForAccessin interfaceAccessClientServiceLocal- Throws:
FrameworkException
-
findForActivation
public AccessClient findForActivation(User user, String activationCode) throws FrameworkException
Description copied from interface:AccessClientServiceLocalFinds an access client for the given user for activation - needs to be in unassigned status- Specified by:
findForActivationin interfaceAccessClientServiceLocal- Throws:
FrameworkException
-
getActivationCode
public String getActivationCode(AccessClientActionParams params) throws FrameworkException
Description copied from interface:AccessClientServiceReturns the code which can be used to activate the access client, connecting an application- Specified by:
getActivationCodein interfaceAccessClientService- Throws:
IllegalActionException- When the status is not unassignedFrameworkException
-
getListData
public AccessClientsListData getListData(PrincipalTypeVO principalTypeVO, UserLocatorVO locator) throws FrameworkException
Description copied from interface:AccessClientServiceReturns data for listing access clients of a given type and user- Specified by:
getListDatain interfaceAccessClientService- Throws:
FrameworkException
-
getSearchData
public AccessClientsSearchData getSearchData() throws FrameworkException
Description copied from interface:AccessClientServiceReturns data for searching access clients- Specified by:
getSearchDatain interfaceAccessClientService- Throws:
FrameworkException
-
getTypeData
public List<AccessClientTypeData> getTypeData(UserLocatorVO locator, ChannelVO channelVO) throws FrameworkException
Description copied from interface:AccessClientServiceReturns data each access client type the authenticated user can see for the given user. If a channel is passed in, will only return types that can be used to access it.- Specified by:
getTypeDatain interfaceAccessClientService- Throws:
FrameworkException
-
isVisible
public boolean isVisible(AccessClient accessClient) throws FrameworkException
Description copied from interface:AccessClientServiceLocalReturns whether the given access client is visible to the logged user- Specified by:
isVisiblein interfaceAccessClientServiceLocal- Throws:
FrameworkException
-
listVisible
public List<AccessClient> listVisible(User user, AccessClientStatus... status) throws FrameworkException
Description copied from interface:AccessClientServiceLocalReturns all visible access clients, ordered by type and then client names- Specified by:
listVisiblein interfaceAccessClientServiceLocalstatus- If not null filter by those status. Otherwise returns all visible.- Throws:
FrameworkException
-
locate
public AccessClientVO locate(AccessClientLocatorVO locator) throws FrameworkException
Description copied from interface:AccessClientServiceReturns an access client by either id or token, but only if it belongs (or is managed by) the authenticated user- Specified by:
locatein interfaceAccessClientService- Throws:
FrameworkException
-
locateAccessClient
public AccessClient locateAccessClient(AccessClientLocatorVO locator) throws FrameworkException
Description copied from interface:AccessClientServiceLocalLocates an access client, either by id or token- Specified by:
locateAccessClientin interfaceAccessClientServiceLocal- Throws:
FrameworkException
-
newEntity
public AccessClient newEntity(AccessClientDataParams params)
Description copied from class:CRUDServiceImplShould be implemented in order to instantiate a new entity based on the given context parameters- Specified by:
newEntityin interfaceCRUDServiceLocal<AccessClient,AccessClientDTO,AccessClientData,AccessClientDataParams>- Specified by:
newEntityin classCRUDServiceImpl<AccessClient,QAccessClient,AccessClientDTO,AccessClientData,AccessClientDataParams>
-
removeAll
public void removeAll(User user)
Description copied from interface:AccessClientServiceLocalRemoves all access clients of the given user- Specified by:
removeAllin interfaceAccessClientServiceLocal
-
search
public Page<AccessClientDetailedVO> search(AccessClientQuery params) throws FrameworkException
Description copied from interface:AccessClientServiceSearches for access clients according to the given criteria- Specified by:
searchin interfaceAccessClientService- Throws:
FrameworkException
-
toEntity
public AccessClient toEntity(AccessClientDTO dto)
Description copied from class:CRUDServiceImplConverts the given DTO in an entity, handling theCRUDServiceImpl.subClassMappings()mappings for subclasses- Specified by:
toEntityin interfaceCRUDServiceLocal<AccessClient,AccessClientDTO,AccessClientData,AccessClientDataParams>- Overrides:
toEntityin classCRUDServiceImpl<AccessClient,QAccessClient,AccessClientDTO,AccessClientData,AccessClientDataParams>
-
unassign
public void unassign(AccessClientActionParams params) throws FrameworkException
Description copied from interface:AccessClientServiceUnassigns the given access client from its connected application- Specified by:
unassignin interfaceAccessClientService- Throws:
IllegalActionException- When the status is unassignedFrameworkException
-
unassignCurrent
public boolean unassignCurrent(ActionWithConfirmationPassword params) throws FrameworkException
Description copied from interface:AccessClientServiceUnassigns the access client in the current authorization. No-op if not authorized as an access client. Returns true if an access client was found associated to the current session.- Specified by:
unassignCurrentin interfaceAccessClientService- Throws:
FrameworkException
-
unblock
public void unblock(AccessClientActionParams params) throws FrameworkException
Description copied from interface:AccessClientServiceUnblocks the given access client- Specified by:
unblockin interfaceAccessClientService- Throws:
IllegalActionException- When the status is not blockedFrameworkException
-
doRemove
protected void doRemove(AccessClient accessClient, boolean flush)
Description copied from class:CRUDServiceImplMay be overridden in order to perform logical removing, instead of physical removing, or to remove some extra relationships as well- Overrides:
doRemovein classCRUDServiceImpl<AccessClient,QAccessClient,AccessClientDTO,AccessClientData,AccessClientDataParams>
-
doSearch
protected <VO> Page<VO> doSearch(Class<VO> resultType, AccessClientQuery params)
-
getData
protected AccessClientData getData(AccessClient accessClient)
Description copied from class:CRUDServiceImplReturns details data for the given entity- Specified by:
getDatain classCRUDServiceImpl<AccessClient,QAccessClient,AccessClientDTO,AccessClientData,AccessClientDataParams>
-
onAfterSave
protected void onAfterSave(AccessClient accessClient, AccessClient currentCopy, Object dataFromOnBeforeSave)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic after saving an entity- Overrides:
onAfterSavein classCRUDServiceImpl<AccessClient,QAccessClient,AccessClientDTO,AccessClientData,AccessClientDataParams>
-
onBeforeSave
protected Object onBeforeSave(AccessClient entity, AccessClient currentCopy)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic before saving an entity. Any returned value will be passed to theCRUDServiceImpl.onAfterSave(BaseEntity, BaseEntity, Object)method- Overrides:
onBeforeSavein classCRUDServiceImpl<AccessClient,QAccessClient,AccessClientDTO,AccessClientData,AccessClientDataParams>
-
registerNetworkMappings
protected void registerNetworkMappings(NetworkPathRegistry networkPathRegistry)
Description copied from class:BaseServiceImplNeeds to be overridden by subclasses to register the path up to the network- Specified by:
registerNetworkMappingsin classBaseServiceImpl
-
resolveValidator
protected Validator resolveValidator(AccessClientDTO dto)
- Specified by:
resolveValidatorin classCRUDServiceImpl<AccessClient,QAccessClient,AccessClientDTO,AccessClientData,AccessClientDataParams>
-
-