예제 #1
0
    @Override
    public void onReceive(Context context, Intent intent) {
      String intentAction = intent.getAction();
      Bundle extras = intent.getExtras();
      boolean shouldRespond = true;
      if (extras != null) {
        // See if an Id was set in the broadcast Intent. If it was, treat it as a filter.
        String broadcastObjectId = extras.getString(LikeActionController.ACTION_OBJECT_ID_KEY);
        shouldRespond =
            Utility.isNullOrEmpty(broadcastObjectId)
                || Utility.areObjectsEqual(objectId, broadcastObjectId);
      }

      if (!shouldRespond) {
        return;
      }

      if (LikeActionController.ACTION_LIKE_ACTION_CONTROLLER_UPDATED.equals(intentAction)) {
        updateLikeStateAndLayout();
      } else if (LikeActionController.ACTION_LIKE_ACTION_CONTROLLER_DID_ERROR.equals(
          intentAction)) {
        if (onErrorListener != null) {
          onErrorListener.onError(NativeProtocol.getExceptionFromErrorData(extras));
        }
      } else if (LikeActionController.ACTION_LIKE_ACTION_CONTROLLER_DID_RESET.equals(
          intentAction)) {
        // This will recreate the controller and associated objects
        setObjectIdAndTypeForced(objectId, objectType);
        updateLikeStateAndLayout();
      }
    }
예제 #2
0
    private static DialogFeatureConfig parseDialogConfig(JSONObject dialogConfigJSON) {
      String dialogNameWithFeature = dialogConfigJSON.optString(DIALOG_CONFIG_NAME_KEY);
      if (Utility.isNullOrEmpty(dialogNameWithFeature)) {
        return null;
      }

      String[] components =
          dialogNameWithFeature.split(DIALOG_CONFIG_DIALOG_NAME_FEATURE_NAME_SEPARATOR);
      if (components.length != 2) {
        // We expect the format to be dialogName|FeatureName, where both components are
        // non-empty.
        return null;
      }

      String dialogName = components[0];
      String featureName = components[1];
      if (isNullOrEmpty(dialogName) || isNullOrEmpty(featureName)) {
        return null;
      }

      String urlString = dialogConfigJSON.optString(DIALOG_CONFIG_URL_KEY);
      Uri fallbackUri = null;
      if (!Utility.isNullOrEmpty(urlString)) {
        fallbackUri = Uri.parse(urlString);
      }

      JSONArray versionsJSON = dialogConfigJSON.optJSONArray(DIALOG_CONFIG_VERSIONS_KEY);

      int[] featureVersionSpec = parseVersionSpec(versionsJSON);

      return new DialogFeatureConfig(dialogName, featureName, fallbackUri, featureVersionSpec);
    }
 public Bundle parseResponseUri(String paramString)
 {
   paramString = Uri.parse(paramString);
   Bundle localBundle = Utility.parseUrlQueryString(paramString.getQuery());
   localBundle.putAll(Utility.parseUrlQueryString(paramString.getFragment()));
   return localBundle;
 }
