diff --git a/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/ComponentsResource.java b/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/ComponentsResource.java index d59c98394c..90b9d40319 100644 --- a/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/ComponentsResource.java +++ b/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/ComponentsResource.java @@ -46,6 +46,12 @@ public interface ComponentsResource { @Produces(MediaType.APPLICATION_JSON) public List query(@QueryParam("parent") String parent, @QueryParam("type") String type); + @GET + @Produces(MediaType.APPLICATION_JSON) + public List query(@QueryParam("parent") String parent, + @QueryParam("type") String type, + @QueryParam("name") String name); + @POST @Consumes(MediaType.APPLICATION_JSON) Response add(ComponentRepresentation rep); diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java b/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java index 1c4393d899..417a38bca2 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java @@ -1030,6 +1030,7 @@ public class RealmAdapter implements RealmModel, JpaModel { for (IdentityProviderEntity entity : realm.getIdentityProviders()) { if (entity.getAlias().equals(alias)) { + IdentityProviderModel model = entityToModel(entity); em.remove(entity); em.flush(); @@ -1042,7 +1043,7 @@ public class RealmAdapter implements RealmModel, JpaModel { @Override public IdentityProviderModel getRemovedIdentityProvider() { - return entityToModel(entity); + return model; } @Override diff --git a/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java b/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java index 077296d3ed..f79bbdacd5 100755 --- a/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java +++ b/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java @@ -840,6 +840,7 @@ public class RealmAdapter extends AbstractMongoAdapter impleme public void removeIdentityProviderByAlias(String alias) { for (IdentityProviderEntity entity : realm.getIdentityProviders()) { if (entity.getAlias().equals(alias)) { + IdentityProviderModel model = entityToModel(entity); realm.getIdentityProviders().remove(entity); updateRealm(); @@ -852,7 +853,7 @@ public class RealmAdapter extends AbstractMongoAdapter impleme @Override public IdentityProviderModel getRemovedIdentityProvider() { - return entityToModel(entity); + return model; } @Override diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ComponentResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ComponentResource.java index d3ac358f46..1b505239ae 100644 --- a/services/src/main/java/org/keycloak/services/resources/admin/ComponentResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ComponentResource.java @@ -100,7 +100,9 @@ public class ComponentResource { @GET @Produces(MediaType.APPLICATION_JSON) @NoCache - public List getComponents(@QueryParam("parent") String parent, @QueryParam("type") String type) { + public List getComponents(@QueryParam("parent") String parent, + @QueryParam("type") String type, + @QueryParam("name") String name) { auth.requireView(); List components = Collections.EMPTY_LIST; if (parent == null && type == null) { @@ -115,6 +117,7 @@ public class ComponentResource { } List reps = new LinkedList<>(); for (ComponentModel component : components) { + if (name != null && !name.equals(component.getName())) continue; ComponentRepresentation rep = ModelToRepresentation.toRepresentation(session, component, false); reps.add(rep); }