Java Code Examples for org.keycloak.models.RealmModel#getComponent()
The following examples show how to use
org.keycloak.models.RealmModel#getComponent() .
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: UserCacheSession.java From keycloak with Apache License 2.0 | 6 votes |
protected UserModel validateCache(RealmModel realm, CachedUser cached) { if (!realm.getId().equals(cached.getRealm())) { return null; } StorageId storageId = cached.getFederationLink() != null ? new StorageId(cached.getFederationLink(), cached.getId()) : new StorageId(cached.getId()); if (!storageId.isLocal()) { ComponentModel component = realm.getComponent(storageId.getProviderId()); CacheableStorageProviderModel model = new CacheableStorageProviderModel(component); // although we do set a timeout, Infinispan has no guarantees when the user will be evicted // its also hard to test stuff if (model.shouldInvalidate(cached)) { registerUserInvalidation(realm, cached); return getDelegate().getUserById(cached.getId(), realm); } } return new UserAdapter(cached, this, session, realm); }
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: UserStorageManager.java From keycloak with Apache License 2.0 | 5 votes |
public static UserStorageProvider getStorageProvider(KeycloakSession session, RealmModel realm, String componentId) { ComponentModel model = realm.getComponent(componentId); if (model == null) return null; UserStorageProviderModel storageModel = new UserStorageProviderModel(model); UserStorageProviderFactory factory = (UserStorageProviderFactory)session.getKeycloakSessionFactory().getProviderFactory(UserStorageProvider.class, model.getProviderId()); if (factory == null) { throw new ModelException("Could not find UserStorageProviderFactory for: " + model.getProviderId()); } return getStorageProviderInstance(session, storageModel, factory); }
Example 4
Source File: ClientStorageManager.java From keycloak with Apache License 2.0 | 5 votes |
public static ClientStorageProvider getStorageProvider(KeycloakSession session, RealmModel realm, String componentId) { ComponentModel model = realm.getComponent(componentId); if (model == null) return null; ClientStorageProviderModel storageModel = new ClientStorageProviderModel(model); ClientStorageProviderFactory factory = (ClientStorageProviderFactory)session.getKeycloakSessionFactory().getProviderFactory(ClientStorageProvider.class, model.getProviderId()); if (factory == null) { throw new ModelException("Could not find ClientStorageProviderFactory for: " + model.getProviderId()); } return getStorageProviderInstance(session, storageModel, factory); }
Example 5
Source File: RoleLDAPStorageMapperFactory.java From keycloak with Apache License 2.0 | 5 votes |
@Override public void onCreate(KeycloakSession session, RealmModel realm, ComponentModel model) { ComponentModel parentModel = realm.getComponent(model.getParentId()); UserStorageProviderModel parent = new UserStorageProviderModel(parentModel); onParentUpdate(realm, parent, parent, model); }
Example 6
Source File: GroupLDAPStorageMapperFactory.java From keycloak with Apache License 2.0 | 5 votes |
@Override public void onCreate(KeycloakSession session, RealmModel realm, ComponentModel model) { ComponentModel parentModel = realm.getComponent(model.getParentId()); UserStorageProviderModel parent = new UserStorageProviderModel(parentModel); onParentUpdate(realm, parent, parent, model); }
Example 7
Source File: UserCacheSession.java From keycloak with Apache License 2.0 | 4 votes |
protected UserModel cacheUser(RealmModel realm, UserModel delegate, Long revision) { int notBefore = getDelegate().getNotBeforeOfUser(realm, delegate); StorageId storageId = delegate.getFederationLink() != null ? new StorageId(delegate.getFederationLink(), delegate.getId()) : new StorageId(delegate.getId()); CachedUser cached = null; UserAdapter adapter = null; if (!storageId.isLocal()) { ComponentModel component = realm.getComponent(storageId.getProviderId()); UserStorageProviderModel model = new UserStorageProviderModel(component); if (!model.isEnabled()) { return new ReadOnlyUserModelDelegate(delegate) { @Override public boolean isEnabled() { return false; } }; } UserStorageProviderModel.CachePolicy policy = model.getCachePolicy(); if (policy != null && policy == UserStorageProviderModel.CachePolicy.NO_CACHE) { return delegate; } cached = new CachedUser(revision, realm, delegate, notBefore); adapter = new UserAdapter(cached, this, session, realm); onCache(realm, adapter, delegate); long lifespan = model.getLifespan(); if (lifespan > 0) { cache.addRevisioned(cached, startupRevision, lifespan); } else { cache.addRevisioned(cached, startupRevision); } } else { cached = new CachedUser(revision, realm, delegate, notBefore); adapter = new UserAdapter(cached, this, session, realm); onCache(realm, adapter, delegate); cache.addRevisioned(cached, startupRevision); } return adapter; }
Example 8
Source File: UserStorageManager.java From keycloak with Apache License 2.0 | 4 votes |
public static UserStorageProviderModel getStorageProviderModel(RealmModel realm, String componentId) { ComponentModel model = realm.getComponent(componentId); if (model == null) return null; return new UserStorageProviderModel(model); }
Example 9
Source File: ClientStorageManager.java From keycloak with Apache License 2.0 | 4 votes |
public static ClientStorageProviderModel getStorageProviderModel(RealmModel realm, String componentId) { ComponentModel model = realm.getComponent(componentId); if (model == null) return null; return new ClientStorageProviderModel(model); }
Example 10
Source File: RoleLDAPStorageMapperFactory.java From keycloak with Apache License 2.0 | 4 votes |
@Override public void onUpdate(KeycloakSession session, RealmModel realm, ComponentModel oldModel, ComponentModel newModel) { ComponentModel parentModel = realm.getComponent(newModel.getParentId()); UserStorageProviderModel parent = new UserStorageProviderModel(parentModel); onParentUpdate(realm, parent, parent, newModel); }
Example 11
Source File: GroupLDAPStorageMapperFactory.java From keycloak with Apache License 2.0 | 4 votes |
@Override public void onUpdate(KeycloakSession session, RealmModel realm, ComponentModel oldModel, ComponentModel newModel) { ComponentModel parentModel = realm.getComponent(newModel.getParentId()); UserStorageProviderModel parent = new UserStorageProviderModel(parentModel); onParentUpdate(realm, parent, parent, newModel); }