예제 #4
0
  /**
   * Sets the associated object for this LikeView. Can be changed during runtime.
   *
   * @param objectId Object Id
   */
  public void setObjectId(String objectId) {
    objectId = Utility.coerceValueIfNullOrEmpty(objectId, null);
    if (!Utility.areObjectsEqual(objectId, this.objectId)) {
      setObjectIdForced(objectId);

      updateLikeStateAndLayout();
    }
  }
  @Override
  boolean tryAuthorize(final LoginClient.Request request) {
    Bundle parameters = new Bundle();
    if (!Utility.isNullOrEmpty(request.getPermissions())) {
      String scope = TextUtils.join(",", request.getPermissions());
      parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
      addLoggingExtra(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
    }

    DefaultAudience audience = request.getDefaultAudience();
    parameters.putString(
        ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience());

    AccessToken previousToken = AccessToken.getCurrentAccessToken();
    String previousTokenString = previousToken != null ? previousToken.getToken() : null;
    if (previousTokenString != null && (previousTokenString.equals(loadCookieToken()))) {
      parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousTokenString);
      // Don't log the actual access token, just its presence or absence.
      addLoggingExtra(
          ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_YES);
    } else {
      // The call to clear cookies will create the first instance of CookieSyncManager if
      // necessary
      Utility.clearFacebookCookies(loginClient.getActivity());
      addLoggingExtra(
          ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_NO);
    }

    WebDialog.OnCompleteListener listener =
        new WebDialog.OnCompleteListener() {
          @Override
          public void onComplete(Bundle values, FacebookException error) {
            onWebDialogComplete(request, values, error);
          }
        };

    e2e = LoginClient.getE2E();
    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    FragmentActivity fragmentActivity = loginClient.getActivity();
    WebDialog.Builder builder =
        new AuthDialogBuilder(fragmentActivity, request.getApplicationId(), parameters)
            .setE2E(e2e)
            .setIsRerequest(request.isRerequest())
            .setReauthenticate(request.isReauthenticate())
            .setOnCompleteListener(listener)
            .setTheme(FacebookSdk.getWebDialogTheme());
    loginDialog = builder.build();

    FacebookDialogFragment dialogFragment = new FacebookDialogFragment();
    dialogFragment.setRetainInstance(true);
    dialogFragment.setDialog(loginDialog);
    dialogFragment.show(fragmentActivity.getSupportFragmentManager(), FacebookDialogFragment.TAG);

    return true;
  }
예제 #6
0
  /**
   * Sets the associated object ID for this LikeView. Can be changed during runtime.
   *
   * @param objectId The object ID, this can be a URL or a Facebook ID.
   */
  public void setObjectIdAndType(String objectId, ObjectType objectType) {
    objectId = Utility.coerceValueIfNullOrEmpty(objectId, null);
    objectType = objectType != null ? objectType : ObjectType.DEFAULT;

    if (!Utility.areObjectsEqual(objectId, this.objectId) || (objectType != this.objectType)) {
      setObjectIdAndTypeForced(objectId, objectType);

      updateLikeStateAndLayout();
    }
  }
  private static synchronized TestSession createTestSession(
      Activity activity, List<String> permissions, Mode mode, String sessionUniqueUserTag) {
    if (Utility.isNullOrEmpty(testApplicationId) || Utility.isNullOrEmpty(testApplicationSecret)) {
      throw new FacebookException("Must provide app ID and secret");
    }

    if (Utility.isNullOrEmpty(permissions)) {
      permissions = Arrays.asList("email", "publish_actions");
    }

    return new TestSession(
        activity, permissions, new TestTokenCachingStrategy(), sessionUniqueUserTag, mode);
  }
예제 #8
0
  public static Intent createProxyAuthIntent(
      Context context,
      String applicationId,
      List<String> permissions,
      String e2e,
      boolean isRerequest,
      SessionDefaultAudience defaultAudience) {
    for (NativeAppInfo appInfo : facebookAppInfoList) {
      Intent intent =
          new Intent()
              .setClassName(appInfo.getPackage(), FACEBOOK_PROXY_AUTH_ACTIVITY)
              .putExtra(FACEBOOK_PROXY_AUTH_APP_ID_KEY, applicationId);

      if (!Utility.isNullOrEmpty(permissions)) {
        intent.putExtra(FACEBOOK_PROXY_AUTH_PERMISSIONS_KEY, TextUtils.join(",", permissions));
      }
      if (!Utility.isNullOrEmpty(e2e)) {
        intent.putExtra(FACEBOOK_PROXY_AUTH_E2E_KEY, e2e);
      }

      intent.putExtra(
          ServerProtocol.DIALOG_PARAM_RESPONSE_TYPE, ServerProtocol.DIALOG_RESPONSE_TYPE_TOKEN);
      intent.putExtra(
          ServerProtocol.DIALOG_PARAM_RETURN_SCOPES, ServerProtocol.DIALOG_RETURN_SCOPES_TRUE);
      intent.putExtra(
          ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE,
          defaultAudience.getNativeProtocolAudience());

      if (!Settings.getPlatformCompatibilityEnabled()) {
        // Override the API Version for Auth
        intent.putExtra(
            ServerProtocol.DIALOG_PARAM_LEGACY_OVERRIDE, ServerProtocol.GRAPH_API_VERSION);

        // Only set the rerequest auth type for non legacy requests
        if (isRerequest) {
          intent.putExtra(
              ServerProtocol.DIALOG_PARAM_AUTH_TYPE, ServerProtocol.DIALOG_REREQUEST_AUTH_TYPE);
        }
      }

      intent = validateActivityIntent(context, intent, appInfo);

      if (intent != null) {
        return intent;
      }
    }
    return null;
  }
