From 07b038e126794c2f57afb1a5202ce2c448275573 Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Fri, 27 Feb 2015 18:21:42 -0500 Subject: [PATCH] add mapper category and help text --- .../idm/ProtocolMapperTypeRepresentation.java | 18 ++++++++++++++++++ .../resources/js/controllers/applications.js | 14 ++++++++++---- .../base/resources/js/controllers/protocols.js | 6 ++---- .../partials/application-mappers-add.html | 6 ++++-- .../partials/application-mappers.html | 6 ++++-- .../partials/protocol-mapper-detail.html | 4 ++-- .../partials/protocol-mapper-list.html | 4 +++- .../org/keycloak/protocol/ProtocolMapper.java | 2 ++ .../mappers/AbstractOIDCProtocolMapper.java | 2 ++ .../oidc/mappers/OIDCAddressMapper.java | 12 +++++++++++- .../mappers/OIDCClientSessionNoteMapper.java | 12 +++++++++++- .../oidc/mappers/OIDCFullNameMapper.java | 12 +++++++++++- .../oidc/mappers/OIDCUserAttributeMapper.java | 12 +++++++++++- .../oidc/mappers/OIDCUserModelMapper.java | 14 ++++++++++++-- .../mappers/OIDCUserSessionNoteMapper.java | 12 +++++++++++- .../admin/ServerInfoAdminResource.java | 2 ++ 16 files changed, 116 insertions(+), 22 deletions(-) diff --git a/core/src/main/java/org/keycloak/representations/idm/ProtocolMapperTypeRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/ProtocolMapperTypeRepresentation.java index b20845333f..78e13bda9a 100755 --- a/core/src/main/java/org/keycloak/representations/idm/ProtocolMapperTypeRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/ProtocolMapperTypeRepresentation.java @@ -9,6 +9,8 @@ import java.util.List; public class ProtocolMapperTypeRepresentation { protected String id; protected String name; + protected String category; + protected String helpText; public static class ConfigProperty { protected String name; @@ -58,6 +60,22 @@ public class ProtocolMapperTypeRepresentation { this.name = name; } + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getHelpText() { + return helpText; + } + + public void setHelpText(String helpText) { + this.helpText = helpText; + } + public List getProperties() { return properties; } diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/applications.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/applications.js index b4122885a1..f617bc26dd 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/applications.js +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/applications.js @@ -1091,11 +1091,14 @@ module.controller('ApplicationProtocolMapperCtrl', function($scope, realm, appli $http, $location, Dialog, Notifications) { $scope.realm = realm; $scope.application = application; + if (application.protocol == null) { + application.protocol = 'openid-connect'; + } var protocolMappers = serverInfo.protocolMapperTypes[application.protocol]; var mapperTypes = {}; for (var i = 0; i < protocolMappers.length; i++) { - mapperTypes[protocolMappers[i].id] = protocolMappers[i].name; + mapperTypes[protocolMappers[i].id] = protocolMappers[i]; } $scope.mapperTypes = mapperTypes; @@ -1135,11 +1138,14 @@ module.controller('AddApplicationProtocolMapperCtrl', function($scope, realm, ap $http, $location, Dialog, Notifications) { $scope.realm = realm; $scope.application = application; + if (application.protocol == null) { + application.protocol = 'openid-connect'; + } - var protocolMapperTypes = serverInfo.protocolMapperTypes[application.protocol]; + var protocolMappers = serverInfo.protocolMapperTypes[application.protocol]; var mapperTypes = {}; - for (var i = 0; i < protocolMapperTypes.length; i++) { - mapperTypes[protocolMapperTypes[i].id] = protocolMapperTypes[i].name; + for (var i = 0; i < protocolMappers.length; i++) { + mapperTypes[protocolMappers[i].id] = protocolMappers[i]; } $scope.mapperTypes = mapperTypes; diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/protocols.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/protocols.js index 9eaa5f9448..f6cef81469 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/protocols.js +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/protocols.js @@ -13,10 +13,8 @@ module.controller('ProtocolMapperListCtrl', function($scope, realm, serverInfo, $scope.protocol = protocol; var protocolMappers = serverInfo.protocolMapperTypes[protocol]; var mapperTypes = {}; - if (protocolMappers) { - for (var i = 0; i < protocolMappers.length; i++) { - mapperTypes[protocolMappers[i].id] = protocolMappers[i].name; - } + for (var i = 0; i < protocolMappers.length; i++) { + mapperTypes[protocolMappers[i].id] = protocolMappers[i]; } $scope.mapperTypes = mapperTypes; diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/application-mappers-add.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/application-mappers-add.html index 36d7a6cacc..5d1520afec 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/application-mappers-add.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/application-mappers-add.html @@ -12,7 +12,7 @@ - + @@ -35,7 +36,8 @@ - + + diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/application-mappers.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/application-mappers.html index a06d07cef2..edaf8cc04a 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/application-mappers.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/application-mappers.html @@ -11,7 +11,7 @@
+
@@ -28,6 +28,7 @@
NameCategory Type Add
{{mapper.name}}{{mapperTypes[mapper.protocolMapper]}}{{mapperTypes[mapper.protocolMapper].category}}{{mapperTypes[mapper.protocolMapper].name}}
- + @@ -36,7 +37,8 @@ - + + diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/protocol-mapper-detail.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/protocol-mapper-detail.html index 7b8c8ad96e..7fb569db59 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/protocol-mapper-detail.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/protocol-mapper-detail.html @@ -64,14 +64,14 @@ - +
- +
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/protocol-mapper-list.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/protocol-mapper-list.html index bc27c660a6..e3a7970bb1 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/protocol-mapper-list.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/protocol-mapper-list.html @@ -22,13 +22,15 @@
+ - + + diff --git a/services/src/main/java/org/keycloak/protocol/ProtocolMapper.java b/services/src/main/java/org/keycloak/protocol/ProtocolMapper.java index c2028479f5..2c3d230d29 100755 --- a/services/src/main/java/org/keycloak/protocol/ProtocolMapper.java +++ b/services/src/main/java/org/keycloak/protocol/ProtocolMapper.java @@ -11,7 +11,9 @@ import java.util.List; */ public interface ProtocolMapper extends Provider, ProviderFactory { String getProtocol(); + String getDisplayCategory(); String getDisplayType(); + String getHelpText(); public static class ConfigProperty { protected String name; diff --git a/services/src/main/java/org/keycloak/protocol/oidc/mappers/AbstractOIDCProtocolMapper.java b/services/src/main/java/org/keycloak/protocol/oidc/mappers/AbstractOIDCProtocolMapper.java index 6e25a7a88c..4675f3d8a9 100755 --- a/services/src/main/java/org/keycloak/protocol/oidc/mappers/AbstractOIDCProtocolMapper.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/mappers/AbstractOIDCProtocolMapper.java @@ -12,6 +12,8 @@ import org.keycloak.protocol.oidc.OIDCLoginProtocol; */ public abstract class AbstractOIDCProtocolMapper implements ProtocolMapper { + public static final String TOKEN_MAPPER_CATEGORY = "Token mapper"; + @Override public String getProtocol() { return OIDCLoginProtocol.LOGIN_PROTOCOL; diff --git a/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCAddressMapper.java b/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCAddressMapper.java index ee7e8150e3..9b3adab21e 100755 --- a/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCAddressMapper.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCAddressMapper.java @@ -39,7 +39,17 @@ public class OIDCAddressMapper extends AbstractOIDCProtocolMapper implements OID @Override public String getDisplayType() { - return "Address Mapper"; + return "User Address"; + } + + @Override + public String getDisplayCategory() { + return TOKEN_MAPPER_CATEGORY; + } + + @Override + public String getHelpText() { + return "Maps user address attributes (street, locality, region, postal_code, and country) to the OpenID Connect 'address' claim."; } @Override diff --git a/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCClientSessionNoteMapper.java b/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCClientSessionNoteMapper.java index 1d39d88427..84d4a32b2d 100755 --- a/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCClientSessionNoteMapper.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCClientSessionNoteMapper.java @@ -46,7 +46,17 @@ public class OIDCClientSessionNoteMapper extends AbstractOIDCProtocolMapper impl @Override public String getDisplayType() { - return "ClientSession Note Mapper"; + return "ClientSession Note"; + } + + @Override + public String getDisplayCategory() { + return TOKEN_MAPPER_CATEGORY; + } + + @Override + public String getHelpText() { + return "Map a temporary note that is attached to the ClientSession to a token claim."; } @Override diff --git a/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCFullNameMapper.java b/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCFullNameMapper.java index b77783a647..169494a514 100755 --- a/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCFullNameMapper.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCFullNameMapper.java @@ -38,7 +38,17 @@ public class OIDCFullNameMapper extends AbstractOIDCProtocolMapper implements OI @Override public String getDisplayType() { - return "Full name Mapper"; + return "User's full name"; + } + + @Override + public String getDisplayCategory() { + return TOKEN_MAPPER_CATEGORY; + } + + @Override + public String getHelpText() { + return "Maps the user's first and last name to the OpenID Connect 'name' claim. Format is + ' ' + "; } @Override diff --git a/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCUserAttributeMapper.java b/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCUserAttributeMapper.java index a63a238163..ffc742db78 100755 --- a/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCUserAttributeMapper.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCUserAttributeMapper.java @@ -52,7 +52,17 @@ public class OIDCUserAttributeMapper extends AbstractOIDCProtocolMapper implemen @Override public String getDisplayType() { - return "UserModel Attribute Mapper"; + return "User Attribute"; + } + + @Override + public String getDisplayCategory() { + return TOKEN_MAPPER_CATEGORY; + } + + @Override + public String getHelpText() { + return "Map a custom user attribute to a token claim."; } @Override diff --git a/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCUserModelMapper.java b/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCUserModelMapper.java index 1ae2a65db6..d5da0fb0cb 100755 --- a/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCUserModelMapper.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCUserModelMapper.java @@ -21,7 +21,7 @@ import java.util.List; */ public class OIDCUserModelMapper extends AbstractOIDCProtocolMapper implements OIDCAccessTokenMapper { private static final List configProperties = new ArrayList(); - public static final String USER_MODEL_PROPERTY = "UserModel Property"; + public static final String USER_MODEL_PROPERTY = "User Property"; static { ConfigProperty property; @@ -51,7 +51,17 @@ public class OIDCUserModelMapper extends AbstractOIDCProtocolMapper implements O @Override public String getDisplayType() { - return "UserModel Property Mapper"; + return "User Property"; + } + + @Override + public String getDisplayCategory() { + return TOKEN_MAPPER_CATEGORY; + } + + @Override + public String getHelpText() { + return "Map a built in user property to a token claim."; } @Override diff --git a/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCUserSessionNoteMapper.java b/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCUserSessionNoteMapper.java index a011adfd29..b176340ed7 100755 --- a/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCUserSessionNoteMapper.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCUserSessionNoteMapper.java @@ -47,7 +47,17 @@ public class OIDCUserSessionNoteMapper extends AbstractOIDCProtocolMapper implem @Override public String getDisplayType() { - return "UserSession Note Mapper"; + return "UserSession Note"; + } + + @Override + public String getDisplayCategory() { + return TOKEN_MAPPER_CATEGORY; + } + + @Override + public String getHelpText() { + return "Map a temporary note that is attached to the UserSession to a token claim."; } @Override diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ServerInfoAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ServerInfoAdminResource.java index d844721f55..6871e95192 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/ServerInfoAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ServerInfoAdminResource.java @@ -143,6 +143,8 @@ public class ServerInfoAdminResource { ProtocolMapperTypeRepresentation rep = new ProtocolMapperTypeRepresentation(); rep.setId(mapper.getId()); rep.setName(mapper.getDisplayType()); + rep.setHelpText(mapper.getHelpText()); + rep.setCategory(mapper.getDisplayCategory()); rep.setProperties(new LinkedList()); for (ProtocolMapper.ConfigProperty prop : mapper.getConfigProperties()) { ProtocolMapperTypeRepresentation.ConfigProperty propRep = new ProtocolMapperTypeRepresentation.ConfigProperty();
+
@@ -29,6 +29,7 @@
NameCategory Type Remove
{{mapper.name}}{{mapperTypes[mapper.protocolMapper]}}{{mapperTypes[mapper.protocolMapper].category}}{{mapperTypes[mapper.protocolMapper].name}}
NameCategory Type
{{mapper.name}}{{mapperTypes[mapper.protocolMapper]}}{{mapperTypes[mapper.protocolMapper].category}}{{mapperTypes[mapper.protocolMapper].name}}
No mappers available