Interface CredentialAccessor


  • public interface CredentialAccessor
    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 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.
      • 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.RESET or 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 given CreateDeviceConfirmationParams object 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 of CredentialUsage.ACCESS this 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.
      • 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.
      • 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 of SendMedium.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 is SendMedium.SMS.
        Returns:
        the email or the normalized phone numbers the OTP was sent.
        Throws:
        SmsSendingException - only if medium is SendMedium.SMS and the OTP could not be sent to any enabled for sms phone.
        MailSendingException - only if medium is SendMedium.EMAIL and the OTP could not be sent.
        MailSendException