Class AuthenticationScriptService
- java.lang.Object
-
- org.xwiki.security.authentication.script.AuthenticationScriptService
-
- All Implemented Interfaces:
org.xwiki.script.service.ScriptService
@Component @Named("security.authentication") @Singleton public class AuthenticationScriptService extends Object implements org.xwiki.script.service.ScriptServiceSecurity Authentication Script service.- Since:
- 11.6RC1
- Version:
- $Id: 282d876232bc707503369d5be2ad7739176fee95 $
-
-
Constructor Summary
Constructors Constructor Description AuthenticationScriptService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcheckVerificationCode(org.xwiki.user.UserReference user, String verificationCode)Check that the given verification code is correct.AuthenticationConfigurationgetAuthenticationConfiguration()Set<String>getAuthenticationFailureAvailableStrategies()StringgetAuthenticationURL(String action, Map<String,Object> params)Compute a relative URL for anAuthenticationResourceReferencebased on the given action string.StringgetErrorMessage(String username)StringgetForm(String username)voidrequestResetPassword(org.xwiki.user.UserReference user)Request a password reset for the given user.voidresetAuthenticationFailureCounter(String username)Reset the authentication failure record for the given username.voidresetPassword(org.xwiki.user.UserReference user, String verificationCode, String newPassword)Reset the password of the given user, iff the given verification code is correct.voidretrieveUsernameAndSendEmail(String userEmail)Retrieve users information associated to the given email address and send them by email.
-
-
-
Field Detail
-
ID
public static final String ID
The role hint of this component.- See Also:
- Constant Field Values
-
-
Method Detail
-
getForm
public String getForm(String username)
- Parameters:
username- the login used in the request for authentication.- Returns:
- the aggregated form field to validate for the authentication
(see
AuthenticationFailureManager.getForm(String, javax.servlet.http.HttpServletRequest)
-
getErrorMessage
public String getErrorMessage(String username)
- Parameters:
username- the login used in the request for authentication.- Returns:
- the aggregated error messages to display for the user
(see
AuthenticationFailureManager.getErrorMessage(String)).
-
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 anAuthenticationResourceReferencebased on the given action string. SeeAuthenticationActionfor 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
nullif an error occurs. - Since:
- 13.1RC1
-
requestResetPassword
@Unstable public void requestResetPassword(org.xwiki.user.UserReference user) throws ResetPasswordExceptionRequest 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 aResetPasswordExceptionis 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 ResetPasswordExceptionReset the password of the given user, iff the given verification code is correct. This methods throws aResetPasswordExceptionif 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
-
-