Example #1
0
        /// <summary>
        /// Return a representation of a JIRA project identified by the string key. ie. NET
        /// </summary>
        public RemoteProject getProjectByKey(string projectKey)
        {
            JiraSoapServiceService service = getServiceEndPoint();
            string token = service.login(_username, _password);

            return(service.getProjectByKey(token, projectKey));
        }
Example #2
0
        private static JiraSoapServiceService GetWSProxy(string url, string port)
        {
            JiraSoapServiceService proxy = new JiraSoapServiceService();

            proxy.Url = url + ":" + port + "/rpc/soap/jirasoapservice-v2";
            return(proxy);
        }
        public SoapSession(string url, Action <WebResponse> webResponseHandler)
        {
            service = new JiraSoapServiceService(url + "/rpc/soap/jirasoapservice-v2", webResponseHandler);
//            service.Url = url + "/rpc/soap/jirasoapservice-v2";
            service.Timeout = 10000;
            service.Proxy   = null;
        }
Example #4
0
        private void doStuff(string user, string pwd)
        {
            string txt = "successfully invoked login/logout at ";

            try {
                JiraSoapServiceService s = new JiraSoapServiceService();
                s.Url     = "https://studio.atlassian.com//rpc/soap/jirasoapservice-v2";
                s.Timeout = 2000;
                string token = s.login(user, pwd);
                s.logout(token);
            } catch (Exception e) {
                txt = "caught exception " + e.Message + " at ";
            }

            try {
                Invoke(new MethodInvoker(delegate {
                    textLog.Text = txt + DateTime.Now.ToLongTimeString() + "\r\n" + textLog.Text;
                    if (inProgress)
                    {
                        t.Start();
                    }
                }));
            } catch {
            }
        }
Example #5
0
        private void createService()
        {
            if (jira != null)
            {
                jira.Dispose();
            }
            string url = config.Url;

            if (!url.EndsWith("wsdl"))
            {
                url = config.Url + "/rpc/soap/jirasoapservice-v2?wsdl";
            }
            if (!suppressBackgroundForm)
            {
                new PleaseWaitForm().ShowAndWait("Jira plug-in", Language.GetString("jira", LangKey.communication_wait),
                                                 delegate() {
                    jira = new JiraSoapServiceService();
                }
                                                 );
            }
            else
            {
                jira = new JiraSoapServiceService();
            }
            jira.Url = url;

            jira.Proxy = NetworkHelper.CreateProxy(new Uri(url));
            // Do not use:
            //jira.AllowAutoRedirect = true;
            jira.UserAgent = "Greenshot";
        }
Example #6
0
        protected override Yield Start(XDoc config, Result result)
        {
            yield return(Coroutine.Invoke(base.Start, config, new Result()));

            // read configuration settings
            _username = config["username"].AsText;
            if (string.IsNullOrEmpty(_username))
            {
                throw new ArgumentException(MISSING_FIELD_ERROR, "username");
            }
            _password = config["password"].AsText;
            if (string.IsNullOrEmpty(_password))
            {
                throw new ArgumentException(MISSING_FIELD_ERROR, "password");
            }
            _uri = config["jira-uri"].AsUri;
            if (_uri == null)
            {
                throw new ArgumentException(MISSING_FIELD_ERROR, "jira-uri");
            }

            _jiraTokenDuration = TimeSpan.FromMinutes(config["jira-session-timeout-mins"].AsInt ?? DEFAULT_LOGIN_TTL);

            // initialize web-service
            _jira     = new JiraSoapServiceService();
            _jira.Url = _uri.At("rpc", "soap", "jirasoapservice-v2").ToString();
            result.Return();
        }
Example #7
0
        /// <summary>
        /// Get the available statuses for the given JIRA install
        /// </summary>
        public IList <RemoteStatus> getStatuses()
        {
            JiraSoapServiceService service = getServiceEndPoint();
            string token = service.login(_username, _password);

            return(new List <RemoteStatus>(service.getStatuses(token)));
        }
Example #8
0
        private JiraSoapServiceService getServiceEndPoint()
        {
            JiraSoapServiceService service = new JiraSoapServiceService();

            service.Url = _baseUrl + "/rpc/soap/jirasoapservice-v2";
            return(service);
        }
 private void InitJiraToken()
 {
     jira = new JiraSoapServiceService {
         Url = Settings.Default.SoapURL
     };
     ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
 }
