Package org.cyclos.impl.access
Interface CredentialAccessor
-
- All Superinterfaces:
ICredentials
public interface CredentialAccessor extends ICredentials
Interface 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.booleancanActivateCredentials()Indicates whether the authenticated user can activate any of the allowed credentialsbooleancanBeUsed()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.List<CredentialType>getActiveCredentials()Returns the credential types that are active for the userCredentialInputDTOgetCredentialInput()Returns information for a credential inputList<SendMedium>getOtpSendMediums()Returns the allowed mediums an OTP can be send to the logged user according to the credential usage.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.List<String>requestNewOTP(@NotNull SendMedium medium, List<Long> mobilePhoneIds)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.-
Methods inherited from interface org.cyclos.entities.system.ICredentials
getAllowedCredentials, getDeviceAvailability, getPassword, getPasswordAvailability, getTotpAvailability, hasPassword, isDefined, isDevice, isDeviceOnly, isPasswordOnly, isTotp, isTotpOnly
-
-
-
-
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.
-
canActivateCredentials
boolean canActivateCredentials()
Indicates whether the authenticated user can activate any of the allowed credentials
-
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.checkCredential(org.cyclos.entities.system.ChannelAccessAccessor, CredentialUsage, org.cyclos.entities.users.UserPrincipal, CreateDeviceConfirmationParams, boolean, String)
-
getActiveCredentials
List<CredentialType> getActiveCredentials()
Returns the credential types that are active for the user
-
getCredentialInput
CredentialInputDTO getCredentialInput()
Returns information for a credential input
-
getOtpSendMediums
List<SendMedium> getOtpSendMediums()
Returns the allowed mediums an OTP can be send to the logged user according to the credential usage.
-
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.
-
requestNewOTP
List<String> requestNewOTP(@NotNull @NotNull SendMedium medium, List<Long> mobilePhoneIds) 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.mobilePhoneIds- the identifiers of 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.MailSendException- only if medium isSendMedium.EMAILand the OTP could not be sent.
-
-