public DefaultPartitionManager(Collection<IdentityConfiguration> configurations, EventBridge eventBridge, Collection<PermissionHandler> permissionHandlers, IdGenerator idGenerator) { super(new PartitionManagerConfiguration(configurations, permissionHandlers, eventBridge, idGenerator)); }
IdentityConfiguration getConfigurationForPartition(IdentityContext identityContext, Partition partition) { IdentityConfiguration partitionManagementConfig = this.configuration.getPartitionManagementConfig(); if (partitionManagementConfig == null) { Collection<IdentityConfiguration> configurations = this.configuration.getConfigurations(); if (configurations.size() == 1) { return configurations.iterator().next(); } } if (!this.partitionConfigurations.containsKey(partition)) { PartitionStore<?> store = getStoreForPartitionOperation(identityContext, partition.getClass()); partitionConfigurations.put(partition, this.configuration.getConfigurationByName(store.getConfigurationName(identityContext, partition))); } IdentityConfiguration identityConfiguration = partitionConfigurations.get(partition); if (identityConfiguration == null) { throw MESSAGES.partitionReferencesInvalidConfiguration(partition); } return identityConfiguration; }
AbstractAttributedTypeManager(PartitionManagerConfiguration configuration, Partition partition) { this.configuration = configuration; this.identityContext = createIdentityContext(partition, configuration.getEventBridge(), configuration.getIdGenerator()); }
@Override public Collection<IdentityConfiguration> getConfigurations() { return getConfiguration().getConfigurations(); }
@Override public void add(Partition partition, String configurationName) throws IdentityManagementException { checkPartitionManagementSupported(); if (partition == null) { throw MESSAGES.nullArgument("Partition"); } if (isNullOrEmpty(configurationName)) { configurationName = getConfiguration().getDefaultConfigurationName(); } if (getConfiguration().getConfigurationByName(configurationName) != null) { checkUniqueness(partition); try { IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForPartitionOperation(identityContext, partition.getClass()).add(identityContext, partition, configurationName); addAttributes(identityContext, partition); fireEvent(new PartitionCreatedEvent(partition, this)); } catch (Exception e) { throw MESSAGES.partitionAddFailed(partition, configurationName, e); } } }
public ContextualPermissionManager(Partition partition, DefaultPartitionManager defaultPartitionManager) { this.identityContext = new DefaultIdentityContext(partition, defaultPartitionManager.getEventBridge(), defaultPartitionManager.getIdGenerator(), defaultPartitionManager.getConfiguration().getPermissionHandlerPolicy()); this.storeSelector = defaultPartitionManager.getStoreSelector(); this.partitionManager = defaultPartitionManager; if (this.storeSelector.getStoreForPermissionOperation(identityContext) == null) { throw IDMInternalMessages.MESSAGES.permissionUnsupportedOperation(); } }
@Override public boolean inheritsPrivileges(IdentityType identity, IdentityType assignee) { if (identity.equals(assignee)) { return true; } PrivilegeChainQuery privilegeChainQuery = getConfiguration().getPrivilegeChainQuery(); return privilegeChainQuery.inheritsPrivileges(this, identity, assignee); }
@Override public <T extends PartitionStore<?>> T getStoreForPartitionOperation(IdentityContext context, Class<? extends Partition> partitionClass) { IdentityConfiguration partitionManagementConfig = this.configuration.getPartitionManagementConfig(); Map<IdentityStoreConfiguration, IdentityStore<?>> configStores = stores.get(partitionManagementConfig); for (IdentityStoreConfiguration cfg : configStores.keySet()) { if (cfg.supportsType(partitionClass, create)) { T store = getIdentityStoreAndInitializeContext(context, partitionManagementConfig, cfg); if (!PartitionStore.class.isInstance(store)) { throw MESSAGES.storeUnexpectedType(store.getClass(), PartitionStore.class); } return store; } } throw MESSAGES.storeNotFound(PartitionStore.class, partitionClass); }
@Override public <T extends AttributeStore<?>> T getStoreForAttributeOperation(IdentityContext context) { IdentityConfiguration attributeManagementConfig = this.configuration.getAttributeManagementConfig(); if (attributeManagementConfig != null) { Map<IdentityStoreConfiguration, IdentityStore<?>> configStores = stores.get(attributeManagementConfig); for (IdentityStoreConfiguration cfg : configStores.keySet()) { if (cfg.supportsAttribute()) { T store = getIdentityStoreAndInitializeContext(context, attributeManagementConfig, cfg); if (!AttributeStore.class.isInstance(store)) { throw MESSAGES.storeUnexpectedType(store.getClass(), AttributeStore.class); } return store; } } } return null; }
@Override public Collection<IdentityConfiguration> getConfigurations() { return getConfiguration().getConfigurations(); }
@Override public void add(Partition partition, String configurationName) throws IdentityManagementException { checkPartitionManagementSupported(); if (partition == null) { throw MESSAGES.nullArgument("Partition"); } if (isNullOrEmpty(configurationName)) { configurationName = getConfiguration().getDefaultConfigurationName(); } if (getConfiguration().getConfigurationByName(configurationName) != null) { checkUniqueness(partition); try { IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForPartitionOperation(identityContext, partition.getClass()).add(identityContext, partition, configurationName); addAttributes(identityContext, partition); fireEvent(new PartitionCreatedEvent(partition, this)); } catch (Exception e) { throw MESSAGES.partitionAddFailed(partition, configurationName, e); } } }
public ContextualPermissionManager(Partition partition, DefaultPartitionManager defaultPartitionManager) { this.identityContext = new DefaultIdentityContext(partition, defaultPartitionManager.getEventBridge(), defaultPartitionManager.getIdGenerator(), defaultPartitionManager.getConfiguration().getPermissionHandlerPolicy()); this.storeSelector = defaultPartitionManager.getStoreSelector(); this.partitionManager = defaultPartitionManager; if (this.storeSelector.getStoreForPermissionOperation(identityContext) == null) { throw IDMInternalMessages.MESSAGES.permissionUnsupportedOperation(); } }
@Override public boolean inheritsPrivileges(IdentityType identity, IdentityType assignee) { if (identity.equals(assignee)) { return true; } PrivilegeChainQuery privilegeChainQuery = getConfiguration().getPrivilegeChainQuery(); return privilegeChainQuery.inheritsPrivileges(this, identity, assignee); }
@Override public <T extends PartitionStore<?>> T getStoreForPartitionOperation(IdentityContext context, Class<? extends Partition> partitionClass) { IdentityConfiguration partitionManagementConfig = this.configuration.getPartitionManagementConfig(); Map<IdentityStoreConfiguration, IdentityStore<?>> configStores = stores.get(partitionManagementConfig); for (IdentityStoreConfiguration cfg : configStores.keySet()) { if (cfg.supportsType(partitionClass, create)) { T store = getIdentityStoreAndInitializeContext(context, partitionManagementConfig, cfg); if (!PartitionStore.class.isInstance(store)) { throw MESSAGES.storeUnexpectedType(store.getClass(), PartitionStore.class); } return store; } } throw MESSAGES.storeNotFound(PartitionStore.class, partitionClass); }
@Override public <T extends AttributeStore<?>> T getStoreForAttributeOperation(IdentityContext context) { IdentityConfiguration attributeManagementConfig = this.configuration.getAttributeManagementConfig(); if (attributeManagementConfig != null) { Map<IdentityStoreConfiguration, IdentityStore<?>> configStores = stores.get(attributeManagementConfig); for (IdentityStoreConfiguration cfg : configStores.keySet()) { if (cfg.supportsAttribute()) { T store = getIdentityStoreAndInitializeContext(context, attributeManagementConfig, cfg); if (!AttributeStore.class.isInstance(store)) { throw MESSAGES.storeUnexpectedType(store.getClass(), AttributeStore.class); } return store; } } } return null; }
IdentityConfiguration getConfigurationForPartition(IdentityContext identityContext, Partition partition) { IdentityConfiguration partitionManagementConfig = this.configuration.getPartitionManagementConfig(); if (partitionManagementConfig == null) { Collection<IdentityConfiguration> configurations = this.configuration.getConfigurations(); if (configurations.size() == 1) { return configurations.iterator().next(); } } if (!this.partitionConfigurations.containsKey(partition)) { PartitionStore<?> store = getStoreForPartitionOperation(identityContext, partition.getClass()); partitionConfigurations.put(partition, this.configuration.getConfigurationByName(store.getConfigurationName(identityContext, partition))); } IdentityConfiguration identityConfiguration = partitionConfigurations.get(partition); if (identityConfiguration == null) { throw MESSAGES.partitionReferencesInvalidConfiguration(partition); } return identityConfiguration; }
AbstractAttributedTypeManager(PartitionManagerConfiguration configuration, Partition partition) { this.configuration = configuration; this.identityContext = createIdentityContext(partition, configuration.getEventBridge(), configuration.getIdGenerator()); }
public DefaultStoreSelector(PartitionManagerConfiguration configuration) { this.configuration = configuration; Map<IdentityConfiguration, Map<IdentityStoreConfiguration, IdentityStore<?>>> configuredStores = new HashMap<IdentityConfiguration, Map<IdentityStoreConfiguration, IdentityStore<?>>>(); for (IdentityConfiguration config : this.configuration.getConfigurations()) { Map<IdentityStoreConfiguration, IdentityStore<?>> storeMap = new HashMap<IdentityStoreConfiguration, IdentityStore<?>>(); for (IdentityStoreConfiguration storeConfig : config.getStoreConfiguration()) { storeMap.put(storeConfig, createIdentityStore(storeConfig)); } configuredStores.put(config, Collections.unmodifiableMap(storeMap)); } this.stores = Collections.unmodifiableMap(configuredStores); }
public DefaultPartitionManager(Collection<IdentityConfiguration> configurations, EventBridge eventBridge, Collection<PermissionHandler> permissionHandlers, IdGenerator idGenerator) { super(new PartitionManagerConfiguration(configurations, permissionHandlers, eventBridge, idGenerator)); }
@Override public IdentityContext getIdentityContext() { return createIdentityContext(null, getConfiguration().getEventBridge(), getConfiguration().getIdGenerator()); } }