package com.worklight.wlclient.api;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.Application;
import android.app.Application.ActivityLifecycleCallbacks;
import android.content.ComponentName;
import android.content.Context;
import android.os.Build.VERSION;
import android.os.Bundle;
import com.worklight.common.Logger;
import com.worklight.common.WLConfig;
import com.worklight.common.WLTrusteer;
import com.worklight.location.api.WLDevice;
import com.worklight.location.api.WLEventTransmissionPolicy;
import com.worklight.location.internal.events.EventTransmitter;
import com.worklight.location.internal.nativeImpl.AndroidWLDevice;
import com.worklight.nativeandroid.common.WLUtils;
import com.worklight.wlclient.AsynchronousRequestSender;
import com.worklight.wlclient.HttpClientManager;
import com.worklight.wlclient.WLRequest;
import com.worklight.wlclient.WLRequestListener;
import com.worklight.wlclient.api.challengehandler.BaseChallengeHandler;
import com.worklight.wlclient.api.challengehandler.ChallengeHandler;
import com.worklight.wlclient.api.challengehandler.WLChallengeHandler;
import com.worklight.wlclient.challengehandler.AntiXSRFChallengeHandler;
import com.worklight.wlclient.challengehandler.AuthenticityChallengeHandler;
import com.worklight.wlclient.challengehandler.NoProvisioningChallengeHandler;
import com.worklight.wlclient.challengehandler.RemoteDisableChallengeHandler;
import java.net.URL;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import org.json.JSONException;
import org.json.JSONObject;

public class WLClient
{
  private static final String ANTI_XSRF_REALM = "wl_antiXSRFRealm";
  private static final String AUTHENTICITY_REALM = "wl_authenticityRealm";
  private static final String CHALLENGE_HANDLER_NULL_ERROR = "Cannot register 'null' challenge handler";
  private static final String HEART_BEAT_ERROR = "WLClient not initialized - cannot send heart beat message before connect";
  private static final String INVOKE_PROCEDURE_INIT_ERROR = "invokeProcedure() will not be executed because WLCLient is not initialized, ensure WLCLient.connect function has been called.";
  private static final String INVOKE_PROCEDURE_INVALID_INVOCATION_DATA = "Error during invocation of remote procedure, because invocation data can't be null.";
  private static final String INVOKE_PROCEDURE_RUN_ERROR = "Error during invocation of remote procedure, because responseListener parameter can't be null.";
  private static final String LOGIN_RUN_ERROR = "Error during login, because realmName or listener parameter can't be null.";
  private static final String LOGOUT_RUN_ERROR = "Error during logout, because realmName or listener parameter can't be null.";
  protected static final String LOG_ACTIVITY_INIT_ERROR = "logActivity() will not be executed because WLCLient is not initialized, ensure WLCLient.connect function has been called.";
  private static final String NO_PROVISIONING_REALM = "wl_deviceNoProvisioningRealm";
  private static final String NO_REALM_REGISTER_ERROR = "Application will exit because the challengeHandler parameter for registerChallengeHandler (challengeHandler) has a null realm property. Call this API with a valid reference to challenge handler.";
  private static final String REMOTE_DISABLE_REALM = "wl_remoteDisableRealm";
  private static final String REQ_PATH_WL_TOKEN = "oauth/token";
  public static final Object WAIT_LOCK = new Object();
  private static Logger logger = Logger.getInstance(WLClient.class.getSimpleName());
  private static WLClient wlClient = null;
  ActivityListener activityListener = null;
  private Hashtable<String, BaseChallengeHandler> chMap;
  private Context context;
  private int heartbeatInterval = 420;
  protected boolean isInitialized;
  private Timer timer;
  private HashMap<String, String> userPreferenceMap;
  private Map<String, String> wlAccessTokens;
  private AndroidWLDevice wlDevice;
  private String wlLastAccessToken = null;
  private WLPush wlPush = null;

  private WLClient(Context paramContext)
  {
    this.context = paramContext;
    this.wlDevice = new AndroidWLDevice(paramContext);
    this.chMap = new Hashtable();
    this.userPreferenceMap = new HashMap();
    this.wlAccessTokens = new HashMap();
    registerDefaultChallengeHandlers();
    if (Build.VERSION.SDK_INT >= 14)
    {
      Application localApplication = (Application)paramContext.getApplicationContext();
      this.activityListener = new ActivityListener();
      localApplication.registerActivityLifecycleCallbacks(this.activityListener);
    }
  }

