A base class for implementations of a Session token cache.
The Session constructor optionally takes a TokenCachingStrategy, from which it will attempt to load a cached token during construction. Also, whenever the Session updates its token, it will also save the token and associated state to the TokenCachingStrategy.
This is the only mechanism supported for an Android service to use Session. The service can create a custom TokenCachingStrategy that returns the Session provided by an Activity through which the user logged in to Facebook.
Erweiterungen: | Object |
Package: | facebook |
TokenCachingStrategy()
public TokenCachingStrategy()
hasTokenInformation(Bundle)
Returns a boolean indicating whether a Bundle contains properties that could be a valid saved token.
public static boolean hasTokenInformation(Bundle bundle)
Parameter | Beschreibung |
---|---|
bundle | A Bundle to check for token information. |
getToken(Bundle)
Gets the cached token value from a Bundle.
public static String getToken(Bundle bundle)
Parameter | Beschreibung |
---|---|
bundle | A Bundle in which the token value was stored. |
putToken(Bundle, String)
Puts the token value into a Bundle.
public static void putToken(Bundle bundle, String value)
Parameter | Beschreibung |
---|---|
bundle | A Bundle in which the token value should be stored. |
value | The String representing the token value, or null. |
getExpirationDate(Bundle)
Gets the cached expiration date from a Bundle.
public static Date getExpirationDate(Bundle bundle)
Parameter | Beschreibung |
---|---|
bundle | A Bundle in which the expiration date was stored. |
putExpirationDate(Bundle, Date)
Puts the expiration date into a Bundle.
public static void putExpirationDate(Bundle bundle, Date value)
Parameter | Beschreibung |
---|---|
bundle | A Bundle in which the expiration date should be stored. |
value | The Date representing the expiration date. |
getExpirationMilliseconds(Bundle)
Gets the cached expiration date from a Bundle.
public static long getExpirationMilliseconds(Bundle bundle)
Parameter | Beschreibung |
---|---|
bundle | A Bundle in which the expiration date was stored. |
putExpirationMilliseconds(Bundle, long)
Puts the expiration date into a Bundle.
public static void putExpirationMilliseconds(Bundle bundle, long value)
Parameter | Beschreibung |
---|---|
bundle | A Bundle in which the expiration date should be stored. |
value | The long representing the expiration date in milliseconds since the epoch. |
getPermissions(Bundle)
Gets the cached list of permissions from a Bundle.
public static List getPermissions(Bundle bundle)
Parameter | Beschreibung |
---|---|
bundle | A Bundle in which the list of permissions was stored. |
putPermissions(Bundle, List)
Puts the list of permissions into a Bundle.
public static void putPermissions(Bundle bundle, List value)
Parameter | Beschreibung |
---|---|
bundle | A Bundle in which the list of permissions should be stored. |
value | The List<String> representing the list of permissions, or null. |
getSource(Bundle)
Gets the cached enum indicating the source of the token from the Bundle.
public static AccessTokenSource getSource(Bundle bundle)
Parameter | Beschreibung |
---|---|
bundle | A Bundle in which the enum was stored. |
putSource(Bundle, AccessTokenSource)
Puts the enum indicating the source of the token into a Bundle.
public static void putSource(Bundle bundle, AccessTokenSource value)
Parameter | Beschreibung |
---|---|
bundle | A Bundle in which the enum should be stored. |
value | Enum indicating the source of the token |
getLastRefreshDate(Bundle)
Gets the cached last refresh date from a Bundle.
public static Date getLastRefreshDate(Bundle bundle)
Parameter | Beschreibung |
---|---|
bundle | A Bundle in which the last refresh date was stored. |
putLastRefreshDate(Bundle, Date)
Puts the last refresh date into a Bundle.
public static void putLastRefreshDate(Bundle bundle, Date value)
Parameter | Beschreibung |
---|---|
bundle | A Bundle in which the last refresh date should be stored. |
value | The Date representing the last refresh date, or null. |
getLastRefreshMilliseconds(Bundle)
Gets the cached last refresh date from a Bundle.
public static long getLastRefreshMilliseconds(Bundle bundle)
Parameter | Beschreibung |
---|---|
bundle | A Bundle in which the last refresh date was stored. |
putLastRefreshMilliseconds(Bundle, long)
Puts the last refresh date into a Bundle.
public static void putLastRefreshMilliseconds(Bundle bundle, long value)
Parameter | Beschreibung |
---|---|
bundle | A Bundle in which the last refresh date should be stored. |
value | The long representing the last refresh date in milliseconds since the epoch. |
load()
Called during Session construction to get the token state. Typically this is loaded from a persistent store that was previously initialized via save. The caller may choose to keep a reference to the returned Bundle indefinitely. Therefore the TokenCachingStrategy should not store the returned Bundle and should return a new Bundle on every call to this method.
public abstract Bundle load()
save(Bundle)
Called when a Session updates its token. This is passed a Bundle of values that should be stored durably for the purpose of being returned from a later call to load. Some implementations may choose to store bundle beyond the scope of this call, so the caller should keep no references to the bundle to ensure that it is not modified later.
public abstract void save(Bundle bundle)
Parameter | Beschreibung |
---|---|
bundle | A Bundle that represents the token state to be saved. |
clear()
Called when a Session learns its token is no longer valid or during a call to closeAndClearTokenInformation.closeAndClearTokenInformation to clear the durable state associated with the token.
public abstract void clear()
TOKEN_KEY
public static final String TOKEN_KEY
EXPIRATION_DATE_KEY
public static final String EXPIRATION_DATE_KEY
LAST_REFRESH_DATE_KEY
public static final String LAST_REFRESH_DATE_KEY
USER_FBID_KEY
public static final String USER_FBID_KEY
TOKEN_SOURCE_KEY
public static final String TOKEN_SOURCE_KEY
PERMISSIONS_KEY
public static final String PERMISSIONS_KEY