Search in sources :

Example 1 with AuthenticatorConfigInfoRepresentation

use of org.keycloak.representations.idm.AuthenticatorConfigInfoRepresentation in project keycloak by keycloak.

the class ProvidersTest method testAuthenticatorConfigDescription.

@Test
public void testAuthenticatorConfigDescription() {
    // Try some not-existent provider
    try {
        authMgmtResource.getAuthenticatorConfigDescription("not-existent");
        Assert.fail("Don't expected to find provider 'not-existent'");
    } catch (NotFoundException nfe) {
    // Expected
    }
    AuthenticatorConfigInfoRepresentation infoRep = authMgmtResource.getAuthenticatorConfigDescription(IdpCreateUserIfUniqueAuthenticatorFactory.PROVIDER_ID);
    Assert.assertEquals("Create User If Unique", infoRep.getName());
    Assert.assertEquals(IdpCreateUserIfUniqueAuthenticatorFactory.PROVIDER_ID, infoRep.getProviderId());
    Assert.assertEquals("Detect if there is existing Keycloak account with same email like identity provider. If no, create new user", infoRep.getHelpText());
    Assert.assertEquals(1, infoRep.getProperties().size());
    Assert.assertProviderConfigProperty(infoRep.getProperties().get(0), "require.password.update.after.registration", "Require Password Update After Registration", null, "If this option is true and new user is successfully imported from Identity Provider to Keycloak (there is no duplicated email or username detected in Keycloak DB), then this user is required to update his password", "boolean");
}
Also used : AuthenticatorConfigInfoRepresentation(org.keycloak.representations.idm.AuthenticatorConfigInfoRepresentation) NotFoundException(javax.ws.rs.NotFoundException) Test(org.junit.Test)

Example 2 with AuthenticatorConfigInfoRepresentation

use of org.keycloak.representations.idm.AuthenticatorConfigInfoRepresentation in project keycloak by keycloak.

the class AuthenticationManagementResource method getAuthenticatorConfigDescription.

/**
 * Get authenticator provider's configuration description
 */
@Path("config-description/{providerId}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@NoCache
public AuthenticatorConfigInfoRepresentation getAuthenticatorConfigDescription(@PathParam("providerId") String providerId) {
    auth.realm().requireViewRealm();
    ConfigurableAuthenticatorFactory factory = CredentialHelper.getConfigurableAuthenticatorFactory(session, providerId);
    if (factory == null) {
        throw new NotFoundException("Could not find authenticator provider");
    }
    AuthenticatorConfigInfoRepresentation rep = new AuthenticatorConfigInfoRepresentation();
    rep.setProviderId(providerId);
    rep.setName(factory.getDisplayType());
    rep.setHelpText(factory.getHelpText());
    rep.setProperties(new LinkedList<>());
    List<ProviderConfigProperty> configProperties = Optional.ofNullable(factory.getConfigProperties()).orElse(Collections.emptyList());
    for (ProviderConfigProperty prop : configProperties) {
        ConfigPropertyRepresentation propRep = getConfigPropertyRep(prop);
        rep.getProperties().add(propRep);
    }
    return rep;
}
Also used : AuthenticatorConfigInfoRepresentation(org.keycloak.representations.idm.AuthenticatorConfigInfoRepresentation) ProviderConfigProperty(org.keycloak.provider.ProviderConfigProperty) ConfigurableAuthenticatorFactory(org.keycloak.authentication.ConfigurableAuthenticatorFactory) NotFoundException(javax.ws.rs.NotFoundException) ConfigPropertyRepresentation(org.keycloak.representations.idm.ConfigPropertyRepresentation) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 3 with AuthenticatorConfigInfoRepresentation

use of org.keycloak.representations.idm.AuthenticatorConfigInfoRepresentation in project keycloak by keycloak.

the class AuthenticatorConfigTest method testNullsafetyIterationOverProperties.

@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());
}
Also used : AuthenticatorConfigInfoRepresentation(org.keycloak.representations.idm.AuthenticatorConfigInfoRepresentation) Test(org.junit.Test)

Aggregations

AuthenticatorConfigInfoRepresentation (org.keycloak.representations.idm.AuthenticatorConfigInfoRepresentation)3 NotFoundException (javax.ws.rs.NotFoundException)2 Test (org.junit.Test)2 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 NoCache (org.jboss.resteasy.annotations.cache.NoCache)1 ConfigurableAuthenticatorFactory (org.keycloak.authentication.ConfigurableAuthenticatorFactory)1 ProviderConfigProperty (org.keycloak.provider.ProviderConfigProperty)1 ConfigPropertyRepresentation (org.keycloak.representations.idm.ConfigPropertyRepresentation)1