public class DefaultPartitionManager extends Object implements PartitionManager, StoreSelector
Provides partition management functionality, and partition-specific IdentityManager
instances.
Before using this factory you need a valid IdentityConfiguration
, usually created using the
IdentityConfigurationBuilder
.
This class is thread safe, and is intended to be used as an application-scoped component.
Constructor and Description |
---|
DefaultPartitionManager(Collection<IdentityConfiguration> configurations) |
DefaultPartitionManager(Collection<IdentityConfiguration> configurations,
EventBridge eventBridge,
Collection<PermissionHandler> permissionHandlers) |
DefaultPartitionManager(Collection<IdentityConfiguration> configurations,
EventBridge eventBridge,
Collection<PermissionHandler> permissionHandlers,
IdGenerator idGenerator) |
DefaultPartitionManager(IdentityConfiguration configuration) |
Modifier and Type | Method and Description |
---|---|
void |
add(Partition partition)
Adds a partition to the default configuration.
|
void |
add(Partition partition,
String configurationName)
Adds a new partition with a reference to the given
configurationName . |
IdentityManager |
createIdentityManager()
Creates an
IdentityManager instance for the default partition. |
IdentityManager |
createIdentityManager(Partition partition)
Creates an
IdentityManager for the specified partition. |
PermissionManager |
createPermissionManager()
Creates a
PermissionManager for the default partition. |
PermissionManager |
createPermissionManager(Partition partition)
Creates a
PermissionManager for the specified partition. |
RelationshipManager |
createRelationshipManager()
Creates an
RelationshipManager . |
Collection<IdentityConfiguration> |
getConfigurations()
Retrieves the configuration used to build this
PartitionManager . |
<T extends Partition> |
getPartition(Class<T> partitionClass,
String name)
Return the partition specified by the partition class and name.
|
<T extends Partition> |
getPartitions(Class<T> partitionClass)
Return all
Partition instances for a given partitionClass . |
<T extends AttributeStore<?>> |
getStoreForAttributeOperation(IdentityContext context)
Returns the AttributeStore that manages attributes.
|
<T extends CredentialStore<?>> |
getStoreForCredentialOperation(IdentityContext context,
Class<?> credentialClass) |
<T extends IdentityStore<?>> |
getStoreForIdentityOperation(IdentityContext context,
Class<T> storeType,
Class<? extends AttributedType> type,
IdentityStoreConfiguration.IdentityOperation operation) |
<T extends PartitionStore<?>> |
getStoreForPartitionOperation(IdentityContext context,
Class<? extends Partition> partitionClass)
Returns the PartitionStore that manages partitions.
|
PermissionStore |
getStoreForPermissionOperation(IdentityContext context)
Returns a PermissionStore instance
|
IdentityStore<?> |
getStoreForRelationshipOperation(IdentityContext context,
Class<? extends Relationship> relationshipClass,
Relationship relationship,
IdentityStoreConfiguration.IdentityOperation operation)
Returns the IdentityStore that manages relationships of the specified type, for the specified partition/s.
|
Set<CredentialStore<?>> |
getStoresForCredentialStorage(IdentityContext context,
Class<? extends CredentialStorage> storageClass)
Returns all available
CredentialStore instances that support the given CredentialStorage
type. |
Set<IdentityStore<?>> |
getStoresForIdentityQuery(IdentityContext context,
Class<? extends IdentityType> identityType)
Returns all available
IdentityStore instances that support the given IdentityType . |
Set<IdentityStore<?>> |
getStoresForRelationshipQuery(IdentityContext context,
Class<? extends Relationship> relationshipClass,
Set<Partition> partitions)
Returns all available
IdentityStore instances that support the given IdentityType . |
<T extends Partition> |
lookupById(Class<T> partitionClass,
String id)
Return the partition specified by the partition class and identifier.
|
<T extends IdentityStore<?>> |
lookupStore(IdentityContext context,
IdentityConfiguration configuration,
Class<? extends AttributedType> type,
IdentityStoreConfiguration.IdentityOperation operation) |
void |
remove(Partition partition)
Removes the specified partition.
|
void |
update(Partition partition)
Updates the attributes of the specified partition.
|
public DefaultPartitionManager(IdentityConfiguration configuration)
public DefaultPartitionManager(Collection<IdentityConfiguration> configurations)
public DefaultPartitionManager(Collection<IdentityConfiguration> configurations, EventBridge eventBridge, Collection<PermissionHandler> permissionHandlers)
public DefaultPartitionManager(Collection<IdentityConfiguration> configurations, EventBridge eventBridge, Collection<PermissionHandler> permissionHandlers, IdGenerator idGenerator)
public IdentityManager createIdentityManager() throws IdentityManagementException
PartitionManager
Creates an IdentityManager
instance for the default partition.
The default partition is always a Realm
type with name
Realm.DEFAULT_REALM
. This partition must exists before calling this method,
otherwise an exception will be thrown.
createIdentityManager
in interface PartitionManager
IdentityManagementException
- if the default partition does not exists or any error occurs during the
creation of the IdentityManager
instance.public IdentityManager createIdentityManager(Partition partition) throws IdentityManagementException
PartitionManager
Creates an IdentityManager
for the specified partition.
createIdentityManager
in interface PartitionManager
partition
- The partition instance where identity management operations will be scoped. The given
partition
must exists before calling this method, otherwise an exception will be
thrown.IdentityManagementException
- if the default partition does not exists or any error occurs during the
creation of the instance.public PermissionManager createPermissionManager()
PartitionManager
PermissionManager
for the default partition.createPermissionManager
in interface PartitionManager
public PermissionManager createPermissionManager(Partition partition) throws IdentityManagementException
PartitionManager
PermissionManager
for the specified partition.createPermissionManager
in interface PartitionManager
partition
- The partition instance where permission operations will be scoped. The given
partition
must exists before calling this method, otherwise an exception will be
thrown.IdentityManagementException
- if the default partition does not exists or any error occurs during the
creation of the instance.public RelationshipManager createRelationshipManager()
PartitionManager
Creates an RelationshipManager
.
createRelationshipManager
in interface PartitionManager
public <T extends Partition> T getPartition(Class<T> partitionClass, String name)
PartitionManager
Return the partition specified by the partition class and name.
getPartition
in interface PartitionManager
partitionClass
- It can be any sub-type of Partition. In this case only partitions of a specific sub-type
will be considered. If it equals the Partition type this method may return any of its sub-types.name
- The name of the partition. It can not me null.public <T extends Partition> List<T> getPartitions(Class<T> partitionClass)
PartitionManager
Return all Partition
instances for a given partitionClass
.
getPartitions
in interface PartitionManager
partitionClass
- It can be any sub-type of Partition. In this case only partitions of a specific sub-type
will be considered. If it equals the Partition type this method may return any of its sub-types.public <T extends Partition> T lookupById(Class<T> partitionClass, String id)
PartitionManager
Return the partition specified by the partition class and identifier.
If partitionClass
equals the Partition
type this method may return any of its
sub-types with the given id
.
lookupById
in interface PartitionManager
partitionClass
- It can be any sub-type of Partition. In this case only partitions of a specific sub-type
will be considered. If it equals the Partition type this method may return any of its sub-types.id
- The identifier of the partition. It can not be null.public void add(Partition partition) throws IdentityManagementException
PartitionManager
Adds a partition to the default configuration.
Only a single configuration may support partition. In this case the partition will be always created with a reference to this configuration.
add
in interface PartitionManager
IdentityManagementException
- if any error occurs during the creation.public void add(Partition partition, String configurationName) throws IdentityManagementException
PartitionManager
Adds a new partition with a reference to the given configurationName
.
add
in interface PartitionManager
IdentityManagementException
- if the configurationName
does not exists or if any error occurs
during the creation.public void update(Partition partition) throws IdentityManagementException
PartitionManager
Updates the attributes of the specified partition.
update
in interface PartitionManager
partition
- The given partition
must exists before calling this method, otherwise an exception
will be
thrown.IdentityManagementException
- if no partition exists or if any error occurs during the update.public void remove(Partition partition) throws IdentityManagementException
PartitionManager
Removes the specified partition.
Before calling this method make sure the partition
references a valid instance that points
to a partition already stored with its identifier.
remove
in interface PartitionManager
partition
- The given partition
must exists before calling this method, otherwise an exception
will be
thrown.IdentityManagementException
- if no partition exists or if any error occurs during the update.public Collection<IdentityConfiguration> getConfigurations()
PartitionManager
Retrieves the configuration used to build this PartitionManager
.
getConfigurations
in interface PartitionManager
public <T extends IdentityStore<?>> T getStoreForIdentityOperation(IdentityContext context, Class<T> storeType, Class<? extends AttributedType> type, IdentityStoreConfiguration.IdentityOperation operation)
getStoreForIdentityOperation
in interface StoreSelector
public Set<IdentityStore<?>> getStoresForIdentityQuery(IdentityContext context, Class<? extends IdentityType> identityType)
StoreSelector
Returns all available IdentityStore
instances that support the given IdentityType
.
getStoresForIdentityQuery
in interface StoreSelector
context
- The current context.identityType
- The type used to restrict which stores should be selected and returned. If
the value is IdentityType
all stores that support any subtype of this interface
will be returned.public <T extends IdentityStore<?>> T lookupStore(IdentityContext context, IdentityConfiguration configuration, Class<? extends AttributedType> type, IdentityStoreConfiguration.IdentityOperation operation)
public <T extends CredentialStore<?>> T getStoreForCredentialOperation(IdentityContext context, Class<?> credentialClass)
getStoreForCredentialOperation
in interface StoreSelector
public IdentityStore<?> getStoreForRelationshipOperation(IdentityContext context, Class<? extends Relationship> relationshipClass, Relationship relationship, IdentityStoreConfiguration.IdentityOperation operation)
StoreSelector
getStoreForRelationshipOperation
in interface StoreSelector
public Set<IdentityStore<?>> getStoresForRelationshipQuery(IdentityContext context, Class<? extends Relationship> relationshipClass, Set<Partition> partitions)
StoreSelector
Returns all available IdentityStore
instances that support the given IdentityType
.
getStoresForRelationshipQuery
in interface StoreSelector
context
- The current context.relationshipClass
- The type used to restrict which stores should be selected and returned. If
the value is IdentityType
all stores that support any subtype of this interface
will be returned.partitions
- A set with the partitions that should be used to restrict which stores should be selected. If empty
only the type will be considered.public <T extends PartitionStore<?>> T getStoreForPartitionOperation(IdentityContext context, Class<? extends Partition> partitionClass)
StoreSelector
getStoreForPartitionOperation
in interface StoreSelector
public <T extends AttributeStore<?>> T getStoreForAttributeOperation(IdentityContext context)
StoreSelector
getStoreForAttributeOperation
in interface StoreSelector
public Set<CredentialStore<?>> getStoresForCredentialStorage(IdentityContext context, Class<? extends CredentialStorage> storageClass)
StoreSelector
Returns all available CredentialStore
instances that support the given CredentialStorage
type.
getStoresForCredentialStorage
in interface StoreSelector
public PermissionStore getStoreForPermissionOperation(IdentityContext context)
StoreSelector
getStoreForPermissionOperation
in interface StoreSelector
Copyright © 2018 JBoss by Red Hat. All rights reserved.