Class AbstractTokenService<T extends Token,K>
java.lang.Object
org.exoplatform.web.security.security.AbstractTokenService<T,K>
- Type Parameters:
T- the token typeK- the token key type
- All Implemented Interfaces:
TokenStore,org.picocontainer.Startable
- Direct Known Subclasses:
CookieTokenService,PlainTokenService
public abstract class AbstractTokenService<T extends Token,K>
extends Object
implements org.picocontainer.Startable, TokenStore
Created by The eXo Platform SAS Author : liem.nguyen ncliam@gmail.com Jun 5, 2009
todo julien : - make delay configuration from init param and @Managed setter - start/stop expiration daemon - manually invoke
the daemon via @Managed
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringstatic final intSeetokenByteLength.protected intprotected final org.exoplatform.services.log.Logprotected Stringprotected static final Stringprotected final intThe number of random bits generared bynextRandom().protected long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidprotected abstract KDecode a key from its string representation.abstract TdeleteToken(K id) abstract TdeleteToken(K id, String tokenType) static <T extends AbstractTokenService<?,?>>
TgetInstance(Class<T> classType) getName()longabstract Tabstract Tlongprotected Stringprotected Stringabstract longsize()voidstart()voidstop()validateToken(String stringKey, boolean remove) Validates a token.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.exoplatform.web.security.TokenStore
createToken
-
Field Details
-
log
protected final org.exoplatform.services.log.Log log -
SERVICE_CONFIG
- See Also:
-
CLEANUP_PERIOD_TIME
- See Also:
-
DEFAULT_TOKEN_BYTE_LENGTH
public static final int DEFAULT_TOKEN_BYTE_LENGTHSeetokenByteLength. 8 bytes (64 bits) would be enough, but we want to get padding-less Byte64 representation, so we take the next greater number divisible by 3 which is 9. 9 bytes is equal to 72 bits.- See Also:
-
tokenByteLength
protected final int tokenByteLengthThe number of random bits generared bynextRandom(). Use values divisible by 3 to produce random strings consisting only of0-9,a-z,A-Z,-and_, i.e. URL safe Byte64 without padding. If a value not divisible by 3 is used the random strings will contain*in addition to the named characters. -
name
-
validityMillis
protected long validityMillis -
delay_time
protected int delay_time
-
-
Constructor Details
-
AbstractTokenService
public AbstractTokenService(org.exoplatform.container.xml.InitParams initParams) throws TokenServiceInitializationException
-
-
Method Details
-
start
public void start()- Specified by:
startin interfaceorg.picocontainer.Startable
-
stop
public void stop()- Specified by:
stopin interfaceorg.picocontainer.Startable
-
getInstance
-
validateToken
Description copied from interface:TokenStoreValidates a token. If the token is valid it returns the attached credentials. The store state may be modified by the removal of the token. The token is removed either if the remove argument is set to true of if the token is not anymore valid.- Specified by:
validateTokenin interfaceTokenStore- Parameters:
stringKey- the token keyremove- true if the token must be removed regardless its validity- Returns:
- the attached credentials or null
-
cleanExpiredTokens
public abstract void cleanExpiredTokens() -
getValidityTime
public long getValidityTime() -
getPeriodTime
public long getPeriodTime() -
getName
-
getToken
-
getToken
-
deleteToken
-
deleteToken
-
decodeKey
Decode a key from its string representation.- Parameters:
stringKey- the key a s a string- Returns:
- the typed key
-
size
public abstract long size() -
nextTokenId
-
nextRandom
-