Java Code Examples for org.keycloak.common.util.MultivaluedHashMap#get()

The following examples show how to use org.keycloak.common.util.MultivaluedHashMap#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComponentImportService.java    From keycloak-config-cli with Apache License 2.0 6 votes vote down vote up
private boolean isComponentEqual(ComponentRepresentation existingComponent, ComponentRepresentation patchedComponent) {
    // compare component config
    MultivaluedHashMap<String, String> existingComponentConfig = existingComponent.getConfig();
    MultivaluedHashMap<String, String> patchedComponentConfig = patchedComponent.getConfig();

    // https://lists.jboss.org/pipermail/keycloak-user/2018-December/016706.html
    boolean isUserStorageProvider = patchedComponent.getProviderType().equals("org.keycloak.storage.ldap.mappers.UserStorageProvider");
    boolean looksEquals = CloneUtil.deepEquals(existingComponent, patchedComponent, "config");
    boolean componentConfigHaveSameKeys = patchedComponentConfig.keySet().equals(existingComponentConfig.keySet());
    if (isUserStorageProvider || !looksEquals || !componentConfigHaveSameKeys) {
        return false;
    }

    for (Map.Entry<String, List<String>> config : patchedComponentConfig.entrySet()) {
        List<String> patchedComponentConfigValue = config.getValue();
        List<String> existingComponentConfigValue = existingComponentConfig.get(config.getKey());

        if (!patchedComponentConfigValue.containsAll(existingComponentConfigValue) || !existingComponentConfigValue.containsAll(patchedComponentConfigValue)) {
            return false;
        }
    }

    return true;
}
 
Example 2
Source File: ImportComponentsIT.java    From keycloak-config-cli with Apache License 2.0 6 votes vote down vote up
@Test
@Order(1)
void shouldCreateRealmWithComponent() {
    doImport("00_create_realm_with_component.json");

    RealmRepresentation createdRealm = keycloakProvider.get().realm(REALM_NAME).toRepresentation();

    assertThat(createdRealm.getRealm(), is(REALM_NAME));
    assertThat(createdRealm.isEnabled(), is(true));

    ComponentRepresentation rsaComponent = getComponent(
            "org.keycloak.keys.KeyProvider",
            "rsa-generated"
    );

    assertThat(rsaComponent.getName(), is("rsa-generated"));
    assertThat(rsaComponent.getProviderId(), is("rsa-generated"));
    MultivaluedHashMap<String, String> componentConfig = rsaComponent.getConfig();

    List<String> keySize = componentConfig.get("keySize");
    assertThat(keySize, hasSize(1));
    assertThat(keySize.get(0), is("4096"));
}
 
Example 3
Source File: ImportComponentsIT.java    From keycloak-config-cli with Apache License 2.0 6 votes vote down vote up
@Test
@Order(2)
void shouldUpdateComponentsConfig() {
    doImport("01_update_realm__change_component_config.json");

    RealmRepresentation createdRealm = keycloakProvider.get().realm(REALM_NAME).toRepresentation();

    assertThat(createdRealm.getRealm(), is(REALM_NAME));
    assertThat(createdRealm.isEnabled(), is(true));

    ComponentRepresentation rsaComponent = getComponent(
            "org.keycloak.keys.KeyProvider",
            "rsa-generated"
    );

    assertThat(rsaComponent.getName(), is("rsa-generated"));
    assertThat(rsaComponent.getProviderId(), is("rsa-generated"));
    MultivaluedHashMap<String, String> componentConfig = rsaComponent.getConfig();

    List<String> keySize = componentConfig.get("keySize");
    assertThat(keySize, hasSize(1));
    assertThat(keySize.get(0), is("2048"));
}
 
Example 4
Source File: ImportComponentsIT.java    From keycloak-config-cli with Apache License 2.0 6 votes vote down vote up
@Test
@Order(4)
void shouldAddComponentForSameProviderType() {
    doImport("03_update_realm__add_component_for_same_providerType.json");

    RealmRepresentation createdRealm = keycloakProvider.get().realm(REALM_NAME).toRepresentation();

    assertThat(createdRealm.getRealm(), is(REALM_NAME));
    assertThat(createdRealm.isEnabled(), is(true));

    ComponentRepresentation createdComponent = getComponent(
            "org.keycloak.keys.KeyProvider",
            "hmac-generated"
    );

    assertThat(createdComponent.getName(), is("hmac-generated"));
    assertThat(createdComponent.getProviderId(), is("hmac-generated"));
    assertThat(createdComponent.getProviderType(), is("org.keycloak.keys.KeyProvider"));
    MultivaluedHashMap<String, String> componentConfig = createdComponent.getConfig();

    List<String> secretSizeSize = componentConfig.get("secretSize");
    assertThat(secretSizeSize, hasSize(1));
    assertThat(secretSizeSize.get(0), is("32"));
}
 
