/// <summary> /// Internal login which catches the exceptions /// </summary> /// <returns>true if login was done sucessfully</returns> private bool doLogin(string user, string password, bool suppressBackgroundForm) { // This is what needs to be done ThreadStart jiraLogin = delegate { LOG.DebugFormat("Loggin in"); try { this.credentials = jira.login(user, password); } catch (Exception) { if (!url.EndsWith("wsdl")) { url = url + "/rpc/soap/jirasoapservice-v2?wsdl"; // recreate the service with the new url createService(); this.credentials = jira.login(user, password); // Worked, store the url in the configuration config.Url = url; IniConfig.Save(); } else { throw; } } LOG.DebugFormat("Logged in"); this.loggedInTime = DateTime.Now; this.loggedIn = true; }; // Here we do it try { if (!suppressBackgroundForm) { new PleaseWaitForm().ShowAndWait(JiraPlugin.Instance.JiraPluginAttributes.Name, Language.GetString("jira", LangKey.communication_wait), jiraLogin); } else { jiraLogin.Invoke(); } } catch (Exception e) { // check if auth failed if (e.Message.Contains(AUTH_FAILED_EXCEPTION_NAME)) { return(false); } // Not an authentication issue this.loggedIn = false; this.credentials = null; e.Data.Add("user", user); e.Data.Add("url", url); throw; } return(true); }
/// <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))); }
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 { } }
internal static string GetToken() { var token = Service.login(_username, _password); Log.DebugFormat("Service.login returned token: {0}", token.Mask()); return(token); }
/// <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)); }
private void InitializeService() { if (string.IsNullOrEmpty(_jiraToken) || new TimeSpan(DateTime.Now.Ticks - _jiraTokenTimestamp.Ticks) > _jiraTokenDuration) { _jiraToken = _jira.login(_username, _password); _jiraTokenTimestamp = DateTime.Now; } }
public string login(string userName, string password) { try { service.Credentials = new NetworkCredential(userName, password); Token = service.login(userName, password); return(Token); } catch (Exception e) { throw new LoginException(e); } }
public string login(string userName, string password) { try { service.Credentials = new NetworkCredential(CredentialUtils.getUserNameWithoutDomain(userName), password, CredentialUtils.getUserDomain(userName)); Token = service.login(CredentialUtils.getUserNameWithoutDomain(userName), password); return(Token); } catch (Exception e) { throw new LoginException(e); } }
private void Connect() { bool loginWasSuccessful = false; bool showLoginDialog = ShowLoginDialog; Utilities.UnprotectUserSettings(); InitJiraToken(); while (!loginWasSuccessful) { if (showLoginDialog) { frmLogin = new frmLogin(); PreSetJiraLoginData(); if (Settings.Default.UseProxy) { PreSetProxyLoginData(); } else { DisableProxyControls(); } if (frmLogin.ShowDialog() == DialogResult.Cancel) { Utilities.ProtectUserSettings(); Environment.Exit(0); } else { SaveCredentials(); } } try { InitProxy(); jiraToken = jira.login(userName, password); jira.Credentials = null; loginWasSuccessful = true; } catch (Exception e) { showLoginDialog = true; MessageBox.Show( "login failed for the following reason: " + "\r\n" + e.Message, "Error occured", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Utilities.ProtectUserSettings(); } } }
public void login(string userName, string password) { try { token = service.login(userName, password); } catch (Exception e) { throw new LoginException(e); } }
private void Connect() { try { if (!String.IsNullOrEmpty(_token)) { _service.logout(_token); } } catch { } finally { _token = null; } _token = _service.login(_userName, _password); if (String.IsNullOrEmpty(_token)) { throw new ApplicationException("Access denied."); } }
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> /// Internal login which catches the exceptions /// </summary> /// <returns>true if login was done sucessfully</returns> private bool doLogin(string user, string password, bool suppressBackgroundForm) { createService(); // This is what needs to be done ThreadStart jiraLogin = delegate { LOG.DebugFormat("Loggin in"); this.credentials = jira.login(user, password); LOG.DebugFormat("Logged in"); this.loggedInTime = DateTime.Now; this.loggedIn = true; }; // Here we do it try { if (!suppressBackgroundForm) { new PleaseWaitForm().ShowAndWait("Jira plug-in", Language.GetString("jira", LangKey.communication_wait), jiraLogin); } else { jiraLogin.Invoke(); } } catch (Exception e) { // check if auth failed if (e.Message.Contains(AUTH_FAILED_EXCEPTION_NAME)) { return(false); } // Not an authentication issue this.loggedIn = false; this.credentials = null; e.Data.Add("user", user); e.Data.Add("url", config.Url); throw; } return(true); }
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); }
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..."); }
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"; })); }