  public static WLClient createInstance(Context paramContext)
  {
    if (wlClient != null)
    {
      logger.debug("WLClient has already been created.");
      releaseInstance();
    }
    wlClient = new WLClient(paramContext);
    WLConfig.createInstance(paramContext);
    HttpClientManager.createInstance(paramContext);
    WLTrusteer.createInstance(paramContext);
    return wlClient;
  }

  public static WLClient getInstance()
  {
    if (wlClient == null)
      throw new RuntimeException("WLClient object has not been created. You must call WLClient.createInstance first.");
    return wlClient;
  }

  public static boolean isApplicationSentToBackground(Context paramContext)
  {
    if (Build.VERSION.SDK_INT >= 14)
      return wlClient.activityListener.isAppInBackground();
    if (paramContext.checkCallingOrSelfPermission("android.permission.GET_TASKS") == 0)
    {
      List localList = ((ActivityManager)paramContext.getSystemService("activity")).getRunningTasks(1);
      return (!localList.isEmpty()) && (!((ActivityManager.RunningTaskInfo)localList.get(0)).topActivity.getPackageName().equals(paramContext.getPackageName()));
    }
    logger.warn("Heartbeat calls will continue while the app is in the background. To suspend heartbeat calls while the app is in the background, add the GET_TASKS permission to AndroidManifest.xml");
    return false;
  }

  private Map<String, String> parseAuthenticationHeader(String paramString)
  {
    String[] arrayOfString1 = paramString.split(" ");
    int i = arrayOfString1.length;
    Object localObject = null;
    if (i < 2);
    while (true)
    {
      return localObject;
      boolean bool = arrayOfString1[0].equals("Bearer");
      localObject = null;
      if (bool)
      {
        String[] arrayOfString2 = paramString.substring(1 + arrayOfString1[0].length()).split(",");
        localObject = new HashMap();
        for (int j = 0; j < arrayOfString2.length; j++)
        {
          String[] arrayOfString3 = arrayOfString2[j].split("=");
          if (arrayOfString3.length == 2)
            ((Map)localObject).put(arrayOfString3[0], arrayOfString3[1].replace("\"", ""));
        }
      }
    }
  }

  private void registerDefaultChallengeHandlers()
  {
    registerChallengeHandler(new AntiXSRFChallengeHandler("wl_antiXSRFRealm"));
    registerChallengeHandler(new NoProvisioningChallengeHandler("wl_deviceNoProvisioningRealm"));
    registerChallengeHandler(new RemoteDisableChallengeHandler("wl_remoteDisableRealm"));
    registerChallengeHandler(new AuthenticityChallengeHandler("wl_authenticityRealm"));
  }

  protected static void releaseInstance()
  {
    wlClient = null;
  }

  public void addGlobalHeader(String paramString1, String paramString2)
  {
    AsynchronousRequestSender.getInstance().addGlobalHeader(paramString1, paramString2);
  }

  public void checkForNotifications()
  {
    if (!this.isInitialized)
      return;
    new WLRequest(new WLRequestListener()
    {
      public void onFailure(WLFailResponse paramAnonymousWLFailResponse)
      {
      }

      public void onSuccess(WLResponse paramAnonymousWLResponse)
      {
      }
    }
    , new WLRequestOptions(), WLConfig.getInstance(), this.context).makeRequest("authenticate");
  }

  public void connect(WLResponseListener paramWLResponseListener)
  {
    connect(paramWLResponseListener, null);
  }

  public void connect(WLResponseListener paramWLResponseListener, WLRequestOptions paramWLRequestOptions)
  {
    String str = WLConfig.getInstance().readWLPref("WL-Instance-Id");
    if (!WLUtils.isStringEmpty(str))
      addGlobalHeader("WL-Instance-Id", str);
    if (paramWLRequestOptions == null)
      paramWLRequestOptions = new WLRequestOptions();
    paramWLRequestOptions.addParameter("action", "test");
    paramWLRequestOptions.setResponseListener(paramWLResponseListener);
    new WLRequest(new InitRequestListener(), paramWLRequestOptions, WLConfig.getInstance(), this.context).makeRequest("init");
  }