Example 5
Source File: ImportComponentsIT.java    From keycloak-config-cli with Apache License 2.0 5 votes vote down vote up
@Test
@Order(3)
void shouldUpdateAddComponentsConfig() {
    doImport("02_update_realm__add_component_with_config.json");

    RealmRepresentation createdRealm = keycloakProvider.get().realm(REALM_NAME).toRepresentation();

    assertThat(createdRealm.getRealm(), is(REALM_NAME));
    assertThat(createdRealm.isEnabled(), is(true));

    ComponentRepresentation createdComponent = getComponent(
            "org.keycloak.services.clientregistration.policy.ClientRegistrationPolicy",
            "Allowed Protocol Mapper Types",
            "authenticated"
    );

    assertThat(createdComponent.getName(), is("Allowed Protocol Mapper Types"));
    assertThat(createdComponent.getProviderId(), is("allowed-protocol-mappers"));
    assertThat(createdComponent.getSubType(), is("authenticated"));
    MultivaluedHashMap<String, String> componentConfig = createdComponent.getConfig();

    List<String> mapperTypes = componentConfig.get("allowed-protocol-mapper-types");
    assertThat(mapperTypes, hasSize(8));
    assertThat(mapperTypes, containsInAnyOrder(
            "oidc-full-name-mapper",
            "oidc-sha256-pairwise-sub-mapper",
            "oidc-address-mapper",
            "saml-user-property-mapper",
            "oidc-usermodel-property-mapper",
            "saml-role-list-mapper",
            "saml-user-attribute-mapper",
            "oidc-usermodel-attribute-mapper"
    ));
}
 
Example 6
Source File: ImportComponentsIT.java    From keycloak-config-cli with Apache License 2.0 5 votes vote down vote up
@Test
@Order(12)
void shouldUpdateComponentRemoveAllSubComponent() {
    doImport("12_update_realm__update_component_remove_all_subcomponent.json");

    ComponentRepresentation rsaComponent = getComponent(
            "org.keycloak.keys.KeyProvider",
            "rsa-generated"
    );

    assertThat(rsaComponent.getName(), is("rsa-generated"));
    assertThat(rsaComponent.getProviderId(), is("rsa-generated"));
    MultivaluedHashMap<String, String> componentConfig = rsaComponent.getConfig();

    List<String> keySize = componentConfig.get("keySize");
    assertThat(keySize, hasSize(1));
    assertThat(keySize.get(0), is("2048"));

    ComponentExportRepresentation subComponent = exportComponent(
            "realmWithSubComponents",
            "org.keycloak.storage.UserStorageProvider",
            "my-realm-userstorage"
    );

    assertThat(subComponent, notNullValue());
    assertThat(subComponent.getName(), is("my-realm-userstorage"));
    assertThat(subComponent.getProviderId(), is("ldap"));

    MultivaluedHashMap<String, ComponentExportRepresentation> subComponentsMap = subComponent.getSubComponents();
    ComponentExportRepresentation subComponent2 = getSubComponent(
            subComponentsMap,
            "org.keycloak.storage.ldap.mappers.LDAPStorageMapper",
            "picture"
    );

    assertThat(subComponent2, is(nullValue()));
}
 
Example 7
Source File: ImportComponentsIT.java    From keycloak-config-cli with Apache License 2.0 5 votes vote down vote up
@Test
@Order(97)
void shouldUpdateSkipComponents() {
    doImport("97_update_realm__skip_components.json");

    ComponentRepresentation rsaComponent = getComponent(
            "org.keycloak.keys.KeyProvider",
            "rsa-generated"
    );

    assertThat(rsaComponent.getName(), is("rsa-generated"));
    assertThat(rsaComponent.getProviderId(), is("rsa-generated"));
    MultivaluedHashMap<String, String> componentConfig = rsaComponent.getConfig();

    List<String> keySize = componentConfig.get("keySize");
    assertThat(keySize, hasSize(1));
    assertThat(keySize.get(0), is("2048"));

    ComponentExportRepresentation subComponent = exportComponent(
            "realmWithSubComponents",
            "org.keycloak.storage.UserStorageProvider",
            "my-realm-userstorage"
    );

    assertThat(subComponent, notNullValue());
    assertThat(subComponent.getName(), is("my-realm-userstorage"));
    assertThat(subComponent.getProviderId(), is("ldap"));

    MultivaluedHashMap<String, ComponentExportRepresentation> subComponentsMap = subComponent.getSubComponents();
    ComponentExportRepresentation subComponent2 = getSubComponent(
            subComponentsMap,
            "org.keycloak.storage.ldap.mappers.LDAPStorageMapper",
            "picture"
    );

    assertThat(subComponent2, is(nullValue()));
}
 
