Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions libs/SalesforceSDK/res/values/sf__strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<string name="sf__invalid_server_url">Please type in a valid URL</string>
<string name="sf__access_token_revoked">Your access token has been revoked by the administrator. You will now be logged out.</string>
<string name="sf__managed_app_error">Authentication only allowed from managed device.</string>
<string name="sf__missing_refresh_token_scope_error">Authentication error: missing refresh_token scope on connected app / external client app. Please contact your administrator.</string>
<string name="sf__jwt_authentication_error">JWT authentication error. Please try again.</string>

<!-- SSL errors -->
Expand Down
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
Copy Markdown
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