Java Code Examples for org.keycloak.component.ComponentModel#getConfig()
The following examples show how to use
org.keycloak.component.ComponentModel#getConfig() .
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: LDAPIdentityStoreRegistry.java From keycloak with Apache License 2.0 | 6 votes |
public LDAPIdentityStore getLdapStore(KeycloakSession session, ComponentModel ldapModel, Map<ComponentModel, LDAPConfigDecorator> configDecorators) { LDAPIdentityStoreContext context = ldapStores.get(ldapModel.getId()); // Ldap config might have changed for the realm. In this case, we must re-initialize MultivaluedHashMap<String, String> configModel = ldapModel.getConfig(); LDAPConfig ldapConfig = new LDAPConfig(configModel); for (Map.Entry<ComponentModel, LDAPConfigDecorator> entry : configDecorators.entrySet()) { ComponentModel mapperModel = entry.getKey(); LDAPConfigDecorator decorator = entry.getValue(); decorator.updateLDAPConfig(ldapConfig, mapperModel); } if (context == null || !ldapConfig.equals(context.config)) { logLDAPConfig(session, ldapModel, ldapConfig); LDAPIdentityStore store = createLdapIdentityStore(session, ldapConfig); context = new LDAPIdentityStoreContext(ldapConfig, store); ldapStores.put(ldapModel.getId(), context); } return context.store; }
Example 2
Source File: FullNameLDAPStorageMapperFactory.java From keycloak with Apache License 2.0 | 6 votes |
@Override public void validateConfiguration(KeycloakSession session, RealmModel realm, ComponentModel config) throws ComponentValidationException { checkMandatoryConfigAttribute(FullNameLDAPStorageMapper.LDAP_FULL_NAME_ATTRIBUTE, "LDAP Full Name Attribute", config); boolean readOnly = AbstractLDAPStorageMapper.parseBooleanParameter(config, FullNameLDAPStorageMapper.READ_ONLY); boolean writeOnly = AbstractLDAPStorageMapper.parseBooleanParameter(config, FullNameLDAPStorageMapper.WRITE_ONLY); ComponentModel parent = realm.getComponent(config.getParentId()); if (parent == null) { throw new ComponentValidationException("can't find parent component model"); } LDAPConfig cfg = new LDAPConfig(parent.getConfig()); UserStorageProvider.EditMode editMode = cfg.getEditMode(); if (writeOnly && cfg.getEditMode() != UserStorageProvider.EditMode.WRITABLE) { throw new ComponentValidationException("ldapErrorCantWriteOnlyForReadOnlyLdap"); } if (writeOnly && readOnly) { throw new ComponentValidationException("ldapErrorCantWriteOnlyAndReadOnly"); } }
Example 3
Source File: FullNameLDAPStorageMapperFactory.java From keycloak with Apache License 2.0 | 5 votes |
private static List<ProviderConfigProperty> getConfigProps(ComponentModel parent) { boolean readOnly = false; if (parent != null) { LDAPConfig config = new LDAPConfig(parent.getConfig()); readOnly = config.getEditMode() != UserStorageProvider.EditMode.WRITABLE; } return ProviderConfigurationBuilder.create() .property().name(FullNameLDAPStorageMapper.LDAP_FULL_NAME_ATTRIBUTE) .label("LDAP Full Name Attribute") .helpText("Name of LDAP attribute, which contains fullName of user. Usually it will be 'cn' ") .type(ProviderConfigProperty.STRING_TYPE) .defaultValue(LDAPConstants.CN) .add() .property().name(FullNameLDAPStorageMapper.READ_ONLY) .label("Read Only") .helpText("For Read-only is data imported from LDAP to Keycloak DB, but it's not saved back to LDAP when user is updated in Keycloak.") .type(ProviderConfigProperty.BOOLEAN_TYPE) .defaultValue(String.valueOf(readOnly)) .add() .property().name(FullNameLDAPStorageMapper.WRITE_ONLY) .label("Write Only") .helpText("For Write-only is data propagated to LDAP when user is created or updated in Keycloak. But this mapper is not used to propagate data from LDAP back into Keycloak. " + "This setting is useful if you configured separate firstName and lastName attribute mappers and you want to use those to read attribute from LDAP into Keycloak") .type(ProviderConfigProperty.BOOLEAN_TYPE) .defaultValue(String.valueOf(!readOnly)) .add() .build(); }
Example 4
Source File: CommonKerberosConfig.java From keycloak with Apache License 2.0 | 4 votes |
public CommonKerberosConfig(ComponentModel componentModel) { this.userStorageConfig = componentModel.getConfig(); }