Example #10
0
        Atlassian.Jira.Jira jira;       // This is the object that interfaces with the atlassian.net-sdk library.

        public JiraConnection(string url, string userName, string password, Converter <string, string> settings)
        {
            Log.Verbose("Creating a new connection");
            _rootUrl = url.TrimEnd('\\', '/');
            int offset = _rootUrl.LastIndexOf("/rpc/soap/jirasoapservice-v2");

            if (offset > 0)
            {
                _rootUrl = _rootUrl.Substring(0, offset);
            }

            Log.Info("Root Url: {0}", _rootUrl);
            _settings    = settings;
            _knownUsers  = new Dictionary <string, JiraUser>(StringComparer.OrdinalIgnoreCase);
            _lookupUsers = StringComparer.OrdinalIgnoreCase.Equals(settings("resolveUserNames"), "true");
            Log.Info("LookUp Users: {0}", _lookupUsers);

            LoadUsers();
            _statuses = new Dictionary <string, JiraStatus>(StringComparer.Ordinal);

            _userName = userName;
            _password = password;
            Log.Verbose("Creating a new internal Soap Service");
            _service = new JiraSoapServiceService();
            Log.Verbose("Service Created");
//          _service.Url = _rootUrl + "/rpc/soap/jirasoapservice-v2";
            _service.UseDefaultCredentials = true;
            if (!String.IsNullOrEmpty(settings("jira:proxyurl")))
            {
                System.Net.ICredentials proxyAuth = System.Net.CredentialCache.DefaultCredentials;
                UriBuilder proxyuri = new UriBuilder(settings("jira:proxyurl"));
                if (!String.IsNullOrEmpty(proxyuri.UserName))
                {
                    proxyAuth         = new System.Net.NetworkCredential(proxyuri.UserName, proxyuri.Password);
                    proxyuri.Password = proxyuri.UserName = String.Empty;
                }
                _service.Proxy             = new System.Net.WebProxy(proxyuri.Uri);
                _service.Proxy.Credentials = proxyAuth;
            }

            _token = null;

            Log.Verbose("Connecting...");
            Connect();
            Log.Verbose("Connection Successfull");
            _currentUser = GetUser(_userName);

            Log.Verbose("Getting Statuses");
            //	foreach (RemoteStatus rs in _service.getStatuses(_token))
            foreach (IssueStatus status in jira.GetIssueStatuses())
            {// Convert IssueStatus to RemoteStatus
                RemoteStatus rs = new RemoteStatus {
                    id = status.Id, name = status.Name
                };
                _statuses[rs.id] = new JiraStatus(rs);
            }
            Log.Verbose("JiraConnection(): _statuses.Count = {0}", _statuses.Count);
            Log.Verbose("Finished creating a new connection");
        }
Example #11
0
 private static void LogOut(JiraSoapServiceService service, string token)
 {
     try
     {
         service.logout(token);
     }
     catch
     {
     }
 }
Example #12
0
        protected override Yield Stop(Result result)
        {
            // clear settings
            _password = null;
            _username = null;
            _jira     = null;
            yield return(Coroutine.Invoke(base.Stop, new Result()));

            result.Return();
        }
Example #13
0
        /// <summary>
        /// Invoke Configure to setup the JIRA connection. This method must be invoked before creating issues via <see cref="IssueBuilder"/>.
        /// </summary>
        /// <param name="url">The URL of the JIRA SOAP service. E.g. https://your-jira-site.com</param>
        /// <param name="username">The username of the user to log into JIRA with.</param>
        /// <param name="password">The password of the user to log into JIRA with.</param>
        public static void Configure(string url, string username, string password)
        {
            _url      = url;
            _username = username;
            _password = password;

            BrowseIssueUrl = url.EnsureTrailing("/") + "browse/";

            _isConfigured = true;
            Service       = new JiraSoapServiceService {
                Url = url.EnsureTrailing("/") + SoapServiceUrl
            };
            Log.DebugFormat("JIRA was configured with url, username, password: '******', '{1}', '{2}'", _url, _username, _password.Mask());
        }
