com.microsoft.aad.adal
Class DefaultTokenCacheStore

java.lang.Object
  extended by com.microsoft.aad.adal.DefaultTokenCacheStore
All Implemented Interfaces:
ITokenCacheStore, ITokenStoreQuery, Serializable

public class DefaultTokenCacheStore
extends Object
implements ITokenCacheStore, ITokenStoreQuery

Store/Retrieve TokenCacheItem from private SharedPreferences. SharedPreferences saves items when it is committed in an atomic operation. One more retry is attempted in case there is a lock in commit.

See Also:
Serialized Form

Constructor Summary
DefaultTokenCacheStore(android.content.Context context)
           
 
Method Summary
 void clearTokensForUser(String userid)
          Clear tokens for user without additional retry.
 boolean contains(String key)
          Checks if cache key exists.
 Iterator<TokenCacheItem> getAll()
          User can query over iterator values.
 TokenCacheItem getItem(String key)
          Get cache item.
 ArrayList<TokenCacheItem> getTokensAboutToExpire()
          Get tokens about to expire.
 ArrayList<TokenCacheItem> getTokensForResource(String resource)
          Tokens for resource.
 ArrayList<TokenCacheItem> getTokensForUser(String userid)
          Get tokens for user.
 HashSet<String> getUniqueUsersWithTokenCache()
          Unique users with tokens.
 void removeAll()
          Removes all items from cache.
 void removeItem(String key)
          Removes item with key.
 void setItem(String key, TokenCacheItem item)
          Sets item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTokenCacheStore

public DefaultTokenCacheStore(android.content.Context context)
                       throws NoSuchAlgorithmException,
                              NoSuchPaddingException
Parameters:
context - Context
Throws:
NoSuchAlgorithmException
NoSuchPaddingException
Method Detail

getItem

public TokenCacheItem getItem(String key)
Description copied from interface: ITokenCacheStore
Get cache item.

Specified by:
getItem in interface ITokenCacheStore
Parameters:
key - CacheKey
Returns:
Token cache item

removeItem

public void removeItem(String key)
Description copied from interface: ITokenCacheStore
Removes item with key.

Specified by:
removeItem in interface ITokenCacheStore
Parameters:
key - CacheKey

setItem

public void setItem(String key,
                    TokenCacheItem item)
Description copied from interface: ITokenCacheStore
Sets item.

Specified by:
setItem in interface ITokenCacheStore
Parameters:
key - CacheKey
item - Cache item

removeAll

public void removeAll()
Description copied from interface: ITokenCacheStore
Removes all items from cache.

Specified by:
removeAll in interface ITokenCacheStore

getAll

public Iterator<TokenCacheItem> getAll()
User can query over iterator values.

Specified by:
getAll in interface ITokenStoreQuery

getUniqueUsersWithTokenCache

public HashSet<String> getUniqueUsersWithTokenCache()
Unique users with tokens.

Specified by:
getUniqueUsersWithTokenCache in interface ITokenStoreQuery
Returns:
unique users

getTokensForResource

public ArrayList<TokenCacheItem> getTokensForResource(String resource)
Tokens for resource.

Specified by:
getTokensForResource in interface ITokenStoreQuery
Parameters:
resource - Resource identifier
Returns:
list of TokenCacheItem

getTokensForUser

public ArrayList<TokenCacheItem> getTokensForUser(String userid)
Get tokens for user.

Specified by:
getTokensForUser in interface ITokenStoreQuery
Parameters:
userid - Userid
Returns:
list of TokenCacheItem

clearTokensForUser

public void clearTokensForUser(String userid)
Clear tokens for user without additional retry.

Specified by:
clearTokensForUser in interface ITokenStoreQuery
Parameters:
userid - UserId

getTokensAboutToExpire

public ArrayList<TokenCacheItem> getTokensAboutToExpire()
Get tokens about to expire.

Specified by:
getTokensAboutToExpire in interface ITokenStoreQuery
Returns:
list of TokenCacheItem

contains

public boolean contains(String key)
Description copied from interface: ITokenCacheStore
Checks if cache key exists.

Specified by:
contains in interface ITokenCacheStore
Parameters:
key - CacheKey
Returns:
true if it exists


Copyright © 2003–2015. All rights reserved.