Package org.cyclos.impl.access
Class TrustedDeviceServiceImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseServiceImpl
-
- org.cyclos.impl.access.TrustedDeviceServiceImpl
-
- All Implemented Interfaces:
TrustedDeviceServiceLocal,TrustedDeviceService,Service
@Service public class TrustedDeviceServiceImpl extends BaseServiceImpl implements TrustedDeviceServiceLocal
Implementation forTrustedDeviceService
-
-
Field Summary
-
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.impl.access.TrustedDeviceServiceLocal
ACTIVATION_CODE_LENGTH, SECRET_KEY_LENGTH
-
-
Constructor Summary
Constructors Constructor Description TrustedDeviceServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ActivateTrustedDeviceDTOactivate(TrustedDeviceActivationParams params)Activates a trusted device by code or if a trusted device is required for activation then use theTrustedDeviceActivationParams.DEVICE_IDandTrustedDeviceActivationParams.DEVICE_CONFIRMATION_IDto ensure the corresponding device confirmation was already approved (using another trusted device).voidcheckForLogin(String remoteAddress, Long deviceConfirmationId, String hmac)Checks the if the current trusted device can be used for login validating the given PENDING confirmation.
This method only work for sessions with a trusted device, i.e if the current session data is not associated to a trusted device it throws anIllegalActionExceptionbooleanexists(long id)Returns true if exist an active trusted device with the given id.TrustedDeviceActivationDatagetActivationData()Returns data required to activate a device for the logged user.PasswordInputDTOgetConfirmationPasswordInputForRemove(@NotNull Long id)Returns thePasswordInputDTOfor the confirmation password that would be required if removing the trusted device with the given idTrustedDeviceDatagetData(long id)Returns data about a trusted device.booleanhasActiveDevices(BasicUser user)Returns true if the given user has at least one active trusted device.booleanhasAvailableSendMediums()Returns true if the logged user has at least one medium to send to the activation code.booleanisRequireTrustedDeviceForLogin()Returns true if at least one channel (not only the current channel) requires trusted devices for loginList<TrustedDeviceVO>list(UserLocatorVO locator)Returns the list of trusted devices for the given user (null resolves to the logged user).
Manager users must have thePermission.USER_TRUSTED_DEVICES_VIEWpermission.TrustedDeviceloadForOperate(long id)Loads an active trusted device for the logged user;longpurgePendingActivations(Date before)Delete all trusted devices created before the date passed as parameter and which activation code is not null (they were not activated).protected voidregisterNetworkMappings(NetworkPathRegistry networkPathRegistry)Needs to be overridden by subclasses to register the path up to the networkvoidremove(Long id, String confirmationPassword)Removes a trusted device by id for the logged user.RequestActivationResultrequestActivationCode(RequestDeviceActivationParams params)Requests for an activation code.voidsave(TrustedDeviceDTO dto)Updates a given trusted device for the logged user.-
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, 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
-
-
-
-
Method Detail
-
activate
public ActivateTrustedDeviceDTO activate(TrustedDeviceActivationParams params)
Description copied from interface:TrustedDeviceServiceActivates a trusted device by code or if a trusted device is required for activation then use theTrustedDeviceActivationParams.DEVICE_IDandTrustedDeviceActivationParams.DEVICE_CONFIRMATION_IDto ensure the corresponding device confirmation was already approved (using another trusted device).- Specified by:
activatein interfaceTrustedDeviceService
-
checkForLogin
public void checkForLogin(String remoteAddress, Long deviceConfirmationId, String hmac)
Description copied from interface:TrustedDeviceServiceLocalChecks the if the current trusted device can be used for login validating the given PENDING confirmation.
This method only work for sessions with a trusted device, i.e if the current session data is not associated to a trusted device it throws anIllegalActionException- Specified by:
checkForLoginin interfaceTrustedDeviceServiceLocal- Parameters:
remoteAddress- the client address to check if it's already blocked or notdeviceConfirmationId- the pendingDeviceConfirmationType.LOGINconfirmationhmac- the HMAC generated in the client using its private key
-
exists
public boolean exists(long id)
Description copied from interface:TrustedDeviceServiceLocalReturns true if exist an active trusted device with the given id.- Specified by:
existsin interfaceTrustedDeviceServiceLocal
-
getActivationData
public TrustedDeviceActivationData getActivationData()
Description copied from interface:TrustedDeviceServiceReturns data required to activate a device for the logged user.- Specified by:
getActivationDatain interfaceTrustedDeviceService
-
getConfirmationPasswordInputForRemove
public PasswordInputDTO getConfirmationPasswordInputForRemove(@NotNull @NotNull Long id) throws FrameworkException
Description copied from interface:TrustedDeviceServiceReturns thePasswordInputDTOfor the confirmation password that would be required if removing the trusted device with the given id- Specified by:
getConfirmationPasswordInputForRemovein interfaceTrustedDeviceService- Throws:
FrameworkException
-
getData
public TrustedDeviceData getData(long id) throws FrameworkException
Description copied from interface:TrustedDeviceServiceReturns data about a trusted device.- Specified by:
getDatain interfaceTrustedDeviceService- Throws:
FrameworkException
-
hasActiveDevices
public boolean hasActiveDevices(BasicUser user)
Description copied from interface:TrustedDeviceServiceLocalReturns true if the given user has at least one active trusted device.- Specified by:
hasActiveDevicesin interfaceTrustedDeviceServiceLocal
-
hasAvailableSendMediums
public boolean hasAvailableSendMediums()
Returns true if the logged user has at least one medium to send to the activation code.- Specified by:
hasAvailableSendMediumsin interfaceTrustedDeviceServiceLocal
-
isRequireTrustedDeviceForLogin
public boolean isRequireTrustedDeviceForLogin()
Description copied from interface:TrustedDeviceServiceLocalReturns true if at least one channel (not only the current channel) requires trusted devices for login- Specified by:
isRequireTrustedDeviceForLoginin interfaceTrustedDeviceServiceLocal
-
list
public List<TrustedDeviceVO> list(UserLocatorVO locator)
Description copied from interface:TrustedDeviceServiceReturns the list of trusted devices for the given user (null resolves to the logged user).
Manager users must have thePermission.USER_TRUSTED_DEVICES_VIEWpermission.- Specified by:
listin interfaceTrustedDeviceService
-
loadForOperate
public TrustedDevice loadForOperate(long id)
Description copied from interface:TrustedDeviceServiceLocalLoads an active trusted device for the logged user;- Specified by:
loadForOperatein interfaceTrustedDeviceServiceLocal
-
purgePendingActivations
public long purgePendingActivations(Date before)
Description copied from interface:TrustedDeviceServiceLocalDelete all trusted devices created before the date passed as parameter and which activation code is not null (they were not activated). Returns the count of deleted trusted devices.- Specified by:
purgePendingActivationsin interfaceTrustedDeviceServiceLocal
-
remove
public void remove(Long id, String confirmationPassword)
Description copied from interface:TrustedDeviceServiceRemoves a trusted device by id for the logged user.- Specified by:
removein interfaceTrustedDeviceService
-
requestActivationCode
public RequestActivationResult requestActivationCode(RequestDeviceActivationParams params)
Description copied from interface:TrustedDeviceServiceRequests for an activation code. This method can be used to request a code for the first time or as a new request for a given device. In case aRequestDeviceActivationParams.DEVICE_IDis given then the same existing code for that device will be send again and the the name won't be changed (it's ignored if given). Otherwise, a new pending trusted device will be created for the logged user and the code will be sent (in that case the name is required). (phone / e-mail). IfRequestDeviceActivationParams.MEDIUMisSendMedium.SMSthen the message will be send to the (required)RequestDeviceActivationParams.MOBILE_PHONE.- Specified by:
requestActivationCodein interfaceTrustedDeviceService- Returns:
- A VO with the following:
- The final name assigned to the device. It could be different to the input name if it's already in use
- The device id (required to re-send the code)
- The e-mail or the normalized mobile phone number that received the code
- The creation date
-
save
public void save(TrustedDeviceDTO dto)
Description copied from interface:TrustedDeviceServiceUpdates a given trusted device for the logged user. It will be used from the mobile in the settings page.- Specified by:
savein interfaceTrustedDeviceService
-
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
-
-