[KEYCLOAK-405]-Fixed deletion of expired Credentials if policy removed.

This commit is contained in:
girirajsharma 2015-04-14 16:02:47 +05:30
parent e3bb61248a
commit 0ff4b6dd93
3 changed files with 12 additions and 0 deletions

View file

@ -259,6 +259,10 @@ public class UserAdapter implements UserModel, Comparable {
setValue(credentialEntity, cred);
user.getCredentials().add(credentialEntity);
} else {
List<CredentialEntity> credentialEntities = getCredentialEntities(user, UserCredentialModel.PASSWORD_HISTORY);
if (credentialEntities != null && credentialEntities.size() > 0) {
user.getCredentials().removeAll(credentialEntities);
}
setValue(credentialEntity, cred);
}
}

View file

@ -260,6 +260,10 @@ public class UserAdapter implements UserModel {
em.persist(credentialEntity);
user.getCredentials().add(credentialEntity);
} else {
List<CredentialEntity> credentialEntities = getCredentialEntities(user, UserCredentialModel.PASSWORD_HISTORY);
if (credentialEntities != null && credentialEntities.size() > 0) {
user.getCredentials().removeAll(credentialEntities);
}
setValue(credentialEntity, cred);
}
}

View file

@ -227,6 +227,10 @@ public class UserAdapter extends AbstractMongoAdapter<MongoUserEntity> implement
setValue(credentialEntity, cred);
user.getCredentials().add(credentialEntity);
} else {
List<CredentialEntity> credentialEntities = getCredentialEntities(user, UserCredentialModel.PASSWORD_HISTORY);
if (credentialEntities != null && credentialEntities.size() > 0) {
user.getCredentials().removeAll(credentialEntities);
}
setValue(credentialEntity, cred);
}
}