Example #1
0
 public SSOCallResult TicketVerification(string ticket)
 {
     try
     {
         SSOCallResult callResult = null;
         if (this.VerifyCredential(this))
         {
             if (string.IsNullOrEmpty(ticket))
                 throw new ArgumentNullException("ticket", "票据为空!");
             SSOAuthTicket authTicket = new SSOAuthTicket(ticket);
             if (authTicket == null)
                 throw new ArgumentException("票据格式不正确!");
             if (!authTicket.HasValid)
                 callResult = new SSOCallResult(-1, "票据无效!");
             else
             {
                 string clientIP = this.Context.Request.UserHostAddress;
                 string err = null;
                 bool result = this.factory.TicketVerification(ref authTicket, clientIP, out err);
                 if (result)
                     callResult = new SSOCallResult(0, authTicket.ToString(), "验证票据成功。");
                 else
                     callResult = new SSOCallResult(-1, err);
             }
         }
         return callResult;
     }
     catch (Exception e)
     {
         this.log.CreateErrorLog(e.Message);
         return new SSOCallResult(-1, e.Message);
     }
 }
Example #2
0
 public SSOCallResult ChangePassword(string userSign, string oldPassword, string newPassword)
 {
     try
     {
         SSOCallResult callResult = null;
         if (this.VerifyCredential(this))
         {
             if (string.IsNullOrEmpty(userSign))
                 throw new ArgumentNullException("userSign", "用户账号不能为空!");
             else if (string.IsNullOrEmpty(oldPassword))
                 throw new ArgumentNullException("oldPassword", "旧用户密码不能为空!");
             else if (string.IsNullOrEmpty(newPassword))
                 throw new ArgumentNullException("newPassword", "新用户密码不能为空!");
             else
             {
                 string err = null;
                 bool result = this.factory.ChangePassword(userSign, oldPassword, newPassword, out err);
                 if (result)
                     callResult = new SSOCallResult(0, "修改用户密码成功。");
                 else
                     callResult = new SSOCallResult(-1, err);
             }
         }
         return callResult;
     }
     catch (Exception e)
     {
         this.log.CreateErrorLog(e.Message);
         return new SSOCallResult(-1, e.Message);
     }
 }
Example #3
0
 public SSOCallResult SignIn(string userSign, string password)
 {
     try
     {
         SSOCallResult callResult = null;
         if (this.VerifyCredential(this))
         {
             if (string.IsNullOrEmpty(userSign) || string.IsNullOrEmpty(password))
                 callResult = new SSOCallResult(-1, "账号或密码不能为空!");
             else
             {
                 string err = null;
                 SSOAuthTicket ticket = this.factory.UserAuthorizationVerification(this.Credentials.AppSystemID, userSign, password, this.Context.Request.UserHostAddress, out err);
                 if (ticket == null)
                     callResult = new SSOCallResult(-1, err);
                 else
                     callResult = new SSOCallResult(0, ticket.ToString(), "登录成功。");
             }
         }
         return callResult;
     }
     catch (Exception e)
     {
         this.log.CreateErrorLog(e.Message);
         return new SSOCallResult(-1, e.Message);
     }
 }