Merge pull request #3162 from mposolda/master
KEYCLOAK-3460 Support for ClientUpdatedEvent
This commit is contained in:
commit
3be47dee37
4 changed files with 34 additions and 5 deletions
|
@ -498,6 +498,18 @@ public class ClientAdapter implements ClientModel, JpaModel<ClientEntity> {
|
||||||
@Override
|
@Override
|
||||||
public void updateClient() {
|
public void updateClient() {
|
||||||
em.flush();
|
em.flush();
|
||||||
|
session.getKeycloakSessionFactory().publish(new RealmModel.ClientUpdatedEvent() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientModel getUpdatedClient() {
|
||||||
|
return ClientAdapter.this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KeycloakSession getKeycloakSession() {
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
|
|
||||||
package org.keycloak.models.mongo.keycloak.adapters;
|
package org.keycloak.models.mongo.keycloak.adapters;
|
||||||
|
|
||||||
import com.mongodb.DBObject;
|
|
||||||
import com.mongodb.QueryBuilder;
|
|
||||||
import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
|
import org.keycloak.connections.mongo.api.context.MongoStoreInvocationContext;
|
||||||
import org.keycloak.models.ClientModel;
|
import org.keycloak.models.ClientModel;
|
||||||
import org.keycloak.models.ClientTemplateModel;
|
import org.keycloak.models.ClientTemplateModel;
|
||||||
|
@ -65,6 +63,19 @@ public class ClientAdapter extends AbstractMongoAdapter<MongoClientEntity> imple
|
||||||
@Override
|
@Override
|
||||||
public void updateClient() {
|
public void updateClient() {
|
||||||
updateMongoEntity();
|
updateMongoEntity();
|
||||||
|
|
||||||
|
session.getKeycloakSessionFactory().publish(new RealmModel.ClientUpdatedEvent() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientModel getUpdatedClient() {
|
||||||
|
return ClientAdapter.this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KeycloakSession getKeycloakSession() {
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,12 @@ public interface RealmModel extends RoleContainerModel {
|
||||||
ClientModel getCreatedClient();
|
ClientModel getCreatedClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called also during client creation after client is fully initialized (including all attributes etc)
|
||||||
|
interface ClientUpdatedEvent extends ProviderEvent {
|
||||||
|
ClientModel getUpdatedClient();
|
||||||
|
KeycloakSession getKeycloakSession();
|
||||||
|
}
|
||||||
|
|
||||||
interface ClientRemovedEvent extends ProviderEvent {
|
interface ClientRemovedEvent extends ProviderEvent {
|
||||||
ClientModel getClient();
|
ClientModel getClient();
|
||||||
KeycloakSession getKeycloakSession();
|
KeycloakSession getKeycloakSession();
|
||||||
|
|
|
@ -943,7 +943,6 @@ public class RepresentationToModel {
|
||||||
} else {
|
} else {
|
||||||
client.setNodeReRegistrationTimeout(-1);
|
client.setNodeReRegistrationTimeout(-1);
|
||||||
}
|
}
|
||||||
client.updateClient();
|
|
||||||
|
|
||||||
if (resourceRep.getNotBefore() != null) {
|
if (resourceRep.getNotBefore() != null) {
|
||||||
client.setNotBefore(resourceRep.getNotBefore());
|
client.setNotBefore(resourceRep.getNotBefore());
|
||||||
|
@ -1043,6 +1042,8 @@ public class RepresentationToModel {
|
||||||
if (resourceRep.isUseTemplateMappers() != null) client.setUseTemplateMappers(resourceRep.isUseTemplateMappers());
|
if (resourceRep.isUseTemplateMappers() != null) client.setUseTemplateMappers(resourceRep.isUseTemplateMappers());
|
||||||
else client.setUseTemplateMappers(resourceRep.getClientTemplate() != null);
|
else client.setUseTemplateMappers(resourceRep.getClientTemplate() != null);
|
||||||
|
|
||||||
|
client.updateClient();
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1066,7 +1067,6 @@ public class RepresentationToModel {
|
||||||
if (rep.isSurrogateAuthRequired() != null) resource.setSurrogateAuthRequired(rep.isSurrogateAuthRequired());
|
if (rep.isSurrogateAuthRequired() != null) resource.setSurrogateAuthRequired(rep.isSurrogateAuthRequired());
|
||||||
if (rep.getNodeReRegistrationTimeout() != null) resource.setNodeReRegistrationTimeout(rep.getNodeReRegistrationTimeout());
|
if (rep.getNodeReRegistrationTimeout() != null) resource.setNodeReRegistrationTimeout(rep.getNodeReRegistrationTimeout());
|
||||||
if (rep.getClientAuthenticatorType() != null) resource.setClientAuthenticatorType(rep.getClientAuthenticatorType());
|
if (rep.getClientAuthenticatorType() != null) resource.setClientAuthenticatorType(rep.getClientAuthenticatorType());
|
||||||
resource.updateClient();
|
|
||||||
|
|
||||||
if (rep.getProtocol() != null) resource.setProtocol(rep.getProtocol());
|
if (rep.getProtocol() != null) resource.setProtocol(rep.getProtocol());
|
||||||
if (rep.getAttributes() != null) {
|
if (rep.getAttributes() != null) {
|
||||||
|
@ -1122,7 +1122,7 @@ public class RepresentationToModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource.updateClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
// CLIENT TEMPLATES
|
// CLIENT TEMPLATES
|
||||||
|
|
Loading…
Reference in a new issue