  public ChallengeHandler getChallengeHandler(WLResponse paramWLResponse)
  {
    Iterator localIterator = this.chMap.entrySet().iterator();
    while (localIterator.hasNext())
    {
      BaseChallengeHandler localBaseChallengeHandler = (BaseChallengeHandler)((Map.Entry)localIterator.next()).getValue();
      if ((localBaseChallengeHandler instanceof ChallengeHandler))
      {
        ChallengeHandler localChallengeHandler = (ChallengeHandler)localBaseChallengeHandler;
        if (localChallengeHandler.isCustomResponse(paramWLResponse))
          return localChallengeHandler;
      }
    }
    return null;
  }

  @Deprecated
  public WLConfig getConfig()
  {
    if (wlClient == null)
      throw new RuntimeException("WLClient object has not been created. You must call WLClient.createInstance first.");
    WLConfig.createInstance(this.context);
    return WLConfig.getInstance();
  }

  public Context getContext()
  {
    return this.context;
  }

  protected Map<String, String> getGlobalHeaders()
  {
    return AsynchronousRequestSender.getInstance().getGlobalHeaders();
  }

  public String getLastAccessToken()
  {
    return this.wlLastAccessToken;
  }

  public String getLastAccessToken(String paramString)
  {
    return (String)this.wlAccessTokens.get(paramString);
  }

  public WLPush getPush()
  {
    if (this.wlPush == null)
      this.wlPush = new WLPush(WLConfig.getInstance(), this.context);
    return this.wlPush;
  }

  public String getRequiredAccessTokenScope(int paramInt, String paramString)
  {
    if ((paramInt != 401) && (paramInt != 403))
      return null;
    return (String)parseAuthenticationHeader(paramString).get("scope");
  }

  protected Map<String, String> getUserPreferencemap()
  {
    return this.userPreferenceMap;
  }

  public WLChallengeHandler getWLChallengeHandler(String paramString)
  {
    if (paramString == null)
      return null;
    BaseChallengeHandler localBaseChallengeHandler = (BaseChallengeHandler)this.chMap.get(paramString);
    if ((localBaseChallengeHandler != null) && ((localBaseChallengeHandler instanceof WLChallengeHandler)))
      return (WLChallengeHandler)localBaseChallengeHandler;
    return null;
  }

  public WLDevice getWLDevice()
  {
    return this.wlDevice;
  }

  protected String getWLServerURL()
  {
    String str1 = WLConfig.getInstance().getServerContext();
    String str2 = WLConfig.getInstance().getAppURL().getHost();
    if ((str1 != null) && (str1.trim().length() > 1))
      return str2 + str1;
    return str2;
  }

  protected Hashtable<String, BaseChallengeHandler> getchMap()
  {
    return this.chMap;
  }

  public void init(WLResponseListener paramWLResponseListener)
  {
    connect(paramWLResponseListener);
  }

  public void invokeProcedure(WLProcedureInvocationData paramWLProcedureInvocationData, WLResponseListener paramWLResponseListener)
  {
    invokeProcedure(paramWLProcedureInvocationData, paramWLResponseListener, null);
  }

  public void invokeProcedure(WLProcedureInvocationData paramWLProcedureInvocationData, WLResponseListener paramWLResponseListener, WLRequestOptions paramWLRequestOptions)
  {
    if (!this.isInitialized)
    {
      logger.error("invokeProcedure() will not be executed because WLCLient is not initialized, ensure WLCLient.connect function has been called.");
      return;
    }
    if (paramWLProcedureInvocationData == null)
      throw new IllegalArgumentException("Error during invocation of remote procedure, because invocation data can't be null.");
    if (paramWLResponseListener == null)
      throw new IllegalArgumentException("Error during invocation of remote procedure, because responseListener parameter can't be null.");
    if (paramWLRequestOptions == null)
      paramWLRequestOptions = new WLRequestOptions();
    paramWLRequestOptions.setResponseListener(paramWLResponseListener);
    paramWLRequestOptions.addParameters(paramWLProcedureInvocationData.getInvocationDataMap());
    new WLRequest(new InvokeProcedureRequestListener(), paramWLRequestOptions, WLConfig.getInstance(), this.context).makeRequest("query");
  }

  public void logActivity(String paramString)
  {
    if (!this.isInitialized)
    {
      logger.error("logActivity() will not be executed because WLCLient is not initialized, ensure WLCLient.connect function has been called.");
      return;
    }
    if (paramString == null)
      throw new RuntimeException("ActivityType cannot be null");
    WLRequestOptions localWLRequestOptions = new WLRequestOptions();
    localWLRequestOptions.addParameter("activity", paramString);
    new WLRequest(new LogActivityListener(), localWLRequestOptions, WLConfig.getInstance(), this.context).makeRequest("logactivity");
  }

