public string getAuthenticationTicket(bool promptUser)
        {
            string strAuthTicket = "";

            if (m_AuthenticationTicket == "")
            {
                // Do we recognise the path as belonging to an Alfresco server?
                if (this.MatchCIFSServer(m_DocumentPhysicalPath))
                {
                    // Try CIFS
                    IServerHelper myAuthTicket = new CIFSHelper(this.CIFSServer);
                    m_AuthenticationTicket = myAuthTicket.GetAuthenticationTicket();
                }
                else
                {
                    // Try WebDAV
                    IServerHelper myAuthTicket = new WebDAVHelper(this.WebDAVURL);
                    strAuthTicket = myAuthTicket.GetAuthenticationTicket();
                    if (strAuthTicket != "401")
                    {
                        m_AuthenticationTicket = strAuthTicket;
                    }
                    else
                    {
                        // Authentication failed - do we have a saved username/password?
                        if ((this.Username.Length > 0) && (this.Password.Length > 0))
                        {
                            strAuthTicket = myAuthTicket.GetAuthenticationTicket(this.Username, this.Password);
                        }
                        if (strAuthTicket != "401")
                        {
                            m_AuthenticationTicket = strAuthTicket;
                        }
                        else
                        {
                            // Last option - pop up the login form
                            using (Login myLogin = new Login())
                            {
                                bool bRetry = true;

                                // Pre-populate with values already configured
                                myLogin.Username = this.Username;
                                myLogin.Password = this.Password;

                                // Retry loop for typos
                                while (bRetry)
                                {
                                    if (myLogin.ShowDialog() == DialogResult.OK)
                                    {
                                        // Try to authenticate with entered credentials
                                        strAuthTicket = myAuthTicket.GetAuthenticationTicket(myLogin.Username, myLogin.Password);
                                        if ((strAuthTicket == "401") || (strAuthTicket == ""))
                                        {
                                            // Retry?
                                            bRetry = (MessageBox.Show("Couldn't authenticate with Alfresco server.", "Alfresco Authentication", MessageBoxButtons.RetryCancel) == DialogResult.Retry);
                                        }
                                        else
                                        {
                                            // Successful login
                                            m_AuthenticationTicket = strAuthTicket;
                                            bRetry = false;
                                        }
                                    }
                                    else
                                    {
                                        // Cancel or close chosen on login dialog
                                        bRetry = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(m_AuthenticationTicket);
        }
示例#2
0
        public string getAuthenticationTicket(bool promptUser)
        {
            string strAuthTicket = "";
             if (m_AuthenticationTicket == "")
             {
            // Do we recognise the path as belonging to an Alfresco server?
            if (this.MatchCIFSServer(m_DocumentPhysicalPath))
            {
               // Try CIFS
               IServerHelper myAuthTicket = new CIFSHelper(this.CIFSServer);
               m_AuthenticationTicket = myAuthTicket.GetAuthenticationTicket();
            }
            else
            {
               // Try WebDAV
               IServerHelper myAuthTicket = new WebDAVHelper(this.WebDAVURL);
               strAuthTicket = myAuthTicket.GetAuthenticationTicket();
               if (strAuthTicket != "401")
               {
                  m_AuthenticationTicket = strAuthTicket;
               }
               else
               {
                  // Authentication failed - do we have a saved username/password?
                  if ((this.Username.Length > 0) && (this.Password.Length > 0))
                  {
                     strAuthTicket = myAuthTicket.GetAuthenticationTicket(this.Username, this.Password);
                  }
                  if (strAuthTicket != "401")
                  {
                     m_AuthenticationTicket = strAuthTicket;
                  }
                  else
                  {
                     // Last option - pop up the login form
                     using (Login myLogin = new Login())
                     {
                        bool bRetry = true;

                        // Pre-populate with values already configured
                        myLogin.Username = this.Username;
                        myLogin.Password = this.Password;

                        // Retry loop for typos
                        while (bRetry)
                        {
                           if (myLogin.ShowDialog() == DialogResult.OK)
                           {
                              // Try to authenticate with entered credentials
                              strAuthTicket = myAuthTicket.GetAuthenticationTicket(myLogin.Username, myLogin.Password);
                              if ((strAuthTicket == "401") || (strAuthTicket == ""))
                              {
                                 // Retry?
                                 bRetry = (MessageBox.Show("Couldn't authenticate with Alfresco server.", "Alfresco Authentication", MessageBoxButtons.RetryCancel) == DialogResult.Retry);
                              }
                              else
                              {
                                 // Successful login
                                 m_AuthenticationTicket = strAuthTicket;
                                 bRetry = false;
                              }
                           }
                           else
                           {
                              // Cancel or close chosen on login dialog
                              bRetry = false;
                           }
                        }
                     }
                  }
               }
            }
             }

             return m_AuthenticationTicket;
        }