Search in sources :

Example 1 with ConfigPropertyRepresentation

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

the class ClientRegistrationPoliciesTest method getProviderConfigProperty.

private List<String> getProviderConfigProperty(ComponentTypeRepresentation provider, String expectedConfigPropName) {
    Assert.assertNotNull(provider);
    List<ConfigPropertyRepresentation> list = provider.getProperties();
    list = list.stream().filter((ConfigPropertyRepresentation rep) -> {
        return rep.getName().equals(expectedConfigPropName);
    }).collect(Collectors.toList());
    Assert.assertEquals(list.size(), 1);
    ConfigPropertyRepresentation allowedProtocolMappers = list.get(0);
    Assert.assertEquals(allowedProtocolMappers.getName(), expectedConfigPropName);
    return allowedProtocolMappers.getOptions();
}
Also used : ConfigPropertyRepresentation(org.keycloak.representations.idm.ConfigPropertyRepresentation)

Example 2 with ConfigPropertyRepresentation

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

the class UserStorageRestTest method testLDAPMapperProviderConfigurationForVendorOther.

// KEYCLOAK-12934
@Test
public void testLDAPMapperProviderConfigurationForVendorOther() {
    ComponentRepresentation ldapRep = createBasicLDAPProviderRep();
    ldapRep.getConfig().putSingle(LDAPConstants.VENDOR, LDAPConstants.VENDOR_OTHER);
    String ldapModelId = createComponent(ldapRep);
    ComponentTypeRepresentation groupLDAPMapperType = findMapperTypeConfiguration(ldapModelId, GroupLDAPStorageMapperFactory.PROVIDER_ID);
    ConfigPropertyRepresentation groupRetrieverConfigProperty = getUserRolesRetrieveStrategyConfigProperty(groupLDAPMapperType, CommonLDAPGroupMapperConfig.USER_ROLES_RETRIEVE_STRATEGY);
    // LOAD_GROUPS_BY_MEMBER_ATTRIBUTE_RECURSIVELY is expected to be present just for the active directory
    List<String> options = groupRetrieverConfigProperty.getOptions();
    Assert.assertNames(options, GroupMapperConfig.LOAD_GROUPS_BY_MEMBER_ATTRIBUTE, GroupMapperConfig.GET_GROUPS_FROM_USER_MEMBEROF_ATTRIBUTE);
    Assert.assertFalse(groupRetrieverConfigProperty.getHelpText().contains("LOAD_GROUPS_BY_MEMBER_ATTRIBUTE_RECURSIVELY"));
    ComponentTypeRepresentation roleLDAPMapperType = findMapperTypeConfiguration(ldapModelId, RoleLDAPStorageMapperFactory.PROVIDER_ID);
    ConfigPropertyRepresentation roleRetrieverConfigProperty = getUserRolesRetrieveStrategyConfigProperty(roleLDAPMapperType, CommonLDAPGroupMapperConfig.USER_ROLES_RETRIEVE_STRATEGY);
    // LOAD_ROLES_BY_MEMBER_ATTRIBUTE_RECURSIVELY is expected to be present just for the active directory
    options = roleRetrieverConfigProperty.getOptions();
    Assert.assertNames(options, RoleMapperConfig.LOAD_ROLES_BY_MEMBER_ATTRIBUTE, RoleMapperConfig.GET_ROLES_FROM_USER_MEMBEROF_ATTRIBUTE);
    Assert.assertFalse(roleRetrieverConfigProperty.getHelpText().contains("LOAD_ROLES_BY_MEMBER_ATTRIBUTE_RECURSIVELY"));
    // Cleanup including mappers
    removeComponent(ldapModelId);
}
Also used : ComponentRepresentation(org.keycloak.representations.idm.ComponentRepresentation) ComponentTypeRepresentation(org.keycloak.representations.idm.ComponentTypeRepresentation) ConfigPropertyRepresentation(org.keycloak.representations.idm.ConfigPropertyRepresentation) Test(org.junit.Test) AbstractAuthenticationTest(org.keycloak.testsuite.admin.authentication.AbstractAuthenticationTest)

Example 3 with ConfigPropertyRepresentation

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

the class ComponentResource method toComponentTypeRepresentation.

private ComponentTypeRepresentation toComponentTypeRepresentation(ProviderFactory factory, ComponentModel parent) {
    ComponentTypeRepresentation rep = new ComponentTypeRepresentation();
    rep.setId(factory.getId());
    ComponentFactory componentFactory = (ComponentFactory) factory;
    rep.setHelpText(componentFactory.getHelpText());
    List<ProviderConfigProperty> props;
    Map<String, Object> metadata;
    if (factory instanceof SubComponentFactory) {
        props = ((SubComponentFactory) factory).getConfigProperties(realm, parent);
        metadata = ((SubComponentFactory) factory).getTypeMetadata(realm, parent);
    } else {
        props = componentFactory.getConfigProperties();
        metadata = componentFactory.getTypeMetadata();
    }
    List<ConfigPropertyRepresentation> propReps = ModelToRepresentation.toRepresentation(props);
    rep.setProperties(propReps);
    rep.setMetadata(metadata);
    return rep;
}
Also used : ComponentTypeRepresentation(org.keycloak.representations.idm.ComponentTypeRepresentation) SubComponentFactory(org.keycloak.component.SubComponentFactory) SubComponentFactory(org.keycloak.component.SubComponentFactory) ComponentFactory(org.keycloak.component.ComponentFactory) ProviderConfigProperty(org.keycloak.provider.ProviderConfigProperty) ConfigPropertyRepresentation(org.keycloak.representations.idm.ConfigPropertyRepresentation)

