public async override void Execute(object parameter) { // Get the portal and check whether a user is signed in ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.ArcGISOnline agol = ArcGISOnlineEnvironment.ArcGISOnline; if (agol != null && agol.User != null && agol.User.IsSignedIn) { // Remove the current user credentials from the application environment, if present IEnumerable <IdentityManager.Credential> credentials = UserManagement.Current.Credentials.Where(c => c.Url.Equals(agol.Url, StringComparison.OrdinalIgnoreCase) && c.UserName.Equals(agol.User.Current.Username, StringComparison.OrdinalIgnoreCase)); if (credentials != null) { int count = credentials.Count(); for (int i = 0; i < count; i++) { UserManagement.Current.Credentials.Remove(credentials.ElementAt(0)); } } // Update the user info on MapApplication.Current's portal instance if (MapApplication.Current != null && MapApplication.Current.Portal != null) { MapApplication.Current.Portal.Token = null; await MapApplication.Current.Portal.InitializeTaskAsync(); } // Sign the user out from ArcGIS Portal ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.ArcGISOnlineEnvironment.ArcGISOnline.User.SignOut(); } }
// Applies the current ArcGIS Online or Portal name to the label in the sign-in UI private void updateSignInLabel() { ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.ArcGISOnline agol = ArcGISOnline ?? ArcGISOnlineEnvironment.ArcGISOnline; if (viewModel != null && agol != null) { // Determine portal name string portalName = Strings.ArcGISOnline; if (agol.PortalInfo != null) { PortalInfo info = agol.PortalInfo; if (!string.IsNullOrEmpty(info.PortalName) && info.PortalName != Strings.ArcGISPortalDefaultName && info.PortalName != Strings.ArcGISOnline) { portalName = info.PortalName; // PortalName property takes precedence } else if (!string.IsNullOrEmpty(info.Name) && info.Name != Strings.ArcGISPortalDefaultName && info.Name != Strings.ArcGISOnline) { portalName = info.Name; // Some instances store their instance name in the Name property } else if (!string.IsNullOrEmpty(info.PortalName)) { portalName = info.PortalName; } else if (!string.IsNullOrEmpty(info.Name)) { portalName = info.Name; } } viewModel.SignInLabel = string.Format(agolStrings.Get("SignInLabel"), portalName); } }
/// <summary> /// Signs into the application environment's current ArcGIS Online/Portal instance using the /// specified credential /// </summary> public static async Task SignInToPortal(IdentityManager.Credential cred, ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.ArcGISOnline agol = null) { ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.ArcGISOnline portal = agol ?? ArcGISOnlineEnvironment.ArcGISOnline; if (portal.User.Current != null && !string.IsNullOrEmpty(portal.User.Current.FullName)) { return; // User is already signed in } await portal.User.InitializeTaskAsync(cred.UserName, cred.Token); if (MapApplication.Current != null && MapApplication.Current.Portal != null) { MapApplication.Current.Portal.Token = cred.Token; await MapApplication.Current.Portal.InitializeTaskAsync(); } }
public static void LoadConfig(string sharing, string secure, string proxy, bool useCachedSignIn = true, bool forceBrowserAuth = false, bool signOutCurrentUser = true) { ConfigurationUrls.Sharing = sharing; ConfigurationUrls.Secure = secure; ConfigurationUrls.ProxyServer = proxy; ConfigurationUrls.ProxyServerEncoded = proxy; ArcGISOnline.Initialize(ArcGISOnlineEnvironment.ConfigurationUrls.Sharing, ArcGISOnlineEnvironment.ConfigurationUrls.Secure, forceBrowserAuth, signOutCurrentUser); if (useCachedSignIn) { ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.ArcGISOnlineEnvironment.ArcGISOnline.User.SignInFromLocalStorage(null); } else { ArcGISOnlineEnvironment.ArcGISOnline.User.DeleteTokenFromStorage(); } LoadedConfig = true; }
public static void LoadConfig(XElement configuration, EventHandler callback) { ConfigurationUrls.Sharing = getElementValue(configuration.Element("Sharing")); ConfigurationUrls.Secure = getElementValue(configuration.Element("Secure")); ConfigurationUrls.ProxyServer = getElementValue(configuration.Element("ProxyServer")); ConfigurationUrls.ProxyServerEncoded = getElementValue(configuration.Element("ProxyServerEncoded")); if (string.IsNullOrEmpty(ConfigurationUrls.ProxyServerEncoded) && !string.IsNullOrEmpty(ConfigurationUrls.ProxyServer)) { ConfigurationUrls.ProxyServerEncoded = ConfigurationUrls.ProxyServer; } else if (string.IsNullOrEmpty(ConfigurationUrls.ProxyServer) && !string.IsNullOrEmpty(ConfigurationUrls.ProxyServerEncoded)) { ConfigurationUrls.ProxyServer = ConfigurationUrls.ProxyServerEncoded; } ArcGISOnline.Initialize(ArcGISOnlineEnvironment.ConfigurationUrls.Sharing, ArcGISOnlineEnvironment.ConfigurationUrls.Secure); ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.ArcGISOnlineEnvironment.ArcGISOnline.User.SignInFromLocalStorage(null); LoadedConfig = true; if (callback != null) { callback(null, EventArgs.Empty); } }
public AGOLUser(ArcGISOnline agol) { _agol = agol; }
private void initializeAgolFromDocument(ESRI.ArcGIS.Client.WebMap.Document doc, Action<ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.ArcGISOnline> callback) { if (doc == null || callback == null) return; ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.ArcGISOnline agol = new ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.ArcGISOnline(); string baseUrl = doc.ServerBaseUrl; string webMapSharingUrl = baseUrl.EndsWith("content", StringComparison.OrdinalIgnoreCase) ? baseUrl.Substring(0, baseUrl.Length - 7) : baseUrl; string webMapSharingUrlSecure = webMapSharingUrl; // Initalize SSL and non-SSL sharing Urls if (webMapSharingUrl.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) webMapSharingUrl = webMapSharingUrl.ToLower().Replace("https://", "http://"); else if (webMapSharingUrl.StartsWith("http://", StringComparison.OrdinalIgnoreCase)) webMapSharingUrlSecure = webMapSharingUrlSecure.ToLower().Replace("http://", "https://"); agol.Initialized += (o, e) => { callback(agol); }; agol.Initialize(webMapSharingUrl, webMapSharingUrlSecure); }
public AGOLGroup(ArcGISOnline agol) { _agol = agol; }
public AGOLContent(ArcGISOnline agol) { _agol = agol; }