Class AbstractTokenService<T extends Token,K>

java.lang.Object
org.exoplatform.web.security.security.AbstractTokenService<T,K>
Type Parameters:
T - the token type
K - 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
  • Field Details

    • log

      protected final org.exoplatform.services.log.Log log
    • SERVICE_CONFIG

      protected static final String SERVICE_CONFIG
      See Also:
    • CLEANUP_PERIOD_TIME

      protected static final String CLEANUP_PERIOD_TIME
      See Also:
    • DEFAULT_TOKEN_BYTE_LENGTH

      public static final int DEFAULT_TOKEN_BYTE_LENGTH
      See tokenByteLength. 16 bytes (128 bits) would be enough (Validator + Selector = 256bits), but we want to get padding-less Byte64 representation, so we take a greater number divisible by 3.
      (24 bytes is equal to 192 bits.)
      See Also:
    • tokenByteLength

      protected final int tokenByteLength
      The number of random bits generared by nextRandom(). Use values divisible by 3 to produce random strings consisting only of 0-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

      protected String name
    • validityMillis

      protected long validityMillis
    • delay_time

      protected int delay_time
  • Constructor Details

  • Method Details

    • start

      public void start()
      Specified by:
      start in interface org.picocontainer.Startable
    • stop

      public void stop()
      Specified by:
      stop in interface org.picocontainer.Startable
    • getInstance

      public static <T extends AbstractTokenService<?, ?>> T getInstance(Class<T> classType)
    • validateToken

      public String validateToken(String stringKey, boolean remove)
      Description copied from interface: TokenStore
      Validates 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:
      validateToken in interface TokenStore
      Parameters:
      stringKey - the token key
      remove - 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

      public String getName()
    • getToken

      public abstract T getToken(K id)
    • getToken

      public abstract T getToken(K id, String tokenType)
    • deleteToken

      public abstract T deleteToken(K id)
    • deleteToken

      public abstract T deleteToken(K id, String tokenType)
    • decodeKey

      protected abstract K decodeKey(String stringKey)
      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

      protected String nextTokenId()
    • nextRandom

      protected String nextRandom()