diff --git a/core/src/main/java/org/keycloak/representations/idm/ConfigPropertyRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/ConfigPropertyRepresentation.java index 6558c410e1..0cd65e1e83 100755 --- a/core/src/main/java/org/keycloak/representations/idm/ConfigPropertyRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/ConfigPropertyRepresentation.java @@ -17,6 +17,8 @@ package org.keycloak.representations.idm; +import java.util.List; + /** * @author Bill Burke * @version $Revision: 1 $ @@ -27,6 +29,7 @@ public class ConfigPropertyRepresentation { protected String helpText; protected String type; protected Object defaultValue; + protected List options; protected boolean secret; public String getName() { @@ -69,6 +72,14 @@ public class ConfigPropertyRepresentation { this.helpText = helpText; } + public List getOptions() { + return options; + } + + public void setOptions(List options) { + this.options = options; + } + public boolean isSecret() { return secret; } diff --git a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/AbstractLDAPFederationMapperFactory.java b/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/AbstractLDAPFederationMapperFactory.java index d681125f90..ccd4aa61dc 100755 --- a/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/AbstractLDAPFederationMapperFactory.java +++ b/federation/ldap/src/main/java/org/keycloak/federation/ldap/mappers/AbstractLDAPFederationMapperFactory.java @@ -17,6 +17,8 @@ package org.keycloak.federation.ldap.mappers; +import java.util.List; + import org.keycloak.Config; import org.keycloak.federation.ldap.LDAPFederationProvider; import org.keycloak.federation.ldap.LDAPFederationProviderFactory; @@ -75,13 +77,13 @@ public abstract class AbstractLDAPFederationMapperFactory implements UserFederat public void close() { } - public static ProviderConfigProperty createConfigProperty(String name, String label, String helpText, String type, Object defaultValue) { + public static ProviderConfigProperty createConfigProperty(String name, String label, String helpText, String type, List options) { ProviderConfigProperty configProperty = new ProviderConfigProperty(); configProperty.setName(name); configProperty.setLabel(label); configProperty.setHelpText(helpText); configProperty.setType(type); - configProperty.setDefaultValue(defaultValue); + configProperty.setOptions(options); return configProperty; } diff --git a/server-spi/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java b/server-spi/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java index 9846d087c0..e647aec66c 100755 --- a/server-spi/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java +++ b/server-spi/src/main/java/org/keycloak/models/utils/ModelToRepresentation.java @@ -782,6 +782,7 @@ public class ModelToRepresentation { propRep.setLabel(prop.getLabel()); propRep.setType(prop.getType()); propRep.setDefaultValue(prop.getDefaultValue()); + propRep.setOptions(prop.getOptions()); propRep.setHelpText(prop.getHelpText()); propRep.setSecret(prop.isSecret()); return propRep; diff --git a/server-spi/src/main/java/org/keycloak/provider/ProviderConfigProperty.java b/server-spi/src/main/java/org/keycloak/provider/ProviderConfigProperty.java index 5b824b3425..a6dbd77e91 100755 --- a/server-spi/src/main/java/org/keycloak/provider/ProviderConfigProperty.java +++ b/server-spi/src/main/java/org/keycloak/provider/ProviderConfigProperty.java @@ -17,6 +17,8 @@ package org.keycloak.provider; +import java.util.List; + /** * @author Bill Burke * @version $Revision: 1 $ @@ -46,6 +48,7 @@ public class ProviderConfigProperty { protected String helpText; protected String type = STRING_TYPE; protected Object defaultValue; + protected List options; protected boolean secret; public ProviderConfigProperty() { @@ -96,6 +99,14 @@ public class ProviderConfigProperty { this.defaultValue = defaultValue; } + public List getOptions() { + return options; + } + + public void setOptions(List options) { + this.options = options; + } + public String getHelpText() { return helpText; } diff --git a/server-spi/src/main/java/org/keycloak/provider/ProviderConfigurationBuilder.java b/server-spi/src/main/java/org/keycloak/provider/ProviderConfigurationBuilder.java index 5382355ce3..607a41b326 100644 --- a/server-spi/src/main/java/org/keycloak/provider/ProviderConfigurationBuilder.java +++ b/server-spi/src/main/java/org/keycloak/provider/ProviderConfigurationBuilder.java @@ -17,6 +17,7 @@ package org.keycloak.provider; +import java.util.Arrays; import java.util.LinkedList; import java.util.List; @@ -43,14 +44,17 @@ public class ProviderConfigurationBuilder { return this; } - public ProviderConfigurationBuilder property(String name, String label, String helpText, String type, Object defaultValue, boolean secret) { + public ProviderConfigurationBuilder property(String name, String label, String helpText, String type, Object defaultValue, List options, boolean secret) { ProviderConfigProperty property = new ProviderConfigProperty(name, label, helpText, type, defaultValue); + property.setOptions(options); property.setSecret(secret); properties.add(property); return this; } - public ProviderConfigurationBuilder property(String name, String label, String helpText, String type, Object defaultValue) { - properties.add(new ProviderConfigProperty(name, label, helpText, type, defaultValue)); + public ProviderConfigurationBuilder property(String name, String label, String helpText, String type, Object defaultValue, List options) { + ProviderConfigProperty property = new ProviderConfigProperty(name, label, helpText, type, defaultValue); + property.setOptions(options); + properties.add(property); return this; } @@ -65,6 +69,7 @@ public class ProviderConfigurationBuilder { private String helpText; private String type; private Object defaultValue; + private List options; private boolean secret; public ProviderConfigPropertyBuilder name(String name) { @@ -92,6 +97,11 @@ public class ProviderConfigurationBuilder { return this; } + public ProviderConfigPropertyBuilder options(String... options) { + this.options = Arrays.asList(options); + return this; + } + public ProviderConfigPropertyBuilder secret(boolean secret) { this.secret = secret; return this; @@ -104,6 +114,7 @@ public class ProviderConfigurationBuilder { property.setHelpText(helpText); property.setType(type); property.setDefaultValue(defaultValue); + property.setOptions(options); property.setSecret(secret); ProviderConfigurationBuilder.this.properties.add(property); return ProviderConfigurationBuilder.this; diff --git a/services/src/main/java/org/keycloak/authentication/authenticators/broker/IdpReviewProfileAuthenticatorFactory.java b/services/src/main/java/org/keycloak/authentication/authenticators/broker/IdpReviewProfileAuthenticatorFactory.java index 4937db3658..b293b716a3 100644 --- a/services/src/main/java/org/keycloak/authentication/authenticators/broker/IdpReviewProfileAuthenticatorFactory.java +++ b/services/src/main/java/org/keycloak/authentication/authenticators/broker/IdpReviewProfileAuthenticatorFactory.java @@ -108,7 +108,8 @@ public class IdpReviewProfileAuthenticatorFactory implements AuthenticatorFactor property.setLabel("{{:: 'update-profile-on-first-login' | translate}}"); property.setType(ProviderConfigProperty.LIST_TYPE); List updateProfileValues = Arrays.asList(IdentityProviderRepresentation.UPFLM_ON, IdentityProviderRepresentation.UPFLM_MISSING, IdentityProviderRepresentation.UPFLM_OFF); - property.setDefaultValue(updateProfileValues); + property.setOptions(updateProfileValues); + property.setDefaultValue(IdentityProviderRepresentation.UPFLM_MISSING); property.setHelpText("Define conditions under which a user has to review and update his profile after first-time login. Value 'On' means that" + " page for reviewing profile will be displayed and user can review and update his profile. Value 'off' means that page won't be displayed." + " Value 'missing' means that page is displayed just when some required attribute is missing (wasn't downloaded from identity provider). Value 'missing' is the default one." diff --git a/services/src/main/java/org/keycloak/authentication/authenticators/browser/ConditionalOtpFormAuthenticatorFactory.java b/services/src/main/java/org/keycloak/authentication/authenticators/browser/ConditionalOtpFormAuthenticatorFactory.java index f19cbb6547..f04ed0770b 100755 --- a/services/src/main/java/org/keycloak/authentication/authenticators/browser/ConditionalOtpFormAuthenticatorFactory.java +++ b/services/src/main/java/org/keycloak/authentication/authenticators/browser/ConditionalOtpFormAuthenticatorFactory.java @@ -156,7 +156,7 @@ public class ConditionalOtpFormAuthenticatorFactory implements AuthenticatorFact defaultOutcome.setType(LIST_TYPE); defaultOutcome.setName(DEFAULT_OTP_OUTCOME); defaultOutcome.setLabel("Fallback OTP handling"); - defaultOutcome.setDefaultValue(asList(SKIP, FORCE)); + defaultOutcome.setOptions(asList(SKIP, FORCE)); defaultOutcome.setHelpText("What to do in case of every check abstains. Defaults to force OTP authentication."); return asList(forceOtpUserAttribute, skipOtpRole, forceOtpRole, skipOtpForHttpHeader, forceOtpForHttpHeader, defaultOutcome); diff --git a/services/src/main/java/org/keycloak/protocol/oidc/mappers/HardcodedClaim.java b/services/src/main/java/org/keycloak/protocol/oidc/mappers/HardcodedClaim.java index f5015bab3f..ffaea829f6 100755 --- a/services/src/main/java/org/keycloak/protocol/oidc/mappers/HardcodedClaim.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/mappers/HardcodedClaim.java @@ -66,7 +66,7 @@ public class HardcodedClaim extends AbstractOIDCProtocolMapper implements OIDCAc types.add("int"); types.add("boolean"); property.setType(ProviderConfigProperty.LIST_TYPE); - property.setDefaultValue(types); + property.setOptions(types); property.setHelpText("JSON type that should be used for the value of the claim. long, int, boolean, and String are valid values."); configProperties.add(property); property = new ProviderConfigProperty(); diff --git a/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCAttributeMapperHelper.java b/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCAttributeMapperHelper.java index 29db856889..79ecec1858 100755 --- a/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCAttributeMapperHelper.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/mappers/OIDCAttributeMapperHelper.java @@ -182,7 +182,7 @@ public class OIDCAttributeMapperHelper { types.add("int"); types.add("boolean"); property.setType(ProviderConfigProperty.LIST_TYPE); - property.setDefaultValue(types); + property.setOptions(types); property.setHelpText(JSON_TYPE_TOOLTIP); configProperties.add(property); property = new ProviderConfigProperty(); diff --git a/services/src/main/java/org/keycloak/protocol/saml/mappers/AttributeStatementHelper.java b/services/src/main/java/org/keycloak/protocol/saml/mappers/AttributeStatementHelper.java index 59ddd49edd..c1cf9c4b73 100755 --- a/services/src/main/java/org/keycloak/protocol/saml/mappers/AttributeStatementHelper.java +++ b/services/src/main/java/org/keycloak/protocol/saml/mappers/AttributeStatementHelper.java @@ -85,7 +85,7 @@ public class AttributeStatementHelper { types.add(AttributeStatementHelper.URI_REFERENCE); types.add(AttributeStatementHelper.UNSPECIFIED); property.setType(ProviderConfigProperty.LIST_TYPE); - property.setDefaultValue(types); + property.setOptions(types); configProperties.add(property); } diff --git a/services/src/main/java/org/keycloak/protocol/saml/mappers/GroupMembershipMapper.java b/services/src/main/java/org/keycloak/protocol/saml/mappers/GroupMembershipMapper.java index 289c40e1a6..1a2db26f59 100755 --- a/services/src/main/java/org/keycloak/protocol/saml/mappers/GroupMembershipMapper.java +++ b/services/src/main/java/org/keycloak/protocol/saml/mappers/GroupMembershipMapper.java @@ -65,7 +65,7 @@ public class GroupMembershipMapper extends AbstractSAMLProtocolMapper implements types.add(AttributeStatementHelper.URI_REFERENCE); types.add(AttributeStatementHelper.UNSPECIFIED); property.setType(ProviderConfigProperty.LIST_TYPE); - property.setDefaultValue(types); + property.setOptions(types); configProperties.add(property); property = new ProviderConfigProperty(); property.setName(SINGLE_GROUP_ATTRIBUTE); diff --git a/services/src/main/java/org/keycloak/protocol/saml/mappers/RoleListMapper.java b/services/src/main/java/org/keycloak/protocol/saml/mappers/RoleListMapper.java index 82d26d3c2b..dd274728e9 100755 --- a/services/src/main/java/org/keycloak/protocol/saml/mappers/RoleListMapper.java +++ b/services/src/main/java/org/keycloak/protocol/saml/mappers/RoleListMapper.java @@ -69,7 +69,7 @@ public class RoleListMapper extends AbstractSAMLProtocolMapper implements SAMLRo types.add(AttributeStatementHelper.URI_REFERENCE); types.add(AttributeStatementHelper.UNSPECIFIED); property.setType(ProviderConfigProperty.LIST_TYPE); - property.setDefaultValue(types); + property.setOptions(types); configProperties.add(property); property = new ProviderConfigProperty(); property.setName(SINGLE_ROLE_ATTRIBUTE); diff --git a/services/src/main/java/org/keycloak/services/clientregistration/policy/impl/ClientTemplatesClientRegistrationPolicyFactory.java b/services/src/main/java/org/keycloak/services/clientregistration/policy/impl/ClientTemplatesClientRegistrationPolicyFactory.java index c886e8f34c..cc71424d7a 100644 --- a/services/src/main/java/org/keycloak/services/clientregistration/policy/impl/ClientTemplatesClientRegistrationPolicyFactory.java +++ b/services/src/main/java/org/keycloak/services/clientregistration/policy/impl/ClientTemplatesClientRegistrationPolicyFactory.java @@ -60,7 +60,7 @@ public class ClientTemplatesClientRegistrationPolicyFactory extends AbstractClie property.setType(ProviderConfigProperty.MULTIVALUED_LIST_TYPE); if (session != null) { - property.setDefaultValue(getClientTemplates(session)); + property.setOptions(getClientTemplates(session)); } configProperties = Collections.singletonList(property); diff --git a/services/src/main/java/org/keycloak/services/clientregistration/policy/impl/ProtocolMappersClientRegistrationPolicyFactory.java b/services/src/main/java/org/keycloak/services/clientregistration/policy/impl/ProtocolMappersClientRegistrationPolicyFactory.java index e794e3cfdb..a9aea1420a 100644 --- a/services/src/main/java/org/keycloak/services/clientregistration/policy/impl/ProtocolMappersClientRegistrationPolicyFactory.java +++ b/services/src/main/java/org/keycloak/services/clientregistration/policy/impl/ProtocolMappersClientRegistrationPolicyFactory.java @@ -58,7 +58,7 @@ public class ProtocolMappersClientRegistrationPolicyFactory extends AbstractClie property.setLabel("allowed-protocol-mappers.label"); property.setHelpText("allowed-protocol-mappers.tooltip"); property.setType(ProviderConfigProperty.MULTIVALUED_LIST_TYPE); - property.setDefaultValue(getProtocolMapperFactoryIds()); + property.setOptions(getProtocolMapperFactoryIds()); configProperties.add(property); property = new ProviderConfigProperty(); diff --git a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/components/TestImplProviderFactory.java b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/components/TestImplProviderFactory.java index 2a1a911aa2..4092501300 100644 --- a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/components/TestImplProviderFactory.java +++ b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/components/TestImplProviderFactory.java @@ -36,12 +36,12 @@ import static org.keycloak.provider.ProviderConfigProperty.STRING_TYPE; public class TestImplProviderFactory implements TestProviderFactory { private List config = ProviderConfigurationBuilder.create() - .property("secret", "Secret", "A secret value", STRING_TYPE, null, true) - .property("number", "Number", "A number value", STRING_TYPE, null, false) - .property("required", "Required", "A required value", STRING_TYPE, null, false) - .property("val1", "Value 1", "Some more values", STRING_TYPE, null, false) - .property("val2", "Value 2", "Some more values", STRING_TYPE, null, false) - .property("val3", "Value 3", "Some more values", STRING_TYPE, null, false) + .property("secret", "Secret", "A secret value", STRING_TYPE, null, null, true) + .property("number", "Number", "A number value", STRING_TYPE, null, null, false) + .property("required", "Required", "A required value", STRING_TYPE, null, null, false) + .property("val1", "Value 1", "Some more values", STRING_TYPE, null, null, false) + .property("val2", "Value 2", "Some more values", STRING_TYPE, null, null, false) + .property("val3", "Value 3", "Some more values", STRING_TYPE, null, null, false) .build(); @Override diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/ComponentsTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/ComponentsTest.java index 07c5bebf58..ab934fe8d3 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/ComponentsTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/ComponentsTest.java @@ -20,25 +20,13 @@ package org.keycloak.testsuite.admin; import org.junit.Before; import org.junit.Test; import org.keycloak.admin.client.resource.ComponentsResource; -import org.keycloak.common.util.CertificateUtils; -import org.keycloak.common.util.KeyUtils; import org.keycloak.common.util.MultivaluedHashMap; -import org.keycloak.common.util.PemUtils; -import org.keycloak.keys.Attributes; -import org.keycloak.keys.KeyProvider; -import org.keycloak.keys.RsaKeyProviderFactory; import org.keycloak.representations.idm.ComponentRepresentation; import org.keycloak.representations.idm.ErrorRepresentation; -import org.keycloak.representations.idm.KeysMetadataRepresentation; -import org.keycloak.representations.idm.RealmRepresentation; -import org.keycloak.testsuite.components.TestImplProviderFactory; import org.keycloak.testsuite.components.TestProvider; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; -import java.math.BigInteger; -import java.security.KeyPair; -import java.security.PublicKey; import java.util.Collections; import java.util.List; import java.util.Map; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/client/ClientRegistrationPoliciesTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/client/ClientRegistrationPoliciesTest.java index 0f0b7cc81a..2a4ef8b7e6 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/client/ClientRegistrationPoliciesTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/client/ClientRegistrationPoliciesTest.java @@ -329,7 +329,7 @@ public class ClientRegistrationPoliciesTest extends AbstractClientRegistrationTe ConfigPropertyRepresentation allowedProtocolMappers = list.get(0); Assert.assertEquals(allowedProtocolMappers.getName(), expectedConfigPropName); - return (List) allowedProtocolMappers.getDefaultValue(); + return allowedProtocolMappers.getOptions(); } diff --git a/themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js b/themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js index 7d8de51ead..2de4453e32 100755 --- a/themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js @@ -1830,6 +1830,8 @@ module.controller('ClientProtocolMapperCreateCtrl', function($scope, realm, serv }, function(error) { if (error.status == 400 && error.data.error_description) { Notifications.error(error.data.error_description); + } else if (error.status == 409 && error.data.errorMessage) { + Notifications.error(error.data.errorMessage); } else { Notifications.error('Unexpected error when updating protocol mapper'); } diff --git a/themes/src/main/resources/theme/base/admin/resources/templates/kc-component-config.html b/themes/src/main/resources/theme/base/admin/resources/templates/kc-component-config.html index dccb17e515..b3b536f1d8 100755 --- a/themes/src/main/resources/theme/base/admin/resources/templates/kc-component-config.html +++ b/themes/src/main/resources/theme/base/admin/resources/templates/kc-component-config.html @@ -12,13 +12,13 @@
-
diff --git a/themes/src/main/resources/theme/base/admin/resources/templates/kc-provider-config.html b/themes/src/main/resources/theme/base/admin/resources/templates/kc-provider-config.html index 2b5f00e5f3..0309bb3227 100755 --- a/themes/src/main/resources/theme/base/admin/resources/templates/kc-provider-config.html +++ b/themes/src/main/resources/theme/base/admin/resources/templates/kc-provider-config.html @@ -12,7 +12,7 @@
-