Merge pull request #3613 from mposolda/master

KEYCLOAK-4042 Better error message when failed updating MSAD password…
This commit is contained in:
Marek Posolda 2016-12-06 11:50:33 +01:00 committed by GitHub
commit 9cd3034762
4 changed files with 28 additions and 3 deletions

View file

@ -488,9 +488,20 @@ public class LDAPStorageProvider implements UserStorageProvider,
UserCredentialModel cred = (UserCredentialModel)input; UserCredentialModel cred = (UserCredentialModel)input;
String password = cred.getValue(); String password = cred.getValue();
LDAPObject ldapUser = loadAndValidateUser(realm, user); LDAPObject ldapUser = loadAndValidateUser(realm, user);
ldapIdentityStore.updatePassword(ldapUser, password);
if (updater != null) updater.passwordUpdated(user, ldapUser, input); try {
return true; ldapIdentityStore.updatePassword(ldapUser, password);
if (updater != null) updater.passwordUpdated(user, ldapUser, input);
return true;
} catch (ModelException me) {
if (updater != null) {
updater.passwordUpdateFailed(user, ldapUser, input, me);
return false;
} else {
throw me;
}
}
} else { } else {
return false; return false;
} }

View file

@ -17,6 +17,7 @@
package org.keycloak.storage.ldap.mappers; package org.keycloak.storage.ldap.mappers;
import org.keycloak.credential.CredentialInput; import org.keycloak.credential.CredentialInput;
import org.keycloak.models.ModelException;
import org.keycloak.models.UserModel; import org.keycloak.models.UserModel;
import org.keycloak.storage.ldap.idm.model.LDAPObject; import org.keycloak.storage.ldap.idm.model.LDAPObject;
@ -25,5 +26,8 @@ import org.keycloak.storage.ldap.idm.model.LDAPObject;
* @version $Revision: 1 $ * @version $Revision: 1 $
*/ */
public interface PasswordUpdated { public interface PasswordUpdated {
void passwordUpdated(UserModel user, LDAPObject ldapUser, CredentialInput input); void passwordUpdated(UserModel user, LDAPObject ldapUser, CredentialInput input);
void passwordUpdateFailed(UserModel user, LDAPObject ldapUser, CredentialInput input, ModelException exception) throws ModelException;
} }

View file

@ -89,6 +89,11 @@ public class MSADUserAccountControlStorageMapper extends AbstractLDAPStorageMapp
updateUserAccountControl(ldapUser, control); updateUserAccountControl(ldapUser, control);
} }
@Override
public void passwordUpdateFailed(UserModel user, LDAPObject ldapUser, CredentialInput input, ModelException exception) {
throw processFailedPasswordUpdateException(exception);
}
@Override @Override
public UserModel proxy(LDAPObject ldapUser, UserModel delegate) { public UserModel proxy(LDAPObject ldapUser, UserModel delegate) {
return new MSADUserModelDelegate(delegate, ldapUser); return new MSADUserModelDelegate(delegate, ldapUser);

View file

@ -88,6 +88,11 @@ public class MSADLDSUserAccountControlStorageMapper extends AbstractLDAPStorageM
ldapProvider.getLdapIdentityStore().update(ldapUser); ldapProvider.getLdapIdentityStore().update(ldapUser);
} }
@Override
public void passwordUpdateFailed(UserModel user, LDAPObject ldapUser, CredentialInput input, ModelException exception) {
throw processFailedPasswordUpdateException(exception);
}
@Override @Override
public UserModel proxy(LDAPObject ldapUser, UserModel delegate) { public UserModel proxy(LDAPObject ldapUser, UserModel delegate) {
return new MSADUserModelDelegate(delegate, ldapUser); return new MSADUserModelDelegate(delegate, ldapUser);