Search in sources :

Example 1 with SaltProvider

use of edu.stanford.bmir.protege.web.shared.auth.SaltProvider in project webprotege by protegeproject.

the class ChangePasswordPresenter method executeChangePassword.

private void executeChangePassword(final ChangePasswordData data, final WebProtegeDialogCloser closer) {
    AuthenticatedActionExecutor executor = new AuthenticatedActionExecutor(dispatchServiceManager, new PasswordDigestAlgorithm(new Md5DigestAlgorithmProvider()), new ChapResponseDigestAlgorithm(new Md5DigestAlgorithmProvider()));
    String currentPassword = data.getOldPassword();
    String newPassword = data.getNewPassword();
    ChangePasswordActionFactory actionFactory = new ChangePasswordActionFactory(newPassword, new SaltProvider());
    executor.execute(userId, currentPassword, actionFactory, new AuthenticatedDispatchServiceCallback<ChangePasswordResult>() {

        @Override
        public void handleAuthenticationResponse(@Nonnull AuthenticationResponse response) {
            if (response == AuthenticationResponse.SUCCESS) {
                MessageBox.showMessage("Your password has been changed");
                closer.hide();
            } else {
                handleIncorrectCurrentPassword();
            }
        }

        @Override
        public String getProgressDisplayTitle() {
            return "Changing password";
        }

        @Override
        public String getProgressDisplayMessage() {
            return "Please wait.";
        }
    });
}
Also used : AuthenticatedActionExecutor(edu.stanford.bmir.protege.web.client.auth.AuthenticatedActionExecutor) SaltProvider(edu.stanford.bmir.protege.web.shared.auth.SaltProvider)

Example 2 with SaltProvider

use of edu.stanford.bmir.protege.web.shared.auth.SaltProvider in project webprotege by protegeproject.

the class SignUpPresenter method handleSuccess.

private void handleSuccess(final SignupInfo data) {
    CreateUserAccountExecutor executor = new CreateUserAccountExecutor(dispatchServiceManager, new PasswordDigestAlgorithm(new Md5DigestAlgorithmProvider()), new SaltProvider());
    UserId userId = UserId.getUserId(data.getUserName());
    executor.execute(userId, data.getEmailAddress(), data.getPassword(), new DispatchServiceCallback<CreateUserAccountResult>() {

        @Override
        public void handleSuccess(CreateUserAccountResult createUserAccountResult) {
            MessageBox.showMessage("Registration complete", "You have successfully registered.");
            goToNextPlace();
        }

        @Override
        public void handleExecutionException(Throwable cause) {
            if (cause instanceof UserNameAlreadyExistsException) {
                String username = ((UserNameAlreadyExistsException) cause).getUsername();
                MessageBox.showAlert("User name already taken", "A user named " + username + " is already registered.  Please choose another name.");
            } else if (cause instanceof UserEmailAlreadyExistsException) {
                String email = ((UserEmailAlreadyExistsException) cause).getEmailAddress();
                MessageBox.showAlert("Email address already taken", "The email address " + email + " is already taken.  Please choose a different email address.");
            } else if (cause instanceof UserRegistrationException) {
                MessageBox.showAlert(cause.getMessage());
            } else {
                MessageBox.showAlert("Error registering account", "There was a problem registering the specified user account.  " + "Please contact administrator.");
            }
        }
    });
}
Also used : CreateUserAccountExecutor(edu.stanford.bmir.protege.web.client.user.CreateUserAccountExecutor) PasswordDigestAlgorithm(edu.stanford.bmir.protege.web.shared.auth.PasswordDigestAlgorithm) Md5DigestAlgorithmProvider(edu.stanford.bmir.protege.web.shared.auth.Md5DigestAlgorithmProvider) SaltProvider(edu.stanford.bmir.protege.web.shared.auth.SaltProvider)

Aggregations

SaltProvider (edu.stanford.bmir.protege.web.shared.auth.SaltProvider)2 AuthenticatedActionExecutor (edu.stanford.bmir.protege.web.client.auth.AuthenticatedActionExecutor)1 CreateUserAccountExecutor (edu.stanford.bmir.protege.web.client.user.CreateUserAccountExecutor)1 Md5DigestAlgorithmProvider (edu.stanford.bmir.protege.web.shared.auth.Md5DigestAlgorithmProvider)1 PasswordDigestAlgorithm (edu.stanford.bmir.protege.web.shared.auth.PasswordDigestAlgorithm)1