Package org.cyclos.impl.access
Class PinServiceImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseServiceImpl
-
- org.cyclos.impl.access.PinServiceImpl
-
- All Implemented Interfaces:
PinServiceLocal,PinService,Service
@Service public class PinServiceImpl extends BaseServiceImpl implements PinServiceLocal
Implementation forPinService
-
-
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.PinServiceLocal
PRINCIPAL_LENGTH, SALT_LENGTH
-
-
Constructor Summary
Constructors Constructor Description PinServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckPin(Pin pin, String pinValue, ChannelAccessAccessor channelAccess)Checks the plain pin's value sent by a client ensuring it matched the value stored in the givenPinentity.PinensurePin(PinLocatorVO locator)Returns thePinfrom the given locator or (if null) from the current session if authenticated with pin.UserPinsDatagetData(UserLocatorVO locator)Returns data regarding pins for the given user (null resolves to the logged user).PinDatagetEditData(PinLocatorVO locator)Returns data for editing a pin.Pair<Pin,ChannelAccessAccessor>getIfActive(PinLocatorVO pinLocator, Channel channel)Returns both thePinand its channel access configuration for the current channel if it is active: exists, not expired and active on channel.PasswordInputDTOgetPasswordInputForCreate()Return the password input required to create a pin for the logged user.voidinitialize()List<PinVO>list(UserLocatorVO locator)Returns the list of device pins for the given user (null resolves to the logged user).
Manager users must have thePermission.USER_PINS_VIEWpermission.PinDetailedVOlocate(PinLocatorVO locator)Locates a device pin, either by id or principal.PinlocatePin(PinLocatorVO locator, boolean ownPin)Locates a device pin, either by id or principal.booleanpinEnabled(BasicUser user)Returns whether the given user has at least one channel with PIN enabled.protected voidregisterNetworkMappings(NetworkPathRegistry networkPathRegistry)Needs to be overridden by subclasses to register the path up to the network<T extends NetworkedEntity>
voidrelatedEntityRemoved(T entity, Supplier<T> newEntitySupplier)Searches for allPininstances related to the entity being removed and for all of those, sets the new entity obtained from the supplier as the new related one.
If the supplier returns null then all related pins are removed.voidremove(PinLocatorVO locator, CurrentCredentialsForPinManage currentCredentials)Removes the given pin.longremoveExpired()Removes all expired PINsvoidsave(PinDTO dto)Updates a given device pin for the logged user.CreatePinDTOset(SetPinParams params)Creates a new pin or modify an existing for the logged user and associates it to the current principal type and password type.ValidationResultvalidate(@NotNull String value)Validates a value to be used as a pin for the logged user and the current channel.-
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
-
-
-
-
Method Detail
-
checkPin
public void checkPin(Pin pin, String pinValue, ChannelAccessAccessor channelAccess)
Description copied from interface:PinServiceLocalChecks the plain pin's value sent by a client ensuring it matched the value stored in the givenPinentity.- Specified by:
checkPinin interfacePinServiceLocal
-
ensurePin
public Pin ensurePin(PinLocatorVO locator)
Description copied from interface:PinServiceLocalReturns thePinfrom the given locator or (if null) from the current session if authenticated with pin. Otherwise, if a pin can be obtained then it throws aValidationException.- Specified by:
ensurePinin interfacePinServiceLocal
-
getData
public UserPinsData getData(UserLocatorVO locator) throws FrameworkException
Description copied from interface:PinServiceReturns data regarding pins for the given user (null resolves to the logged user).- Specified by:
getDatain interfacePinService- Throws:
FrameworkException
-
getEditData
public PinData getEditData(PinLocatorVO locator) throws FrameworkException
Description copied from interface:PinServiceReturns data for editing a pin.- Specified by:
getEditDatain interfacePinService- Parameters:
locator- Optional if authenticated with a pin. Otherwise it must not be null.- Throws:
FrameworkException
-
getIfActive
public Pair<Pin,ChannelAccessAccessor> getIfActive(PinLocatorVO pinLocator, Channel channel)
Description copied from interface:PinServiceLocalReturns both thePinand its channel access configuration for the current channel if it is active: exists, not expired and active on channel. Otherwise, returns null.- Specified by:
getIfActivein interfacePinServiceLocal
-
getPasswordInputForCreate
public PasswordInputDTO getPasswordInputForCreate() throws FrameworkException
Description copied from interface:PinServiceReturn the password input required to create a pin for the logged user.- Specified by:
getPasswordInputForCreatein interfacePinService- Throws:
FrameworkException
-
initialize
@PostConstruct public void initialize()
-
list
public List<PinVO> list(UserLocatorVO locator) throws FrameworkException
Description copied from interface:PinServiceReturns the list of device pins for the given user (null resolves to the logged user).
Manager users must have thePermission.USER_PINS_VIEWpermission.- Specified by:
listin interfacePinService- Throws:
FrameworkException
-
locate
public PinDetailedVO locate(PinLocatorVO locator)
Description copied from interface:PinServiceLocates a device pin, either by id or principal. For users other than the pin's owner (admin / brokers) thePermission.USER_PINS_VIEWpermission must be granted- Specified by:
locatein interfacePinService- Parameters:
locator- Optional if authenticated with a pin. Otherwise it must not be null.
-
locatePin
public Pin locatePin(PinLocatorVO locator, boolean ownPin)
Description copied from interface:PinServiceLocalLocates a device pin, either by id or principal. If the ownPin parameter is true then the located pin (if any) must belong to the logged user.- Specified by:
locatePinin interfacePinServiceLocal
-
pinEnabled
public boolean pinEnabled(BasicUser user)
Description copied from interface:PinServiceLocalReturns whether the given user has at least one channel with PIN enabled.- Specified by:
pinEnabledin interfacePinServiceLocal
-
relatedEntityRemoved
public <T extends NetworkedEntity> void relatedEntityRemoved(T entity, Supplier<T> newEntitySupplier)
Description copied from interface:PinServiceLocalSearches for allPininstances related to the entity being removed and for all of those, sets the new entity obtained from the supplier as the new related one.
If the supplier returns null then all related pins are removed.- Specified by:
relatedEntityRemovedin interfacePinServiceLocal
-
remove
public void remove(PinLocatorVO locator, CurrentCredentialsForPinManage currentCredentials) throws FrameworkException
Description copied from interface:PinServiceRemoves the given pin. For managers (admin / brokers) thePermission.USER_PINS_MANAGEpermission must be granted. For the pin owner the action must be confirmed with the current login password for the current channel or the current pin. Only one of these is mandatory to be given.- Specified by:
removein interfacePinService- Parameters:
locator- Optional if authenticated with a pin. Otherwise it must not be null.- Throws:
FrameworkException
-
removeExpired
public long removeExpired()
Description copied from interface:PinServiceLocalRemoves all expired PINs- Specified by:
removeExpiredin interfacePinServiceLocal
-
save
public void save(PinDTO dto) throws FrameworkException
Description copied from interface:PinServiceUpdates a given device pin for the logged user. It will be used from the mobile in the settings page. The given pin's name must be unique, otherwise it throws aValidationException- Specified by:
savein interfacePinService- Throws:
FrameworkException
-
set
public CreatePinDTO set(SetPinParams params) throws FrameworkException
Description copied from interface:PinServiceCreates a new pin or modify an existing for the logged user and associates it to the current principal type and password type. The result will contain the generated principal and a salt that must be prepended to the pin entered by the user when login. In case of a modification the current pin or login password must be given.- Specified by:
setin interfacePinService- Throws:
FrameworkException
-
validate
public ValidationResult validate(@NotNull @NotNull String value)
Description copied from interface:PinServiceValidates a value to be used as a pin for the logged user and the current channel.- Specified by:
validatein interfacePinService- Returns:
- null if the value is valid. Otherwise return the validation error.
-
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
-
-