From 8f2c7a92b0a9c36f463ceb38d96cd4f6c42b9d04 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Tue, 26 Nov 2013 12:15:54 +0000 Subject: [PATCH 1/7] Upgrade to Hibernate 4.0.1.Final - this is the version from AS7 --- model/jpa/pom.xml | 1 + pom.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/model/jpa/pom.xml b/model/jpa/pom.xml index c8cba66d4c..e766c70d3a 100755 --- a/model/jpa/pom.xml +++ b/model/jpa/pom.xml @@ -38,6 +38,7 @@ org.hibernate hibernate-entitymanager ${hibernate.entitymanager.version} + provided org.jboss.resteasy diff --git a/pom.xml b/pom.xml index e3d08f5f03..19630c6918 100755 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ 2.11.2 3.1.1.GA 1.0.1.Final - 3.6.6.Final + 4.0.1.Final 1.3.161 1.6.1 5.1.25 From 2deaca8fc64206457c20cf65e27ff5cd1724e510 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Tue, 26 Nov 2013 12:52:15 +0000 Subject: [PATCH 2/7] Fix connection string for h2 db in dist --- dist-as7/src/main/xslt/standalone.xsl | 4 ++-- dist/src/main/xslt/standalone.xsl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist-as7/src/main/xslt/standalone.xsl b/dist-as7/src/main/xslt/standalone.xsl index 711b71f63f..2507ba3604 100644 --- a/dist-as7/src/main/xslt/standalone.xsl +++ b/dist-as7/src/main/xslt/standalone.xsl @@ -14,7 +14,7 @@ - jdbc:h2:${jboss.server.data.dir}/keycloak;DB_CLOSE_DELAY=-1 + jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE h2 sa @@ -30,4 +30,4 @@ - \ No newline at end of file + diff --git a/dist/src/main/xslt/standalone.xsl b/dist/src/main/xslt/standalone.xsl index 711b71f63f..2507ba3604 100644 --- a/dist/src/main/xslt/standalone.xsl +++ b/dist/src/main/xslt/standalone.xsl @@ -14,7 +14,7 @@ - jdbc:h2:${jboss.server.data.dir}/keycloak;DB_CLOSE_DELAY=-1 + jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE h2 sa @@ -30,4 +30,4 @@ - \ No newline at end of file + From 36f91ac75c9b79629ef4f4f4d9d77f45c365a328 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Tue, 26 Nov 2013 13:31:46 +0000 Subject: [PATCH 3/7] KEYCLOAK-165 Confusing automatic converstion of time units --- .../resources/admin/js/controllers/realm.js | 53 +++++++++---------- .../META-INF/resources/admin/js/services.js | 53 +++++++++++++++++-- .../admin/partials/realm-tokens.html | 2 +- 3 files changed, 75 insertions(+), 33 deletions(-) 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 5fd73658e3..fffbfc0e46 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 @@ -484,16 +484,29 @@ module.controller('RealmSocialCtrl', function($scope, realm, Realm, $location, N }); -module.controller('RealmTokenDetailCtrl', function($scope, Realm, realm, $http, $location, Dialog, Notifications) { +module.controller('RealmTokenDetailCtrl', function($scope, Realm, realm, $http, $location, Dialog, Notifications, TimeUnit) { console.log('RealmTokenDetailCtrl'); - $scope.realm = { id : realm.id, realm : realm.realm, social : realm.social, registrationAllowed : realm.registrationAllowed, - tokenLifespan : realm.tokenLifespan, accessCodeLifespan : realm.accessCodeLifespan, - accessCodeLifespanUserAction : realm.accessCodeLifespanUserAction }; + $scope.realm = { id : realm.id, realm : realm.realm, social : realm.social, registrationAllowed : realm.registrationAllowed }; + + $scope.realm.tokenLifespanUnit = TimeUnit.autoUnit(realm.tokenLifespan); + $scope.realm.tokenLifespan = TimeUnit.toUnit(realm.tokenLifespan, $scope.realm.tokenLifespanUnit); + $scope.$watch('realm.tokenLifespanUnit', function(to, from) { + $scope.realm.tokenLifespan = TimeUnit.convert($scope.realm.tokenLifespan, from, to); + }); + + $scope.realm.accessCodeLifespanUnit = TimeUnit.autoUnit(realm.accessCodeLifespan); + $scope.realm.accessCodeLifespan = TimeUnit.toUnit(realm.accessCodeLifespan, $scope.realm.accessCodeLifespanUnit); + $scope.$watch('realm.accessCodeLifespanUnit', function(to, from) { + $scope.realm.accessCodeLifespan = TimeUnit.convert($scope.realm.accessCodeLifespan, from, to); + }); + + $scope.realm.accessCodeLifespanUserActionUnit = TimeUnit.autoUnit(realm.accessCodeLifespanUserAction); + $scope.realm.accessCodeLifespanUserAction = TimeUnit.toUnit(realm.accessCodeLifespanUserAction, $scope.realm.accessCodeLifespanUserActionUnit); + $scope.$watch('realm.accessCodeLifespanUserActionUnit', function(to, from) { + $scope.realm.accessCodeLifespanUserAction = TimeUnit.convert($scope.realm.accessCodeLifespanUserAction, from, to); + }); - $scope.realm.tokenLifespanUnit = 'Seconds'; - $scope.realm.accessCodeLifespanUnit = 'Seconds'; - $scope.realm.accessCodeLifespanUserActionUnit = 'Seconds'; var oldCopy = angular.copy($scope.realm); $scope.changed = false; @@ -509,27 +522,11 @@ module.controller('RealmTokenDetailCtrl', function($scope, Realm, realm, $http, delete realmCopy["tokenLifespanUnit"]; delete realmCopy["accessCodeLifespanUnit"]; delete realmCopy["accessCodeLifespanUserActionUnit"]; - if ($scope.realm.tokenLifespanUnit == 'Minutes') { - realmCopy.tokenLifespan = $scope.realm.tokenLifespan * 60; - } else if ($scope.realm.tokenLifespanUnit == 'Hours') { - realmCopy.tokenLifespan = $scope.realm.tokenLifespan * 60 * 60; - } else if ($scope.realm.tokenLifespanUnit == 'Days') { - realmCopy.tokenLifespan = $scope.realm.tokenLifespan * 60 * 60 * 24; - } - if ($scope.realm.accessCodeLifespanUnit == 'Minutes') { - realmCopy.accessCodeLifespan = $scope.realm.accessCodeLifespan * 60; - } else if ($scope.realm.accessCodeLifespanUnit == 'Hours') { - realmCopy.accessCodeLifespan = $scope.realm.accessCodeLifespan * 60 * 60; - } else if ($scope.realm.accessCodeLifespanUnit == 'Days') { - realmCopy.accessCodeLifespan = $scope.realm.accessCodeLifespan * 60 * 60 * 24; - } - if ($scope.realm.accessCodeLifespanUserActionUnit == 'Minutes') { - realmCopy.accessCodeLifespanUserAction = $scope.realm.accessCodeLifespanUserAction * 60; - } else if ($scope.realm.accessCodeLifespanUserActionUnit == 'Hours') { - realmCopy.accessCodeLifespanUserAction = $scope.realm.accessCodeLifespanUserAction * 60 * 60; - } else if ($scope.realm.accessCodeLifespanUserActionUnit == 'Days') { - realmCopy.accessCodeLifespanUserAction = $scope.realm.accessCodeLifespanUserAction * 60 * 60 * 24; - } + + realmCopy.tokenLifespan = TimeUnit.toSeconds($scope.realm.tokenLifespan, $scope.realm.tokenLifespanUnit) + realmCopy.accessCodeLifespan = TimeUnit.toSeconds($scope.realm.accessCodeLifespan, $scope.realm.accessCodeLifespanUnit) + realmCopy.accessCodeLifespanUserAction = TimeUnit.toSeconds($scope.realm.accessCodeLifespanUserAction, $scope.realm.accessCodeLifespanUserActionUnit) + $scope.changed = false; Realm.update(realmCopy, function () { $location.url("/realms/" + realm.id + "/token-settings"); 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 c0e3c6a9f4..8e7e6c5792 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 @@ -226,9 +226,6 @@ module.factory('ApplicationOrigins', function($resource) { }); }); - - - module.factory('Current', function(Realm, $route) { var current = {}; @@ -253,4 +250,52 @@ module.factory('Current', function(Realm, $route) { current.refresh(); return current; -}); \ No newline at end of file +}); + +module.factory('TimeUnit', function() { + var t = {}; + + t.autoUnit = function(time) { + var unit = 'Seconds'; + if (time % 60 == 0) { + unit = 'Minutes'; + time = time / 60; + } + if (time % 60 == 0) { + unit = 'Hours'; + time = time / 60; + } + if (time % 24 == 0) { + unit = 'Days' + time = time / 24; + } + return unit; + } + + t.toSeconds = function(time, unit) { + switch (unit) { + case 'Seconds': return time; + case 'Minutes': return time * 60; + case 'Hours': return time * 360; + case 'Days': return time * 86400; + default: throw 'invalid unit ' + unit; + } + } + + t.toUnit = function(time, unit) { + switch (unit) { + case 'Seconds': return time; + case 'Minutes': return Math.ceil(time / 60); + case 'Hours': return Math.ceil(time / 360); + case 'Days': return Math.ceil(time / 86400); + default: throw 'invalid unit ' + unit; + } + } + + t.convert = function(time, from, to) { + var seconds = t.toSeconds(time, from); + return t.toUnit(seconds, to); + } + + return t; +}); diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/partials/realm-tokens.html b/admin-ui/src/main/resources/META-INF/resources/admin/partials/realm-tokens.html index 492110161e..7a2b92b9b2 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/partials/realm-tokens.html +++ b/admin-ui/src/main/resources/META-INF/resources/admin/partials/realm-tokens.html @@ -28,7 +28,7 @@
- From 57987c9ae7f9669305b1ea768934c67acd0c774c Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Tue, 26 Nov 2013 13:35:32 +0000 Subject: [PATCH 4/7] Replace on/off switch with yes/no where approriate --- .../src/main/resources/META-INF/resources/admin/js/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js index 311175d513..3f571d3c60 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js +++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js @@ -431,8 +431,8 @@ module.directive('onoffswitch', function() { offText: '@offText' }, compile: function(element, attrs) { - if (!attrs.onText) { attrs.onText = "ON"; } - if (!attrs.offText) { attrs.offText = "OFF"; } + if (!attrs.onText) { attrs.onText = "YES"; } + if (!attrs.offText) { attrs.offText = "NO"; } var html = "
" + "" + From f80522c6a50cfef4392aa0d42a40ed6719755322 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Tue, 26 Nov 2013 13:48:47 +0000 Subject: [PATCH 5/7] Fixes to user search --- .../META-INF/resources/admin/js/controllers/users.js | 9 ++++++--- .../META-INF/resources/admin/partials/user-list.html | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) 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 fdddd07ff6..ffd9355ef1 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 @@ -119,10 +119,13 @@ module.controller('UserRoleMappingCtrl', function($scope, $http, realm, user, ro module.controller('UserListCtrl', function($scope, realm, User) { $scope.realm = realm; $scope.searchQuery = function() { + $scope.currentSearch = $scope.search; $scope.searchLoaded = false; - $scope.users = User.query({ realm: realm.id, search : $scope.search }, function() { - $scope.searchLoaded = true; - }); + if ($scope.search) { + $scope.users = User.query({ realm: realm.id, search : $scope.search }, function() { + $scope.searchLoaded = true; + }); + } }; }); diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/partials/user-list.html b/admin-ui/src/main/resources/META-INF/resources/admin/partials/user-list.html index 942ea954da..c79b243125 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/partials/user-list.html +++ b/admin-ui/src/main/resources/META-INF/resources/admin/partials/user-list.html @@ -33,7 +33,7 @@ - + Username Last Name First Name @@ -66,7 +66,7 @@ -