private void Connect() { var settings = VersionOneSettings.FromXmlElement(configuration); var connector = V1Connector .WithInstanceUrl(settings.Url) .WithUserAgentHeader("VersionOne.Integration.Bugzilla", Assembly.GetEntryAssembly().GetName().Version.ToString()); ICanSetProxyOrEndpointOrGetConnector connectorWithAuth; switch (settings.AuthenticationType) { case AuthenticationTypes.AccessToken: connectorWithAuth = connector.WithAccessToken(settings.AccessToken); break; default: throw new Exception("Invalid authentication type"); } if (settings.ProxySettings.Enabled) { connectorWithAuth.WithProxy( new ProxyProvider(new Uri(settings.ProxySettings.Url), settings.ProxySettings.Username, settings.ProxySettings.Password, settings.ProxySettings.Domain)); } services = new Services(connectorWithAuth.UseOAuthEndpoints().Build()); queryBuilder.Setup(services); }
public V1Component(VersionOneSettings settings) { Settings = settings; var nativeSettings = ConvertSettings(settings); processor = new VersionOneProcessor(nativeSettings, new BlackholeLogger()); AddProperties(); }
private void btnTestV1Connection_Click(object sender, EventArgs e) { V1StatusLabel.ForeColor = Color.Black; V1StatusLabel.Text = "Connecting to " + V1URLTB.Text + "..."; V1StatusLabel.Refresh(); try { Cursor.Current = Cursors.WaitCursor; var versionOneSettings = new VersionOneSettings() { Path = V1URLTB.Text, Username = V1UsernameTB.Text, Password = V1PasswordTB.Text, Integrated = UseIntegratedAuthenticationCB.Checked, ProxySettings = GetProxySettings() }; var v1Component = new V1Component(versionOneSettings); var connectionStatus = v1Component.ValidateConnection(); DisplayConnectionValidationStatus(connectionStatus); } catch (Exception ex) { DisplayConnectionValidationStatus(false, ex.Message); } finally { Cursor.Current = Cursors.Default; } }
public void Connect(VersionOneSettings settings) { var path = settings.Path; var username = settings.Username; var password = settings.Password; var integrated = settings.Integrated; var proxy = GetProxy(settings.ProxySettings); VersionOneSettings = settings; if (VersionOneSettings.OAuth2) { var storage = OAuth2Client.Storage.JsonFileStorage.Default; var metaConnector = new V1OAuth2APIConnector(path + MetaUrlSuffix, storage, proxy); MetaModel = new MetaModel(metaConnector); var localizerConnector = new V1OAuth2APIConnector(path + LocalizerUrlSuffix, storage, proxy); Localizer = new Localizer(localizerConnector); var dataConnector = new V1OAuth2APIConnector(path + DataUrlSuffix, storage, proxy); Services = new Services(MetaModel, dataConnector); } else { var metaConnector = new V1APIConnector(path + MetaUrlSuffix, username, password, integrated, proxy); MetaModel = new MetaModel(metaConnector); var localizerConnector = new V1APIConnector(path + LocalizerUrlSuffix, username, password, integrated, proxy); Localizer = new Localizer(localizerConnector); var dataConnector = new V1APIConnector(path + DataUrlSuffix, username, password, integrated, proxy); Services = new Services(MetaModel, dataConnector); } V1Configuration = LoadV1Configuration(); }
public void CheckConnection(VersionOneSettings settings) { try { connector.CheckConnection(settings); } catch (Exception ex) { logger.Error("Cannot connect to V1 server.", ex); throw new DataLayerException("Cannot connect to VersionOne server.", ex); } }
public void LogVersionOneConfiguration(LogMessage.SeverityType severity, XmlElement config) { try { var entity = VersionOneSettings.FromXmlElement(config); Log(severity, " VersionOne URL: " + entity.Url); Log(severity, string.Format(" Using proxy server: {0}, Authentication type: {1}", entity.ProxySettings != null && entity.ProxySettings.Enabled, entity.AuthenticationType)); } catch (Exception ex) { Log(LogMessage.SeverityType.Warning, "Failed to log VersionOne configuration data.", ex); } }
public bool ValidateIsAccessToken() { var settings = VersionOneSettings.FromXmlElement(configuration); if ((settings.AccessToken == null) || (settings.AccessToken == "")) { return(false); } return(true); }
public void TestFixtureSetUp() { var settings = new VersionOneSettings { Path = "http://integsrv01/VersionOne12/", Username = "******", Password = "******", ProxySettings = null }; component = new V1Component(settings); component.ValidateConnection(); }
public void CheckConnection(VersionOneSettings settings) { if (settings.OAuth2) { return; } else { var connectionValidator = new V1ConnectionValidator(settings.Path, settings.Username, settings.Password, settings.Integrated, GetProxy(settings.ProxySettings)); connectionValidator.Test(ApiVersion); } }
private bool Equals(VersionOneSettings other) { if (ReferenceEquals(null, other)) { return false; } if (ReferenceEquals(this, other)) { return true; } return other.Integrated.Equals(Integrated) && Equals(other.Path, Path) && Equals(other.Username, Username) && Equals(other.Password, Password) && Equals(other.ProxySettings, ProxySettings); }
private bool Equals(VersionOneSettings other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(other.Integrated.Equals(Integrated) && Equals(other.Path, Path) && Equals(other.Username, Username) && Equals(other.Password, Password) && Equals(other.ProxySettings, ProxySettings)); }
/// <summary> /// Default constructor of the package. /// Inside this method you can place any initialization code that does not require /// any Visual Studio service because at this point the package object is created but /// not sited yet inside Visual Studio environment. The place to do all the other /// initialization is the Initialize method. /// </summary> public V1Tracker() { ServiceLocator.Instance.SetContainer(new StandardKernel()); dataLayer = new ApiDataLayer(); RegisterComponents(); var cfg = ServiceLocator.Instance.Get <Configuration>(); var settings = ServiceLocator.Instance.Get <ISettings>(); var eventDispatcher = ServiceLocator.Instance.Get <IEventDispatcher>(); var loggerFactory = ServiceLocator.Instance.Get <ILoggerFactory>(); loggerFactory.MinLogLevel = settings.MinLogLevel; var logger = loggerFactory.GetLogger("V1Tracker"); try { //Setup DataLayer dataLayer.LoggerFactory = loggerFactory; dataLayer.ApiVersion = cfg.APIVersion; AddProperties(cfg); dataLayer.CurrentProjectId = settings.SelectedProjectId; dataLayer.ShowAllTasks = !settings.ShowMyTasks; var versionOneSettings = new VersionOneSettings { Path = settings.ApplicationUrl, Username = settings.Username, Password = settings.Password, Integrated = settings.IntegratedAuth, ProxySettings = { UseProxy = settings.UseProxy, Url = settings.ProxyUrl, Domain = settings.ProxyDomain, Username = settings.ProxyUsername, Password = settings.ProxyPassword } }; dataLayer.Connect(versionOneSettings); eventDispatcher.Notify(this, new ModelChangedArgs(EventReceiver.OptionsView, EventContext.V1SettingsChanged)); } catch (DataLayerException ex) { logger.Error("Error while loading V1Package: " + ex.Message, ex); } logger.Debug("Completed constructor execution."); }
public V1Component GetV1Component(VersionOneSettings settings) { if(component == null || DifferentSettingsRequired(settings)) { component = new V1Component(settings); if(!component.ValidateConnection()) { logger.Info("Failed to validate VersionOne connection"); throw new InvalidOperationException("Failed to validate VersionOne connection"); } logger.Info("Successfully connected to VersionOne."); } return component; }
private static VersionOneSettings CreateVersionOneSettings(ISettings settings) { var versionOneSettings = new VersionOneSettings { Path = settings.ApplicationUrl, Username = settings.Username, Password = settings.Password, Integrated = settings.IntegratedAuth, ProxySettings = { UseProxy = settings.UseProxy, Url = settings.ProxyUrl, Domain = settings.ProxyDomain, Username = settings.ProxyUsername, Password = settings.ProxyPassword } }; return(versionOneSettings); }
private V1Component GetV1Component() { var settings = new VersionOneSettings { Path = v1Url, Username = username, Password = password, Integrated = integratedAuthentication, ProxySettings = !useProxy ? null : new ProxyConnectionSettings { UseProxy = useProxy, Url = proxyUrl, Username = proxyUsername, Password = proxyPassword, Domain = proxyDomain, } }; return(container.GetV1Component(settings)); }
private void btnVerifyV1Connection_Click(object sender, EventArgs e) { if (ValidationRequested == null) { return; } var settings = new VersionOneSettings { ApplicationUrl = txtServerUrl.Text, AccessToken = txtAccessToken.Text, ProxySettings = new ProxyConnectionSettings { Enabled = chkUseProxy.Checked, Domain = txtProxyDomain.Text, UserName = txtProxyUsername.Text, Password = txtProxyPassword.Text, Uri = txtProxyUri.Text } }; ValidationRequested(this, new ConnectionValidationEventArgs(settings)); }
private void Connect() { var settings = VersionOneSettings.FromXmlElement(configuration); var connector = V1Connector .WithInstanceUrl(settings.Url) .WithUserAgentHeader("VersionOne.Integration.JIRASync", Assembly.GetEntryAssembly().GetName().Version.ToString()); ICanSetProxyOrEndpointOrGetConnector connectorWithAuth; connectorWithAuth = connector.WithAccessToken(settings.AccessToken); if (settings.ProxySettings.Enabled) { connectorWithAuth.WithProxy( new ProxyProvider( new Uri(settings.ProxySettings.Url), settings.ProxySettings.Username, settings.ProxySettings.Password, settings.ProxySettings.Domain)); } services = new Services(connectorWithAuth.UseOAuthEndpoints().Build()); queryBuilder.Setup(services); }
public void given_settings_are_being_converted() { context["when i convert VersionOneSettings to VersionOneProcessorSettings"] = () => { var source = new VersionOneSettings() { Integrated = false, Username = "******", Password = "******", Path = "//file/path", ProxySettings = new ProxyConnectionSettings() { Domain = "AD", Username = "******", Password = "******", Url = new Uri("http://localProxy:9999/"), ProxyIsEnabled = true } }; var destination = V1Component.ConvertSettings(source); it["then all settings are converted successfully"] = () => { destination.Url.should_be(source.Path); destination.Username.should_be(source.Username); destination.IntegratedAuth.should_be(source.Integrated); destination.Password.should_be(source.Password); destination.ProxySettings.Domain.should_be(source.ProxySettings.Domain); destination.ProxySettings.Enabled.should_be(source.ProxySettings.ProxyIsEnabled); destination.ProxySettings.Username.should_be(source.ProxySettings.Username); destination.ProxySettings.Password.should_be(source.ProxySettings.Password); destination.ProxySettings.Url.should_be(source.ProxySettings.Url.ToString()); }; }; }
public void given_settings_are_being_converted() { context["when i convert VersionOneSettings to VersionOneProcessorSettings"] = () => { var source = new VersionOneSettings() { Integrated = false, Username = "******", Password = "******", Path = "//file/path", ProxySettings = new ProxyConnectionSettings() { Domain = "AD", Username = "******", Password = "******", Uri = new Uri("http://localProxy:9999/"), ProxyIsEnabled = true } }; var destination = V1Component.ConvertSettings(source); it["then all settings are converted successfully"] = () => { destination.Url.should_be(source.Path); destination.Username.should_be(source.Username); destination.IntegratedAuth.should_be(source.Integrated); destination.Password.should_be(source.Password); destination.ProxySettings.Domain.should_be(source.ProxySettings.Domain); destination.ProxySettings.Enabled.should_be(source.ProxySettings.ProxyIsEnabled); destination.ProxySettings.Username.should_be(source.ProxySettings.Username); destination.ProxySettings.Password.should_be(source.ProxySettings.Password); destination.ProxySettings.Url.should_be(source.ProxySettings.Uri.ToString()); }; }; }
public bool Connect(VersionOneSettings settings) { connector.IsConnected = false; try { connector.Connect(settings); Types = new Dictionary <string, IAssetType>(5); ProjectType = GetAssetType(Entity.ProjectType); TaskType = GetAssetType(Entity.TaskType); TestType = GetAssetType(Entity.TestType); DefectType = GetAssetType(Entity.DefectType); StoryType = GetAssetType(Entity.StoryType); workitemType = connector.MetaModel.GetAssetType("Workitem"); primaryWorkitemType = connector.MetaModel.GetAssetType("PrimaryWorkitem"); InitEffortTracking(); MemberOid = connector.Services.LoggedIn; listPropertyValues = GetListPropertyValues(); requiredFieldsValidator = new RequiredFieldsValidator(connector.MetaModel, connector.Services, this); connector.IsConnected = true; return(true); } catch (MetaException ex) { Logger.Error("Cannot connect to V1 server.", ex); return(false); } catch (WebException ex) { connector.IsConnected = false; Logger.Error("Cannot connect to V1 server.", ex); return(false); } catch (Exception ex) { Logger.Error("Cannot connect to V1 server.", ex); return(false); } }
private VersionOneQuery GetVersionOneHelper() { var settings = new VersionOneSettings { Path = v1Url, Username = username, Password = password, Integrated = integratedAuthentication, ProxySettings = !useProxy ? null : new ProxyConnectionSettings { ProxyIsEnabled = useProxy, Uri = new Uri(proxyUrl), Username = proxyUsername, Password = proxyPassword, Domain = proxyDomain, } }; return versionOneHelper.GetVersionOneHelper(settings); }
/// <summary> /// Validate V1 connection settings. /// </summary> /// <param name="settings">settings for validation.</param> /// <returns>true, if validation succeeds.</returns> public bool IsVersionOneConnectionValid(VersionOneSettings settings) { //TODO remove this hack after changing V1Connector with ServerConnector return(V1Connector.Instance.ValidateConnection(settings)); }
private bool DifferentSettingsRequired(VersionOneSettings settings) { return component == null || !component.Settings.Equals(settings); }
public VersionOneProcessor(VersionOneSettings settings, ILogger logger) : this(settings.ToXmlElement(), logger) { }
private static VersionOneProcessorSettings ConvertSettings(VersionOneSettings settings) { return new VersionOneProcessorSettings { Url = settings.Path, Username = settings.Username, Password = settings.Password, IntegratedAuth = settings.Integrated, ProxySettings = settings.ProxySettings == null || !settings.ProxySettings.UseProxy ? null : new ProxySettings { Url = settings.ProxySettings.Url, Domain = settings.ProxySettings.Domain, Username = settings.ProxySettings.Username, Password = settings.ProxySettings.Password, Enabled = settings.ProxySettings.UseProxy, } }; }
public VersionOneProcessor(VersionOneSettings settings) : this(settings, null) { }