Search in sources :

Example 1 with Md5DigestAlgorithmProvider

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

the class DigestedPassword_TestCase method shouldGenerateSameDigestedPassword.

@Test
public void shouldGenerateSameDigestedPassword() {
    PasswordDigestAlgorithm passwordDigestAlgorithm = new PasswordDigestAlgorithm(new Md5DigestAlgorithmProvider());
    Salt salt = new Salt(BaseEncoding.base16().lowerCase().decode(SALT));
    SaltedPasswordDigest digest = passwordDigestAlgorithm.getDigestOfSaltedPassword("password", salt);
    assertThat(digest.getBytes(), is(BaseEncoding.base16().lowerCase().decode(DIGESTED_PASSWORD)));
}
Also used : Salt(edu.stanford.bmir.protege.web.shared.auth.Salt) SaltedPasswordDigest(edu.stanford.bmir.protege.web.shared.auth.SaltedPasswordDigest) Md5DigestAlgorithmProvider(edu.stanford.bmir.protege.web.shared.auth.Md5DigestAlgorithmProvider) PasswordDigestAlgorithm(edu.stanford.bmir.protege.web.shared.auth.PasswordDigestAlgorithm) Test(org.junit.Test)

Example 2 with Md5DigestAlgorithmProvider

use of edu.stanford.bmir.protege.web.shared.auth.Md5DigestAlgorithmProvider 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)

Example 3 with Md5DigestAlgorithmProvider

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

the class UserIcon method getHue.

private static float getHue(String name) {
    MessageDigestAlgorithm alg = new Md5DigestAlgorithmProvider().get();
    alg.update(name.getBytes());
    byte[] hash = alg.computeDigest();
    BigInteger bi = new BigInteger(hash);
    double percentageHue = Math.abs(bi.longValue() * 1.0 / Long.MAX_VALUE);
    // Bound the value so that it's not a Red colour
    double minHue = 25;
    double maxHue = 340;
    return (float) ((minHue + percentageHue * (maxHue - minHue)) / 360.0);
}
Also used : Md5DigestAlgorithmProvider(edu.stanford.bmir.protege.web.shared.auth.Md5DigestAlgorithmProvider) BigInteger(java.math.BigInteger) MessageDigestAlgorithm(edu.stanford.bmir.protege.web.shared.auth.MessageDigestAlgorithm)

Aggregations

Md5DigestAlgorithmProvider (edu.stanford.bmir.protege.web.shared.auth.Md5DigestAlgorithmProvider)3 PasswordDigestAlgorithm (edu.stanford.bmir.protege.web.shared.auth.PasswordDigestAlgorithm)2 CreateUserAccountExecutor (edu.stanford.bmir.protege.web.client.user.CreateUserAccountExecutor)1 MessageDigestAlgorithm (edu.stanford.bmir.protege.web.shared.auth.MessageDigestAlgorithm)1 Salt (edu.stanford.bmir.protege.web.shared.auth.Salt)1 SaltProvider (edu.stanford.bmir.protege.web.shared.auth.SaltProvider)1 SaltedPasswordDigest (edu.stanford.bmir.protege.web.shared.auth.SaltedPasswordDigest)1 BigInteger (java.math.BigInteger)1 Test (org.junit.Test)1