use of org.keycloak.models.credential.PasswordCredentialModel in project keycloak by keycloak.
the class PasswordHashingTest method testDefault.
@Test
public void testDefault() throws Exception {
setPasswordPolicy("");
String username = "testDefault";
createUser(username);
PasswordCredentialModel credential = PasswordCredentialModel.createFromCredentialModel(fetchCredentials(username));
assertEncoded(credential, "password", credential.getPasswordSecretData().getSalt(), "PBKDF2WithHmacSHA256", 27500);
}
use of org.keycloak.models.credential.PasswordCredentialModel in project keycloak by keycloak.
the class PasswordHashingTest method testPasswordNotRehasedUnchangedIterations.
// KEYCLOAK-5282
@Test
// TODO remove this (KEYCLOAK-16228)
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true)
public void testPasswordNotRehasedUnchangedIterations() {
setPasswordPolicy("");
String username = "testPasswordNotRehasedUnchangedIterations";
createUser(username);
PasswordCredentialModel credential = PasswordCredentialModel.createFromCredentialModel(fetchCredentials(username));
String credentialId = credential.getId();
byte[] salt = credential.getPasswordSecretData().getSalt();
setPasswordPolicy("hashIterations");
loginPage.open();
loginPage.login(username, "password");
credential = PasswordCredentialModel.createFromCredentialModel(fetchCredentials(username));
assertEquals(credentialId, credential.getId());
assertArrayEquals(salt, credential.getPasswordSecretData().getSalt());
setPasswordPolicy("hashIterations(" + Pbkdf2Sha256PasswordHashProviderFactory.DEFAULT_ITERATIONS + ")");
updateProfilePage.open();
updateProfilePage.logout();
loginPage.open();
loginPage.login(username, "password");
credential = PasswordCredentialModel.createFromCredentialModel(fetchCredentials(username));
assertEquals(credentialId, credential.getId());
assertArrayEquals(salt, credential.getPasswordSecretData().getSalt());
}
use of org.keycloak.models.credential.PasswordCredentialModel in project keycloak by keycloak.
the class PasswordHashingTest method testPbkdf2Sha1.
@Test
public void testPbkdf2Sha1() throws Exception {
setPasswordPolicy("hashAlgorithm(" + Pbkdf2PasswordHashProviderFactory.ID + ")");
String username = "testPbkdf2Sha1";
createUser(username);
PasswordCredentialModel credential = PasswordCredentialModel.createFromCredentialModel(fetchCredentials(username));
assertEncoded(credential, "password", credential.getPasswordSecretData().getSalt(), "PBKDF2WithHmacSHA1", 20000);
}
Aggregations