diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AuthenticationManagementResource.java b/services/src/main/java/org/keycloak/services/resources/admin/AuthenticationManagementResource.java index a9551f8dab..c07c3e3e72 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/AuthenticationManagementResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/AuthenticationManagementResource.java @@ -1143,7 +1143,7 @@ public class AuthenticationManagementResource { rep.setName(factory.getDisplayType()); rep.setHelpText(factory.getHelpText()); rep.setProperties(new LinkedList<>()); - List configProperties = factory.getConfigProperties(); + List configProperties = Optional.ofNullable(factory.getConfigProperties()).orElse(Collections.emptyList()); for (ProviderConfigProperty prop : configProperties) { ConfigPropertyRepresentation propRep = getConfigPropertyRep(prop); rep.getProperties().add(propRep); diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/AuthenticatorConfigTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/AuthenticatorConfigTest.java index 7069595649..c79323efc4 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/AuthenticatorConfigTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/AuthenticatorConfigTest.java @@ -24,6 +24,7 @@ import org.keycloak.events.admin.OperationType; import org.keycloak.events.admin.ResourceType; import org.keycloak.representations.idm.AuthenticationExecutionInfoRepresentation; import org.keycloak.representations.idm.AuthenticationFlowRepresentation; +import org.keycloak.representations.idm.AuthenticatorConfigInfoRepresentation; import org.keycloak.representations.idm.AuthenticatorConfigRepresentation; import org.keycloak.testsuite.Assert; import org.keycloak.testsuite.admin.ApiUtil; @@ -167,6 +168,15 @@ public class AuthenticatorConfigTest extends AbstractAuthenticationTest { Assert.assertNull(execution.getAuthenticationConfig()); } + @Test + public void testNullsafetyIterationOverProperties() { + String providerId = "auth-cookie"; + String providerName = "Cookie"; + AuthenticatorConfigInfoRepresentation description = authMgmtResource.getAuthenticatorConfigDescription(providerId); + + Assert.assertEquals(providerName, description.getName()); + Assert.assertTrue(description.getProperties().isEmpty()); + } private String createConfig(String executionId, AuthenticatorConfigRepresentation cfg) { Response resp = authMgmtResource.newExecutionConfig(executionId, cfg);