Package org.cyclos.security.access
Class PasswordServiceSecurity
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.security.BaseServiceSecurity
-
- org.cyclos.security.access.PasswordServiceSecurity
-
- All Implemented Interfaces:
PasswordService,Service
@Security public class PasswordServiceSecurity extends BaseServiceSecurity implements PasswordService
Security layer for password checks
-
-
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.services.access.PasswordService
MAX_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH
-
-
Constructor Summary
Constructors Constructor Description PasswordServiceSecurity()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringactivate(PasswordTypeVO passwordTypeVO)Activates a password whose mode isPasswordMode.GENERATEDcreating a new password for the current user.voidallowActivation(PasswordActionDTO params)Allows the given user to activate the given generated and pending passwordvoidchange(ChangePasswordDTO dto)Manually changes a passwordvoidchangeForgottenPassword(ChangeForgottenPasswordDTO dto)Changes a manual password leaving asPasswordStatus.ACTIVE, or if generated, send a new one (leaving asPasswordStatus.ACTIVEorPasswordStatus.RESETwhether the user has the change permission or not)voiddisable(PasswordActionDTO params)Disables a password.voidenable(PasswordActionDTO params)Enables a disabled password.ForgotPasswordRequestResponseforgotPasswordRequest(ForgotPasswordRequestDTO params)Initiates the forgot password operation, sending a code either by e-mail or SMS to the user.StringgenerateNew(ChangeGeneratedPasswordDTO params)Allows to change a generated password by generating a new oneChangeForgottenPasswordDatagetChangeForgottenPasswordData(GetChangeForgottenPasswordDataParams params)Returns data for a forgot password change requestChangePasswordDatagetChangePasswordData(boolean changeSecondaryPassword)Returns data for change the main/secondary access password (manual or generated)UserPasswordsDatagetData(UserLocatorVO locator)Returns data for user passwordsPasswordDatagetPasswordData(UserLocatorVO locator, PasswordTypeVO type)Returns data for a given password of the given user.SetSecurityQuestionDatagetSetSecurityQuestionData()Returns data used to set the security questionList<String>requestNewOTP(SendMedium medium, String channel)Generates a new OTP (removing any previous password, if any) and sends it by the specified medium using the confirmation mode configured the given channel for the logged user.List<String>requestNewOTPForSecondaryPassword(SendMedium medium)Same asPasswordService.requestNewOTP(SendMedium, String)but using the secondary password type configured in the current channel for the logged user.voidreset(PasswordActionDTO params)Resets the given generated password and allow it to be activated againvoidresetAndSend(ResetAndSendPasswordDTO params)Generates a new value of a manual password and send it to the user (for example, via e-mail).voidresetSecurityQuestion(UserLocatorVO locator)Resets the security question, forcing the user to set a new one in the next loginprotected EntityCheck<?>resolveEntityCheck()Must be implemented in order to return theEntityCheckmanaged by this security component, or null if nonevoidsetSecurityQuestion(SetSecurityQuestionDTO params)Sets the security question's answer for the logged uservoidunblock(PasswordActionDTO params)Unblocks the given user password-
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
-
-
-
-
Method Detail
-
activate
public String activate(PasswordTypeVO passwordTypeVO) throws FrameworkException, IllegalActionException
Description copied from interface:PasswordServiceActivates a password whose mode isPasswordMode.GENERATEDcreating a new password for the current user.- Specified by:
activatein interfacePasswordService- Throws:
IllegalActionException- When the given password type is not generated, or is not in any of the following statuses:FrameworkException
-
allowActivation
public void allowActivation(PasswordActionDTO params) throws FrameworkException, IllegalActionException
Description copied from interface:PasswordServiceAllows the given user to activate the given generated and pending password- Specified by:
allowActivationin interfacePasswordService- Throws:
IllegalActionException- When the given password is not generated / doesn't apply to the given userFrameworkException
-
change
public void change(ChangePasswordDTO dto) throws FrameworkException, IllegalActionException, PasswordException, ValidationException
Description copied from interface:PasswordServiceManually changes a password- Specified by:
changein interfacePasswordService- Throws:
PasswordException- The current password is invalidValidationException- When the given new password is invalid according to the constraintsIllegalActionException- When the current password cannot be changed (for example, it is generated)FrameworkException
-
changeForgottenPassword
public void changeForgottenPassword(ChangeForgottenPasswordDTO dto) throws FrameworkException, InvalidSecurityAnswerException
Description copied from interface:PasswordServiceChanges a manual password leaving asPasswordStatus.ACTIVE, or if generated, send a new one (leaving asPasswordStatus.ACTIVEorPasswordStatus.RESETwhether the user has the change permission or not)- Specified by:
changeForgottenPasswordin interfacePasswordService- Throws:
FrameworkExceptionInvalidSecurityAnswerException
-
disable
public void disable(PasswordActionDTO params) throws FrameworkException, IllegalActionException
Description copied from interface:PasswordServiceDisables a password. A disabled password cannot be used again, unless re-enabled- Specified by:
disablein interfacePasswordService- Throws:
IllegalActionException- When the current password cannot be disabled (for example, is already disabled)FrameworkException
-
enable
public void enable(PasswordActionDTO params) throws FrameworkException, IllegalActionException
Description copied from interface:PasswordServiceEnables a disabled password. A disabled password cannot be used again, unless re-enabled- Specified by:
enablein interfacePasswordService- Throws:
IllegalActionException- When the current password cannot be enabled (not in the disabled state)FrameworkException
-
forgotPasswordRequest
public ForgotPasswordRequestResponse forgotPasswordRequest(ForgotPasswordRequestDTO params) throws FrameworkException
Description copied from interface:PasswordServiceInitiates the forgot password operation, sending a code either by e-mail or SMS to the user. May also require a security question verification. Returns the e-mail address of phone numbers the code was sent to. The value will be masked if not the same one as requested in the params.- Specified by:
forgotPasswordRequestin interfacePasswordService- Throws:
FrameworkException
-
generateNew
public String generateNew(ChangeGeneratedPasswordDTO params) throws FrameworkException, IllegalActionException
Description copied from interface:PasswordServiceAllows to change a generated password by generating a new one- Specified by:
generateNewin interfacePasswordService- Throws:
FrameworkExceptionIllegalActionException
-
getChangeForgottenPasswordData
public ChangeForgottenPasswordData getChangeForgottenPasswordData(GetChangeForgottenPasswordDataParams params) throws FrameworkException
Description copied from interface:PasswordServiceReturns data for a forgot password change request- Specified by:
getChangeForgottenPasswordDatain interfacePasswordService- Throws:
FrameworkException
-
getChangePasswordData
public ChangePasswordData getChangePasswordData(boolean changeSecondaryPassword) throws FrameworkException
Description copied from interface:PasswordServiceReturns data for change the main/secondary access password (manual or generated)- Specified by:
getChangePasswordDatain interfacePasswordService- Throws:
FrameworkException
-
getData
public UserPasswordsData getData(UserLocatorVO locator) throws FrameworkException
Description copied from interface:PasswordServiceReturns data for user passwords- Specified by:
getDatain interfacePasswordService- Throws:
FrameworkException
-
getPasswordData
public PasswordData getPasswordData(UserLocatorVO locator, PasswordTypeVO type) throws FrameworkException
Description copied from interface:PasswordServiceReturns data for a given password of the given user.- Specified by:
getPasswordDatain interfacePasswordService- Throws:
FrameworkException
-
getSetSecurityQuestionData
public SetSecurityQuestionData getSetSecurityQuestionData() throws FrameworkException
Description copied from interface:PasswordServiceReturns data used to set the security question- Specified by:
getSetSecurityQuestionDatain interfacePasswordService- Throws:
FrameworkException
-
requestNewOTP
public List<String> requestNewOTP(SendMedium medium, String channel) throws FrameworkException
Description copied from interface:PasswordServiceGenerates a new OTP (removing any previous password, if any) and sends it by the specified medium using the confirmation mode configured the given channel for the logged user. If the channel is null then it use the current channel.- Specified by:
requestNewOTPin interfacePasswordService- Parameters:
medium- the medium used to send the OTP.channel- the channel used to get the confirmation mode configuration (password type / device)- Returns:
- the email or the normalized phones number the OTP was sent.
- Throws:
SmsSendingException- only if medium isSendMedium.SMSand the OTP could not be sent to any enabled for sms phone.FrameworkException
-
requestNewOTPForSecondaryPassword
public List<String> requestNewOTPForSecondaryPassword(SendMedium medium) throws FrameworkException
Description copied from interface:PasswordServiceSame asPasswordService.requestNewOTP(SendMedium, String)but using the secondary password type configured in the current channel for the logged user.- Specified by:
requestNewOTPForSecondaryPasswordin interfacePasswordService- Throws:
FrameworkException
-
reset
public void reset(PasswordActionDTO params) throws FrameworkException, IllegalActionException
Description copied from interface:PasswordServiceResets the given generated password and allow it to be activated again- Specified by:
resetin interfacePasswordService- Throws:
FrameworkExceptionIllegalActionException
-
resetAndSend
public void resetAndSend(ResetAndSendPasswordDTO params) throws FrameworkException, IllegalActionException
Description copied from interface:PasswordServiceGenerates a new value of a manual password and send it to the user (for example, via e-mail). If the password is generated, it will be initially active. If it is manual, it will keep the statusPasswordStatus.RESET, forcing the user to change it.- Specified by:
resetAndSendin interfacePasswordService- Throws:
FrameworkExceptionIllegalActionException
-
resetSecurityQuestion
public void resetSecurityQuestion(UserLocatorVO locator) throws FrameworkException
Description copied from interface:PasswordServiceResets the security question, forcing the user to set a new one in the next login- Specified by:
resetSecurityQuestionin interfacePasswordService- Throws:
FrameworkException
-
setSecurityQuestion
public void setSecurityQuestion(SetSecurityQuestionDTO params) throws FrameworkException
Description copied from interface:PasswordServiceSets the security question's answer for the logged user- Specified by:
setSecurityQuestionin interfacePasswordService- Throws:
FrameworkException
-
unblock
public void unblock(PasswordActionDTO params) throws FrameworkException, IllegalActionException
Description copied from interface:PasswordServiceUnblocks the given user password- Specified by:
unblockin interfacePasswordService- Throws:
IllegalActionException- When the given password is not blocked / doesn't apply to the given userFrameworkException
-
resolveEntityCheck
protected EntityCheck<?> resolveEntityCheck()
Description copied from class:BaseServiceSecurityMust be implemented in order to return theEntityCheckmanaged by this security component, or null if none- Specified by:
resolveEntityCheckin classBaseServiceSecurity
-
-