diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js b/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js
index e7d074214..9f9a2878b 100644
--- a/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js
+++ b/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js
@@ -504,6 +504,7 @@ var AppRouter = Backbone.Router.extend({
"user/tokens":"tokens",
"user/profile":"profile",
"user/policy":"policy",
+ "user/policy/:rsid":"editPolicy",
"dev/dynreg":"dynReg",
"dev/dynreg/new":"newDynReg",
@@ -1081,7 +1082,7 @@ var AppRouter = Backbone.Router.extend({
this.breadCrumbView.collection.reset();
this.breadCrumbView.collection.add([
{text:$.t('admin.home'), href:""},
- {text:$.t('policy.resource-sets'), href:"manage/#user/profile"}
+ {text:$.t('policy.resource-sets'), href:"manage/#user/policy"}
]);
this.updateSidebar('user/policy');
@@ -1095,6 +1096,37 @@ var AppRouter = Backbone.Router.extend({
},
+ editPolicy:function(rsid) {
+ this.breadCrumbView.collection.reset();
+ this.breadCrumbView.collection.add([
+ {text:$.t('admin.home'), href:""},
+ {text:$.t('policy.resource-sets'), href:"manage/#user/policy"},
+ {text:$.t('policy.edit-policy'), href:"manage/#user/policy/" + rsid}
+ ]);
+
+ this.updateSidebar('user/policy');
+
+ var rs = this.resourceSetList.get(rsid);
+ if (rs == null) {
+ // need to load it directly
+ var claims = new ClaimCollection();
+ } else {
+ // the resource set is loaded, preload the claims
+ var claims = new ClaimCollection(rs.get('claimsRequired'));
+ claims.isFetched = true;
+ }
+ // set the URL for the collection
+ claims.url = 'api/claims/' + rsid;
+
+ var view = new ClaimListView({model: claims});
+
+ view.load(function() {
+ $('#content').html(view.render().el);
+ setPageTitle($.t('policy.edit-policy'));
+ });
+
+ },
+
updateSidebar:function(item) {
$('.sidebar-nav li.active').removeClass('active');
diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/locale/en/messages.json b/openid-connect-server-webapp/src/main/webapp/resources/js/locale/en/messages.json
index 8b921d949..6729d9f78 100644
--- a/openid-connect-server-webapp/src/main/webapp/resources/js/locale/en/messages.json
+++ b/openid-connect-server-webapp/src/main/webapp/resources/js/locale/en/messages.json
@@ -340,10 +340,13 @@
}
},
"policy" : {
- "resource-sets": "Resource sets",
+ "resource-sets": "Resource Sets",
+ "edit-policy": "Edit Policy",
+ "required-claims": "Required Claims",
"policy-table": {
"edit": "Edit Policies",
- "no-resource-sets": "There are no resource sets registered. Introduce a protected to this authorization server to let it register some."
+ "no-resource-sets": "There are no resource sets registered. Introduce a protected to this authorization server to let it register some.",
+ "no-required-claims": "There are no required claims for this resource set."
}
},
"copyright": "Powered by MITREid Connect {0} © 2015 The MITRE Corporation and MIT KIT..",
diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/policy.js b/openid-connect-server-webapp/src/main/webapp/resources/js/policy.js
index 719a27225..ca120b3f4 100644
--- a/openid-connect-server-webapp/src/main/webapp/resources/js/policy.js
+++ b/openid-connect-server-webapp/src/main/webapp/resources/js/policy.js
@@ -184,5 +184,82 @@ var ResourceSetView = Backbone.View.extend({
}
},
+});
+var ClaimListView = Backbone.View.extend({
+ tagName: 'span',
+
+ initialize:function(options) {
+ this.options = options;
+ },
+
+ load:function(callback) {
+ if (this.model.isFetched) {
+ callback();
+ return;
+ }
+
+ $('#loadingbox').sheet('show');
+ $('#loading').html(
+ '' + $.t('policy.required-claims') + ' '
+ );
+
+ $.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-claims').addClass('label-success');}}))
+ .done(function() {
+ $('#loadingbox').sheet('hide');
+ callback();
+ });
+ },
+
+ togglePlaceholder:function() {
+ if (this.model.length > 0) {
+ $('#required-claim-table', this.el).show();
+ $('#required-claim-table-empty', this.el).hide();
+ } else {
+ $('#required-claim-table', this.el).hide();
+ $('#required-claim-table-empty', this.el).show();
+ }
+ },
+
+ render:function (eventName) {
+ $(this.el).html($('#tmpl-required-claim-table').html());
+
+ var _self = this;
+
+ _.each(this.model.models, function (claim) {
+
+ var view = new ClaimView({model: claim});
+ view.parentView = _self;
+ $('#required-claim-table', this.el).append(view.render().el);
+
+ }, this);
+
+ this.togglePlaceholder();
+ $(this.el).i18n();
+ return this;
+ }
+});
+
+
+var ClaimView = Backbone.View.extend({
+ tagName: 'tr',
+
+ initialize:function(options) {
+ this.options = options;
+
+ if (!this.template) {
+ this.template = _.template($('#tmpl-required-claim').html());
+ }
+ },
+
+ render:function (eventName) {
+ var json = this.model.toJSON();
+
+ this.$el.html(this.template(json));
+
+ $(this.el).i18n();
+ return this;
+ }
+
+
});
\ No newline at end of file
diff --git a/openid-connect-server-webapp/src/main/webapp/resources/template/policy.html b/openid-connect-server-webapp/src/main/webapp/resources/template/policy.html
index 0b58f12b8..8e8aa391f 100644
--- a/openid-connect-server-webapp/src/main/webapp/resources/template/policy.html
+++ b/openid-connect-server-webapp/src/main/webapp/resources/template/policy.html
@@ -57,3 +57,64 @@
+
+
+
+
+
\ No newline at end of file