Example 8
Source File: ImportComponentsIT.java    From keycloak-config-cli with Apache License 2.0 5 votes vote down vote up
@Test
@Order(98)
void shouldUpdateRemoveComponents() {
    doImport("98_update_realm__remove_component.json");

    ComponentExportRepresentation createdComponent = exportComponent(
            "realmWithSubComponents",
            "org.keycloak.storage.UserStorageProvider",
            "my-realm-userstorage"
    );

    assertThat(createdComponent, is(nullValue()));

    ComponentRepresentation clientRegistrationPolicyComponent = getComponent(
            "org.keycloak.services.clientregistration.policy.ClientRegistrationPolicy",
            "Allowed Protocol Mapper Types",
            "authenticated"
    );

    assertThat(clientRegistrationPolicyComponent.getName(), is("Allowed Protocol Mapper Types"));
    assertThat(clientRegistrationPolicyComponent.getProviderId(), is("allowed-protocol-mappers"));
    assertThat(clientRegistrationPolicyComponent.getSubType(), is("authenticated"));
    MultivaluedHashMap<String, String> componentConfig = clientRegistrationPolicyComponent.getConfig();

    List<String> mapperTypes = componentConfig.get("allowed-protocol-mapper-types");
    assertThat(mapperTypes, hasSize(8));
    assertThat(mapperTypes, containsInAnyOrder(
            "oidc-full-name-mapper",
            "oidc-sha256-pairwise-sub-mapper",
            "oidc-address-mapper",
            "saml-user-property-mapper",
            "oidc-usermodel-property-mapper",
            "saml-role-list-mapper",
            "saml-user-attribute-mapper",
            "oidc-usermodel-attribute-mapper"
    ));
}
 
Example 9
Source File: ImportComponentsIT.java    From keycloak-config-cli with Apache License 2.0 5 votes vote down vote up
private void assertConfigHasValue(MultivaluedHashMap<String, String> config, String configKey, String expectedConfigValue) {
    assertThat(config, hasKey(configKey));
    List<String> configValues = config.get(configKey);

    assertThat(configValues, hasSize(1));

    String configValue = configValues.get(0);
    assertThat(configValue, is(equalTo(expectedConfigValue)));
}
 
Example 10
Source File: ImportComponentsIT.java    From keycloak-config-cli with Apache License 2.0 4 votes vote down vote up
@Test
@Order(7)
void shouldUpdateComponentAddSubComponent() {
    doImport("06_create_realm__with_component_without_subcomponent.json");
    doImport("07_update_realm__update_component_add_subcomponent.json");

    ComponentRepresentation rsaComponent = getComponent(
            "org.keycloak.keys.KeyProvider",
            "rsa-generated"
    );

    assertThat(rsaComponent.getName(), is("rsa-generated"));
    assertThat(rsaComponent.getProviderId(), is("rsa-generated"));
    MultivaluedHashMap<String, String> componentConfig = rsaComponent.getConfig();

    List<String> keySize = componentConfig.get("keySize");
    assertThat(keySize, hasSize(1));
    assertThat(keySize.get(0), is("2048"));

    ComponentExportRepresentation createdComponent = exportComponent(
            "realmWithSubComponents",
            "org.keycloak.storage.UserStorageProvider",
            "my-realm-userstorage"
    );

    assertThat(createdComponent, notNullValue());
    assertThat(createdComponent.getName(), is("my-realm-userstorage"));
    assertThat(createdComponent.getProviderId(), is("ldap"));

    MultivaluedHashMap<String, ComponentExportRepresentation> subComponentsMap = createdComponent.getSubComponents();
    ComponentExportRepresentation subComponent = getSubComponent(
            subComponentsMap,
            "org.keycloak.storage.ldap.mappers.LDAPStorageMapper",
            "my-realm-role-mapper"
    );

    assertThat(subComponent.getName(), is(equalTo("my-realm-role-mapper")));
    assertThat(subComponent.getProviderId(), is(equalTo("role-ldap-mapper")));

    MultivaluedHashMap<String, String> config = subComponent.getConfig();
    assertThat(config.size(), is(10));

    assertConfigHasValue(config, "mode", "LDAP_ONLY");
    assertConfigHasValue(config, "membership.attribute.type", "DN");
    assertConfigHasValue(config, "user.roles.retrieve.strategy", "LOAD_ROLES_BY_MEMBER_ATTRIBUTE_RECURSIVELY");
    assertConfigHasValue(config, "roles.dn", "someDN");
    assertConfigHasValue(config, "membership.ldap.attribute", "member");
    assertConfigHasValue(config, "membership.user.ldap.attribute", "userPrincipalName");
    assertConfigHasValue(config, "memberof.ldap.attribute", "memberOf");
    assertConfigHasValue(config, "role.name.ldap.attribute", "cn");
    assertConfigHasValue(config, "use.realm.roles.mapping", "true");
    assertConfigHasValue(config, "role.object.classes", "group");
}
 
