public class LDAPStorageService extends AbstractStorageService
StorageService that stores data in an LDAP. Does not support
expiration or versioning at this time.| Modifier and Type | Field and Description |
|---|---|
private org.ldaptive.pool.PooledConnectionFactory |
connectionFactory
LDAP connection factory.
|
private org.ldaptive.LdapAttribute[] |
defaultAttributes
Attributes to include in merge operations.
|
private org.slf4j.Logger |
log
Class logger.
|
| Constructor and Description |
|---|
LDAPStorageService(org.ldaptive.pool.PooledConnectionFactory factory,
org.ldaptive.LdapAttribute... attrs)
Creates a new LDAP storage service.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
create(java.lang.String context,
java.lang.String key,
java.lang.String value,
java.lang.Long expiration)
Creates a new record in the store with an expiration.
|
private org.ldaptive.Response<java.lang.Void> |
delete(java.lang.String dn)
Executes a
DeleteOperation on the supplied DN. |
boolean |
delete(java.lang.String context,
java.lang.String key)
Deletes an existing record from the store.
|
private org.ldaptive.Response<java.lang.Void> |
deleteAttribute(java.lang.String dn,
java.lang.String attrName)
Executes a
ModifyOperation on the supplied DN, removing the supplied attribute. |
void |
deleteContext(java.lang.String context)
Forcibly removes all records in a given context along with any
associated resources devoted to maintaining the context.
|
boolean |
deleteWithVersion(long version,
java.lang.String context,
java.lang.String key)
Deletes an existing record from the store if it currently has a specified version.
|
protected void |
doDestroy() |
protected void |
doInitialize() |
private org.ldaptive.Response<java.lang.Void> |
merge(org.ldaptive.LdapEntry entry)
Executes a
MergeOperation with the supplied entry. |
StorageRecord |
read(java.lang.String context,
java.lang.String key)
Returns an existing record from the store, if one exists.
|
net.shibboleth.utilities.java.support.collection.Pair<java.lang.Long,StorageRecord> |
read(java.lang.String context,
java.lang.String key,
long version)
Returns an existing record from the store, along with its version.
|
void |
reap(java.lang.String context)
Manually trigger a cleanup of expired records.
|
private org.ldaptive.Response<org.ldaptive.SearchResult> |
search(java.lang.String dn,
java.lang.String... attrs)
Executes a object level
SearchOperation on the supplied DN, returning the supplied attributes. |
boolean |
update(java.lang.String context,
java.lang.String key,
java.lang.String value,
java.lang.Long expiration)
Updates an existing record in the store.
|
void |
updateContextExpiration(java.lang.String context,
java.lang.Long expiration)
Updates the expiration time of all records in the context.
|
boolean |
updateExpiration(java.lang.String context,
java.lang.String key,
java.lang.Long expiration)
Updates expiration of an existing record in the store.
|
java.lang.Long |
updateWithVersion(long version,
java.lang.String context,
java.lang.String key,
java.lang.String value,
java.lang.Long expiration)
Updates an existing record in the store, if a version matches.
|
create, create, delete, deleteWithVersion, getCapabilities, getCleanupInterval, getCleanupTask, getCleanupTaskTimer, getContextSize, getKeySize, getValueSize, read, setCleanupInterval, setCleanupTaskTimer, setContextSize, setKeySize, setValueSize, update, update, updateExpiration, updateWithVersion, updateWithVersionsetIdgetIddestroy, initialize, isDestroyed, isInitializedprivate final org.slf4j.Logger log
private org.ldaptive.pool.PooledConnectionFactory connectionFactory
private org.ldaptive.LdapAttribute[] defaultAttributes
public LDAPStorageService(@Nonnull
org.ldaptive.pool.PooledConnectionFactory factory,
org.ldaptive.LdapAttribute... attrs)
factory - to retrieve LDAP connections fromattrs - to include in all LDAP entriesprotected void doInitialize()
throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
doInitialize in class AbstractStorageServicenet.shibboleth.utilities.java.support.component.ComponentInitializationExceptionprotected void doDestroy()
doDestroy in class AbstractStorageServicepublic boolean create(@Nonnull @NotEmpty
java.lang.String context,
@Nonnull @NotEmpty
java.lang.String key,
@Nonnull @NotEmpty
java.lang.String value,
@Nullable @Positive
java.lang.Long expiration)
throws java.io.IOException
context - a storage context labelkey - a key unique to contextvalue - value to storeexpiration - expiration for record, or nulljava.io.IOException - if fatal errors occur in the insertion process@Nullable public StorageRecord read(@Nonnull @NotEmpty java.lang.String context, @Nonnull @NotEmpty java.lang.String key) throws java.io.IOException
context - a storage context labelkey - a key unique to contextjava.io.IOException - if errors occur in the read process@Nonnull public net.shibboleth.utilities.java.support.collection.Pair<java.lang.Long,StorageRecord> read(@Nonnull @NotEmpty java.lang.String context, @Nonnull @NotEmpty java.lang.String key, @Positive long version) throws java.io.IOException
The first member of the pair returned will contain the version of the record in the store, or will be null if no record exists. The second member will contain the record read back. If null, the record either didn't exist (if the first member was also null) or the record was the same version as that supplied by the caller.
context - a storage context labelkey - a key unique to contextversion - only return record if newer than supplied versionjava.io.IOException - if errors occur in the read processpublic boolean update(@Nonnull @NotEmpty
java.lang.String context,
@Nonnull @NotEmpty
java.lang.String key,
@Nonnull @NotEmpty
java.lang.String value,
@Nullable @Positive
java.lang.Long expiration)
throws java.io.IOException
context - a storage context labelkey - a key unique to contextvalue - updated valueexpiration - expiration for record, or nulljava.io.IOException - if errors occur in the update process@Nullable
public java.lang.Long updateWithVersion(@Positive
long version,
@Nonnull @NotEmpty
java.lang.String context,
@Nonnull @NotEmpty
java.lang.String key,
@Nonnull @NotEmpty
java.lang.String value,
@Nullable @Positive
java.lang.Long expiration)
throws java.io.IOException,
VersionMismatchException
version - only update if the current version matches this valuecontext - a storage context labelkey - a key unique to contextvalue - updated valueexpiration - expiration for record, or nulljava.io.IOException - if errors occur in the update processVersionMismatchException - if the record has already been updated to a newer versionpublic boolean updateExpiration(@Nonnull @NotEmpty
java.lang.String context,
@Nonnull @NotEmpty
java.lang.String key,
@Nullable @Positive
java.lang.Long expiration)
throws java.io.IOException
context - a storage context labelkey - a key unique to contextexpiration - expiration for record, or nulljava.io.IOException - if errors occur in the update processpublic boolean delete(@Nonnull @NotEmpty
java.lang.String context,
@Nonnull @NotEmpty
java.lang.String key)
throws java.io.IOException
context - a storage context labelkey - a key unique to contextjava.io.IOException - if errors occur in the deletion processpublic boolean deleteWithVersion(@Positive
long version,
@Nonnull @NotEmpty
java.lang.String context,
@Nonnull @NotEmpty
java.lang.String key)
throws java.io.IOException,
VersionMismatchException
version - record version to deletecontext - a storage context labelkey - a key unique to contextjava.io.IOException - if errors occur in the deletion processVersionMismatchException - if the record has already been updated to a newer versionpublic void reap(@Nonnull @NotEmpty
java.lang.String context)
throws java.io.IOException
context - a storage context labeljava.io.IOException - if errors occur in the cleanup processpublic void updateContextExpiration(@Nonnull @NotEmpty
java.lang.String context,
@Nullable @Positive
java.lang.Long expiration)
throws java.io.IOException
context - a storage context labelexpiration - a new expiration timestamp, or nulljava.io.IOException - if errors occur in the cleanup processpublic void deleteContext(@Nonnull @NotEmpty
java.lang.String context)
throws java.io.IOException
context - a storage context labeljava.io.IOException - if errors occur in the cleanup process@Nonnull
private org.ldaptive.Response<java.lang.Void> merge(@Nonnull
org.ldaptive.LdapEntry entry)
throws org.ldaptive.LdapException
MergeOperation with the supplied entry.entry - to mergeorg.ldaptive.LdapException - if the operation fails@Nonnull
private org.ldaptive.Response<org.ldaptive.SearchResult> search(@Nonnull
java.lang.String dn,
java.lang.String... attrs)
throws org.ldaptive.LdapException
SearchOperation on the supplied DN, returning the supplied attributes.dn - to search onattrs - to returnorg.ldaptive.LdapException - if the operation fails@Nonnull
private org.ldaptive.Response<java.lang.Void> deleteAttribute(@Nonnull
java.lang.String dn,
@Nonnull
java.lang.String attrName)
throws org.ldaptive.LdapException
ModifyOperation on the supplied DN, removing the supplied attribute.dn - to modifyattrName - to removeorg.ldaptive.LdapException - if the operation fails@Nonnull
private org.ldaptive.Response<java.lang.Void> delete(@Nonnull
java.lang.String dn)
throws org.ldaptive.LdapException
DeleteOperation on the supplied DN.dn - to deleteorg.ldaptive.LdapException - if the operation fails