Password authentication credentials
Ejemplo n.º 1
0
 private XmlElement GetForceLoginXmlNode(PasswordAuthentication pa, Guid oldLoginGuid)
 {
     LOG.InfoFormat("User login will be forced. Old login guid was: {0}", oldLoginGuid.ToRQLString());
     //hide user password in log message
     string rql = string.Format(RQL_IODATA, RQL_LOGIN_FORCE.RQLFormat(pa.Username, pa.Password, oldLoginGuid));
     string debugRQLOutput = string.Format(RQL_IODATA,
                                           RQL_LOGIN_FORCE.RQLFormat(pa.Username, "*****", oldLoginGuid));
     string result = SendRQLToServer(rql, debugRQLOutput);
     var xmlDoc = new XmlDocument();
     xmlDoc.LoadXml(result);
     XmlNodeList xmlNodes = xmlDoc.GetElementsByTagName("LOGIN");
     return (XmlElement) (xmlNodes.Count > 0 ? xmlNodes[0] : null);
 }
Ejemplo n.º 2
0
 public ServerLogin(string url, PasswordAuthentication authData)
 {
     Address = new Uri(url);
     AuthData = authData;
 }
Ejemplo n.º 3
0
        private void ParseLoginResponse(XmlNodeList xmlNodes, PasswordAuthentication authData, XmlDocument xmlDoc,
                                        Func<IEnumerable<RunningSessionInfo>, RunningSessionInfo>
                                            sessionReplacementSelector)
        {
            // check if already logged in
            var xmlNode = (XmlElement) xmlNodes[0];
            string oldLoginGuid = CheckAlreadyLoggedIn(xmlNode);
            if (oldLoginGuid != "")
            {
                RunningSessionInfo sessionToReplace;
                if (sessionReplacementSelector == null ||
                    !TryGetSessionInfo(xmlDoc, sessionReplacementSelector, out sessionToReplace))
                {
                    throw new RedDotConnectionException(RedDotConnectionException.FailureTypes.AlreadyLoggedIn,
                                                        "User is already logged in and no open session was selected to get replaced");
                }
                xmlNode = GetForceLoginXmlNode(authData, sessionToReplace.LoginGuid);
                if (xmlNode == null)
                {
                    throw new RedDotConnectionException(RedDotConnectionException.FailureTypes.CouldNotLogin,
                                                        "Could not force login.");
                }
            }

            // here xmlNode has a valid login guid
            string loginGuid = xmlNode.GetAttributeValue("guid");
            if (string.IsNullOrEmpty(loginGuid))
            {
                throw new RedDotConnectionException(RedDotConnectionException.FailureTypes.CouldNotLogin,
                                                    "Could not login");
            }
            LogonGuid = Guid.Parse(loginGuid);
            SessionKey = LogonGuid.ToRQLString();
            LoadSelectedProject(xmlNode.OwnerDocument);
            var loginNode = (XmlElement) xmlNodes[0];
            string userGuidStr = loginNode.GetAttributeValue("userguid");
            if (string.IsNullOrEmpty(userGuidStr))
            {
                XmlNodeList userNodes = xmlDoc.GetElementsByTagName("USER");
                if (userNodes.Count != 1)
                {
                    throw new RedDotConnectionException(RedDotConnectionException.FailureTypes.CouldNotLogin,
                                                        "Could not login; Invalid user data");
                }
                var xmlElement = ((XmlElement) userNodes[0]);
                ((Users)ServerManager.Users).Current = new User(this, xmlElement.GetGuid()) { Name = xmlElement.GetAttributeValue("name") };
            }
            else
            {
                ((Users)ServerManager.Users).Current = new User(this, Guid.Parse(loginNode.GetAttributeValue("userguid")));
            }
        }
Ejemplo n.º 4
0
 public ServerLogin(string url, PasswordAuthentication authData)
 {
     Address  = new Uri(url);
     AuthData = authData;
 }