Example 11
Source File: ImportComponentsIT.java    From keycloak-config-cli with Apache License 2.0 4 votes vote down vote up
@Test
@Order(8)
void shouldUpdateComponentAddMoreSubComponent() {
    doImport("08_update_realm__update_component_add_more_subcomponent.json");

    ComponentRepresentation rsaComponent = getComponent(
            "org.keycloak.keys.KeyProvider",
            "rsa-generated"
    );

    assertThat(rsaComponent.getName(), is("rsa-generated"));
    assertThat(rsaComponent.getProviderId(), is("rsa-generated"));
    MultivaluedHashMap<String, String> componentConfig = rsaComponent.getConfig();

    List<String> keySize = componentConfig.get("keySize");
    assertThat(keySize, hasSize(1));
    assertThat(keySize.get(0), is("2048"));

    ComponentExportRepresentation createdComponent = exportComponent(
            "realmWithSubComponents",
            "org.keycloak.storage.UserStorageProvider",
            "my-realm-userstorage"
    );

    assertThat(createdComponent, notNullValue());
    assertThat(createdComponent.getName(), is("my-realm-userstorage"));
    assertThat(createdComponent.getProviderId(), is("ldap"));

    MultivaluedHashMap<String, ComponentExportRepresentation> subComponentsMap = createdComponent.getSubComponents();
    ComponentExportRepresentation subComponent = getSubComponent(
            subComponentsMap,
            "org.keycloak.storage.ldap.mappers.LDAPStorageMapper",
            "my-realm-role-mapper"
    );

    assertThat(subComponent.getName(), is(equalTo("my-realm-role-mapper")));
    assertThat(subComponent.getProviderId(), is(equalTo("role-ldap-mapper")));

    MultivaluedHashMap<String, String> config = subComponent.getConfig();
    assertThat(config.size(), is(10));

    assertConfigHasValue(config, "mode", "LDAP_ONLY");
    assertConfigHasValue(config, "membership.attribute.type", "DN");
    assertConfigHasValue(config, "user.roles.retrieve.strategy", "LOAD_ROLES_BY_MEMBER_ATTRIBUTE_RECURSIVELY");
    assertConfigHasValue(config, "roles.dn", "someDN");
    assertConfigHasValue(config, "membership.ldap.attribute", "member");
    assertConfigHasValue(config, "membership.user.ldap.attribute", "userPrincipalName");
    assertConfigHasValue(config, "memberof.ldap.attribute", "memberOf");
    assertConfigHasValue(config, "role.name.ldap.attribute", "cn");
    assertConfigHasValue(config, "use.realm.roles.mapping", "true");
    assertConfigHasValue(config, "role.object.classes", "group");

    ComponentExportRepresentation subComponent2 = getSubComponent(
            subComponentsMap,
            "org.keycloak.storage.ldap.mappers.LDAPStorageMapper",
            "picture"
    );

    assertThat(subComponent2.getName(), is(equalTo("picture")));
    assertThat(subComponent2.getProviderId(), is(equalTo("user-attribute-ldap-mapper")));

    MultivaluedHashMap<String, String> config2 = subComponent2.getConfig();
    assertThat(config2.size(), is(5));

    assertConfigHasValue(config2, "ldap.attribute", "jpegPhoto");
    assertConfigHasValue(config2, "is.mandatory.in.ldap", "true");
    assertConfigHasValue(config2, "is.binary.attribute", "true");
    assertConfigHasValue(config2, "always.read.value.from.ldap", "true");
    assertConfigHasValue(config2, "user.model.attribute", "picture");
}
 
