keycloak-aplcache

KEYCLOAK-1327 Updated for clients

5/28/2015 6:28:56 AM

Details

diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js
index 8108df9..d5c7226 100755
--- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js
+++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js
@@ -230,7 +230,7 @@ module.controller('ClientCertificateImportCtrl', function($scope, $location, $ht
         for (var i = 0; i < $scope.files.length; i++) {
             var $file = $scope.files[i];
             $scope.upload = $upload.upload({
-                url: authUrl + '/admin/realms/' + realm.realm + '/clients-by-id/' + client.id + '/certificates/' + attribute + '/upload',
+                url: authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id + '/certificates/' + attribute + '/upload',
                 // method: POST or PUT,
                 // headers: {'headerKey': 'headerValue'}, withCredential: true,
                 data: {keystoreFormat: $scope.uploadKeyFormat,
@@ -290,7 +290,7 @@ module.controller('ClientCertificateExportCtrl', function($scope, $location, $ht
 
     $scope.download = function() {
         $http({
-            url: authUrl + '/admin/realms/' + realm.realm + '/clients-by-id/' + client.id + '/certificates/' + attribute + '/download',
+            url: authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id + '/certificates/' + attribute + '/download',
             method: 'POST',
             responseType: 'arraybuffer',
             data: $scope.jks,
@@ -906,7 +906,7 @@ module.controller('ClientScopeMappingCtrl', function($scope, $http, realm, clien
     };
 
     $scope.addRealmRole = function() {
-        $http.post(authUrl + '/admin/realms/' + realm.realm + '/clients-by-id/' + client.id + '/scope-mappings/realm',
+        $http.post(authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id + '/scope-mappings/realm',
                 $scope.selectedRealmRoles).success(function() {
                 updateRealmRoles();
                 Notifications.success("Scope mappings updated.");
@@ -914,7 +914,7 @@ module.controller('ClientScopeMappingCtrl', function($scope, $http, realm, clien
     };
 
     $scope.deleteRealmRole = function() {
-        $http.delete(authUrl + '/admin/realms/' + realm.realm + '/clients-by-id/' + client.id +  '/scope-mappings/realm',
+        $http.delete(authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id +  '/scope-mappings/realm',
             {data : $scope.selectedRealmMappings, headers : {"content-type" : "application/json"}}).success(function () {
                 updateRealmRoles();
                 Notifications.success("Scope mappings updated.");
@@ -922,7 +922,7 @@ module.controller('ClientScopeMappingCtrl', function($scope, $http, realm, clien
     };
 
     $scope.addClientRole = function() {
-        $http.post(authUrl + '/admin/realms/' + realm.realm + '/clients-by-id/' + client.id +  '/scope-mappings/clients-by-id/' + $scope.targetClient.id,
+        $http.post(authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id +  '/scope-mappings/clients/' + $scope.targetClient.id,
                 $scope.selectedClientRoles).success(function () {
                 updateClientRoles();
                 Notifications.success("Scope mappings updated.");
@@ -930,7 +930,7 @@ module.controller('ClientScopeMappingCtrl', function($scope, $http, realm, clien
     };
 
     $scope.deleteClientRole = function() {
-        $http.delete(authUrl + '/admin/realms/' + realm.realm + '/clients-by-id/' + client.id +  '/scope-mappings/clients-by-id/' + $scope.targetClient.id,
+        $http.delete(authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id +  '/scope-mappings/clients/' + $scope.targetClient.id,
             {data : $scope.selectedClientMappings, headers : {"content-type" : "application/json"}}).success(function () {
                 updateClientRoles();
                 Notifications.success("Scope mappings updated.");
@@ -1151,7 +1151,7 @@ module.controller('AddBuiltinProtocolMapperCtrl', function($scope, realm, client
                 toAdd.push($scope.mappers[i]);
             }
         }
-        $http.post(authUrl + '/admin/realms/' + realm.realm + '/clients-by-id/' + client.id + '/protocol-mappers/add-models',
+        $http.post(authUrl + '/admin/realms/' + realm.realm + '/clients/' + client.id + '/protocol-mappers/add-models',
                    toAdd).success(function() {
                 Notifications.success("Mappers added");
                 $location.url('/realms/' + realm.realm + '/clients/' + client.id +  '/mappers');
diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js
index 0be5122..b5d1eb4 100755
--- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js
+++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js
@@ -60,7 +60,7 @@ module.controller('UserRoleMappingCtrl', function($scope, $http, realm, user, cl
     };
 
     $scope.addClientRole = function() {
-        $http.post(authUrl + '/admin/realms/' + realm.realm + '/users/' + user.username + '/role-mappings/clients-by-id/' + $scope.client.id,
+        $http.post(authUrl + '/admin/realms/' + realm.realm + '/users/' + user.username + '/role-mappings/clients/' + $scope.client.id,
                 $scope.selectedClientRoles).success(function() {
                 $scope.clientMappings = ClientRoleMapping.query({realm : realm.realm, userId : user.username, client : $scope.client.id});
                 $scope.clientRoles = AvailableClientRoleMapping.query({realm : realm.realm, userId : user.username, client : $scope.client.id});
@@ -72,7 +72,7 @@ module.controller('UserRoleMappingCtrl', function($scope, $http, realm, user, cl
     };
 
     $scope.deleteClientRole = function() {
-        $http.delete(authUrl + '/admin/realms/' + realm.realm + '/users/' + user.username + '/role-mappings/clients-by-id/' + $scope.client.id,
+        $http.delete(authUrl + '/admin/realms/' + realm.realm + '/users/' + user.username + '/role-mappings/clients/' + $scope.client.id,
             {data : $scope.selectedClientMappings, headers : {"content-type" : "application/json"}}).success(function() {
                 $scope.clientMappings = ClientRoleMapping.query({realm : realm.realm, userId : user.username, client : $scope.client.id});
                 $scope.clientRoles = AvailableClientRoleMapping.query({realm : realm.realm, userId : user.username, client : $scope.client.id});
diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/services.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/services.js
index f192516..6a2edc3 100755
--- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/services.js
+++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/services.js
@@ -197,7 +197,7 @@ module.factory('ServerInfo', function($resource) {
 
 
 module.factory('ClientProtocolMapper', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/protocol-mappers/models/:id', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/protocol-mappers/models/:id', {
         realm : '@realm',
         client: '@client',
         id : "@id"
@@ -364,7 +364,7 @@ module.factory('AvailableRealmRoleMapping', function($resource) {
 
 
 module.factory('ClientRoleMapping', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/users/:userId/role-mappings/clients-by-id/:client', {
+    return $resource(authUrl + '/admin/realms/:realm/users/:userId/role-mappings/clients/:client', {
         realm : '@realm',
         userId : '@userId',
         client : "@client"
@@ -372,7 +372,7 @@ module.factory('ClientRoleMapping', function($resource) {
 });
 
 module.factory('AvailableClientRoleMapping', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/users/:userId/role-mappings/clients-by-id/:client/available', {
+    return $resource(authUrl + '/admin/realms/:realm/users/:userId/role-mappings/clients/:client/available', {
         realm : '@realm',
         userId : '@userId',
         client : "@client"
@@ -380,7 +380,7 @@ module.factory('AvailableClientRoleMapping', function($resource) {
 });
 
 module.factory('CompositeClientRoleMapping', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/users/:userId/role-mappings/clients-by-id/:client/composite', {
+    return $resource(authUrl + '/admin/realms/:realm/users/:userId/role-mappings/clients/:client/composite', {
         realm : '@realm',
         userId : '@userId',
         client : "@client"
@@ -388,28 +388,28 @@ module.factory('CompositeClientRoleMapping', function($resource) {
 });
 
 module.factory('ClientRealmScopeMapping', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/scope-mappings/realm', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/scope-mappings/realm', {
         realm : '@realm',
         client : '@client'
     });
 });
 
 module.factory('ClientAvailableRealmScopeMapping', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/scope-mappings/realm/available', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/scope-mappings/realm/available', {
         realm : '@realm',
         client : '@client'
     });
 });
 
 module.factory('ClientCompositeRealmScopeMapping', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/scope-mappings/realm/composite', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/scope-mappings/realm/composite', {
         realm : '@realm',
         client : '@client'
     });
 });
 
 module.factory('ClientClientScopeMapping', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/scope-mappings/clients-by-id/:targetClient', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/scope-mappings/clients/:targetClient', {
         realm : '@realm',
         client : '@client',
         targetClient : '@targetClient'
@@ -417,7 +417,7 @@ module.factory('ClientClientScopeMapping', function($resource) {
 });
 
 module.factory('ClientAvailableClientScopeMapping', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/scope-mappings/clients-by-id/:targetClient/available', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/scope-mappings/clients/:targetClient/available', {
         realm : '@realm',
         client : '@client',
         targetClient : '@targetClient'
@@ -425,7 +425,7 @@ module.factory('ClientAvailableClientScopeMapping', function($resource) {
 });
 
 module.factory('ClientCompositeClientScopeMapping', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/scope-mappings/clients-by-id/:targetClient/composite', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/scope-mappings/clients/:targetClient/composite', {
         realm : '@realm',
         client : '@client',
         targetClient : '@targetClient'
@@ -467,7 +467,7 @@ module.factory('RealmClientSessionStats', function($resource) {
 
 
 module.factory('RoleClientComposites', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/roles-by-id/:role/composites/clients-by-id/:client', {
+    return $resource(authUrl + '/admin/realms/:realm/roles-by-id/:role/composites/clients/:client', {
         realm : '@realm',
         role : '@role',
         client : "@client"
@@ -670,7 +670,7 @@ module.factory('RoleById', function($resource) {
 });
 
 module.factory('ClientRole', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/roles/:role', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/roles/:role', {
         realm : '@realm',
         client : "@client",
         role : '@role'
@@ -682,7 +682,7 @@ module.factory('ClientRole', function($resource) {
 });
 
 module.factory('ClientClaims', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/claims', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/claims', {
         realm : '@realm',
         client : "@client"
     },  {
@@ -693,7 +693,7 @@ module.factory('ClientClaims', function($resource) {
 });
 
 module.factory('ClientProtocolMappersByProtocol', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/protocol-mappers/protocol/:protocol', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/protocol-mappers/protocol/:protocol', {
         realm : '@realm',
         client : "@client",
         protocol : "@protocol"
@@ -701,41 +701,41 @@ module.factory('ClientProtocolMappersByProtocol', function($resource) {
 });
 
 module.factory('ClientSessionStats', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/session-stats', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/session-stats', {
         realm : '@realm',
         client : "@client"
     });
 });
 
 module.factory('ClientSessionStatsWithUsers', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/session-stats?users=true', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/session-stats?users=true', {
         realm : '@realm',
         client : "@client"
     });
 });
 
 module.factory('ClientSessionCount', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/session-count', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/session-count', {
         realm : '@realm',
         client : "@client"
     });
 });
 
 module.factory('ClientUserSessions', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/user-sessions', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/user-sessions', {
         realm : '@realm',
         client : "@client"
     });
 });
 
 module.factory('ClientLogoutAll', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/logout-all', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/logout-all', {
         realm : '@realm',
         client : "@client"
     });
 });
 module.factory('ClientLogoutUser', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/logout-user/:user', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/logout-user/:user', {
         realm : '@realm',
         client : "@client",
         user : "@user"
@@ -748,28 +748,28 @@ module.factory('RealmLogoutAll', function($resource) {
 });
 
 module.factory('ClientPushRevocation', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/push-revocation', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/push-revocation', {
         realm : '@realm',
         client : "@client"
     });
 });
 
 module.factory('ClientClusterNode', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/nodes/:node', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/nodes/:node', {
         realm : '@realm',
         client : "@client"
     });
 });
 
 module.factory('ClientTestNodesAvailable', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/test-nodes-available', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/test-nodes-available', {
         realm : '@realm',
         client : "@client"
     });
 });
 
 module.factory('ClientCertificate', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/certificates/:attribute', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/certificates/:attribute', {
             realm : '@realm',
             client : "@client",
             attribute: "@attribute"
@@ -777,7 +777,7 @@ module.factory('ClientCertificate', function($resource) {
 });
 
 module.factory('ClientCertificateGenerate', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/certificates/:attribute/generate', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/certificates/:attribute/generate', {
             realm : '@realm',
             client : "@client",
             attribute: "@attribute"
@@ -790,7 +790,7 @@ module.factory('ClientCertificateGenerate', function($resource) {
 });
 
 module.factory('ClientCertificateDownload', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/certificates/:attribute/download', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/certificates/:attribute/download', {
         realm : '@realm',
         client : "@client",
         attribute: "@attribute"
@@ -804,7 +804,7 @@ module.factory('ClientCertificateDownload', function($resource) {
 });
 
 module.factory('Client', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client', {
         realm : '@realm',
         client : '@client'
     },  {
@@ -815,7 +815,7 @@ module.factory('Client', function($resource) {
 });
 
 module.factory('ClientInstallation', function($resource) {
-    var url = authUrl + '/admin/realms/:realm/clients-by-id/:client/installation/json';
+    var url = authUrl + '/admin/realms/:realm/clients/:client/installation/json';
     return {
         url : function(parameters)
         {
@@ -824,7 +824,7 @@ module.factory('ClientInstallation', function($resource) {
     }
 });
 module.factory('ClientInstallationJBoss', function($resource) {
-    var url = authUrl + '/admin/realms/:realm/clients-by-id/:client/installation/jboss';
+    var url = authUrl + '/admin/realms/:realm/clients/:client/installation/jboss';
     return {
         url : function(parameters)
      {
@@ -834,7 +834,7 @@ module.factory('ClientInstallationJBoss', function($resource) {
 });
 
 module.factory('ClientCredentials', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/client-secret', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/client-secret', {
         realm : '@realm',
         client : '@client'
     },  {
@@ -845,7 +845,7 @@ module.factory('ClientCredentials', function($resource) {
 });
 
 module.factory('ClientOrigins', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/clients-by-id/:client/allowed-origins', {
+    return $resource(authUrl + '/admin/realms/:realm/clients/:client/allowed-origins', {
         realm : '@realm',
         client : '@client'
     },  {
diff --git a/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/ClientsResource.java b/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/ClientsResource.java
index 9843bc5..d02ce9b 100755
--- a/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/ClientsResource.java
+++ b/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/ClientsResource.java
@@ -9,6 +9,7 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import java.util.List;
 
 /**
@@ -16,12 +17,12 @@ import java.util.List;
  */
 public interface ClientsResource {
 
-    @Path("{clientId}")
-    public ClientResource get(@PathParam("clientId") String clientId);
+    @Path("{id}")
+    public ClientResource get(@PathParam("id") String id);
 
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
-    public void create(ClientRepresentation clientRepresentation);
+    public Response create(ClientRepresentation clientRepresentation);
 
     @GET
     @Produces(MediaType.APPLICATION_JSON)
diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AdminEventBuilder.java b/services/src/main/java/org/keycloak/services/resources/admin/AdminEventBuilder.java
index b9d2036..bc2bcc1 100644
--- a/services/src/main/java/org/keycloak/services/resources/admin/AdminEventBuilder.java
+++ b/services/src/main/java/org/keycloak/services/resources/admin/AdminEventBuilder.java
@@ -154,19 +154,7 @@ public class AdminEventBuilder {
         sb.append("/");
         String realmRelative = sb.toString();
 
-        path = path.substring(path.indexOf(realmRelative) + realmRelative.length());
-
-        if (path.contains("clients-by-id")) {
-            path = path.replaceAll("clients-by-id", "clients");
-        } else if (path.contains("roles-by-id")) {
-            path = path.replaceAll("roles-by-id", "roles");
-        } else if (path.contains("role-mappings/realm")) {
-            path = path.replaceFirst("role-mappings/realm", "role-mappings");
-        } else if (path.contains("role-mappings/clients")) {
-            path = path.replaceFirst("role-mappings/clients", "role-mappings");
-        }
-
-        return path;
+        return path.substring(path.indexOf(realmRelative) + realmRelative.length());
     }
 
     public void error(String error) {
diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ClientsResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ClientsResource.java
index 6fe3837..5d7c703 100755
--- a/services/src/main/java/org/keycloak/services/resources/admin/ClientsResource.java
+++ b/services/src/main/java/org/keycloak/services/resources/admin/ClientsResource.java
@@ -96,27 +96,23 @@ public class ClientsResource {
             
             adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo, clientModel.getId()).representation(rep).success();
             
-            return Response.created(uriInfo.getAbsolutePathBuilder().path(getClientPath(clientModel)).build()).build();
+            return Response.created(uriInfo.getAbsolutePathBuilder().path(clientModel.getId()).build()).build();
         } catch (ModelDuplicateException e) {
             return ErrorResponse.exists("Client " + rep.getClientId() + " already exists");
         }
     }
 
-    protected String getClientPath(ClientModel clientModel) {
-        return clientModel.getClientId();
-    }
-
     /**
      * Base path for managing a specific client.
      *
-     * @param name
+     * @param id id of client (not client-id)
      * @return
      */
-    @Path("{app-name}")
-    public ClientResource getClient(final @PathParam("app-name") String name) {
-        ClientModel clientModel = getClientByPathParam(name);
+    @Path("{id}")
+    public ClientResource getClient(final @PathParam("id") String id) {
+        ClientModel clientModel = realm.getClientById(id);
         if (clientModel == null) {
-            throw new NotFoundException("Could not find client: " + name);
+            throw new NotFoundException("Could not find client: " + id);
         }
 
         session.getContext().setClient(clientModel);
@@ -126,8 +122,4 @@ public class ClientsResource {
         return clientResource;
     }
 
-    protected ClientModel getClientByPathParam(String name) {
-        return realm.getClientByClientId(name);
-    }
-
 }
diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java
index 21c3cc9..e480294 100755
--- a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java
+++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java
@@ -119,18 +119,6 @@ public class RealmAdminResource {
     }
 
     /**
-     * Base path for managing clients under this realm.
-     *
-     * @return
-     */
-    @Path("clients-by-id")
-    public ClientsByIdResource getClientsById() {
-        ClientsByIdResource clientsResource = new ClientsByIdResource(realm, auth, adminEvent);
-        ResteasyProviderFactory.getInstance().injectProperties(clientsResource);
-        return clientsResource;
-    }
-
-    /**
      * base path for managing realm-level roles of this realm
      *
      * @return
diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RoleByIdResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RoleByIdResource.java
index 2f912f5..c138a46 100755
--- a/services/src/main/java/org/keycloak/services/resources/admin/RoleByIdResource.java
+++ b/services/src/main/java/org/keycloak/services/resources/admin/RoleByIdResource.java
@@ -170,46 +170,45 @@ public class RoleByIdResource extends RoleResource {
      * Return a set of client-level roles for a specific client that are in the role's composite
      *
      * @param id
-     * @param appName
+     * @param client
      * @return
      */
-    @Path("{role-id}/composites/clients/{app}")
+    @Path("{role-id}/composites/clients/{client}")
     @GET
     @NoCache
     @Produces(MediaType.APPLICATION_JSON)
     public Set<RoleRepresentation> getClientRoleComposites(final @PathParam("role-id") String id,
-                                                                final @PathParam("app") String appName) {
+                                                                final @PathParam("client") String client) {
         RoleModel role = getRoleModel(id);
         auth.requireView();
-        ClientModel app = realm.getClientByClientId(appName);
-        if (app == null) {
-            throw new NotFoundException("Could not find client: " + appName);
-
+        ClientModel clientModel = realm.getClientById(client);
+        if (clientModel == null) {
+            throw new NotFoundException("Could not find client: " + client);
         }
-        return getClientRoleComposites(app, role);
+        return getClientRoleComposites(clientModel, role);
     }
 
     /**
      * Return a set of client-level roles for a specific client that are in the role's composite
      *
-     * @param id
-     * @param appId
+     * @param role
+     * @param client
      * @return
      */
-    @Path("{role-id}/composites/clients-by-id/{appId}")
+    @Path("{role}/composites/clients/{client}")
     @GET
     @NoCache
     @Produces(MediaType.APPLICATION_JSON)
-    public Set<RoleRepresentation> getClientByIdRoleComposites(final @PathParam("role-id") String id,
-                                                                final @PathParam("appId") String appId) {
-        RoleModel role = getRoleModel(id);
+    public Set<RoleRepresentation> getClientByIdRoleComposites(final @PathParam("role-id") String role,
+                                                                final @PathParam("client") String client) {
+        RoleModel roleModel = getRoleModel(role);
         auth.requireView();
-        ClientModel app = realm.getClientById(appId);
-        if (app == null) {
-            throw new NotFoundException("Could not find client: " + appId);
+        ClientModel clientModel = realm.getClientById(client);
+        if (clientModel == null) {
+            throw new NotFoundException("Could not find client: " + client);
 
         }
-        return getClientRoleComposites(app, role);
+        return getClientRoleComposites(clientModel, roleModel);
     }
 
     /**
diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RoleContainerResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RoleContainerResource.java
index 111942d..2b225b6 100755
--- a/services/src/main/java/org/keycloak/services/resources/admin/RoleContainerResource.java
+++ b/services/src/main/java/org/keycloak/services/resources/admin/RoleContainerResource.java
@@ -223,60 +223,31 @@ public class RoleContainerResource extends RoleResource {
     }
 
     /**
-     * An client-level roles for a specific client for this role's composite
-     *
-     * @param roleName role's name (not id!)
-     * @param clientId
-     * @return
-     */
-    @Path("{role-name}/composites/client/{clientId}")
-    @GET
-    @NoCache
-    @Produces(MediaType.APPLICATION_JSON)
-    public Set<RoleRepresentation> getClientRoleComposites(
-                                                           final @PathParam("role-name") String roleName,
-                                                           final @PathParam("clientId") String clientId) {
-        auth.requireManage();
-
-        RoleModel role = roleContainer.getRole(roleName);
-        if (role == null) {
-            throw new NotFoundException("Could not find role: " + roleName);
-        }
-        ClientModel app = realm.getClientByClientId(clientId);
-        if (app == null) {
-            throw new NotFoundException("Could not find client: " + clientId);
-
-        }
-        return getClientRoleComposites(app, role);
-    }
-
-
-    /**
      * An app-level roles for a specific app for this role's composite
      *
      * @param roleName role's name (not id!)
-     * @param id
+     * @param client
      * @return
      */
-    @Path("{role-name}/composites/client-by-id/{id}")
+    @Path("{role-name}/composites/clients/{client}")
     @GET
     @NoCache
     @Produces(MediaType.APPLICATION_JSON)
-    public Set<RoleRepresentation> getClientByIdRoleComposites(@Context final UriInfo uriInfo,
+    public Set<RoleRepresentation> getClientRoleComposites(@Context final UriInfo uriInfo,
                                                                 final @PathParam("role-name") String roleName,
-                                                                final @PathParam("id") String id) {
+                                                                final @PathParam("client") String client) {
         auth.requireManage();
 
         RoleModel role = roleContainer.getRole(roleName);
         if (role == null) {
             throw new NotFoundException("Could not find role: " + roleName);
         }
-        ClientModel client = realm.getClientById(id);
+        ClientModel clientModel = realm.getClientById(client);
         if (client == null) {
-            throw new NotFoundException("Could not find client: " + id);
+            throw new NotFoundException("Could not find client: " + client);
 
         }
-        return getClientRoleComposites(client, role);
+        return getClientRoleComposites(clientModel, role);
     }
 
 
diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ScopeMappedResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ScopeMappedResource.java
index 587114d..d443a43 100755
--- a/services/src/main/java/org/keycloak/services/resources/admin/ScopeMappedResource.java
+++ b/services/src/main/java/org/keycloak/services/resources/admin/ScopeMappedResource.java
@@ -215,23 +215,12 @@ public class ScopeMappedResource {
 
     }
 
-    @Path("clients/{clientId}")
-    public ScopeMappedClientResource getClientScopeMappings(@PathParam("clientId") String clientId) {
-        ClientModel app = realm.getClientByClientId(clientId);
-
-        if (app == null) {
-            throw new NotFoundException("Role not found");
-        }
-        return new ScopeMappedClientResource(realm, auth, client, session, app, adminEvent);
-    }
-
-    @Path("clients-by-id/{id}")
-    public ScopeMappedClientResource getClientByIdScopeMappings(@PathParam("id") String id) {
-        ClientModel app = realm.getClientById(id);
-
-        if (app == null) {
+    @Path("clients/{client}")
+    public ScopeMappedClientResource getClientByIdScopeMappings(@PathParam("client") String client) {
+        ClientModel clientModel = realm.getClientById(client);
+        if (clientModel == null) {
             throw new NotFoundException("Client not found");
         }
-        return new ScopeMappedClientResource(realm, auth, client, session, app, adminEvent);
+        return new ScopeMappedClientResource(realm, auth, this.client, session, clientModel, adminEvent);
     }
 }
diff --git a/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java b/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java
index 42f6420..d56e506 100755
--- a/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java
+++ b/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java
@@ -681,35 +681,19 @@ public class UsersResource {
         
     }
 
-    @Path("{username}/role-mappings/clients/{clientId}")
-    public UserClientRoleMappingsResource getUserClientRoleMappingsResource(@PathParam("username") String username, @PathParam("clientId") String clientId) {
+    @Path("{username}/role-mappings/clients/{client}")
+    public UserClientRoleMappingsResource getUserClientRoleMappingsResource(@PathParam("username") String username, @PathParam("client") String client) {
         UserModel user = session.users().getUserByUsername(username, realm);
         if (user == null) {
             throw new NotFoundException("User not found");
         }
 
-        ClientModel client = realm.getClientByClientId(clientId);
-
-        if (client == null) {
-            throw new NotFoundException("Client not found");
-        }
-        return new UserClientRoleMappingsResource(uriInfo, realm, auth, user, client, adminEvent);
-
-    }
-    @Path("{username}/role-mappings/clients-by-id/{id}")
-    public UserClientRoleMappingsResource getUserClientRoleMappingsResourceById(@PathParam("username") String username, @PathParam("id") String id) {
-        UserModel user = session.users().getUserByUsername(username, realm);
-        if (user == null) {
-            throw new NotFoundException("User not found");
-        }
-
-        ClientModel client = realm.getClientById(id);
-
+        ClientModel clientModel = realm.getClientById(client);
         if (client == null) {
             throw new NotFoundException("Client not found");
         }
         
-        return new UserClientRoleMappingsResource(uriInfo, realm, auth, user, client, adminEvent);
+        return new UserClientRoleMappingsResource(uriInfo, realm, auth, user, clientModel, adminEvent);
 
     }
     /**
diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/ApiUtil.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/ApiUtil.java
new file mode 100644
index 0000000..a0b23c1
--- /dev/null
+++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/ApiUtil.java
@@ -0,0 +1,33 @@
+package org.keycloak.testsuite.admin;
+
+import org.keycloak.admin.client.resource.ClientResource;
+import org.keycloak.admin.client.resource.RealmResource;
+import org.keycloak.representations.idm.ClientRepresentation;
+
+import javax.ws.rs.core.Response;
+import java.net.URI;
+
+/**
+ * Created by st on 28.05.15.
+ */
+public class ApiUtil {
+
+    public static String getCreatedId(Response response) {
+        URI location = response.getLocation();
+        if (location == null) {
+            return null;
+        }
+        String path = location.getPath();
+        return path.substring(path.lastIndexOf('/') + 1);
+    }
+
+    public static ClientResource findClientByClientId(RealmResource realm, String clientId) {
+        for (ClientRepresentation c : realm.clients().findAll()) {
+            if (c.getClientId().equals(clientId)) {
+                return realm.clients().get(c.getId());
+            }
+        }
+        return null;
+    }
+
+}
diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/ClientTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/ClientTest.java
index 9d2fa9d..c30ee36 100755
--- a/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/ClientTest.java
+++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/ClientTest.java
@@ -45,28 +45,36 @@ public class ClientTest extends AbstractClientTest {
         assertNames(realm.clients().findAll(), "account", "realm-management", "security-admin-console", "broker");
     }
 
-    @Test
-    public void createClient() {
+    private String createClient() {
         ClientRepresentation rep = new ClientRepresentation();
         rep.setClientId("my-app");
         rep.setEnabled(true);
-        realm.clients().create(rep);
+        Response response = realm.clients().create(rep);
+        response.close();
+        return ApiUtil.getCreatedId(response);
+    }
+
+    @Test
+    public void createClientVerify() {
+        String id = createClient();
 
+        assertNotNull(realm.clients().get(id));
         assertNames(realm.clients().findAll(), "account", "realm-management", "security-admin-console", "broker", "my-app");
     }
 
     @Test
     public void removeClient() {
-        createClient();
+        String id = createClient();
 
-        realm.clients().get("my-app").remove();
+        realm.clients().get(id).remove();
     }
 
     @Test
     public void getClientRepresentation() {
-        createClient();
+        String id = createClient();
 
-        ClientRepresentation rep = realm.clients().get("my-app").toRepresentation();
+        ClientRepresentation rep = realm.clients().get(id).toRepresentation();
+        assertEquals(id, rep.getId());
         assertEquals("my-app", rep.getClientId());
         assertTrue(rep.isEnabled());
     }
@@ -81,7 +89,7 @@ public class ClientTest extends AbstractClientTest {
         OAuthClient.AccessTokenResponse response2 = oauth.doAccessTokenRequest(codeResponse.getCode(), "password");
         assertEquals(200, response2.getStatusCode());
 
-        ClientResource app = keycloak.realm("test").clients().get("test-app");
+        ClientResource app = ApiUtil.findClientByClientId(keycloak.realm("test"), "test-app");
 
         assertEquals(2, (long) app.getApplicationSessionCount().get("count"));
 
@@ -96,26 +104,28 @@ public class ClientTest extends AbstractClientTest {
         ClientRepresentation rep = new ClientRepresentation();
         rep.setClientId("my-app");
         rep.setEnabled(true);
-        realm.clients().create(rep);
+        Response response = realm.clients().create(rep);
+        response.close();
+        String id = ApiUtil.getCreatedId(response);
 
         RoleRepresentation role = new RoleRepresentation("test", "test");
-        realm.clients().get("my-app").roles().create(role);
+        realm.clients().get(id).roles().create(role);
 
-        rep = realm.clients().get("my-app").toRepresentation();
+        rep = realm.clients().get(id).toRepresentation();
         rep.setDefaultRoles(new String[] { "test" });
-        realm.clients().get("my-app").update(rep);
+        realm.clients().get(id).update(rep);
 
-        assertArrayEquals(new String[] { "test" }, realm.clients().get("my-app").toRepresentation().getDefaultRoles());
+        assertArrayEquals(new String[] { "test" }, realm.clients().get(id).toRepresentation().getDefaultRoles());
 
-        realm.clients().get("my-app").roles().deleteRole("test");
+        realm.clients().get(id).roles().deleteRole("test");
 
-        assertNull(realm.clients().get("my-app").toRepresentation().getDefaultRoles());
+        assertNull(realm.clients().get(id).toRepresentation().getDefaultRoles());
     }
 
     @Test
     public void testProtocolMappers() {
         createClient();
-        ProtocolMappersResource mappersResource = realm.clients().get("my-app").getProtocolMappers();
+        ProtocolMappersResource mappersResource = ApiUtil.findClientByClientId(realm, "my-app").getProtocolMappers();
 
         protocolMappersTest(mappersResource);
     }
@@ -171,4 +181,5 @@ public class ClientTest extends AbstractClientTest {
         } catch (NotFoundException nfe) {
         }
     }
+
 }