Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import com.salesforce.androidsdk.app.Features;
import com.salesforce.androidsdk.app.SalesforceSDKManager;
import com.salesforce.androidsdk.auth.ScopeParser;
import com.salesforce.androidsdk.util.MapUtil;
import com.salesforce.androidsdk.util.SalesforceSDKLogger;

Expand Down Expand Up @@ -681,38 +682,14 @@ public String getScope() {
return scope;
}

/**
* Parses the space-delimited scope string into its individual components.
*
* @return Array of scope strings (empty if scope is null/empty).
*/
public String[] parseScopes() {
if (TextUtils.isEmpty(scope)) {
return new String[0];
}
final String trimmed = scope.trim();
if (trimmed.isEmpty()) {
return new String[0];
}
return trimmed.split("\\s+");
}

/**
* Checks whether the provided scope exists in this account's scope list.
*
* @param scopeToCheck Scope name to check.
* @return True if present, false otherwise.
*/
public boolean hasScope(String scopeToCheck) {
if (TextUtils.isEmpty(scopeToCheck)) {
return false;
}
for (final String s : parseScopes()) {
if (scopeToCheck.equals(s)) {
return true;
}
}
return false;
return new ScopeParser(scope).hasScope(scopeToCheck);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syntax isn't as clean in Java, but I wonder if ScopeParser could just be a couple String[] extensions?

Edit: There are several functions in ScopeParser so I see its need to be a class.

}
/**
* Returns the beacon child consumer key.
Expand Down
Loading
Loading