예제 #9
0
 private void checkToolTipSettings() {
   switch (toolTipMode) {
     case AUTOMATIC:
       // kick off an async request
       final String appId = Utility.getMetadataApplicationId(getContext());
       FacebookSdk.getExecutor()
           .execute(
               new Runnable() {
                 @Override
                 public void run() {
                   final FetchedAppSettings settings = Utility.queryAppSettings(appId, false);
                   getActivity()
                       .runOnUiThread(
                           new Runnable() {
                             @Override
                             public void run() {
                               showToolTipPerSettings(settings);
                             }
                           });
                 }
               });
       break;
     case DISPLAY_ALWAYS:
       String toolTipString = getResources().getString(R.string.com_facebook_tooltip_default);
       displayToolTip(toolTipString);
       break;
     case NEVER_DISPLAY:
       break;
   }
 }
  @SmallTest
  @MediumTest
  @LargeTest
  public void testCacheRoundtrip() {
    ArrayList<String> permissions = Utility.arrayList("stream_publish", "go_outside_and_play");
    String token = "AnImaginaryTokenValue";
    Date later = TestUtils.nowPlusSeconds(60);
    Date earlier = TestUtils.nowPlusSeconds(-60);

    SharedPreferencesTokenCachingStrategy cache =
        new SharedPreferencesTokenCachingStrategy(getContext());
    cache.clear();

    Bundle bundle = new Bundle();
    TokenCachingStrategy.putToken(bundle, token);
    TokenCachingStrategy.putExpirationDate(bundle, later);
    TokenCachingStrategy.putSource(bundle, AccessTokenSource.FACEBOOK_APPLICATION_NATIVE);
    TokenCachingStrategy.putLastRefreshDate(bundle, earlier);
    TokenCachingStrategy.putPermissions(bundle, permissions);

    cache.save(bundle);
    bundle = cache.load();

    AccessToken accessToken = AccessToken.createFromCache(bundle);
    TestUtils.assertSamePermissions(permissions, accessToken);
    assertEquals(token, accessToken.getToken());
    assertEquals(AccessTokenSource.FACEBOOK_APPLICATION_NATIVE, accessToken.getSource());
    assertTrue(!accessToken.isInvalid());

    Bundle cachedBundle = accessToken.toCacheBundle();
    TestUtils.assertEqualContents(bundle, cachedBundle);
  }
 private boolean validatePermissions(
     List<String> permissions, SessionAuthorizationType authType, Session currentSession) {
   if (SessionAuthorizationType.PUBLISH.equals(authType)) {
     if (Utility.isNullOrEmpty(permissions)) {
       throw new IllegalArgumentException(
           "Permissions for publish actions cannot be null or empty.");
     }
   }
   if (currentSession != null && currentSession.isOpened()) {
     if (!Utility.isSubset(permissions, currentSession.getPermissions())) {
       Log.e(TAG, "Cannot set additional permissions when session is already open.");
       return false;
     }
   }
   return true;
 }
