public class LDAPStorageService extends AbstractStorageService
StorageService
that stores data in an LDAP. Does not support
expiration or versioning at this time.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(String context,
String key,
String value,
Long expiration)
Creates a new record in the store with an expiration.
|
boolean |
delete(String context,
String key)
Deletes an existing record from the store.
|
void |
deleteContext(String context)
Forcibly removes all records in a given context along with any
associated resources devoted to maintaining the context.
|
boolean |
deleteWithVersion(long version,
String context,
String key)
Deletes an existing record from the store if it currently has a specified version.
|
protected void |
doDestroy() |
protected void |
doInitialize() |
StorageRecord |
read(String context,
String key)
Returns an existing record from the store, if one exists.
|
net.shibboleth.utilities.java.support.collection.Pair<Long,StorageRecord> |
read(String context,
String key,
long version)
Returns an existing record from the store, along with its version.
|
void |
reap(String context)
Manually trigger a cleanup of expired records.
|
boolean |
update(String context,
String key,
String value,
Long expiration)
Updates an existing record in the store.
|
void |
updateContextExpiration(String context,
Long expiration)
Updates the expiration time of all records in the context.
|
boolean |
updateExpiration(String context,
String key,
Long expiration)
Updates expiration of an existing record in the store.
|
Long |
updateWithVersion(long version,
String context,
String key,
String value,
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, updateWithVersion
setId
getId
destroy, initialize, isDestroyed, isInitialized
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 AbstractStorageService
net.shibboleth.utilities.java.support.component.ComponentInitializationException
protected void doDestroy()
doDestroy
in class AbstractStorageService
public boolean create(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nonnull @NotEmpty String value, @Nullable @Positive Long expiration) throws IOException
context
- a storage context labelkey
- a key unique to contextvalue
- value to storeexpiration
- expiration for record, or nullIOException
- if fatal errors occur in the insertion process@Nullable public StorageRecord read(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key) throws IOException
context
- a storage context labelkey
- a key unique to contextIOException
- if errors occur in the read process@Nonnull public net.shibboleth.utilities.java.support.collection.Pair<Long,StorageRecord> read(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Positive long version) throws 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 versionIOException
- if errors occur in the read processpublic boolean update(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nonnull @NotEmpty String value, @Nullable @Positive Long expiration) throws IOException
context
- a storage context labelkey
- a key unique to contextvalue
- updated valueexpiration
- expiration for record, or nullIOException
- if errors occur in the update process@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
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 nullIOException
- if errors occur in the update processVersionMismatchException
- if the record has already been updated to a newer versionpublic boolean updateExpiration(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nullable @Positive Long expiration) throws IOException
context
- a storage context labelkey
- a key unique to contextexpiration
- expiration for record, or nullIOException
- if errors occur in the update processpublic boolean delete(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key) throws IOException
context
- a storage context labelkey
- a key unique to contextIOException
- if errors occur in the deletion processpublic boolean deleteWithVersion(@Positive long version, @Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key) throws IOException, VersionMismatchException
version
- record version to deletecontext
- a storage context labelkey
- a key unique to contextIOException
- if errors occur in the deletion processVersionMismatchException
- if the record has already been updated to a newer versionpublic void reap(@Nonnull @NotEmpty String context) throws IOException
context
- a storage context labelIOException
- if errors occur in the cleanup processpublic void updateContextExpiration(@Nonnull @NotEmpty String context, @Nullable @Positive Long expiration) throws IOException
context
- a storage context labelexpiration
- a new expiration timestamp, or nullIOException
- if errors occur in the cleanup processpublic void deleteContext(@Nonnull @NotEmpty String context) throws IOException
context
- a storage context labelIOException
- if errors occur in the cleanup processCopyright © 2017. All rights reserved.