diff --git a/services/src/main/java/org/keycloak/partialimport/ClientsPartialImport.java b/services/src/main/java/org/keycloak/partialimport/ClientsPartialImport.java index 308d634cc3..954c29166b 100755 --- a/services/src/main/java/org/keycloak/partialimport/ClientsPartialImport.java +++ b/services/src/main/java/org/keycloak/partialimport/ClientsPartialImport.java @@ -17,7 +17,9 @@ package org.keycloak.partialimport; +import org.jboss.logging.Logger; import org.keycloak.models.ClientModel; +import org.keycloak.models.Constants; import org.keycloak.models.KeycloakSession; import org.keycloak.models.RealmModel; import org.keycloak.models.utils.KeycloakModelUtils; @@ -26,7 +28,11 @@ import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.representations.idm.PartialImportRepresentation; import org.keycloak.representations.idm.ProtocolMapperRepresentation; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * PartialImport handler for Clients. @@ -35,9 +41,28 @@ import java.util.List; */ public class ClientsPartialImport extends AbstractPartialImport { + private static Set INTERNAL_CLIENTS = Collections.unmodifiableSet(new HashSet(Constants.defaultClients)); + + private static Logger logger = Logger.getLogger(ClientsPartialImport.class); + @Override public List getRepList(PartialImportRepresentation partialImportRep) { - return partialImportRep.getClients(); + List clients = partialImportRep.getClients(); + if (clients == null || clients.size() == 0) { + return clients; + } + + // filter out internal clients + List ret = new ArrayList(); + + for (ClientRepresentation c: clients) { + if (!isInternalClient(c.getClientId())) { + ret.add(c); + } else { + logger.debugv("Internal client {0} will not be processed", c.getClientId()); + } + } + return ret; } @Override @@ -85,4 +110,10 @@ public class ClientsPartialImport extends AbstractPartialImport