  public void login(String paramString, WLRequestListener paramWLRequestListener)
  {
    login(paramString, paramWLRequestListener, null);
  }

  public void login(String paramString, WLRequestListener paramWLRequestListener, WLRequestOptions paramWLRequestOptions)
  {
    if ((paramString == null) || (paramWLRequestListener == null))
      throw new IllegalArgumentException("Error during login, because realmName or listener parameter can't be null.");
    if (paramWLRequestOptions == null)
      paramWLRequestOptions = new WLRequestOptions();
    paramWLRequestOptions.addParameter("realm", paramString);
    new WLRequest(paramWLRequestListener, paramWLRequestOptions, WLConfig.getInstance(), this.context).makeRequest("login");
  }

  public void logout(String paramString, WLRequestListener paramWLRequestListener)
  {
    logout(paramString, paramWLRequestListener, null);
  }

  public void logout(String paramString, WLRequestListener paramWLRequestListener, WLRequestOptions paramWLRequestOptions)
  {
    if ((paramString == null) || (paramWLRequestListener == null))
      throw new IllegalArgumentException("Error during logout, because realmName or listener parameter can't be null.");
    if (paramWLRequestOptions == null)
      paramWLRequestOptions = new WLRequestOptions();
    paramWLRequestOptions.addParameter("realm", paramString);
    new WLRequest(paramWLRequestListener, paramWLRequestOptions, WLConfig.getInstance(), this.context).makeRequest("logout");
  }

  public void obtainAccessToken(String paramString, WLResponseListener paramWLResponseListener)
  {
    obtainAccessToken(paramString, paramWLResponseListener, null);
  }

  public void obtainAccessToken(String paramString, WLResponseListener paramWLResponseListener, WLRequestOptions paramWLRequestOptions)
  {
    if (paramString == null)
      throw new IllegalArgumentException("scope cannot be null");
    WLConfig localWLConfig = WLConfig.getInstance();
    if (paramWLRequestOptions == null)
      paramWLRequestOptions = new WLRequestOptions();
    paramWLRequestOptions.addHeader("wl-oauth-client", String.format("WLapp %s:%s", new Object[] { localWLConfig.getAppId(), localWLConfig.getWLEnvironment() }));
    paramWLRequestOptions.addParameter("grant_type", "client_credentials");
    paramWLRequestOptions.addParameter("scope", paramString);
    paramWLRequestOptions.setResponseListener(paramWLResponseListener);
    new WLRequest(new ObtainAccessTokenRequestListener(), paramWLRequestOptions, localWLConfig, this.context).makeRequest("oauth/token", true);
  }

  public void purgeEventTransmissionBuffer()
  {
    this.wlDevice.getEventTransmitter().purgeEvents();
  }

  public void registerChallengeHandler(BaseChallengeHandler paramBaseChallengeHandler)
  {
    if (paramBaseChallengeHandler == null)
    {
      logger.error("Cannot register 'null' challenge handler");
      throw new RuntimeException("Cannot register 'null' challenge handler");
    }
    String str = paramBaseChallengeHandler.getRealm();
    if (str == null)
    {
      logger.error("Application will exit because the challengeHandler parameter for registerChallengeHandler (challengeHandler) has a null realm property. Call this API with a valid reference to challenge handler.");
      throw new RuntimeException("Application will exit because the challengeHandler parameter for registerChallengeHandler (challengeHandler) has a null realm property. Call this API with a valid reference to challenge handler.");
    }
    this.chMap.put(str, paramBaseChallengeHandler);
  }

  public void removeGlobalHeader(String paramString)
  {
    AsynchronousRequestSender.getInstance().removeGlobalHeader(paramString);
  }

  void sendHeartBeat()
  {
    if ((this.timer == null) && (this.heartbeatInterval > 0))
    {
      this.timer = new Timer();
      this.timer.scheduleAtFixedRate(new HeartBeatTask(this.context), 1000 * this.heartbeatInterval, 1000 * this.heartbeatInterval);
    }
  }

