com.kii.sdk.photocolle
Class AuthenticationContext

java.lang.Object
  extended by com.kii.sdk.photocolle.AuthenticationContext

public class AuthenticationContext
extends Object

Context of an authentication.


Method Summary
 String getAccessToken()
          Get access token.
 long getRemainingTime(TimeUnit timeUnit)
          Remaining time of this AuthenticationContext.
static boolean hasSaved(Context context, String key)
          Check whether AuthenticationContext has stored or not.
static AuthenticationContext loadFrom(Context context, String key)
          Deprecated. authenticate() loads AuthenticationContext automatically if saved. Applications should use authenticate(). If applications need to load AuthenticationContext by itself, Applications should use loadFrom(Context, String, String, String) instead of this method..
static AuthenticationContext loadFrom(Context context, String key, String clientId, String clientSecret)
          Load AuthenticationContext object.
static void removeAll(Context context)
          Remove all stored AuthenticationContext objects.
static void removeFrom(Context context, String key)
          Remove an AuthenticationContext object.
 void saveTo(Context context, String key)
          Save AuthenticationContext object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

hasSaved

public static boolean hasSaved(Context context,
                               String key)
                        throws AuthenticationContextAccessException
Check whether AuthenticationContext has stored or not.

This method uses SharedPreferences. If you access this method from main thread, you will see the disk read violation on StrictMode.

Parameters:
context - context of an application. must not be null.
key - a key to specify an AuthenticationContext object to check. must not be null or empty.
Returns:
AuthenticationContext object exists or not.
Throws:
AuthenticationContextAccessException - fail to access stored AuthenticationContext.
ParameterException - One or more arguments are invalid.

loadFrom

@Deprecated
public static AuthenticationContext loadFrom(Context context,
                                                        String key)
                                      throws AuthenticationContextAccessException,
                                             AuthenticationContextNotFoundException
Deprecated. authenticate() loads AuthenticationContext automatically if saved. Applications should use authenticate(). If applications need to load AuthenticationContext by itself, Applications should use loadFrom(Context, String, String, String) instead of this method..

Load AuthenticationContext object.

This method uses SharedPreferences. If you access this method from main thread, you will see the disk read violation on StrictMode.

Parameters:
context - context of an application. must not be null.
key - a key to specify an AuthenticationContext object to load. must not be null or empty.
Returns:
loaded AuthenticationContext object.
Throws:
AuthenticationContextAccessException - fail to access stored AuthenticationContext
AuthenticationContextNotFoundException - target data does not exist.
ParameterException - One or more arguments are invalid.

loadFrom

public static AuthenticationContext loadFrom(Context context,
                                             String key,
                                             String clientId,
                                             String clientSecret)
                                      throws AuthenticationContextAccessException,
                                             AuthenticationContextNotFoundException
Load AuthenticationContext object.

This method uses SharedPreferences. If you access this method from main thread, you will see the disk read violation on StrictMode.

Parameters:
context - context of an application. must not be null.
key - a key to specify an AuthenticationContext object to load. must not be null or empty
clientId - A client ID issued by docomo Developer support. must not be null or empty.
clientSecret - A client secret issued by docomo Developer support. must not be null or empty.
Returns:
loaded AuthenticationContext object.
Throws:
AuthenticationContextAccessException - fail to access stored AuthenticationContext.
AuthenticationContextNotFoundException - target data does not exist.
ParameterException - One or more arguments are invalid.

removeFrom

public static void removeFrom(Context context,
                              String key)
                       throws AuthenticationContextAccessException
Remove an AuthenticationContext object. The AuthenticationContext object which is removed by this method can not load by the loadFrom().

This method uses SharedPreferences. If you access this method from main thread, you will see the disk read violation or disk write violation on StrictMode.

Parameters:
context - context of an application. must not be null.
key - a key to specify an AuthenticationContext object to remove. must not be null or empty.
Throws:
AuthenticationContextAccessException - fail to access stored AuthenticationContext.
ParameterException - One or more arguments are invalid.

removeAll

public static void removeAll(Context context)
                      throws AuthenticationContextAccessException
Remove all stored AuthenticationContext objects.

This method uses SharedPreferences. If you access this method from main thread, you will see the disk read violation or disk write violation on StrictMode.

Parameters:
context - context of an application. must not be null or empty.
Throws:
AuthenticationContextAccessException - fail to access stored
ParameterException - One or more arguments are invalid.

saveTo

public void saveTo(Context context,
                   String key)
            throws AuthenticationContextAccessException
Save AuthenticationContext object.

This method uses SharedPreferences. If you access this method from main thread, you will see the disk read violation or disk write violation on StrictMode.

After calling this method, PhotoColleSDK automatically saves AuthenticationContext with the storeKey provided to this method. The timing to save AuthenticationContext is when new access toekn is received by refresh token.

If this method is called several times with different storeKey, the storeKey which is provided at last call is used to automatically save.

Parameters:
context - context of an application. must not be null.
key - a key to save an AuthenticationContext object. must not be null or empty.
Throws:
AuthenticationContextAccessException - fail to store AuthenticationContext.
ParameterException - One or more arguments are invalid.

getRemainingTime

public long getRemainingTime(TimeUnit timeUnit)
                      throws ParameterException
Remaining time of this AuthenticationContext. Returns remaining time of this AuthenticationContext in TimeUnit. If remaining time is more than 0, access token of this AuthenticationContext is valid at the time. If remaining time is equals or less than 0, applications should refresh access token.

Parameters:
timeUnit - time unit of returning value. must not be null.
Throws:
ParameterException - an argument is invalid.

getAccessToken

public String getAccessToken()
Get access token.

Applications should get access token by this method every time applications use access token because access token is expired after a period of time.

PhotoColleSDK get new access token by using PhotoColle methods accessing to PhotoColle network if access token is expired.

Returns:
the accessToken