@Override
	public boolean execute(String action, JSONArray args,
			final CallbackContext callbackContext) throws JSONException {
		// TODO Auto-generated method stub
		super.execute(action, args, callbackContext);
		Log.v("iGreet", "iGreet: execute");

		try {
			String baseUrl = null, consumerKey = null, secretKey = null, redirectUrl = null;

			if (ACTION_ENTERPRISE_LOGOUT.equals(action)) {
				JSONObject arg_object = args.getJSONObject(0);
				baseUrl = arg_object.getString("baseUrl");

			} else if (!ACTION_PEAS_LOGOUT.equals(action)) {
				JSONObject arg_object = args.getJSONObject(0);
				baseUrl = arg_object.getString("baseUrl");
				consumerKey = arg_object.getString("consumerKey");
				secretKey = arg_object.getString("secretKey");
				redirectUrl = arg_object.getString("redirectUrl");

			}
			Log.v(TAG, "iGreet:" + baseUrl + consumerKey + secretKey
					+ redirectUrl + action);

			if (ACTION_ENTERPRISE_LOGOUT.equals(action)) {
				EnterpriseAuthenticator authenticator = EnterpriseAuthenticator
						.getAuthenticationHandler();
				authenticator.setListener(new OAuthPluginListener() {

					@Override
					public void onSuccess(JSONObject tokenDetails) {
						// TODO Auto-generated method stub
						callbackContext.success(tokenDetails);
						Log.v(TAG, "onSuccess: " + tokenDetails);
					}

					@Override
					public void onFail(String error) {
						callbackContext.error(error);

					}

					@Override
					public void onLogoutSuccess(JSONObject result) {
						callbackContext.success(result);
						// TODO Auto-generated method stub

					}
				});
				authenticator.logout(baseUrl);
				return true;

			} else if (ACTION_ENTERPRISE_AUTHORIZE.equals(action)) {
				EnterpriseAuthenticator authenticator = EnterpriseAuthenticator
						.getAuthenticationHandler();
				authenticator.setPluginActivity(this.cordova.getActivity());
				authenticator.setParams(consumerKey, secretKey, redirectUrl);
				authenticator.setListener(new OAuthPluginListener() {

					@Override
					public void onSuccess(JSONObject tokenDetails) {
						// TODO Auto-generated method stub
						callbackContext.success(tokenDetails);
						Log.v(TAG, "onSuccess: " + tokenDetails);
					}

					@Override
					public void onFail(String error) {
						callbackContext.error(error);

					}

					@Override
					public void onLogoutSuccess(JSONObject result) {
						// TODO Auto-generated method stub

					}
				});
				authenticator.authorize(baseUrl);
				return true;
			} else {

				PeasClientAuthenticator authenticator = PeasClientAuthenticator
						.getAuthenticationHandler();
				authenticator.setPluginActivity(this.cordova.getActivity());
				authenticator.setParams(consumerKey, secretKey, redirectUrl);
				authenticator.setListener(new OAuthPluginListener() {

					@Override
					public void onSuccess(JSONObject tokenDetails) {
						// TODO Auto-generated method stub
						callbackContext.success(tokenDetails);
						Log.v(TAG, "onSuccess: " + tokenDetails);
					}

					@Override
					public void onFail(String error) {
						callbackContext.error(error);
						// TODO Auto-generated method stub

					}

					@Override
					public void onLogoutSuccess(JSONObject result) {
						// TODO Auto-generated method stub
						callbackContext.success(result);
					}
				});
				if (ACTION_AUTHORIZE.equals(action)) {
					authenticator.authorize(baseUrl);
					return true;
				} else if (ACTION_PEAS_AUTHORIZE.equals(action)) {
					authenticator.peasAuthorize(baseUrl);
					return true;
				} else if (ACTION_PEAS_LOGOUT.equals(action)) {
					authenticator.logout();
					return true;
				}
			}
			return false;
		} catch (Exception e) {
			System.err.println("Exception: " + e.getMessage());
			callbackContext.error(e.getMessage());
			return false;
		}
	}