Class AuthenticationScriptService

  • All Implemented Interfaces:
    org.xwiki.script.service.ScriptService

    @Component
    @Named("security.authentication")
    @Singleton
    public class AuthenticationScriptService
    extends Object
    implements org.xwiki.script.service.ScriptService
    Security Authentication Script service.
    Since:
    11.6RC1
    Version:
    $Id: 282d876232bc707503369d5be2ad7739176fee95 $
    • Constructor Detail

      • AuthenticationScriptService

        public AuthenticationScriptService()
    • Method Detail

      • getAuthenticationFailureAvailableStrategies

        public Set<String> getAuthenticationFailureAvailableStrategies()
        Returns:
        name of all available authentication failure strategies.
      • getAuthenticationConfiguration

        public AuthenticationConfiguration getAuthenticationConfiguration()
        Returns:
        the current configuration.
      • resetAuthenticationFailureCounter

        public void resetAuthenticationFailureCounter​(String username)
        Reset the authentication failure record for the given username.
        Parameters:
        username - the username for which to remove the record.
      • getAuthenticationURL

        @Unstable
        public String getAuthenticationURL​(String action,
                                           Map<String,​Object> params)
        Compute a relative URL for an AuthenticationResourceReference based on the given action string. See AuthenticationAction for more information.
        Parameters:
        action - the authentication action from which to build the right URL.
        params - the query string parameters of the URL.
        Returns:
        a relative URL for the current wiki or null if an error occurs.
        Since:
        13.1RC1
      • requestResetPassword

        @Unstable
        public void requestResetPassword​(org.xwiki.user.UserReference user)
                                  throws ResetPasswordException
        Request a password reset for the given user. This will result in computing a verification code and sending the appropriate link by email to the user. This method returns the email address used, so that we can display it to the user.
        Parameters:
        user - the user for which to perform a reset password request.
        Throws:
        ResetPasswordException - if any error occurs for performing the reset password request.
        Since:
        13.1RC1
      • checkVerificationCode

        @Unstable
        public String checkVerificationCode​(org.xwiki.user.UserReference user,
                                            String verificationCode)
                                     throws ResetPasswordException
        Check that the given verification code is correct. Since a new verification code is generated (to avoid reusing a code several times), we also return the new code. Note that we don't need to protect this API for programming rights: if the verificationCode is not correct a ResetPasswordException is thrown and the verificationCode is reset. So a script attacker with wrong credentials cannot access the new verification code, or bruteforce it.
        Parameters:
        user - the user for which to check the verification code.
        verificationCode - the code to check.
        Returns:
        a newly generated verification code if it is correct.
        Throws:
        ResetPasswordException - if the code is not correct or if an error occurs.
        Since:
        13.1RC1
      • resetPassword

        @Unstable
        public void resetPassword​(org.xwiki.user.UserReference user,
                                  String verificationCode,
                                  String newPassword)
                           throws ResetPasswordException
        Reset the password of the given user, iff the given verification code is correct. This methods throws a ResetPasswordException if the verification code is wrong.
        Parameters:
        user - the user for which to reset the password.
        verificationCode - the code to check before resetting the passord.
        newPassword - the new password to user.
        Throws:
        ResetPasswordException - if the verification code is wrong, or if an error occurs.
        Since:
        13.1RC1
      • retrieveUsernameAndSendEmail

        @Unstable
        public void retrieveUsernameAndSendEmail​(String userEmail)
                                          throws RetrieveUsernameException
        Retrieve users information associated to the given email address and send them by email.
        Parameters:
        userEmail - the email address for which to find associated accounts
        Throws:
        RetrieveUsernameException - in case of problem for finding the information or for sending the email
        Since:
        14.9, 13.10.10, 14.4.6