Example #14
0
        protected virtual void Dispose(bool disposing)
        {
            if (jira != null)
            {
                logout();
            }

            if (disposing)
            {
                if (jira != null)
                {
                    jira.Dispose();
                    jira = null;
                }
            }
        }
Example #15
0
        public JiraConnection(string url, string userName, string password, Converter <string, string> settings)
        {
            _rootUrl = url.TrimEnd('\\', '/');
            int offset = _rootUrl.LastIndexOf("/rpc/soap/jirasoapservice-v2");

            if (offset > 0)
            {
                _rootUrl = _rootUrl.Substring(0, offset);
            }

            _settings    = settings;
            _knownUsers  = new Dictionary <string, JiraUser>(StringComparer.OrdinalIgnoreCase);
            _lookupUsers = StringComparer.OrdinalIgnoreCase.Equals(settings("resolveUserNames"), "true");
            LoadUsers();
            _statuses = new Dictionary <string, JiraStatus>(StringComparer.Ordinal);

            _userName    = userName;
            _password    = password;
            _service     = new CSharpTest.Net.SvnJiraIntegration.Jira.JiraSoapServiceService();
            _service.Url = _rootUrl + "/rpc/soap/jirasoapservice-v2";
            _service.UseDefaultCredentials = true;
            if (!String.IsNullOrEmpty(settings("jira:proxyurl")))
            {
                System.Net.ICredentials proxyAuth = System.Net.CredentialCache.DefaultCredentials;
                UriBuilder proxyuri = new UriBuilder(settings("jira:proxyurl"));
                if (!String.IsNullOrEmpty(proxyuri.UserName))
                {
                    proxyAuth         = new System.Net.NetworkCredential(proxyuri.UserName, proxyuri.Password);
                    proxyuri.Password = proxyuri.UserName = String.Empty;
                }
                _service.Proxy             = new System.Net.WebProxy(proxyuri.Uri);
                _service.Proxy.Credentials = proxyAuth;
            }

            _token = null;

            Connect();
            _currentUser = GetUser(_userName);

            foreach (RemoteStatus rs in _service.getStatuses(_token))
            {
                _statuses[rs.id] = new JiraStatus(rs);
            }
        }
Example #16
0
 private void createService()
 {
     if (!suppressBackgroundForm)
     {
         new PleaseWaitForm().ShowAndWait(JiraPlugin.Instance.JiraPluginAttributes.Name, Language.GetString("jira", LangKey.communication_wait),
                                          delegate() {
             jira = new JiraSoapServiceService();
         }
                                          );
     }
     else
     {
         jira = new JiraSoapServiceService();
     }
     jira.Url   = url;
     jira.Proxy = NetworkHelper.CreateProxy(new Uri(url));
     // Do not use:
     //jira.AllowAutoRedirect = true;
     jira.UserAgent = "Greenshot";
 }
Example #17
0
 private RemoteIssue GetIssue(JiraSoapServiceService jss, string token, string jiraId)
 {
     if (loadedJiraItems.ContainsKey(jiraId))
     {
         return((RemoteIssue)(loadedJiraItems[jiraId]));
     }
     else
     {
         try
         {
             RemoteIssue issue = jss.getIssue(token, jiraId);
             loadedJiraItems[jiraId] = issue;
             return(issue);
         }
         catch (Exception exp)
         {
             rp("Loading Jira issue failed..." + exp.Message);
             return(null);
         }
     }
 }
