Ejemplo n.º 1
0
 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 setBasicAuthHeader(string url, WebRequest req)
        {
            if (userName == null || password == null)
            {
                return;
            }
#if true
            req.Credentials = CredentialUtils.getCredentialsForUserAndPassword(url, userName, password);
#else
            string authInfo = CredentialUtils.getUserNameWithoutDomain(userName) + ":" + password;
            authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
            req.Headers["Authorization"] = "Basic " + authInfo;
#endif
        }
        public RestSession login(string username, string pwd)
        {
#if OLDSKOOL_AUTH
            string endpoint = server.Url + LOGIN_ACTION
                              + "?username="******"&password="******"&os_username="******"&os_password="******"/response/auth");
                XPathNodeIterator it   = nav.Select(expr);
                if (it.Count == 0)
                {
                    throw new Exception("Server did not return any authentication token");
                }
                if (it.Count != 1)
                {
                    throw new Exception("Server returned unexpected number of authentication tokens (" + it.Count + ")");
                }
                it.MoveNext();
                authToken = it.Current.Value;

                getServerBuildNumber();

                LoggedIn = true;
                return(this);
            }
        }
Ejemplo n.º 4
0
        private void runActivateIssueActionsWorker(Action onFinish)
        {
            JiraServer server = JiraServerModel.Instance.getServer(new Guid(CurrentActiveIssue.ServerGuid));

            if (server != null)
            {
                try {
                    int       mods  = 0;
                    JiraIssue issue = SmartJiraServerFacade.Instance.getIssue(server, CurrentActiveIssue.Key);
                    if (issue != null)
                    {
                        string me = CredentialUtils.getUserNameWithoutDomain(server.UserName);
                        if (issue.Assignee == null || issue.Assignee.Equals("Unknown") || !issue.Assignee.Equals(me))
                        {
                            jiraStatus.setInfo("Assigning issue to me...");
                            JiraField assignee = new JiraField("assignee", null)
                            {
                                Values = new List <string> {
                                    me
                                },
                                SettablePropertyName = "name"
                            };
                            var rawIssueObject = SmartJiraServerFacade.Instance.getRawIssueObject(issue);
                            assignee.setRawIssueObject(rawIssueObject);
                            SmartJiraServerFacade.Instance.updateIssue(issue, new List <JiraField> {
                                assignee
                            });
                            ++mods;
                        }
                        List <JiraNamedEntity> actions = SmartJiraServerFacade.Instance.getActionsForIssue(issue);
                        JiraNamedEntity        action  = actions.Find(a => a.Id.Equals(START_PROGRESS_ACTION_ID));
                        if (action == null)
                        {
                            container.safeInvoke(new MethodInvoker(delegate {
                                ActionSelector sel = new ActionSelector(actions);
                                if (sel.ShowDialog() == DialogResult.OK)
                                {
                                    action = sel.SelectedAction;
                                }
                            }));
                        }
//                        foreach (JiraNamedEntity action in actions.Where(action => action.Id.Equals(START_PROGRESS_ACTION_ID))) {
                        if (action != null)
                        {
                            jiraStatus.setInfo("Setting issue in progress...");
                            SmartJiraServerFacade.Instance.runIssueActionWithoutParams(issue, action);
                            ++mods;
                        }
                        if (mods > 0)
                        {
                            issue = SmartJiraServerFacade.Instance.getIssue(server, CurrentActiveIssue.Key);
                        }
                    }
                    jiraStatus.setInfo("Work on issue " + CurrentActiveIssue.Key + " started");
                    container.safeInvoke(new MethodInvoker(() => {
                        JiraIssueListModelImpl.Instance.updateIssue(issue);
                        onFinish();
                    }));
                } catch (Exception e) {
                    CurrentActiveIssue = null;
                    jiraStatus.setError(FAILED_TO_START_WORK, e);
                    container.safeInvoke(new MethodInvoker(() => PlvsUtils.showError(FAILED_TO_START_WORK, e)));
                }
            }
            else
            {
                container.safeInvoke(new MethodInvoker(
                                         () => PlvsUtils.showError(FAILED_TO_START_WORK, new Exception("Unknown JIRA server"))));
            }
        }
 public static string getLoginPostData(string userName, string password) {
     return string.Format("os_username={0}&os_password={1}&os_cookie=true",
         HttpUtility.UrlEncode(CredentialUtils.getUserNameWithoutDomain(userName)),
         HttpUtility.UrlEncode(password));
 }