@Override public void add(Partition attributedType) throws IdentityManagementException { add(attributedType, null); }
@Override public IdentityManager createIdentityManager() throws IdentityManagementException { return createIdentityManager(DEFAULT_REALM); }
private Partition getStoredPartition(final Partition partition) { Partition storedPartition; if (getConfiguration().supportsPartition()) { storedPartition = getPartition(partition.getClass(), partition.getName()); } else { storedPartition = createDefaultPartition(); } if (storedPartition == null) { throw MESSAGES.partitionNotFoundWithName(partition.getClass(), partition.getName()); } return storedPartition; }
@Override protected void doUpdate(Partition attributedType) { checkPartitionManagementSupported(); IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForPartitionOperation(identityContext, attributedType.getClass()).update(identityContext, attributedType); }
@Override public void start(StartContext context) throws StartException { ROOT_LOGGER.debugf("Starting PartitionManagerService for [%s]", this.alias); this.partitionManager = new DefaultPartitionManager(this.configurationBuilder.buildAll()); publishPartitionManager(context); }
DefaultPartitionManager partitionManager = new DefaultPartitionManager(builder.buildAll()); if (partitionManager.getPartition(Realm.class, Realm.DEFAULT_REALM) == null) { partitionManager.add(new Realm(Realm.DEFAULT_REALM)); identityManager = partitionManager.createIdentityManager();
@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); } } }
@Override protected void doRemove(Partition attributedType) { checkPartitionManagementSupported(); IdentityManager identityManager = createIdentityManager(attributedType); IdentityQueryBuilder queryBuilder = identityManager.getQueryBuilder(); IdentityQuery<IdentityType> query = queryBuilder.createIdentityQuery(IdentityType.class); for (IdentityType identityType : query.getResultList()) { identityManager.remove(identityType); } IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForPartitionOperation(identityContext, attributedType.getClass()).remove(identityContext, attributedType); }
@Override public IdentityManager createIdentityManager(Partition partition) throws IdentityManagementException { if (partition == null) { if (!getConfiguration().supportsPartition()) { return createIdentityManager(); } throw MESSAGES.nullArgument("Partition"); } Partition storedPartition = getStoredPartition(partition); try { return new ContextualIdentityManager(storedPartition, this); } catch (Exception e) { throw MESSAGES.partitionCouldNotCreateIdentityManager(storedPartition, e); } }
@Override protected void checkUniqueness(Partition attributedType) throws IdentityManagementException { Partition storedPartition = getPartition(attributedType.getClass(), attributedType.getName()); if (storedPartition != null) { throw MESSAGES.partitionAlreadyExistsWithName(attributedType.getClass(), storedPartition.getName()); } }
@Override public PartitionManager create(CreationalContext<PartitionManager> creationalContext) { this.configuration = resolveIdentityConfiguration(); PartitionManager identity = new DefaultPartitionManager(this.configuration); this.injectionTarget.inject(identity, creationalContext); this.injectionTarget.postConstruct(identity); return identity; }
@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); } } }
@Override protected void doRemove(Partition attributedType) { checkPartitionManagementSupported(); IdentityManager identityManager = createIdentityManager(attributedType); IdentityQueryBuilder queryBuilder = identityManager.getQueryBuilder(); IdentityQuery<IdentityType> query = queryBuilder.createIdentityQuery(IdentityType.class); for (IdentityType identityType : query.getResultList()) { identityManager.remove(identityType); } IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForPartitionOperation(identityContext, attributedType.getClass()).remove(identityContext, attributedType); }
@Override public IdentityManager createIdentityManager(Partition partition) throws IdentityManagementException { if (partition == null) { if (!getConfiguration().supportsPartition()) { return createIdentityManager(); } throw MESSAGES.nullArgument("Partition"); } Partition storedPartition = getStoredPartition(partition); try { return new ContextualIdentityManager(storedPartition, this); } catch (Exception e) { throw MESSAGES.partitionCouldNotCreateIdentityManager(storedPartition, e); } }
@Override protected void doUpdate(Partition attributedType) { checkPartitionManagementSupported(); IdentityContext identityContext = getIdentityContext(); getStoreSelector().getStoreForPartitionOperation(identityContext, attributedType.getClass()).update(identityContext, attributedType); }
@Override protected void checkUniqueness(Partition attributedType) throws IdentityManagementException { Partition storedPartition = getPartition(attributedType.getClass(), attributedType.getName()); if (storedPartition != null) { throw MESSAGES.partitionAlreadyExistsWithName(attributedType.getClass(), storedPartition.getName()); } }
@Override public void start(StartContext context) throws StartException { ROOT_LOGGER.debugf("Starting PartitionManagerService for [%s]", this.alias); this.partitionManager = new DefaultPartitionManager(this.configurationBuilder.buildAll()); publishPartitionManager(context); }
private Partition getStoredPartition(final Partition partition) { Partition storedPartition; if (getConfiguration().supportsPartition()) { storedPartition = getPartition(partition.getClass(), partition.getName()); } else { storedPartition = createDefaultPartition(); } if (storedPartition == null) { throw MESSAGES.partitionNotFoundWithName(partition.getClass(), partition.getName()); } return storedPartition; }
@Override public IdentityManager createIdentityManager() throws IdentityManagementException { return createIdentityManager(DEFAULT_REALM); }
@Override public void add(Partition attributedType) throws IdentityManagementException { add(attributedType, null); }