Example #18
0
        private void jiraUploadBySoapWithToken()
        {
            try {
                JiraSoapServiceService service = new JiraSoapServiceService {
                    Url = serverUrl + "/rpc/soap/jirasoapservice-v2"
                };

                string[] fileNames = new[] { name };
                byte[]   bytes     = File.ReadAllBytes(path);

                service.addBase64EncodedAttachmentsToIssue(token, issueKey, fileNames, new[] { Convert.ToBase64String(bytes) });
                if (!string.IsNullOrEmpty(comment) && comment.Trim().Length > 0)
                {
                    RemoteComment c = new RemoteComment {
                        body = comment
                    };
                    service.addComment(token, issueKey, c);
                }

                Invoke(new MethodInvoker(delegate
                {
                    uploadLog.Text += "Done. See " + serverUrl + "/browse/" + issueKey + "\r\n";
                }));
            } catch (Exception e) {
                Debug.Write(e.StackTrace);
                Invoke(new MethodInvoker(delegate
                {
                    uploadLog.Text += "Failed: " + e.Message + "\r\n";
                }));
            }

            done = true;

            Invoke(new MethodInvoker(delegate
            {
                saveLastUsed();
                buttonCancel.Enabled = true;
                buttonCancel.Text    = "Close";
            }));
        }
        public void TestJIRAWebService() {
            JiraSoapServiceService jiraSoapService = new JiraSoapServiceService();
            //Asi cambiaria dinamicamente la URL del web service
            //jiraSoapService.Url = "http://jira.atlassian.com/rpc/soap/jirasoapservice-v2";

            
            String token = jiraSoapService.login("testjconn", "testjconn");
            //String token = jiraSoapService.login("soaptester", "soaptester");
            
            string[] projects = new string[1];
            projects[0] = "SACTA";
           
            //Esto trae todos los issues de Sacta
            RemoteIssue[] issuesFromTextSearch = jiraSoapService.getIssuesFromTextSearchWithProject(token, projects, "", 100);

            //foreach (RemoteIssue r in issuesFromTextSearch)
            //{
            //    //Hacer algo
            //}

            Assert.IsTrue(issuesFromTextSearch.Length > 0);
        }
        public void TestJIRAWebService()
        {
            JiraSoapServiceService jiraSoapService = new JiraSoapServiceService();
            //Asi cambiaria dinamicamente la URL del web service
            //jiraSoapService.Url = "http://jira.atlassian.com/rpc/soap/jirasoapservice-v2";


            String token = jiraSoapService.login("testjconn", "testjconn");

            //String token = jiraSoapService.login("soaptester", "soaptester");

            string[] projects = new string[1];
            projects[0] = "SACTA";

            //Esto trae todos los issues de Sacta
            RemoteIssue[] issuesFromTextSearch = jiraSoapService.getIssuesFromTextSearchWithProject(token, projects, "", 100);

            //foreach (RemoteIssue r in issuesFromTextSearch)
            //{
            //    //Hacer algo
            //}

            Assert.IsTrue(issuesFromTextSearch.Length > 0);
        }
        /// <summary>
        /// Authenticates a user in a JIRA Server instance, generating an authentication token
        /// that is saved for future calls between JiraConnector and the server.
        /// </summary>
        /// <param name="url">The URL of the JIRA Server Instance</param>
        /// <param name="port">The corresponding port</param>
        /// <param name="username">The username to authenticate</param>
        /// <param name="password">The password corresponding to the user</param>
        public void AuthenticateUser(string url, string port, string username, string password)
        {
            JiraSoapServiceService proxy = JiraSoapHelper.GetJiraSoapServiceProxy(url, port);

            this.authenticationToken = proxy.login(username, password);
        }
