diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/applications.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/applications.js index fc08bac447..12274e1564 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/applications.js +++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/applications.js @@ -54,7 +54,7 @@ module.controller('ApplicationCredentialsCtrl', function($scope, $location, real } ]; - ApplicationCredentials.update({ realm : realm.realm, application : application.id }, creds, + ApplicationCredentials.update({ realm : realm.realm, application : application.name }, creds, function() { Notifications.success('The password has been changed.'); $scope.password = null; @@ -76,7 +76,7 @@ module.controller('ApplicationCredentialsCtrl', function($scope, $location, real } ]; - ApplicationCredentials.update({ realm : realm.realm, application : application.id }, creds, + ApplicationCredentials.update({ realm : realm.realm, application : application.name }, creds, function() { Notifications.success('The totp was changed.'); $scope.totp = null; @@ -123,20 +123,20 @@ module.controller('ApplicationRoleDetailCtrl', function($scope, realm, applicati if ($scope.create) { ApplicationRole.save({ realm: realm.realm, - application : application.id + application : application.name }, $scope.role, function (data, headers) { $scope.changed = false; role = angular.copy($scope.role); var l = headers().location; var id = l.substring(l.lastIndexOf("/") + 1); - $location.url("/realms/" + realm.realm + "/applications/" + application.id + "/roles/" + id); + $location.url("/realms/" + realm.realm + "/applications/" + application.name + "/roles/" + id); Notifications.success("The role has been created."); }); } else { ApplicationRole.update({ realm : realm.realm, - application : application.id, + application : application.name, roleId : role.id }, $scope.role, function() { $scope.changed = false; @@ -152,17 +152,17 @@ module.controller('ApplicationRoleDetailCtrl', function($scope, realm, applicati }; $scope.cancel = function() { - $location.url("/realms/" + realm.realm + "/applications/" + application.id + "/roles"); + $location.url("/realms/" + realm.realm + "/applications/" + application.name + "/roles"); }; $scope.remove = function() { Dialog.confirmDelete($scope.role.name, 'role', function() { $scope.role.$remove({ realm : realm.realm, - application : application.id, + application : application.name, roleId : $scope.role.id }, function() { - $location.url("/realms/" + realm.realm + "/applications/" + application.id + "/roles"); + $location.url("/realms/" + realm.realm + "/applications/" + application.name + "/roles"); Notifications.success("The role has been deleted."); }); }); @@ -192,7 +192,7 @@ module.controller('ApplicationDetailCtrl', function($scope, realm, application, console.log('ApplicationDetailCtrl'); $scope.realm = realm; - $scope.create = !application.id; + $scope.create = !application.name; if (!$scope.create) { $scope.application= angular.copy(application); } else { @@ -233,7 +233,8 @@ module.controller('ApplicationDetailCtrl', function($scope, realm, application, $scope.save = function() { if ($scope.create) { Application.save({ - realm: realm.realm + realm: realm.realm, + application: '' }, $scope.application, function (data, headers) { $scope.changed = false; var l = headers().location; @@ -244,7 +245,7 @@ module.controller('ApplicationDetailCtrl', function($scope, realm, application, } else { Application.update({ realm : realm.realm, - id : application.id + id : application.name }, $scope.application, function() { $scope.changed = false; application = angular.copy($scope.application); @@ -266,7 +267,7 @@ module.controller('ApplicationDetailCtrl', function($scope, realm, application, Dialog.confirmDelete($scope.application.name, 'application', function() { $scope.application.$remove({ realm : realm.realm, - id : $scope.application.id + id : $scope.application.name }, function() { $location.url("/realms/" + realm.realm + "/applications"); Notifications.success("The application has been deleted."); @@ -292,7 +293,7 @@ module.controller('ApplicationScopeMappingCtrl', function($scope, $http, realm, - $scope.realmMappings = ApplicationRealmScopeMapping.query({realm : realm.realm, application : application.id}, function(){ + $scope.realmMappings = ApplicationRealmScopeMapping.query({realm : realm.realm, application : application.name}, function(){ for (var i = 0; i < $scope.realmMappings.length; i++) { var role = $scope.realmMappings[i]; for (var j = 0; j < $scope.realmRoles.length; j++) { @@ -309,7 +310,7 @@ module.controller('ApplicationScopeMappingCtrl', function($scope, $http, realm, }); $scope.addRealmRole = function() { - $http.post('/auth/rest/admin/realms/' + realm.realm + '/applications/' + application.id + '/scope-mappings/realm', + $http.post('/auth/rest/admin/realms/' + realm.realm + '/applications/' + application.name + '/scope-mappings/realm', $scope.selectedRealmRoles).success(function() { for (var i = 0; i < $scope.selectedRealmRoles.length; i++) { var role = $scope.selectedRealmRoles[i]; @@ -324,7 +325,7 @@ module.controller('ApplicationScopeMappingCtrl', function($scope, $http, realm, }; $scope.deleteRealmRole = function() { - $http.delete('/auth/rest/admin/realms/' + realm.realm + '/applications/' + application.id + '/scope-mappings/realm', + $http.delete('/auth/rest/admin/realms/' + realm.realm + '/applications/' + application.name + '/scope-mappings/realm', {data : $scope.selectedRealmMappings, headers : {"content-type" : "application/json"}}).success(function() { for (var i = 0; i < $scope.selectedRealmMappings.length; i++) { var role = $scope.selectedRealmMappings[i]; @@ -339,7 +340,7 @@ module.controller('ApplicationScopeMappingCtrl', function($scope, $http, realm, }; $scope.addApplicationRole = function() { - $http.post('/auth/rest/admin/realms/' + realm.realm + '/applications/' + application.id + '/scope-mappings/applications/' + $scope.targetApp.id, + $http.post('/auth/rest/admin/realms/' + realm.realm + '/applications/' + application.name + '/scope-mappings/applications/' + $scope.targetApp.name, $scope.selectedApplicationRoles).success(function() { for (var i = 0; i < $scope.selectedApplicationRoles.length; i++) { var role = $scope.selectedApplicationRoles[i]; @@ -354,7 +355,7 @@ module.controller('ApplicationScopeMappingCtrl', function($scope, $http, realm, }; $scope.deleteApplicationRole = function() { - $http.delete('/auth/rest/admin/realms/' + realm.realm + '/applications/' + application.id + '/scope-mappings/applications/' + $scope.targetApp.id, + $http.delete('/auth/rest/admin/realms/' + realm.realm + '/applications/' + application.name + '/scope-mappings/applications/' + $scope.targetApp.name, {data : $scope.selectedApplicationMappings, headers : {"content-type" : "application/json"}}).success(function() { for (var i = 0; i < $scope.selectedApplicationMappings.length; i++) { var role = $scope.selectedApplicationMappings[i]; @@ -370,8 +371,8 @@ module.controller('ApplicationScopeMappingCtrl', function($scope, $http, realm, $scope.changeApplication = function() { - $scope.applicationRoles = ApplicationRole.query({realm : realm.realm, application : $scope.targetApp.id}, function() { - $scope.applicationMappings = ApplicationApplicationScopeMapping.query({realm : realm.realm, application : application.id, targetApp : $scope.targetApp.id}, function(){ + $scope.applicationRoles = ApplicationRole.query({realm : realm.realm, application : $scope.targetApp.name}, function() { + $scope.applicationMappings = ApplicationApplicationScopeMapping.query({realm : realm.realm, application : application.name, targetApp : $scope.targetApp.name}, function(){ for (var i = 0; i < $scope.applicationMappings.length; i++) { var role = $scope.applicationMappings[i]; for (var j = 0; j < $scope.applicationRoles.length; j++) { diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/oauth-clients.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/oauth-clients.js index 7443130c0e..84b21fe58e 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/oauth-clients.js +++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/oauth-clients.js @@ -239,7 +239,7 @@ module.controller('OAuthClientScopeMappingCtrl', function($scope, $http, realm, }; $scope.addApplicationRole = function() { - $http.post('/auth/rest/admin/realms/' + realm.realm + '/oauth-clients/' + oauth.id + '/scope-mappings/applications/' + $scope.targetApp.id, + $http.post('/auth/rest/admin/realms/' + realm.realm + '/oauth-clients/' + oauth.id + '/scope-mappings/applications/' + $scope.targetApp.name, $scope.selectedApplicationRoles).success(function() { for (var i = 0; i < $scope.selectedApplicationRoles.length; i++) { var role = $scope.selectedApplicationRoles[i]; @@ -254,7 +254,7 @@ module.controller('OAuthClientScopeMappingCtrl', function($scope, $http, realm, }; $scope.deleteApplicationRole = function() { - $http.delete('/auth/rest/admin/realms/' + realm.realm + '/oauth-clients/' + oauth.id + '/scope-mappings/applications/' + $scope.targetApp.id, + $http.delete('/auth/rest/admin/realms/' + realm.realm + '/oauth-clients/' + oauth.id + '/scope-mappings/applications/' + $scope.targetApp.name, {data : $scope.selectedApplicationMappings, headers : {"content-type" : "application/json"}}).success(function() { for (var i = 0; i < $scope.selectedApplicationMappings.length; i++) { var role = $scope.selectedApplicationMappings[i]; @@ -270,8 +270,8 @@ module.controller('OAuthClientScopeMappingCtrl', function($scope, $http, realm, $scope.changeApplication = function() { - $scope.applicationRoles = ApplicationRole.query({realm : realm.realm, application : $scope.targetApp.id}, function() { - $scope.applicationMappings = OAuthClientApplicationScopeMapping.query({realm : realm.realm, oauth : oauth.id, targetApp : $scope.targetApp.id}, function(){ + $scope.applicationRoles = ApplicationRole.query({realm : realm.realm, application : $scope.targetApp.name}, function() { + $scope.applicationMappings = OAuthClientApplicationScopeMapping.query({realm : realm.realm, oauth : oauth.id, targetApp : $scope.targetApp.name}, function(){ for (var i = 0; i < $scope.applicationMappings.length; i++) { var role = $scope.applicationMappings[i]; for (var j = 0; j < $scope.applicationRoles.length; j++) { diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/realm.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/realm.js index 4b1cb4328d..f3e3da020b 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/realm.js +++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/realm.js @@ -28,7 +28,7 @@ module.controller('HomeCtrl', function(Realm, $location) { } else if (realms.length == 2) { if (realms[0].realm == 'keycloak-admin') { realm = realms[1].realm; - } else if (realms[1].realm == 'keycloak-admin') { + } else if (realms[1].realm == 'administration') { realm = realms[0].realm; } } @@ -502,7 +502,7 @@ module.controller('RealmRegistrationCtrl', function ($scope, Realm, realm, appli $scope.selectedAppDefRoles = []; // Populate available roles for selected application - var appDefaultRoles = ApplicationRole.query({realm: $scope.realm.realm, application: $scope.application.id}, function () { + var appDefaultRoles = ApplicationRole.query({realm: $scope.realm.realm, application: $scope.application.name}, function () { if (!$scope.application.hasOwnProperty('defaultRoles') || $scope.application.defaultRoles === null) { $scope.application.defaultRoles = []; @@ -540,7 +540,7 @@ module.controller('RealmRegistrationCtrl', function ($scope, Realm, realm, appli // Update/save the selected application with new default roles. Application.update({ realm: $scope.realm.realm, - id: $scope.application.id + id: $scope.application.name }, $scope.application, function () { Notifications.success("Your changes have been saved to the application."); }); @@ -564,7 +564,7 @@ module.controller('RealmRegistrationCtrl', function ($scope, Realm, realm, appli // Update/save the selected application with new default roles. Application.update({ realm: $scope.realm.realm, - id: $scope.application.id + id: $scope.application.name }, $scope.application, function () { Notifications.success("Your changes have been saved to the application."); }); diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/users.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/users.js index cf73bf9473..a90c45a027 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/users.js +++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/users.js @@ -60,7 +60,7 @@ module.controller('UserRoleMappingCtrl', function($scope, $http, realm, user, ro }; $scope.addApplicationRole = function() { - $http.post('/auth/rest/admin/realms/' + realm.realm + '/users/' + user.username + '/role-mappings/applications/' + $scope.application.id, + $http.post('/auth/rest/admin/realms/' + realm.realm + '/users/' + user.username + '/role-mappings/applications/' + $scope.application.name, $scope.selectedApplicationRoles).success(function() { for (var i = 0; i < $scope.selectedApplicationRoles.length; i++) { var role = $scope.selectedApplicationRoles[i]; @@ -75,7 +75,7 @@ module.controller('UserRoleMappingCtrl', function($scope, $http, realm, user, ro }; $scope.deleteApplicationRole = function() { - $http.delete('/auth/rest/admin/realms/' + realm.realm + '/users/' + user.username + '/role-mappings/applications/' + $scope.application.id, + $http.delete('/auth/rest/admin/realms/' + realm.realm + '/users/' + user.username + '/role-mappings/applications/' + $scope.application.name, {data : $scope.selectedApplicationMappings, headers : {"content-type" : "application/json"}}).success(function() { for (var i = 0; i < $scope.selectedApplicationMappings.length; i++) { var role = $scope.selectedApplicationMappings[i]; @@ -91,8 +91,8 @@ module.controller('UserRoleMappingCtrl', function($scope, $http, realm, user, ro $scope.changeApplication = function() { - $scope.applicationRoles = ApplicationRole.query({realm : realm.realm, userId : user.username, application : $scope.application.id}, function() { - $scope.applicationMappings = ApplicationRoleMapping.query({realm : realm.realm, userId : user.username, application : $scope.application.id}, function(){ + $scope.applicationRoles = ApplicationRole.query({realm : realm.realm, userId : user.username, application : $scope.application.name}, function() { + $scope.applicationMappings = ApplicationRoleMapping.query({realm : realm.realm, userId : user.username, application : $scope.application.name}, function(){ for (var i = 0; i < $scope.applicationMappings.length; i++) { var role = $scope.applicationMappings[i]; for (var j = 0; j < $scope.applicationRoles.length; j++) { diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/loaders.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/loaders.js index e3d1746f1d..84d3251686 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/js/loaders.js +++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/loaders.js @@ -111,7 +111,7 @@ module.factory('ApplicationLoader', function(Loader, Application, $route, $q) { return Loader.get(Application, function() { return { realm : $route.current.params.realm, - id : $route.current.params.application + application : $route.current.params.application } }); }); diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/services.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/services.js index 1b661f8d88..e3e73b5d91 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/js/services.js +++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/services.js @@ -208,9 +208,9 @@ module.factory('ApplicationRole', function($resource) { module.factory('Application', function($resource) { - return $resource('/auth/rest/admin/realms/:realm/applications/:id', { + return $resource('/auth/rest/admin/realms/:realm/applications/:application', { realm : '@realm', - id : '@id' + application : '@name' }, { update : { method : 'PUT' diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-credentials.html b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-credentials.html index 94e5145e16..59de7a6473 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-credentials.html +++ b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-credentials.html @@ -4,19 +4,19 @@

{{application.name}} Credentials

diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-detail.html b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-detail.html index 9c83a6deb2..b8ea14464c 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-detail.html +++ b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-detail.html @@ -4,12 +4,12 @@
@@ -28,7 +28,7 @@

{{application.name}} Settings

diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-installation.html b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-installation.html index 773d034748..88064bb5bc 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-installation.html +++ b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-installation.html @@ -4,12 +4,12 @@
diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-list.html b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-list.html index b68312190c..801074deaa 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-list.html +++ b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-list.html @@ -53,7 +53,7 @@ - {{app.name}} + {{app.name}} {{app.enabled}} {{app.baseUrl || "Not defined"}} diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-role-detail.html b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-role-detail.html index c5ddb25a20..84a39e3a14 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-role-detail.html +++ b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-role-detail.html @@ -4,20 +4,20 @@

{{application.name}} Add Role

@@ -26,8 +26,8 @@ diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-role-list.html b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-role-list.html index b497e24182..0561a6cc84 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-role-list.html +++ b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-role-list.html @@ -4,24 +4,24 @@

{{application.name}} Roles

@@ -29,7 +29,7 @@ @@ -64,7 +64,7 @@ - + diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-scope-mappings.html b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-scope-mappings.html index 2e9b94a3cd..c452c973b5 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-scope-mappings.html +++ b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-scope-mappings.html @@ -4,19 +4,19 @@

{{application.name}} Scope Mappings

diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-sessions.html b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-sessions.html index 1c5aa76f10..b00d13c0e9 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-sessions.html +++ b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-sessions.html @@ -4,19 +4,19 @@

{{application.name}} Sessions (Placeholder Page)

diff --git a/docbook/reference/en/en-US/modules/adapter-config.xml b/docbook/reference/en/en-US/modules/adapter-config.xml index 32ae3894d3..0152f2c858 100755 --- a/docbook/reference/en/en-US/modules/adapter-config.xml +++ b/docbook/reference/en/en-US/modules/adapter-config.xml @@ -9,8 +9,7 @@ "realm" : "demo", "resource" : "customer-portal", "realm-public-key" : "MIGfMA0GCSqGSIb3D...31LwIDAQAB", - "auth-url" : "https://localhost:8443/.../realms/demo/tokens/login", - "code-url" : "https://localhost:8443/.../realms/demo/tokens/access/codes", + "auth-server-url" : "https://localhost:8443/auth", "ssl-not-required" : false, "user-resource-role-mappings" : false, "enable-cors" : true, @@ -22,9 +21,9 @@ "password" : "password" } - "connection-pool-size" : 5, - "allo-any-hostname" : false, + "connection-pool-size" : 20, "disable-trust-manager" false, + "allow-any-hostname" : false, "truststore" : "path/to/truststore.jks", "truststore-password" : "geheim", "client-keystore" : "path/to/client-keystore.jks", @@ -79,22 +78,11 @@ - auth-url + auth-server-url - URL of the realm's login page of the Keycloak Server's token service. You can obtain - this URL from the admin console. - This is - REQUIRED. - - - - - code-url - - - URL to turn an access code into an access token. You can obtain - this URL from the admin console. + The base URL of the Keycloak Server. All other Keycloak pages and REST services are derived + from this. It is usually of the form https://host:port/auth This is REQUIRED. @@ -191,6 +179,41 @@ + + + connection-pool-size + + + Adapters will make separate HTTP invocations to the Keycloak Server to turn an access code + into an access token. This config option defines how many connections to the Keycloak Server + should be pooled. + This isOPTIONAL. The default value is 20. + + + + + disable-trust-manager + + + If the Keycloak Server requires HTTPS and this config option is set to true + you do not have to specify a truststore. While convenient, this setting is not recommended + as you will not be verifying the host name of the Keycloak Server. + This isOPTIONAL. The default value is false. + + + + + allow-any-hostname + + + If the Keycloak Server requires HTTPS and this config option is set to true + the Keycloak Server's certificate is validated via the truststore, but host name validation is + not done. This is not a recommended. This seting may be useful in test environments + This isOPTIONAL. The default value is false. + + + + truststore diff --git a/model/api/src/main/java/org/keycloak/models/RealmModel.java b/model/api/src/main/java/org/keycloak/models/RealmModel.java index 77710972e2..40d4eeb6d7 100755 --- a/model/api/src/main/java/org/keycloak/models/RealmModel.java +++ b/model/api/src/main/java/org/keycloak/models/RealmModel.java @@ -112,6 +112,7 @@ public interface RealmModel extends RoleContainerModel, RoleMapperModel, ScopeMa List getRequiredOAuthClientCredentials(); ApplicationModel getApplicationById(String id); + ApplicationModel getApplicationByName(String name); void addRequiredOAuthClientCredential(String type); 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 3427777ef9..ce55d8ebda 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 @@ -604,6 +604,11 @@ public class RealmAdapter implements RealmModel { return new ApplicationAdapter(em, app); } + @Override + public ApplicationModel getApplicationByName(String name) { + return getApplicationNameMap().get(name); + } + @Override public UserModel getUserBySocialLink(SocialLinkModel socialLink) { TypedQuery query = em.createNamedQuery("findUserByLinkAndRealm", UserEntity.class); diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java index 353face466..7bf11030bd 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java @@ -26,7 +26,8 @@ import java.util.Map; @NamedQueries({ @NamedQuery(name="getAllRealms", query="select realm from RealmEntity realm"), @NamedQuery(name="getRealmByName", query="select realm from RealmEntity realm where realm.name = :name"), -})public class RealmEntity { +}) +public class RealmEntity { @Id protected String id; diff --git a/model/picketlink/src/main/java/org/keycloak/models/picketlink/RealmAdapter.java b/model/picketlink/src/main/java/org/keycloak/models/picketlink/RealmAdapter.java index 637ee1cba5..debb24607a 100755 --- a/model/picketlink/src/main/java/org/keycloak/models/picketlink/RealmAdapter.java +++ b/model/picketlink/src/main/java/org/keycloak/models/picketlink/RealmAdapter.java @@ -618,6 +618,12 @@ public class RealmAdapter implements RealmModel { return model; } + @Override + public ApplicationModel getApplicationByName(String name) { + return getApplicationNameMap().get(name); + } + + @Override public List getApplications() { diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsResource.java index efcc0f63cb..faf90e711b 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ApplicationsResource.java @@ -64,12 +64,12 @@ public class ApplicationsResource { } ApplicationManager resourceManager = new ApplicationManager(new RealmManager(session)); ApplicationModel applicationModel = resourceManager.createApplication(realm, rep); - return Response.created(uriInfo.getAbsolutePathBuilder().path(applicationModel.getId()).build()).build(); + return Response.created(uriInfo.getAbsolutePathBuilder().path(applicationModel.getName()).build()).build(); } - @Path("{id}") - public ApplicationResource getApplication(final @PathParam("id") String id) { - ApplicationModel applicationModel = realm.getApplicationById(id); + @Path("{app-name}") + public ApplicationResource getApplication(final @PathParam("app-name") String name) { + ApplicationModel applicationModel = realm.getApplicationByName(name); if (applicationModel == null) { throw new NotFoundException(); } 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 f3f91ef8ae..b3e6f0105e 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 @@ -126,12 +126,12 @@ public class ScopeMappedResource { } } - @Path("applications/{appId}") + @Path("applications/{app}") @GET @Produces("application/json") @NoCache - public List getApplicationScopeMappings(@PathParam("appId") String appId) { - ApplicationModel app = realm.getApplicationById(appId); + public List getApplicationScopeMappings(@PathParam("app") String appName) { + ApplicationModel app = realm.getApplicationByName(appName); if (app == null) { throw new NotFoundException(); @@ -145,11 +145,11 @@ public class ScopeMappedResource { return mapRep; } - @Path("applications/{appId}") + @Path("applications/{app}") @POST @Consumes("application/json") - public void addApplicationScopeMapping(@PathParam("appId") String appId, List roles) { - ApplicationModel app = realm.getApplicationById(appId); + public void addApplicationScopeMapping(@PathParam("app") String appName, List roles) { + ApplicationModel app = realm.getApplicationByName(appName); if (app == null) { throw new NotFoundException(); @@ -165,11 +165,11 @@ public class ScopeMappedResource { } - @Path("applications/{appId}") + @Path("applications/{app}") @DELETE @Consumes("application/json") - public void deleteApplicationRoleMapping(@PathParam("appId") String appId, List roles) { - ApplicationModel app = realm.getApplicationById(appId); + public void deleteApplicationRoleMapping(@PathParam("app") String appName, List roles) { + ApplicationModel app = realm.getApplicationByName(appName); if (app == null) { throw new NotFoundException(); @@ -190,4 +190,5 @@ public class ScopeMappedResource { app.deleteScopeMapping(agent, roleModel); } } - }} + } +} 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 e8e34c76e1..bd643c7982 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 @@ -282,11 +282,11 @@ public class UsersResource { } } - @Path("{username}/role-mappings/applications/{appId}") + @Path("{username}/role-mappings/applications/{app}") @GET @Produces("application/json") @NoCache - public List getApplicationRoleMappings(@PathParam("username") String username, @PathParam("appId") String appId) { + public List getApplicationRoleMappings(@PathParam("username") String username, @PathParam("app") String appName) { logger.debug("getApplicationRoleMappings"); UserModel user = realm.getUser(username); @@ -294,7 +294,7 @@ public class UsersResource { throw new NotFoundException(); } - ApplicationModel application = realm.getApplicationById(appId); + ApplicationModel application = realm.getApplicationByName(appName); if (application == null) { throw new NotFoundException(); @@ -309,17 +309,17 @@ public class UsersResource { return mapRep; } - @Path("{username}/role-mappings/applications/{appId}") + @Path("{username}/role-mappings/applications/{app}") @POST @Consumes("application/json") - public void addApplicationRoleMapping(@PathParam("username") String username, @PathParam("appId") String appId, List roles) { + public void addApplicationRoleMapping(@PathParam("username") String username, @PathParam("app") String appName, List roles) { logger.debug("addApplicationRoleMapping"); UserModel user = realm.getUser(username); if (user == null) { throw new NotFoundException(); } - ApplicationModel application = realm.getApplicationById(appId); + ApplicationModel application = realm.getApplicationByName(appName); if (application == null) { throw new NotFoundException(); @@ -335,16 +335,16 @@ public class UsersResource { } - @Path("{username}/role-mappings/applications/{appId}") + @Path("{username}/role-mappings/applications/{app}") @DELETE @Consumes("application/json") - public void deleteApplicationRoleMapping(@PathParam("username") String username, @PathParam("appId") String appId, List roles) { + public void deleteApplicationRoleMapping(@PathParam("username") String username, @PathParam("app") String appName, List roles) { UserModel user = realm.getUser(username); if (user == null) { throw new NotFoundException(); } - ApplicationModel application = realm.getApplicationById(appId); + ApplicationModel application = realm.getApplicationByName(appName); if (application == null) { throw new NotFoundException();
{{role.name}}{{role.name}} {{role.description}}