Example 12
Source File: ImportComponentsIT.java    From keycloak-config-cli with Apache License 2.0 4 votes vote down vote up
@Test
@Order(9)
void shouldUpdateComponentUpdateSubComponent() {
    doImport("09_update_realm__update_component_update_subcomponent.json");

    ComponentRepresentation rsaComponent = getComponent(
            "org.keycloak.keys.KeyProvider",
            "rsa-generated"
    );

    assertThat(rsaComponent.getName(), is("rsa-generated"));
    assertThat(rsaComponent.getProviderId(), is("rsa-generated"));
    MultivaluedHashMap<String, String> componentConfig = rsaComponent.getConfig();

    List<String> keySize = componentConfig.get("keySize");
    assertThat(keySize, hasSize(1));
    assertThat(keySize.get(0), is("2048"));

    ComponentExportRepresentation createdComponent = exportComponent(
            "realmWithSubComponents",
            "org.keycloak.storage.UserStorageProvider",
            "my-realm-userstorage"
    );

    assertThat(createdComponent, notNullValue());
    assertThat(createdComponent.getName(), is("my-realm-userstorage"));
    assertThat(createdComponent.getProviderId(), is("ldap"));

    MultivaluedHashMap<String, ComponentExportRepresentation> subComponentsMap = createdComponent.getSubComponents();
    ComponentExportRepresentation subComponent = getSubComponent(
            subComponentsMap,
            "org.keycloak.storage.ldap.mappers.LDAPStorageMapper",
            "my-realm-role-mapper"
    );

    assertThat(subComponent.getName(), is(equalTo("my-realm-role-mapper")));
    assertThat(subComponent.getProviderId(), is(equalTo("role-ldap-mapper")));

    MultivaluedHashMap<String, String> config = subComponent.getConfig();
    assertThat(config.size(), is(10));

    assertConfigHasValue(config, "mode", "LDAP_ONLY");
    assertConfigHasValue(config, "membership.attribute.type", "DN");
    assertConfigHasValue(config, "user.roles.retrieve.strategy", "LOAD_ROLES_BY_MEMBER_ATTRIBUTE_RECURSIVELY");
    assertConfigHasValue(config, "roles.dn", "someDN");
    assertConfigHasValue(config, "membership.ldap.attribute", "member");
    assertConfigHasValue(config, "membership.user.ldap.attribute", "userPrincipalName");
    assertConfigHasValue(config, "memberof.ldap.attribute", "memberOf");
    assertConfigHasValue(config, "role.name.ldap.attribute", "cn");
    assertConfigHasValue(config, "use.realm.roles.mapping", "true");
    assertConfigHasValue(config, "role.object.classes", "group");

    ComponentExportRepresentation subComponent2 = getSubComponent(
            subComponentsMap,
            "org.keycloak.storage.ldap.mappers.LDAPStorageMapper",
            "picture"
    );

    assertThat(subComponent2.getName(), is(equalTo("picture")));
    assertThat(subComponent2.getProviderId(), is(equalTo("user-attribute-ldap-mapper")));

    MultivaluedHashMap<String, String> config2 = subComponent2.getConfig();
    assertThat(config2.size(), is(6));

    assertConfigHasValue(config2, "ldap.attribute", "jpegPhoto");
    assertConfigHasValue(config2, "is.mandatory.in.ldap", "false");
    assertConfigHasValue(config2, "is.binary.attribute", "true");
    assertConfigHasValue(config2, "read.only", "true");
    assertConfigHasValue(config2, "always.read.value.from.ldap", "true");
    assertConfigHasValue(config2, "user.model.attribute", "picture");
}
 