예제 #12
0
    public boolean validateSignature(Context context, String packageName) {
      String brand = Build.BRAND;
      int applicationFlags = context.getApplicationInfo().flags;
      if (brand.startsWith("generic")
          && (applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
        // We are debugging on an emulator, don't validate package signature.
        return true;
      }

      PackageInfo packageInfo = null;
      try {
        packageInfo =
            context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
      } catch (PackageManager.NameNotFoundException e) {
        return false;
      }

      for (Signature signature : packageInfo.signatures) {
        String hashedSignature = Utility.sha1hash(signature.toByteArray());
        if (validAppSignatureHashes.contains(hashedSignature)) {
          return true;
        }
      }

      return false;
    }
예제 #13
0
  @UnityCallable
  public static void Init(final String params_str) {
    Log.v(TAG, "Init(" + params_str + ")");
    UnityParams unity_params =
        UnityParams.parse(params_str, "couldn't parse init params: " + params_str);
    final String appID;
    if (unity_params.hasString("appId")) {
      appID = unity_params.getString("appId");
    } else {
      appID = Utility.getMetadataApplicationId(getUnityActivity());
    }

    FacebookSdk.setApplicationId(appID);
    FacebookSdk.sdkInitialize(
        FB.getUnityActivity(),
        new FacebookSdk.InitializeCallback() {
          @Override
          public void onInitialized() {
            final UnityMessage unityMessage = new UnityMessage("OnInitComplete");
            // If we have a cached access token send it back as well
            AccessToken token = AccessToken.getCurrentAccessToken();
            if (token != null) {
              FBLogin.addLoginParametersToMessage(unityMessage, token, null);
            } else {
              unityMessage.put("key_hash", FB.getKeyHash());
            }

            FB.ActivateApp(appID);

            unityMessage.send();
          }
        });
  }
 private static void processAttachmentFile(Uri uri, boolean z, File file) throws IOException {
   InputStream openInputStream;
   Closeable fileOutputStream = new FileOutputStream(file);
   if (z) {
     openInputStream =
         FacebookSdk.getApplicationContext().getContentResolver().openInputStream(uri);
   } else {
     try {
       openInputStream = new FileInputStream(uri.getPath());
     } catch (Throwable th) {
       Utility.closeQuietly(fileOutputStream);
     }
   }
   Utility.copyAndCloseInputStream(openInputStream, fileOutputStream);
   Utility.closeQuietly(fileOutputStream);
 }
예제 #15
0
  public static DialogFeatureConfig getDialogFeatureConfig(
      String applicationId, String actionName, String featureName) {
    if (Utility.isNullOrEmpty(actionName) || Utility.isNullOrEmpty(featureName)) {
      return null;
    }

    FetchedAppSettings settings = fetchedAppSettings.get(applicationId);
    if (settings != null) {
      Map<String, DialogFeatureConfig> featureMap =
          settings.getDialogConfigurations().get(actionName);
      if (featureMap != null) {
        return featureMap.get(featureName);
      }
    }
    return null;
  }
 private Attachment(UUID uuid, Bitmap bitmap, Uri uri) {
   String attachmentUrl;
   boolean z = true;
   this.callId = uuid;
   this.bitmap = bitmap;
   this.originalUri = uri;
   if (uri != null) {
     String scheme = uri.getScheme();
     if ("content".equalsIgnoreCase(scheme)) {
       this.isContentUri = true;
       if (uri.getAuthority() == null || uri.getAuthority().startsWith("media")) {
         z = false;
       }
       this.shouldCreateFile = z;
     } else if ("file".equalsIgnoreCase(uri.getScheme())) {
       this.shouldCreateFile = true;
     } else if (!Utility.isWebUri(uri)) {
       throw new FacebookException("Unsupported scheme for media Uri : " + scheme);
     }
   } else if (bitmap != null) {
     this.shouldCreateFile = true;
   } else {
     throw new FacebookException("Cannot share media without a bitmap or Uri set");
   }
   this.attachmentName = !this.shouldCreateFile ? null : UUID.randomUUID().toString();
   if (this.shouldCreateFile) {
     attachmentUrl =
         FacebookContentProvider.getAttachmentUrl(
             FacebookSdk.getApplicationId(), uuid, this.attachmentName);
   } else {
     attachmentUrl = this.originalUri.toString();
   }
   this.attachmentUrl = attachmentUrl;
 }
 private static void processAttachmentBitmap(Bitmap bitmap, File file) throws IOException {
   Closeable fileOutputStream = new FileOutputStream(file);
   try {
     bitmap.compress(CompressFormat.JPEG, 100, fileOutputStream);
   } finally {
     Utility.closeQuietly(fileOutputStream);
   }
 }
예제 #18
0
 static AccessToken createFromWebBundle(List list, Bundle bundle, AccessTokenSource accesstokensource)
 {
     Date date = getBundleLongAsDate(bundle, "expires_in", new Date());
     String s = bundle.getString("access_token");
     String s1 = bundle.getString("granted_scopes");
     if (!Utility.isNullOrEmpty(s1))
     {
         list = new ArrayList(Arrays.asList(s1.split(",")));
     }
     s1 = bundle.getString("denied_scopes");
     bundle = null;
     if (!Utility.isNullOrEmpty(s1))
     {
         bundle = new ArrayList(Arrays.asList(s1.split(",")));
     }
     return createNew(list, bundle, s, date, accesstokensource);
 }
 private static TestSession createTestSession(Activity paramActivity, List<String> paramList, TestSession.Mode paramMode, String paramString)
 {
   try
   {
     if ((Utility.isNullOrEmpty(testApplicationId)) || (Utility.isNullOrEmpty(testApplicationSecret))) {
       throw new FacebookException("Must provide app ID and secret");
     }
   }
   finally
   {
     throw paramActivity;
     if (Utility.isNullOrEmpty(paramList))
     {
       paramList = Arrays.asList(new String[] { "email", "publish_actions" });
       paramActivity = new TestSession(paramActivity, paramList, new TestSession.TestTokenCachingStrategy(null), paramString, paramMode);
     }
   }
 }
  void onWebDialogComplete(LoginClient.Request request, Bundle values, FacebookException error) {
    LoginClient.Result outcome;
    if (values != null) {
      // Actual e2e we got from the dialog should be used for logging.
      if (values.containsKey(ServerProtocol.DIALOG_PARAM_E2E)) {
        e2e = values.getString(ServerProtocol.DIALOG_PARAM_E2E);
      }

      try {
        AccessToken token =
            createAccessTokenFromWebBundle(
                request.getPermissions(),
                values,
                AccessTokenSource.WEB_VIEW,
                request.getApplicationId());
        outcome = LoginClient.Result.createTokenResult(loginClient.getPendingRequest(), token);

        // Ensure any cookies set by the dialog are saved
        // This is to work around a bug where CookieManager may fail to instantiate if
        // CookieSyncManager has never been created.
        CookieSyncManager syncManager = CookieSyncManager.createInstance(loginClient.getActivity());
        syncManager.sync();
        saveCookieToken(token.getToken());
      } catch (FacebookException ex) {
        outcome =
            LoginClient.Result.createErrorResult(
                loginClient.getPendingRequest(), null, ex.getMessage());
      }
    } else {
      if (error instanceof FacebookOperationCanceledException) {
        outcome =
            LoginClient.Result.createCancelResult(
                loginClient.getPendingRequest(), "User canceled log in.");
      } else {
        // Something went wrong, don't log a completion event since it will skew timing
        // results.
        e2e = null;

        String errorCode = null;
        String errorMessage = error.getMessage();
        if (error instanceof FacebookServiceException) {
          FacebookRequestError requestError = ((FacebookServiceException) error).getRequestError();
          errorCode = String.format(Locale.ROOT, "%d", requestError.getErrorCode());
          errorMessage = requestError.toString();
        }
        outcome =
            LoginClient.Result.createErrorResult(
                loginClient.getPendingRequest(), null, errorMessage, errorCode);
      }
    }

    if (!Utility.isNullOrEmpty(e2e)) {
      logWebLoginCompleted(e2e);
    }

    loginClient.completeAndValidate(outcome);
  }
 public static File openAttachment(UUID uuid, String str) throws FileNotFoundException {
   if (Utility.isNullOrEmpty(str) || uuid == null) {
     throw new FileNotFoundException();
   }
   try {
     return getAttachmentFile(uuid, str, false);
   } catch (IOException e) {
     throw new FileNotFoundException();
   }
 }
예제 #22
0
 private static AccessToken createNew(List list, List list1, String s, Date date, AccessTokenSource accesstokensource)
 {
     if (Utility.isNullOrEmpty(s) || date == null)
     {
         return createEmptyToken();
     } else
     {
         return new AccessToken(s, date, list, list1, accesstokensource, new Date());
     }
 }
예제 #23
0
  /**
   * Sets the profile Id for this profile photo
   *
   * @param profileId The profileId NULL/Empty String will show the blank profile photo
   */
  public final void setProfileId(String profileId) {
    boolean force = false;
    if (Utility.isNullOrEmpty(this.profileId) || !this.profileId.equalsIgnoreCase(profileId)) {
      // Clear out the old profilePicture before requesting for the new one.
      setBlankProfilePicture();
      force = true;
    }

    this.profileId = profileId;
    refreshImage(force);
  }
예제 #24
0
  private void setObjectIdForced(String newObjectId) {
    tearDownObjectAssociations();

    objectId = newObjectId;
    if (Utility.isNullOrEmpty(newObjectId)) {
      return;
    }

    creationCallback = new LikeActionControllerCreationCallback();
    LikeActionController.getControllerForObjectId(getContext(), newObjectId, creationCallback);
  }
예제 #25
0
 public static void notNullOrEmpty(String s, String s1) {
   if (Utility.isNullOrEmpty(s)) {
     throw new IllegalArgumentException(
         (new StringBuilder())
             .append("Argument '")
             .append(s1)
             .append("' cannot be null or empty")
             .toString());
   } else {
     return;
   }
 }
예제 #26
0
 private Bundle getAnalyticsParameters() {
   Bundle params = new Bundle();
   params.putString(AnalyticsEvents.PARAMETER_LIKE_VIEW_STYLE, likeViewStyle.toString());
   params.putString(
       AnalyticsEvents.PARAMETER_LIKE_VIEW_AUXILIARY_POSITION, auxiliaryViewPosition.toString());
   params.putString(
       AnalyticsEvents.PARAMETER_LIKE_VIEW_HORIZONTAL_ALIGNMENT, horizontalAlignment.toString());
   params.putString(
       AnalyticsEvents.PARAMETER_LIKE_VIEW_OBJECT_ID,
       Utility.coerceValueIfNullOrEmpty(objectId, ""));
   return params;
 }
 public WebDialog(Context paramContext, String paramString, Bundle paramBundle, int paramInt, WebDialog.OnCompleteListener paramOnCompleteListener)
 {
   super(paramContext, paramInt);
   paramContext = paramBundle;
   if (paramBundle == null) {
     paramContext = new Bundle();
   }
   paramContext.putString("redirect_uri", "fbconnect://success");
   paramContext.putString("display", "touch");
   url = Utility.buildUri(ServerProtocol.getDialogAuthority(), ServerProtocol.getAPIVersion() + "/" + "dialog/" + paramString, paramContext).toString();
   onCompleteListener = paramOnCompleteListener;
 }
예제 #28
0
 private static AccessToken createFromBundle(List list, Bundle bundle, AccessTokenSource accesstokensource, Date date)
 {
     String s = bundle.getString("access_token");
     bundle = getBundleLongAsDate(bundle, "expires_in", date);
     if (Utility.isNullOrEmpty(s) || bundle == null)
     {
         return null;
     } else
     {
         return new AccessToken(s, bundle, list, null, accesstokensource, new Date());
     }
 }
  /**
   * Creates a {@link com.facebook.SharedPreferencesTokenCachingStrategy
   * SharedPreferencesTokenCachingStrategy} instance that is distinct for the passed in cacheKey.
   *
   * @param context The Context object to use to get the SharedPreferences object.
   * @param cacheKey Identifies a distinct set of token information.
   * @throws NullPointerException if the passed in Context is null
   */
  public SharedPreferencesTokenCachingStrategy(Context context, String cacheKey) {
    Validate.notNull(context, "context");

    this.cacheKey = Utility.isNullOrEmpty(cacheKey) ? DEFAULT_CACHE_KEY : cacheKey;

    // If the application context is available, use that. However, if it isn't
    // available (possibly because of a context that was created manually), use
    // the passed in context directly.
    Context applicationContext = context.getApplicationContext();
    context = applicationContext != null ? applicationContext : context;

    this.cache = context.getSharedPreferences(this.cacheKey, Context.MODE_PRIVATE);
  }
예제 #30
0
    public void setPublishPermissions(List<String> permissions) {

      if (LoginAuthorizationType.READ.equals(authorizationType)) {
        throw new UnsupportedOperationException(
            "Cannot call setPublishPermissions after " + "setReadPermissions has been called.");
      }
      if (Utility.isNullOrEmpty(permissions)) {
        throw new IllegalArgumentException(
            "Permissions for publish actions cannot be null or empty.");
      }
      this.permissions = permissions;
      authorizationType = LoginAuthorizationType.PUBLISH;
    }