  public void sendInvoke(WLProcedureInvocationData paramWLProcedureInvocationData, WLResponseListener paramWLResponseListener, WLRequestOptions paramWLRequestOptions)
  {
    if (paramWLResponseListener == null)
      throw new IllegalArgumentException("Error during invocation of remote procedure, because responseListener parameter can't be null.");
    if (paramWLRequestOptions == null)
      paramWLRequestOptions = new WLRequestOptions();
    paramWLRequestOptions.setResponseListener(paramWLResponseListener);
    paramWLRequestOptions.addParameters(paramWLProcedureInvocationData.getInvocationDataMap());
    new WLRequest(new InvokeProcedureRequestListener(), paramWLRequestOptions, WLConfig.getInstance(), this.context).makeRequest("invoke", true);
  }

  public void setEventTransmissionPolicy(WLEventTransmissionPolicy paramWLEventTransmissionPolicy)
  {
    this.wlDevice.getEventTransmitter().setEventTransmissionPolicy(paramWLEventTransmissionPolicy);
  }

  public void setHeartBeatInterval(int paramInt)
  {
    this.heartbeatInterval = paramInt;
    if (this.timer != null)
    {
      this.timer.cancel();
      this.timer = null;
    }
    sendHeartBeat();
  }

  protected void setInitialized(boolean paramBoolean)
  {
    this.isInitialized = paramBoolean;
  }

  public void transmitEvent(JSONObject paramJSONObject)
  {
    transmitEvent(paramJSONObject, false);
  }

  public void transmitEvent(JSONObject paramJSONObject, boolean paramBoolean)
  {
    this.wlDevice.getEventTransmitter().transmitEvent(paramJSONObject, paramBoolean);
  }

  class ActivityListener
    implements Application.ActivityLifecycleCallbacks
  {
    private int activityCount = 0;

    ActivityListener()
    {
    }

    public boolean isAppInBackground()
    {
      return this.activityCount == 0;
    }

    public void onActivityCreated(Activity paramActivity, Bundle paramBundle)
    {
      WLClient.logger.debug("on activity created " + paramActivity.getClass().getName());
    }

    public void onActivityDestroyed(Activity paramActivity)
    {
      WLClient.logger.debug("on activity destroyed " + paramActivity.getClass().getName());
    }

    public void onActivityPaused(Activity paramActivity)
    {
      this.activityCount = (-1 + this.activityCount);
      WLClient.logger.debug("on activity paused " + paramActivity.getClass().getName() + " . activity count = " + this.activityCount);
    }

    public void onActivityResumed(Activity paramActivity)
    {
      this.activityCount = (1 + this.activityCount);
      WLClient.logger.debug("on activity resumed " + paramActivity.getClass().getName() + " . activity count = " + this.activityCount);
    }

    public void onActivitySaveInstanceState(Activity paramActivity, Bundle paramBundle)
    {
      WLClient.logger.debug("on activity save instance state " + paramActivity.getClass().getName());
    }

    public void onActivityStarted(Activity paramActivity)
    {
      WLClient.logger.debug("on activity started " + paramActivity.getClass().getName());
    }

    public void onActivityStopped(Activity paramActivity)
    {
      WLClient.logger.debug("on activity stopped " + paramActivity.getClass().getName());
    }
  }

  class HeartBeatTask extends TimerTask
  {
    private Context context = null;

    HeartBeatTask(Context arg2)
    {
      Object localObject;
      this.context = localObject;
    }

    public void run()
    {
      if (!WLClient.this.isInitialized)
        throw new RuntimeException("WLClient not initialized - cannot send heart beat message before connect");
      if (WLClient.isApplicationSentToBackground(this.context));
      WLRequestOptions localWLRequestOptions;
      WLClient.HeartbeatListener localHeartbeatListener;
      WLClient localWLClient;
      do
      {
        return;
        localWLRequestOptions = new WLRequestOptions();
        localHeartbeatListener = new WLClient.HeartbeatListener(WLClient.this);
        localWLClient = WLClient.getInstance();
      }
      while (localWLClient == null);
      new WLRequest(localHeartbeatListener, localWLRequestOptions, WLConfig.getInstance(), localWLClient.getContext()).makeRequest("heartbeat");
    }
  }

  class HeartbeatListener
    implements WLRequestListener
  {
    HeartbeatListener()
    {
    }

    public void onFailure(WLFailResponse paramWLFailResponse)
    {
      WLClient.logger.debug("Failed to send heartbeat.");
    }

    public void onSuccess(WLResponse paramWLResponse)
    {
      WLClient.logger.debug("Heartbeat sent successfully");
    }
  }