Example 4 with ConfigPropertyRepresentation

use of org.keycloak.representations.idm.ConfigPropertyRepresentation 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 5 with ConfigPropertyRepresentation

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

the class UserStorageRestTest method testLDAPMapperProviderConfigurationForVendorMSAD.

// KEYCLOAK-12934
@Test
public void testLDAPMapperProviderConfigurationForVendorMSAD() {
    ComponentRepresentation ldapRep = createBasicLDAPProviderRep();
    ldapRep.getConfig().putSingle(LDAPConstants.VENDOR, LDAPConstants.VENDOR_ACTIVE_DIRECTORY);
    String ldapModelId = createComponent(ldapRep);
    ComponentTypeRepresentation groupLDAPMapperType = findMapperTypeConfiguration(ldapModelId, GroupLDAPStorageMapperFactory.PROVIDER_ID);
    ConfigPropertyRepresentation groupRetrieverConfigProperty = getUserRolesRetrieveStrategyConfigProperty(groupLDAPMapperType, CommonLDAPGroupMapperConfig.USER_ROLES_RETRIEVE_STRATEGY);
    // LOAD_GROUPS_BY_MEMBER_ATTRIBUTE_RECURSIVELY is expected to be present just for the active directory
    List<String> options = groupRetrieverConfigProperty.getOptions();
    Assert.assertNames(options, GroupMapperConfig.LOAD_GROUPS_BY_MEMBER_ATTRIBUTE, GroupMapperConfig.GET_GROUPS_FROM_USER_MEMBEROF_ATTRIBUTE, GroupMapperConfig.LOAD_GROUPS_BY_MEMBER_ATTRIBUTE_RECURSIVELY);
    Assert.assertTrue(groupRetrieverConfigProperty.getHelpText().contains("LOAD_GROUPS_BY_MEMBER_ATTRIBUTE_RECURSIVELY"));
    ComponentTypeRepresentation roleLDAPMapperType = findMapperTypeConfiguration(ldapModelId, RoleLDAPStorageMapperFactory.PROVIDER_ID);
    ConfigPropertyRepresentation roleRetrieverConfigProperty = getUserRolesRetrieveStrategyConfigProperty(roleLDAPMapperType, CommonLDAPGroupMapperConfig.USER_ROLES_RETRIEVE_STRATEGY);
    // LOAD_ROLES_BY_MEMBER_ATTRIBUTE_RECURSIVELY is expected to be present just for the active directory
    options = roleRetrieverConfigProperty.getOptions();
    Assert.assertNames(options, RoleMapperConfig.LOAD_ROLES_BY_MEMBER_ATTRIBUTE, RoleMapperConfig.GET_ROLES_FROM_USER_MEMBEROF_ATTRIBUTE, RoleMapperConfig.LOAD_ROLES_BY_MEMBER_ATTRIBUTE_RECURSIVELY);
    Assert.assertTrue(roleRetrieverConfigProperty.getHelpText().contains("LOAD_ROLES_BY_MEMBER_ATTRIBUTE_RECURSIVELY"));
    // Cleanup including mappers
    removeComponent(ldapModelId);
}
Also used : ComponentRepresentation(org.keycloak.representations.idm.ComponentRepresentation) ComponentTypeRepresentation(org.keycloak.representations.idm.ComponentTypeRepresentation) ConfigPropertyRepresentation(org.keycloak.representations.idm.ConfigPropertyRepresentation) Test(org.junit.Test) AbstractAuthenticationTest(org.keycloak.testsuite.admin.authentication.AbstractAuthenticationTest)

Aggregations

ConfigPropertyRepresentation (org.keycloak.representations.idm.ConfigPropertyRepresentation)5 ComponentTypeRepresentation (org.keycloak.representations.idm.ComponentTypeRepresentation)3 Test (org.junit.Test)2 ProviderConfigProperty (org.keycloak.provider.ProviderConfigProperty)2 ComponentRepresentation (org.keycloak.representations.idm.ComponentRepresentation)2 AbstractAuthenticationTest (org.keycloak.testsuite.admin.authentication.AbstractAuthenticationTest)2 GET (javax.ws.rs.GET)1 NotFoundException (javax.ws.rs.NotFoundException)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 ComponentFactory (org.keycloak.component.ComponentFactory)1 SubComponentFactory (org.keycloak.component.SubComponentFactory)1 AuthenticatorConfigInfoRepresentation (org.keycloak.representations.idm.AuthenticatorConfigInfoRepresentation)1