Example #22
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                CommentCount = 1;

                rp("Logging in into Crucible...");

                Stream auth = getHttpStream(
                    String.Format(Properties.Settings.Default.CrucibleLoginUrl, Properties.Settings.Default.CrucibleUserName,
                                  Properties.Settings.Default.CruciblePassword));
                XmlSerializer asr = new XmlSerializer(typeof(loginResult));
                loginResult   lr  = (loginResult)asr.Deserialize(auth);

                rp("Login complete...");

                rp("Fetching reviews...");
                Stream rvs = getHttpStream(String.Format(Properties.Settings.Default.CrucibleReviewsUrl,
                                                         Properties.Settings.Default.CrucibleProject, lr.token));

                XmlSerializer rsr     = new XmlSerializer(typeof(reviews));
                reviews       reviews = (reviews)rsr.Deserialize(rvs);

                rp("Opening Excel...");

                Excel.Application oXL      = new Excel.Application();
                Excel.Workbook    workBook = oXL.Workbooks.Add(System.Reflection.Missing.Value);

                rp("Preparing the workbook...");

                PrepareExcelWorkbook(workBook);
                Excel.Worksheet workSheet = (Excel.Worksheet)workBook.Sheets[1];

                rp("Logging in into Jira...");
                JiraSoapServiceService jss = new JiraSoapServiceService();

                string token = jss.login(Properties.Settings.Default.CrucibleUserName,
                                         Properties.Settings.Default.CruciblePassword);

                rp("Loading Jira versions");
                foreach (RemoteVersion ver in jss.getVersions(token, Properties.Settings.Default.JiraProjectName))
                {
                    revHash[ver.id] = ver.name;
                    log(String.Format("Adding [{0}] : [{1}] to hash", ver.name, ver.id));
                }

                rp("Populating data into workbook...");
                int rowIndex = 2;

                foreach (reviewData rv in reviews.reviewData)
                {
                    if (
                        (Properties.Settings.Default.CrucibleFetchAllReviews == false) &&
                        (rv.state != state.Closed)
                        )
                    {
                        log("Incomplete review, skipping " + rv.permaId.id);
                        continue;
                    }
                    else
                    {
                        rp("Processing " + rv.permaId.id);

                        Stream cms = getHttpStream(String.Format(Properties.Settings.Default.CrucibleCommentUrl, rv.permaId.id, lr.token));

                        XmlSerializer cmr       = new XmlSerializer(typeof(comments));
                        comments      rcomments = (comments)cmr.Deserialize(cms);
                        if (rcomments.Any != null)
                        {
                            foreach (System.Xml.XmlElement elem in rcomments.Any)
                            {
                                XmlSerializer            vlcdr = new XmlSerializer(typeof(versionedLineCommentData));
                                versionedLineCommentData vlcd  = (versionedLineCommentData)vlcdr.Deserialize(new StringReader(
                                                                                                                 decorate(elem.InnerXml, "versionedLineCommentData")));
                                WriteExcelRow(workSheet, rowIndex, rv, vlcd, jss, token);
                                rowIndex++;
                            }
                        }
                        else
                        {
                            rp("Skipping " + rv.permaId.id + ". No review comments detected.");
                        }
                    }
                }
                oXL.Visible     = true;
                oXL.UserControl = true;
            }
            catch (Exception exp)
            {
                rp("Sorry, exception occured, after all this is software and there is no CI for this :)\r\n" +
                   exp.Message + "\r\n" + exp.StackTrace);
            }
            rp("Completed...");
        }
Example #23
0
        private void WriteExcelRow(Excel.Worksheet oSheet, int index, reviewData rv, versionedLineCommentData vlcd,
                                   JiraSoapServiceService jss, string token)
        {
            int column = 1;

            rp(String.Format("[{0}] Processing comment [{1}] from [{2}]", CommentCount,
                             vlcd.permaId.id, vlcd.user.displayName));
            CommentCount++;

            Excel.Range rng = (Excel.Range)(oSheet.Cells[index, 1]);
            rng.EntireRow.Font.Size = 9;
            rng.EntireRow.WrapText  = true;

            oSheet.Cells[index, column++] = rv.author.userName;
            oSheet.Cells[index, column++] = rv.author.displayName;
            oSheet.Cells[index, column++] = bf(rv.closeDate);
            oSheet.Cells[index, column++] = bf(rv.createDate);
            oSheet.Cells[index, column++] = rv.creator.userName;
            oSheet.Cells[index, column++] = rv.creator.displayName;
            oSheet.Cells[index, column++] = rv.description;
            oSheet.Cells[index, column++] = bf(rv.dueDate);
            oSheet.Cells[index, column++] = rv.jiraIssueKey;
            if (rv.jiraIssueKey != null && rv.jiraIssueKey != "")
            {
                RemoteIssue issue = GetIssue(jss, token, rv.jiraIssueKey);
                oSheet.Cells[index, column++] = verToString(issue.affectsVersions);
                oSheet.Cells[index, column++] = GetCvValue(issue, Properties.Settings.Default.JiraAddlCustomField);
            }
            else
            {
                column++;
                column++;
            }
            oSheet.Cells[index, column++] = rv.moderator.userName;
            oSheet.Cells[index, column++] = rv.moderator.displayName;
            oSheet.Cells[index, column++] = rv.name;
            oSheet.Cells[index, column++] = rv.permaId.id;
            oSheet.Cells[index, column++] = rv.projectKey;
            oSheet.Cells[index, column++] = rv.state.ToString();
            oSheet.Cells[index, column++] = rv.summary;
            oSheet.Cells[index, column++] = vlcd.fromLineRange;
            oSheet.Cells[index, column++] = vlcd.toLineRange;
            if (vlcd.lineRanges != null)
            {
                string lineRanges = "";
                foreach (lineRangeDetail lr in vlcd.lineRanges)
                {
                    lineRanges += lr.revision + "-" + lr.range + "\r\n";
                }
                oSheet.Cells[index, column++] = lineRanges;
            }
            else
            {
                column++;
            }
            oSheet.Cells[index, column++] = bf(vlcd.createDate);
            oSheet.Cells[index, column++] = Convert.ToString(vlcd.defectRaised);
            oSheet.Cells[index, column++] = Convert.ToString(vlcd.deleted);
            oSheet.Cells[index, column++] = Convert.ToString(vlcd.draft);
            oSheet.Cells[index, column++] = Convert.ToString(vlcd.message);
            oSheet.Cells[index, column++] = vlcd.user.userName;
            oSheet.Cells[index, column++] = vlcd.user.displayName;
            accepted = false;
            if (vlcd.replies.Any != null)
            {
                oSheet.Cells[index, column++] = ProcessReplies(vlcd.replies.Any, 1);
            }
            else
            {
                column++;
            }

            oSheet.Cells[index, column++] = Convert.ToString(accepted);
        }
