Package org.opensaml.storage.impl
Class LDAPStorageService
-
- All Implemented Interfaces:
Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent,StorageCapabilities,StorageCapabilitiesEx,StorageService
public class LDAPStorageService extends AbstractStorageService implements StorageCapabilitiesEx
Implementation ofStorageServicethat stores data in an LDAP. Does not support expiration or versioning at this time.
-
-
Field Summary
Fields Modifier and Type Field Description private PooledConnectionFactoryconnectionFactoryLDAP connection factory.private LdapAttribute[]defaultAttributesAttributes to include in merge operations.private org.slf4j.LoggerlogClass logger.
-
Constructor Summary
Constructors Constructor Description LDAPStorageService(PooledConnectionFactory factory, LdapAttribute... attrs)Creates a new LDAP storage service.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancreate(String context, String key, String value, Long expiration)private Response<Void>delete(String dn)Executes aDeleteOperationon the supplied DN.booleandelete(String context, String key)private Response<Void>deleteAttribute(String dn, String attrName)Executes aModifyOperationon the supplied DN, removing the supplied attribute.voiddeleteContext(String context)booleandeleteWithVersion(long version, String context, String key)protected voiddoDestroy()protected voiddoInitialize()booleanisClustered()booleanisServerSide()private Response<Void>merge(LdapEntry entry)Executes aMergeOperationwith the supplied entry.<T> StorageRecord<T>read(String context, String key)<T> Pair<Long,StorageRecord<T>>read(String context, String key, long version)voidreap(String context)private Response<SearchResult>search(String dn, String... attrs)Executes a object levelSearchOperationon the supplied DN, returning the supplied attributes.booleanupdate(String context, String key, String value, Long expiration)voidupdateContextExpiration(String context, Long expiration)booleanupdateExpiration(String context, String key, Long expiration)LongupdateWithVersion(long version, String context, String key, String value, Long expiration)-
Methods inherited from class org.opensaml.storage.AbstractStorageService
create, create, delete, deleteWithVersion, getCapabilities, getCleanupInterval, getCleanupTask, getCleanupTaskTimer, getContextSize, getKeySize, getValueSize, read, setCleanupInterval, setCleanupTaskTimer, setContextSize, setKeySize, setValueSize, update, update, updateExpiration, updateWithVersion, updateWithVersion
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
setId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
getId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, initialize, isDestroyed, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiedComponent
getId
-
Methods inherited from interface org.opensaml.storage.StorageCapabilities
getContextSize, getKeySize, getValueSize
-
-
-
-
Field Detail
-
log
private final org.slf4j.Logger log
Class logger.
-
connectionFactory
private PooledConnectionFactory connectionFactory
LDAP connection factory.
-
defaultAttributes
private LdapAttribute[] defaultAttributes
Attributes to include in merge operations.
-
-
Constructor Detail
-
LDAPStorageService
public LDAPStorageService(@Nonnull PooledConnectionFactory factory, LdapAttribute... attrs)Creates a new LDAP storage service.- Parameters:
factory- to retrieve LDAP connections fromattrs- to include in all LDAP entries
-
-
Method Detail
-
isServerSide
public boolean isServerSide()
- Specified by:
isServerSidein interfaceStorageCapabilitiesEx
-
isClustered
public boolean isClustered()
- Specified by:
isClusteredin interfaceStorageCapabilitiesEx
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractStorageService- Throws:
ComponentInitializationException
-
doDestroy
protected void doDestroy()
- Overrides:
doDestroyin classAbstractStorageService
-
create
public boolean create(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nonnull @NotEmpty String value, @Nullable @Positive Long expiration) throws IOException
- Specified by:
createin interfaceStorageService- Throws:
IOException
-
read
@Nullable public <T> StorageRecord<T> read(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key) throws IOException
- Specified by:
readin interfaceStorageService- Throws:
IOException
-
read
@Nonnull public <T> Pair<Long,StorageRecord<T>> read(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Positive long version) throws IOException
- Specified by:
readin interfaceStorageService- Throws:
IOException
-
update
public boolean update(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nonnull @NotEmpty String value, @Nullable @Positive Long expiration) throws IOException
- Specified by:
updatein interfaceStorageService- Throws:
IOException
-
updateWithVersion
@Nullable public Long updateWithVersion(@Positive long version, @Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nonnull @NotEmpty String value, @Nullable @Positive Long expiration) throws IOException, VersionMismatchException
- Specified by:
updateWithVersionin interfaceStorageService- Throws:
IOExceptionVersionMismatchException
-
updateExpiration
public boolean updateExpiration(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nullable @Positive Long expiration) throws IOException
- Specified by:
updateExpirationin interfaceStorageService- Throws:
IOException
-
delete
public boolean delete(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key) throws IOException
- Specified by:
deletein interfaceStorageService- Throws:
IOException
-
deleteWithVersion
public boolean deleteWithVersion(@Positive long version, @Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key) throws IOException, VersionMismatchException
- Specified by:
deleteWithVersionin interfaceStorageService- Throws:
IOExceptionVersionMismatchException
-
reap
public void reap(@Nonnull @NotEmpty String context) throws IOException
- Specified by:
reapin interfaceStorageService- Throws:
IOException
-
updateContextExpiration
public void updateContextExpiration(@Nonnull @NotEmpty String context, @Nullable @Positive Long expiration) throws IOException
- Specified by:
updateContextExpirationin interfaceStorageService- Throws:
IOException
-
deleteContext
public void deleteContext(@Nonnull @NotEmpty String context) throws IOException
- Specified by:
deleteContextin interfaceStorageService- Throws:
IOException
-
merge
@Nonnull private Response<Void> merge(@Nonnull LdapEntry entry) throws LdapException
Executes aMergeOperationwith the supplied entry.- Parameters:
entry- to merge- Returns:
- response for the merge operation
- Throws:
LdapException- if the operation fails
-
search
@Nonnull private Response<SearchResult> search(@Nonnull String dn, String... attrs) throws LdapException
Executes a object levelSearchOperationon the supplied DN, returning the supplied attributes.- Parameters:
dn- to search onattrs- to return- Returns:
- response for the search operation
- Throws:
LdapException- if the operation fails
-
deleteAttribute
@Nonnull private Response<Void> deleteAttribute(@Nonnull String dn, @Nonnull String attrName) throws LdapException
Executes aModifyOperationon the supplied DN, removing the supplied attribute.- Parameters:
dn- to modifyattrName- to remove- Returns:
- response for the modify operation
- Throws:
LdapException- if the operation fails
-
delete
@Nonnull private Response<Void> delete(@Nonnull String dn) throws LdapException
Executes aDeleteOperationon the supplied DN.- Parameters:
dn- to delete- Returns:
- response for the delete operation
- Throws:
LdapException- if the operation fails
-
-