|
||||||||||
| 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 String |
JMX_DOMAIN
|
static String |
PROP_EXPIRY_TIME_SECONDS
Name of the property that defines the timeout in seconds for caching. |
static String |
PROP_REALM_NAME
|
| Constructor Summary | |
|---|---|
SimpleExpiryCache(Properties aProperties)
Constructs the cache. |
|
SimpleExpiryCache(Properties aProperties,
SimpleExpiryCache.Clock aClock)
Constructor for unit test. |
|
| Method Summary | |
|---|---|
protected void |
clearExpired()
|
int |
getExpiryTimeSeconds()
|
List<String> |
getGroups(String aUsername)
Gets the groups a user belongs to from the cache. |
String |
getPassword(String aUsername)
Gets the cached password for a given user. |
String |
getSeed(String aUsername)
Gets a cached seed for a given username based on the configured sql seed query. |
void |
setGroups(String aUsername,
List<String> aGroups)
Sets the groups for a given user. |
void |
setPassword(String aUserName,
String aPassword)
Sets the cached password for a user. |
void |
setSeed(String aUsername,
String aSeed)
Sets the seed. |
int |
size()
|
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String PROP_EXPIRY_TIME_SECONDS
public static final String JMX_DOMAIN
public static final String PROP_REALM_NAME
public static final long DEFAULT_EXPIRY_TIME_SECONDS
| Constructor Detail |
|---|
public SimpleExpiryCache(Properties aProperties)
aProperties - Properties to configure the cache with.
public SimpleExpiryCache(Properties aProperties,
SimpleExpiryCache.Clock aClock)
aProperties - Properties.aClock - Clock.| Method Detail |
|---|
protected void clearExpired()
public int getExpiryTimeSeconds()
public int size()
public String toString()
toString in class Objectpublic List<String> getGroups(String aUsername)
AuthenticationCache
getGroups in interface AuthenticationCacheaUsername - User.
public String getPassword(String aUsername)
AuthenticationCache
getPassword in interface AuthenticationCacheaUsername - Username.
public String getSeed(String aUsername)
AuthenticationCache
getSeed in interface AuthenticationCacheaUsername - Username.
public void setGroups(String aUsername,
List<String> aGroups)
AuthenticationCache
setGroups in interface AuthenticationCacheaUsername - User name.aGroups - Groups (must be non-null).
public void setPassword(String aUserName,
String aPassword)
AuthenticationCache
setPassword in interface AuthenticationCacheaUserName - Username.aPassword - Password.
public void setSeed(String aUsername,
String aSeed)
AuthenticationCache
setSeed in interface AuthenticationCacheaUsername - Username.aSeed - Seed (may not be null).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||