com.kii.sdk.photocolle
Class Authority

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

public class Authority
extends Object

Execute authentication.


Constructor Summary
Authority()
           
 
Method Summary
static void authenticate(Context context, String clientId, String clientSecret, String redirectUri, EnumSet<Scope> predefinedScopes, String[] extendedScopes, String storeKey, AuthenticateCallback callback)
          Invoke authentication process to get AuthenticationContext object.
static void refreshToken(AuthenticationContext authenticationContext, AuthenticateCallback callback)
          Invoke refresh token process to update AuthenticationContext object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Authority

public Authority()
Method Detail

authenticate

public static void authenticate(Context context,
                                String clientId,
                                String clientSecret,
                                String redirectUri,
                                EnumSet<Scope> predefinedScopes,
                                String[] extendedScopes,
                                String storeKey,
                                AuthenticateCallback callback)
                         throws ParameterException
Invoke authentication process to get AuthenticationContext object.

Access token is saved with specified storeKey. If valid access token is stored with specified storedKey, this method skips authentication and uses stored access token. Otherwise this method authenticate with PhotoColle network by OAuth2.0. After success of authentication, PhotoColleSDK saves retrieved access token with specified storeKey.

PhotoColleSDK refreshes access token if the stored token is going to be expired. Calling this method or method in PhotoColle requires authentication triggers refresh token. After the refresh token succeeded, stored token will be overwritten with the storeKey given to this method.

If refresh token fails in this method, this method start to authenticate with PhotoColle network.

If refresh token fails in the method of PhotoColle, PhotoColleSDK removes stored access token bound to specified storeKey.

Applications must need to request permissions with scope. Applications must send at least one scope to Docomo authentication server.

Parameters:
context - Android context (Activity or so). must not be null.
clientId - The client id string which is issued for your service. must not be null or empty.
clientSecret - The client secret string which is issued for your service. must not be null or empty.
redirectUri - The redirect URI which you registered. must not be null or empty.
predefinedScopes - Applications request permissions to Docomo authentication server by Scopes. One or more Scopes can be set. The Scopes is defined in docomo Developer support API common reference version 2.0.0. If extendedScopes is null or empty, then this parameter must not be null or empty.
extendedScopes - Applications request permissions to Docomo authentication server by scopes. If applications need to request scopes defined after docomo Developer support API common reference version 2.0.0, applications can request these scopes with String values defined in a newest specification. If predefinedScopes is null or empty, then this parameter must not be null or empty. Elements of this array must not be null or empty string. If same scope strings in this array, one of the string is ignored.
storeKey - A key to save and load AuthenticationContext automatically. If null or empty, automatic saving and loading does not occur.
callback - The callback for receiving a result of authentication process. must not be null.
Throws:
ParameterException - One or more arguments are invalid.

refreshToken

public static void refreshToken(AuthenticationContext authenticationContext,
                                AuthenticateCallback callback)
                         throws ParameterException
Invoke refresh token process to update AuthenticationContext object. This method refreshes access token with PhotoColle network by OAuth2.0. If refresh token process succeed and automatic saving is enabled on authenticationContext, then updated authenticationContext is saved automatically. AuthenticationContext satisfying one or more following conditions is automatic saving enabled. You can check remaining time of access token by AuthenticationContext#getRemainingTimeInMilliseconds().

Parameters:
authenticationContext - the authentication context to be updated. must not be null. authenticationContext loaded by AuthenticationContext.loadFrom(Context, String) can not be refreshed.
callback - The callback for receiving a result refresh token process. must not be null.
Throws:
ParameterException - One or more arguments are invalid.