|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.wamblee.glassfish.auth.cache.impl.SimpleExpiryCache
public class SimpleExpiryCache
Simple cache that has entries that expire after a certain amount of time.
Also, the cache has a JMX interface SimpleExpiryCacheManagementMBean
by which the entries for one or all users can be expired. The cache does not
do an automatic cleanup of expired items although it is possible to trigger
cleanup through JMX.
The cache exposes an MBean for remote management and for managing it from an
application. This access is unsecured so anyone can in principle clean the
cache. The main intention of the JMX MBean is to use it for invalidating the
cache for a specific user in case his authentication information has changed.
The MBean is exposed at the domain specified by JMX_DOMAIN
with a
property specified by JMX_REALM_PROPERTY
with the value of the
realm.
To clear a specific user, proceed as follows:
ObjectName objectName = new ObjectName( "org.wamblee.glassfish.auth.FlexibleJdbcRealm", "realm", REALM_NAME); ManagementFactory.getPlatformMBeanServer().invoke(objectName, "clearUser", new Object[] { "username" }, new String[] { String.class.getName() });
Nested Class Summary | |
---|---|
static interface |
SimpleExpiryCache.Clock
|
static class |
SimpleExpiryCache.SystemClock
|
static class |
SimpleExpiryCache.UserEntry
Class representing cached information about a user. |
Field Summary | |
---|---|
static long |
DEFAULT_EXPIRY_TIME_SECONDS
Default expiry time in seconds. |
static java.lang.String |
JMX_DOMAIN
|
static java.lang.String |
PROP_EXPIRY_TIME_SECONDS
Name of the property that defines the timeout in seconds for caching. |
static java.lang.String |
PROP_REALM_NAME
|
Constructor Summary | |
---|---|
SimpleExpiryCache(java.util.Properties aProperties)
Constructs the cache. |
|
SimpleExpiryCache(java.util.Properties aProperties,
SimpleExpiryCache.Clock aClock)
Constructor for unit test. |
Method Summary | |
---|---|
protected void |
clearExpired()
|
SimpleExpiryCache.UserEntry |
evict(java.lang.String aUsername)
|
int |
getExpiryTimeSeconds()
|
java.util.List<java.lang.String> |
getGroups(java.lang.String aUsername)
Gets the groups a user belongs to from the cache. |
java.lang.String |
getPassword(java.lang.String aUsername)
Gets the cached password for a given user. |
java.lang.String |
getSeed(java.lang.String aUsername)
Gets a cached seed for a given username based on the configured sql seed query. |
void |
setGroups(java.lang.String aUsername,
java.util.List<java.lang.String> aGroups)
Sets the groups for a given user. |
void |
setPassword(java.lang.String aUserName,
java.lang.String aPassword)
Sets the cached password for a user. |
void |
setSeed(java.lang.String aUsername,
java.lang.String aSeed)
Sets the seed. |
int |
size()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PROP_EXPIRY_TIME_SECONDS
public static final java.lang.String JMX_DOMAIN
public static final java.lang.String PROP_REALM_NAME
public static final long DEFAULT_EXPIRY_TIME_SECONDS
Constructor Detail |
---|
public SimpleExpiryCache(java.util.Properties aProperties)
aProperties
- Properties to configure the cache with.public SimpleExpiryCache(java.util.Properties aProperties, SimpleExpiryCache.Clock aClock)
aProperties
- Properties.aClock
- Clock.Method Detail |
---|
protected void clearExpired()
public int getExpiryTimeSeconds()
public int size()
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.List<java.lang.String> getGroups(java.lang.String aUsername)
AuthenticationCache
getGroups
in interface AuthenticationCache
aUsername
- User.
public java.lang.String getPassword(java.lang.String aUsername)
AuthenticationCache
getPassword
in interface AuthenticationCache
aUsername
- Username.
public java.lang.String getSeed(java.lang.String aUsername)
AuthenticationCache
getSeed
in interface AuthenticationCache
aUsername
- Username.
public void setGroups(java.lang.String aUsername, java.util.List<java.lang.String> aGroups)
AuthenticationCache
setGroups
in interface AuthenticationCache
aUsername
- User name.aGroups
- Groups (must be non-null).public void setPassword(java.lang.String aUserName, java.lang.String aPassword)
AuthenticationCache
setPassword
in interface AuthenticationCache
aUserName
- Username.aPassword
- Password.public void setSeed(java.lang.String aUsername, java.lang.String aSeed)
AuthenticationCache
setSeed
in interface AuthenticationCache
aUsername
- Username.aSeed
- Seed (may not be null).public SimpleExpiryCache.UserEntry evict(java.lang.String aUsername)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |