public void ValidateSettings() { if (!PublishToPanorama) { return; } if (string.IsNullOrWhiteSpace(PanoramaServerUrl)) { throw new ArgumentException("Please specify a Panorama server URL."); } try { PanoramaServerUri = new Uri(PanoramaUtil.ServerNameToUrl(PanoramaServerUrl)); } catch (UriFormatException) { throw new ArgumentException("Panorama server name is invalid."); } if (string.IsNullOrWhiteSpace(PanoramaUserEmail)) { throw new ArgumentException("Please specify a Panorama login email."); } if (string.IsNullOrWhiteSpace(PanoramaPassword)) { throw new ArgumentException("Please specify a Panorama user password."); } if (string.IsNullOrWhiteSpace(PanoramaFolder)) { throw new ArgumentException("Please specify a folder on the Panorama server."); } // Verify that we can connect to the given Panorama server with the user's credentials. var panoramaClient = new WebPanoramaClient(PanoramaServerUri); try { PanoramaUtil.VerifyServerInformation(panoramaClient, PanoramaUserEmail, PanoramaPassword); PanoramaServerUri = panoramaClient.ServerUri ?? PanoramaServerUri; PanoramaServerUrl = PanoramaServerUri.AbsoluteUri; } catch (Exception ex) { throw new ArgumentException(ex.Message); } try { PanoramaUtil.VerifyFolder(panoramaClient, new Server(PanoramaServerUri, PanoramaUserEmail, PanoramaPassword), PanoramaFolder); } catch (Exception ex) { throw new ArgumentException(ex.Message); } }
public override bool ValidateSettings() { var panoramaSettingsUI = _appControl.GetUIPanoramaSettings(); if (!panoramaSettingsUI.PublishToPanorama) { LogOutput("Will NOT publish Skyline documents to Panorama."); Settings.PublishToPanorama = false; return(true); } LogOutput("Validating Panorama settings..."); var error = false; var panoramaUrl = panoramaSettingsUI.PanoramaServerUrl; Uri serverUri = null; if (string.IsNullOrWhiteSpace(panoramaUrl)) { LogErrorOutput("Please specify a Panorama server URL."); error = true; } else { try { serverUri = new Uri(PanoramaUtil.ServerNameToUrl(panoramaUrl)); } catch (UriFormatException) { LogError("Panorama server name is invalid."); return(false); } } var panoramaEmail = panoramaSettingsUI.PanoramaUserEmail; var panoramaPasswd = panoramaSettingsUI.PanoramaPassword; var panoramaFolder = panoramaSettingsUI.PanoramaFolder; if (string.IsNullOrWhiteSpace(panoramaEmail)) { LogErrorOutput("Please specify a Panorama login name."); error = true; } if (string.IsNullOrWhiteSpace(panoramaPasswd)) { LogErrorOutput("Please specify a Panorama user password."); error = true; } else { if (!panoramaPasswd.Equals(Settings.PanoramaPassword)) { // Encrypt the password try { panoramaPasswd = EncryptPassword(panoramaPasswd); panoramaSettingsUI.PanoramaPassword = panoramaPasswd; } catch (ObjectDisposedException) { } } } if (string.IsNullOrWhiteSpace(panoramaFolder)) { LogErrorOutput("Please specify a folder on the Panorama server."); error = true; } if (error) { return(false); } // Verify that we can connect to the given Panorama server with the user's credentials. var panoramaClient = new WebPanoramaClient(serverUri); try { PanoramaUtil.VerifyServerInformation(panoramaClient, serverUri, panoramaEmail, DecryptPassword(panoramaPasswd)); } catch (Exception ex) { LogErrorOutput(ex.Message); return(false); } try { PanoramaUtil.VerifyFolder(panoramaClient, new Server(serverUri, panoramaEmail, DecryptPassword(panoramaPasswd)), panoramaFolder); } catch (Exception ex) { LogErrorOutput(ex.Message); return(false); } PanoramaServerUri = serverUri; Settings = panoramaSettingsUI; return(true); }