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)));
}
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.");
}
}
});
}
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);
}
Aggregations