Example #24
0
        private void jiraUploadByPost()
        {
            try {
                JiraSoapServiceService service = new JiraSoapServiceService {
                    Url = serverUrl + "/rpc/soap/jirasoapservice-v2"
                };
                string tok = null;

                if (issueId == null)
                {
                    tok = service.login(userLogin, userPassword);

                    RemoteIssue issue = service.getIssue(tok, issueKey);
                    issueId = issue.id;
                }

                FileStream fs   = new FileStream(path, FileMode.Open, FileAccess.Read);
                byte[]     data = new byte[fs.Length];
                fs.Read(data, 0, data.Length);
                fs.Close();

                Dictionary <string, object> postParameters = new Dictionary <string, object>
                {
                    { "filename.1", new FormUpload.FileParameter(data, name, getMimeType(name)) },
                };

                const string userAgent = "Mazio";

                string postUrl =
                    serverUrl + "/secure/AttachFile.jspa?id=" + issueId
                    + (jSessionId == null
                        ? ("&os_username="******"&os_password="******"");

                HttpWebResponse webResponse;
                if (jSessionId != null)
                {
                    Cookie cookie = new Cookie("JSESSIONID", jSessionId, "/jira", serverUrl.Substring(0, serverUrl.LastIndexOf("/")));
                    webResponse = FormUpload.MultipartFormDataPost(postUrl, userAgent, postParameters, cookie);
                }
                else
                {
                    webResponse = FormUpload.MultipartFormDataPost(postUrl, userAgent, postParameters);
                }

                StreamReader responseReader = new StreamReader(webResponse.GetResponseStream());
#pragma warning disable 168
                string result = responseReader.ReadToEnd();
#pragma warning restore 168
                webResponse.Close();

                if (token != null && !string.IsNullOrEmpty(comment))
                {
                    service.addComment(tok, issueKey, new RemoteComment {
                        body = comment
                    });
                }

                Invoke(new MethodInvoker(delegate { uploadLog.Text += "Done. See " + serverUrl + "/browse/" + issueKey + "\r\n"; }));
            } catch (Exception e) {
                Debug.Write(e.StackTrace);
                Invoke(new MethodInvoker(delegate { uploadLog.Text += "Failed: " + e.Message + "\r\n"; }));
            }
            done = true;

            Invoke(new MethodInvoker(delegate {
                saveLastUsed();
                buttonCancel.Enabled = true;
                buttonCancel.Text    = "Close";
            }));
        }
 private void InitJiraToken() {
     jira = new JiraSoapServiceService { Url = Settings.Default.SoapURL };
     ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
 }
 private static JiraSoapServiceService GetWSProxy(string url, string port) {
     JiraSoapServiceService proxy = new JiraSoapServiceService();
     proxy.Url = url + ":" + port + "/rpc/soap/jirasoapservice-v2";
     return proxy;
 }