|
48 | 48 | import android.webkit.CookieManager;
|
49 | 49 |
|
50 | 50 | import androidx.annotation.NonNull;
|
| 51 | +import androidx.annotation.Nullable; |
51 | 52 | import androidx.lifecycle.Lifecycle;
|
52 | 53 | import androidx.lifecycle.LifecycleObserver;
|
53 | 54 | import androidx.lifecycle.OnLifecycleEvent;
|
|
100 | 101 | import java.util.SortedSet;
|
101 | 102 | import java.util.UUID;
|
102 | 103 | import java.util.concurrent.ConcurrentSkipListSet;
|
| 104 | +import java.util.regex.Pattern; |
103 | 105 |
|
104 | 106 | /**
|
105 | 107 | * This class serves as an interface to the various
|
@@ -182,7 +184,7 @@ public class SalesforceSDKManager implements LifecycleObserver {
|
182 | 184 |
|
183 | 185 | private boolean useHybridAuthentication = true; // hybrid authentication flows ON by default - but app can opt out by calling setUseHybridAuthentication(false)
|
184 | 186 |
|
185 |
| - private boolean shouldInferCustomDomain = false; // Do not detect use of Custom Domain input from login webview but app can opt in by calling setInferCustomDomain(ture) |
| 187 | + private Pattern customDomainInferencePattern; |
186 | 188 |
|
187 | 189 | private Theme theme = Theme.SYSTEM_DEFAULT;
|
188 | 190 | private String appName;
|
@@ -676,20 +678,25 @@ public synchronized void setUseHybridAuthentication(boolean useHybridAuthenticat
|
676 | 678 | }
|
677 | 679 |
|
678 | 680 | /**
|
679 |
| - * Returns whether the SDK should infer if the user has entered a new login server through |
680 |
| - * the "Use Custom Domain" button on the login screen. |
| 681 | + * Returns the pattern used to detect the use of "Use Custom Domain" input from login web view. |
| 682 | + * |
| 683 | + * @return pattern if set or null |
681 | 684 | */
|
682 |
| - public boolean shouldInferCustomDomain() { |
683 |
| - return this.shouldInferCustomDomain; |
| 685 | + public synchronized Pattern getCustomDomainInferencePattern() { |
| 686 | + return customDomainInferencePattern; |
684 | 687 | }
|
685 | 688 |
|
686 | 689 | /**
|
687 |
| - * Sets whether the SDK should infer if the user has entered a new login server through |
688 |
| - * the "Use Custom Domain" button on the login screen. |
689 |
| - * @param shouldInferCustomDomain |
| 690 | + * Detect use of "Use Custom Domain" input from login web view using the given regex. |
| 691 | + * Example for a specific org: |
| 692 | + * "^https:\\/\\/mobilesdk\\.my\\.salesforce\\.com\\/\\?startURL=%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage\\.apexp" |
| 693 | + * For any my domain: |
| 694 | + * "^https:\\/\\/[a-zA-Z0-9]+\\.my\\.salesforce\\.com/\\?startURL=%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage\\.apexp" |
| 695 | + * |
| 696 | + * @param pattern regex to use when detecting use of custom domain on login |
690 | 697 | */
|
691 |
| - public synchronized void setShouldInferCustomDomain(boolean shouldInferCustomDomain) { |
692 |
| - this.shouldInferCustomDomain = shouldInferCustomDomain; |
| 698 | + public synchronized void setCustomDomainInferencePattern(@Nullable Pattern pattern) { |
| 699 | + this.customDomainInferencePattern = pattern; |
693 | 700 | }
|
694 | 701 |
|
695 | 702 | /**
|
|
0 commit comments