  class InitRequestListener
    implements WLRequestListener
  {
    InitRequestListener()
    {
    }

    public void onFailure(WLFailResponse paramWLFailResponse)
    {
      paramWLFailResponse.getOptions().getResponseListener().onFailure(paramWLFailResponse);
    }

    public void onSuccess(WLResponse paramWLResponse)
    {
      WLClient.getInstance().setInitialized(true);
      WLClient localWLClient = WLClient.getInstance();
      if (localWLClient != null)
      {
        localWLClient.sendHeartBeat();
        try
        {
          JSONObject localJSONObject = paramWLResponse.getResponseJSON().getJSONObject("userPrefs");
          if (localJSONObject != null)
          {
            Iterator localIterator = localJSONObject.keys();
            while (true)
            {
              boolean bool = localIterator.hasNext();
              if (bool)
                try
                {
                  String str1 = (String)localIterator.next();
                  String str2 = (String)localJSONObject.get(str1);
                  WLClient.this.userPreferenceMap.put(str1, str2);
                }
                catch (JSONException localJSONException2)
                {
                  throw new RuntimeException(localJSONException2.getMessage());
                }
            }
          }
        }
        catch (JSONException localJSONException1)
        {
          localJSONException1.printStackTrace();
        }
      }
      paramWLResponse.getOptions().getResponseListener().onSuccess(paramWLResponse);
      Logger.processAutomaticTrigger();
    }
  }

  class InvokeProcedureRequestListener
    implements WLRequestListener
  {
    InvokeProcedureRequestListener()
    {
    }

    public void onFailure(WLFailResponse paramWLFailResponse)
    {
      WLProcedureInvocationFailResponse localWLProcedureInvocationFailResponse = new WLProcedureInvocationFailResponse(paramWLFailResponse);
      paramWLFailResponse.getOptions().getResponseListener().onFailure(localWLProcedureInvocationFailResponse);
    }

    public void onSuccess(WLResponse paramWLResponse)
    {
      WLProcedureInvocationResult localWLProcedureInvocationResult = new WLProcedureInvocationResult(paramWLResponse);
      if (localWLProcedureInvocationResult.isSuccessful())
        localWLProcedureInvocationResult.getOptions().getResponseListener().onSuccess(localWLProcedureInvocationResult);
      while (true)
      {
        Logger.processAutomaticTrigger();
        return;
        WLProcedureInvocationFailResponse localWLProcedureInvocationFailResponse = new WLProcedureInvocationFailResponse(paramWLResponse);
        localWLProcedureInvocationFailResponse.setErrorCode(WLErrorCode.PROCEDURE_ERROR);
        localWLProcedureInvocationFailResponse.getOptions().getResponseListener().onFailure(localWLProcedureInvocationFailResponse);
      }
    }
  }

  class LogActivityListener
    implements WLRequestListener
  {
    LogActivityListener()
    {
    }

    public void onFailure(WLFailResponse paramWLFailResponse)
    {
      WLClient.logger.error("Activity will not be logged in Worklight server using logActivity() because of " + paramWLFailResponse.getErrorMsg());
    }

    public void onSuccess(WLResponse paramWLResponse)
    {
      WLClient.logger.debug("logActivity success. Response from server is " + paramWLResponse.toString());
    }
  }

  class ObtainAccessTokenRequestListener
    implements WLRequestListener
  {
    ObtainAccessTokenRequestListener()
    {
    }

    public void onFailure(WLFailResponse paramWLFailResponse)
    {
      paramWLFailResponse.getOptions().getResponseListener().onFailure(paramWLFailResponse);
    }

    public void onSuccess(WLResponse paramWLResponse)
    {
      try
      {
        String str1 = paramWLResponse.getResponseJSON().getString("access_token");
        String str2 = paramWLResponse.getResponseJSON().getString("scope");
        WLClient.this.wlAccessTokens.put(str2, str1);
        WLClient.access$302(WLClient.this, str1);
        paramWLResponse.getOptions().getResponseListener().onSuccess(paramWLResponse);
        return;
      }
      catch (JSONException localJSONException)
      {
        paramWLResponse.getOptions().getResponseListener().onFailure(new WLFailResponse(paramWLResponse));
      }
    }
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.worklight.wlclient.api.WLClient
 * JD-Core Version:    0.6.2
 */