Merge pull request #3820 from patriot1burke/master

KEYCLOAK-4363
This commit is contained in:
Stian Thorgersen 2017-02-02 11:32:30 +01:00 committed by GitHub
commit be2378a424
4 changed files with 28 additions and 5 deletions

View file

@ -151,7 +151,7 @@ public class KerberosFederationProviderFactory implements UserStorageProviderFac
} }
@Override @Override
public void onUpdate(KeycloakSession session, RealmModel realm, ComponentModel model) { public void onUpdate(KeycloakSession session, RealmModel realm, ComponentModel oldModel, ComponentModel newModel) {
CredentialHelper.setOrReplaceAuthenticationRequirement(session, realm, CredentialRepresentation.KERBEROS, CredentialHelper.setOrReplaceAuthenticationRequirement(session, realm, CredentialRepresentation.KERBEROS,
AuthenticationExecutionModel.Requirement.ALTERNATIVE, AuthenticationExecutionModel.Requirement.DISABLED); AuthenticationExecutionModel.Requirement.ALTERNATIVE, AuthenticationExecutionModel.Requirement.DISABLED);
} }

View file

@ -375,8 +375,8 @@ public class LDAPStorageProviderFactory implements UserStorageProviderFactory<LD
} }
@Override @Override
public void onUpdate(KeycloakSession session, RealmModel realm, ComponentModel model) { public void onUpdate(KeycloakSession session, RealmModel realm, ComponentModel oldModel, ComponentModel newModel) {
checkKerberosCredential(session, realm, model); checkKerberosCredential(session, realm, newModel);
} }

View file

@ -97,7 +97,7 @@ public class ComponentUtil {
} }
public static void notifyUpdated(KeycloakSession session, RealmModel realm, ComponentModel oldModel, ComponentModel newModel) { public static void notifyUpdated(KeycloakSession session, RealmModel realm, ComponentModel oldModel, ComponentModel newModel) {
ComponentFactory factory = getComponentFactory(session, newModel); ComponentFactory factory = getComponentFactory(session, newModel);
factory.onUpdate(session, realm, newModel); factory.onUpdate(session, realm, oldModel, newModel);
if (factory instanceof UserStorageProviderFactory) { if (factory instanceof UserStorageProviderFactory) {
((OnUpdateComponent)session.userStorageManager()).onUpdate(session, realm, oldModel, newModel); ((OnUpdateComponent)session.userStorageManager()).onUpdate(session, realm, oldModel, newModel);
} }

View file

@ -39,20 +39,43 @@ public interface ComponentFactory<CreatedType, ProviderType extends Provider> ex
return null; return null;
} }
/**
* Called before a component is created or updated. Allows you to validate the configuration
*
* @param session
* @param realm
* @param model
* @throws ComponentValidationException
*/
default default
void validateConfiguration(KeycloakSession session, RealmModel realm, ComponentModel model) throws ComponentValidationException void validateConfiguration(KeycloakSession session, RealmModel realm, ComponentModel model) throws ComponentValidationException
{ {
} }
/**
* Called after a component is created
*
* @param session
* @param realm
* @param model
*/
default default
void onCreate(KeycloakSession session, RealmModel realm, ComponentModel model) { void onCreate(KeycloakSession session, RealmModel realm, ComponentModel model) {
} }
/**
* Called after the component is updated.
*
* @param session
* @param realm
* @param oldModel old saved model
* @param newModel new configuration
*/
default default
void onUpdate(KeycloakSession session, RealmModel realm, ComponentModel model) { void onUpdate(KeycloakSession session, RealmModel realm, ComponentModel oldModel, ComponentModel newModel) {
} }