Example 13
Source File: ImportComponentsIT.java    From keycloak-config-cli with Apache License 2.0 4 votes vote down vote up
@Test
@Order(11)
void shouldUpdateComponentRemoveSubComponent() {
    doImport("11_update_realm__update_component_remove_subcomponent.json");

    ComponentRepresentation rsaComponent = getComponent(
            "org.keycloak.keys.KeyProvider",
            "rsa-generated"
    );

    assertThat(rsaComponent.getName(), is("rsa-generated"));
    assertThat(rsaComponent.getProviderId(), is("rsa-generated"));
    MultivaluedHashMap<String, String> componentConfig = rsaComponent.getConfig();

    List<String> keySize = componentConfig.get("keySize");
    assertThat(keySize, hasSize(1));
    assertThat(keySize.get(0), is("2048"));

    ComponentExportRepresentation createdComponent = exportComponent(
            "realmWithSubComponents",
            "org.keycloak.storage.UserStorageProvider",
            "my-realm-userstorage"
    );

    assertThat(createdComponent, notNullValue());
    assertThat(createdComponent.getName(), is("my-realm-userstorage"));
    assertThat(createdComponent.getProviderId(), is("ldap"));

    MultivaluedHashMap<String, ComponentExportRepresentation> subComponentsMap = createdComponent.getSubComponents();
    ComponentExportRepresentation subComponent = getSubComponent(
            subComponentsMap,
            "org.keycloak.storage.ldap.mappers.LDAPStorageMapper",
            "my-realm-role-mapper"
    );

    assertThat(subComponent, is(nullValue()));

    ComponentExportRepresentation subComponent2 = getSubComponent(
            subComponentsMap,
            "org.keycloak.storage.ldap.mappers.LDAPStorageMapper",
            "picture"
    );

    assertThat(subComponent2.getName(), is(equalTo("picture")));
    assertThat(subComponent2.getProviderId(), is(equalTo("user-attribute-ldap-mapper")));

    MultivaluedHashMap<String, String> config2 = subComponent2.getConfig();
    assertThat(config2.size(), is(6));

    assertConfigHasValue(config2, "ldap.attribute", "jpegPhoto");
    assertConfigHasValue(config2, "is.mandatory.in.ldap", "false");
    assertConfigHasValue(config2, "is.binary.attribute", "true");
    assertConfigHasValue(config2, "read.only", "true");
    assertConfigHasValue(config2, "always.read.value.from.ldap", "true");
    assertConfigHasValue(config2, "user.model.attribute", "picture");
}
 
Example 14
Source File: MigrateTo1_3_0.java    From keycloak with Apache License 2.0 4 votes vote down vote up
private void migrateLDAPProviders(KeycloakSession session, RealmModel realm) {
    List<UserStorageProviderModel> federationProviders = realm.getUserStorageProviders();
    for (UserStorageProviderModel fedProvider : federationProviders) {

        if (fedProvider.getProviderId().equals(LDAPConstants.LDAP_PROVIDER)) {
            fedProvider = new UserStorageProviderModel(fedProvider);  // copy don't want to muck with cache
            MultivaluedHashMap<String, String> config = fedProvider.getConfig();

            // Update config properties for LDAP federation provider
            if (config.get(LDAPConstants.SEARCH_SCOPE) == null) {
                config.putSingle(LDAPConstants.SEARCH_SCOPE, String.valueOf(SearchControls.SUBTREE_SCOPE));
            }

            List<String> usersDn = config.remove("userDnSuffix");
            if (usersDn != null && !usersDn.isEmpty() && config.getFirst(LDAPConstants.USERS_DN) == null) {
                config.put(LDAPConstants.USERS_DN, usersDn);
            }

            String usernameLdapAttribute = config.getFirst(LDAPConstants.USERNAME_LDAP_ATTRIBUTE);
            if (usernameLdapAttribute != null && config.getFirst(LDAPConstants.RDN_LDAP_ATTRIBUTE) == null) {
                if (usernameLdapAttribute.equalsIgnoreCase(LDAPConstants.SAM_ACCOUNT_NAME)) {
                    config.putSingle(LDAPConstants.RDN_LDAP_ATTRIBUTE, LDAPConstants.CN);
                } else {
                    config.putSingle(LDAPConstants.RDN_LDAP_ATTRIBUTE, usernameLdapAttribute);
                }
            }

            if (config.getFirst(LDAPConstants.UUID_LDAP_ATTRIBUTE) == null) {
                String uuidAttrName = LDAPConstants.getUuidAttributeName(config.getFirst(LDAPConstants.VENDOR));
                config.putSingle(LDAPConstants.UUID_LDAP_ATTRIBUTE, uuidAttrName);
            }

            realm.updateComponent(fedProvider);

            // Create default mappers for LDAP
            List<ComponentModel> mappers = realm.getComponents(fedProvider.getId());
            if (mappers.isEmpty()) {
                ProviderFactory ldapFactory = session.getKeycloakSessionFactory().getProviderFactory(UserStorageProvider.class, LDAPConstants.LDAP_PROVIDER);
                if (ldapFactory != null) {
                    ((ComponentFactory) ldapFactory).onCreate(session, realm, fedProvider);
                }
            }
        }
    }
}