Package org.cyclos.impl.access
Interface CredentialAccessor
-
public interface CredentialAccessorInterface used to retrieve information about a credential for a specific usage. All data retrieved through this interface is related to the logged user and the current channel.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddRequiredValidation(Validator validator, PropertyAccess propertyAccess)Same as foraddRequiredValidation(Validator, Property)but with property access.voidaddRequiredValidation(Validator validator, Property<?,?> property)Adds a required property validation for the given property ONLY if credentials are used.
If the property is null then the validations are added as general ones.booleanallowDevice()Returns true if devices are allowed as credentials.booleanallowPassword()Returns true if passwords are allowed as credentials.
It takes into account the requested usage and also the current channel configuration of the logged user.booleancanBeUsed()Returns true if at least one of the defined credentials can be used, i.e: if passwords can be used and its status is one of these:PasswordStatus.ACTIVE,PasswordStatus.EXPIRED,PasswordStatus.RESETor if devices can be used and the user has at least one trusted device.
If no credentials are defined for the current usage then it returns false.voidcheck(String password, CreateDeviceConfirmationParams params)Checks the given password value or device confirmation for the current usage.
The givenCreateDeviceConfirmationParamsobject is required only when the password value represents a device confirmation.Set<SendMedium>getOtpSendMediums()Returns the allowed mediums an OTP can be send to the logged user according to the credential usage.PasswordInputDTOgetPasswordInput()PasswordTypegetPasswordType()Returns the password type according to the usage for the logged user and the current channel or null if the credential is only devices or credentials are not used at all.booleanhasExpired()Returns true if the allowed credentials has expired, i.e: if passwords can be used but is expired (the status is one of these:PasswordStatus.EXPIRED,PasswordStatus.RESET) or if devices can be used but the user doesn't have any trusted device.
If no credentials are defined for the current usage then it returns false.booleanhasTrustedDevices()Returns true if devices can be used and the logged has at least one trusted device configured.booleanisDefined()Returns true if any of the credentials are allowed.List<String>requestNewOTP(@NotNull SendMedium medium, List<Long> mobilePhonesIds)Generates a new OTP (removing any previous password, if any) and sends it by the specified medium (to the given mobile phones if any, in case ofSendMedium.SMS) using the password type for the current usage, current channel and the logged user.
-
-
-
Method Detail
-
addRequiredValidation
void addRequiredValidation(Validator validator, Property<?,?> property)
Adds a required property validation for the given property ONLY if credentials are used.
If the property is null then the validations are added as general ones.
-
addRequiredValidation
void addRequiredValidation(Validator validator, PropertyAccess propertyAccess)
Same as foraddRequiredValidation(Validator, Property)but with property access. If the property access is null then the validations are added as general ones.
-
allowDevice
boolean allowDevice()
Returns true if devices are allowed as credentials. It takes into account the requested usage and also the current channel configuration of the logged user.
-
allowPassword
boolean allowPassword()
Returns true if passwords are allowed as credentials.
It takes into account the requested usage and also the current channel configuration of the logged user.
-
canBeUsed
boolean canBeUsed()
Returns true if at least one of the defined credentials can be used, i.e: if passwords can be used and its status is one of these:PasswordStatus.ACTIVE,PasswordStatus.EXPIRED,PasswordStatus.RESETor if devices can be used and the user has at least one trusted device.
If no credentials are defined for the current usage then it returns false.
-
check
void check(String password, CreateDeviceConfirmationParams params)
Checks the given password value or device confirmation for the current usage.
The givenCreateDeviceConfirmationParamsobject is required only when the password value represents a device confirmation. In that case it's used to make sure that the operation the user confirmed is the same for which the password is being checked for.
IMPORTANT: In case ofCredentialUsage.ACCESSthis method checks the password but throws an error if the password has expired or has been reset. If you need to check the password for that usage and also support expired/reset then check it using this method:PasswordHandler#checkPassword(org.cyclos.entities.system.ChannelConfiguration, CredentialUsage, BasicUser, org.cyclos.model.access.devices.CreateDeviceConfirmationParams, boolean, String)
-
getOtpSendMediums
Set<SendMedium> getOtpSendMediums()
Returns the allowed mediums an OTP can be send to the logged user according to the credential usage.
-
getPasswordInput
PasswordInputDTO getPasswordInput()
-
getPasswordType
PasswordType getPasswordType()
Returns the password type according to the usage for the logged user and the current channel or null if the credential is only devices or credentials are not used at all.
-
hasExpired
boolean hasExpired()
Returns true if the allowed credentials has expired, i.e: if passwords can be used but is expired (the status is one of these:PasswordStatus.EXPIRED,PasswordStatus.RESET) or if devices can be used but the user doesn't have any trusted device.
If no credentials are defined for the current usage then it returns false.
-
hasTrustedDevices
boolean hasTrustedDevices()
Returns true if devices can be used and the logged has at least one trusted device configured. If devices can not be used then it returns false.
-
isDefined
boolean isDefined()
Returns true if any of the credentials are allowed. E.g if usage isCredentialUsage.CONFIRMATIONbut the current channel don't use confirmation at all then it returns false.- See Also:
allowDevice(),allowPassword()
-
requestNewOTP
List<String> requestNewOTP(@NotNull @NotNull SendMedium medium, List<Long> mobilePhonesIds) throws SmsSendingException, MailSendException
Generates a new OTP (removing any previous password, if any) and sends it by the specified medium (to the given mobile phones if any, in case ofSendMedium.SMS) using the password type for the current usage, current channel and the logged user.- Parameters:
medium- the medium used to send the OTP.mobilePhones- the mobile phones to send the OTP if the medium isSendMedium.SMS.- Returns:
- the email or the normalized phone numbers the OTP was sent.
- Throws:
SmsSendingException- only if medium isSendMedium.SMSand the OTP could not be sent to any enabled for sms phone.MailSendingException- only if medium isSendMedium.EMAILand the OTP could not be sent.MailSendException
-
-