ajax-login-system 学习笔记

AuthenticationService.cs

  1//------------------------------------
  2// Implementation of:
  3//  - Snip.Authentication service
  4//      - Login methods
  5//      - Registration methods
  6//
  7// BSD License: http://www.opensource.org/licenses/bsd-license.php
  8//Copyright (c) 2007, Kyle Beyer (http://daptivate.com)
  9//All rights reserved.
 10//
 11//Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 12//
 13//Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
 14//Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 
 15//Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 
 16//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 17//------------------------------------
 18
 19using System;
 20using System.Data.SqlClient;
 21using System.Text;
 22using System.Web;
 23using System.Web.Security;
 24using System.Configuration;
 25using System.Collections.Generic;
 26using System.Web.Services;
 27using System.Web.Services.Protocols;
 28using System.Security.Cryptography;
 29using System.Net.Mail;
 30using System.Web.Profile;
 31using System.Web.Script.Services;
 32
 33namespace snip
 34{
 35
 36    public class CheckRegistrationRequest
 37    {
 38        public string email;
 39        public string username;
 40    }

 41
 42    public class CheckRegistrationResponse
 43    {
 44        public string salt;
 45        public bool email_available;
 46        public bool username_available;
 47    }

 48
 49    public class RegistrationRequest
 50    {
 51        public string username;
 52        public string email;
 53        public string pwd;
 54        public string salt;
 55        public bool createCookie;
 56    }

 57
 58    public class RegistrationResponse
 59    {
 60        public bool success;
 61        public string message;
 62        public bool email_sent;
 63    }

 64
 65
 66    public class SaltRequest
 67    {
 68        public string username;
 69    }

 70
 71    public class SaltResponse
 72    {
 73        public string salt;
 74        public string challenge;
 75        public bool success;
 76    }

 77
 78    public class LoginRequest
 79    {
 80        public string username;
 81        public string passwordHMAC;
 82        public bool createCookie;
 83    }

 84
 85    public enum UserStatus
 86    {
 87        LoggedOut = 0,
 88        LoggedIn = 1,
 89        Locked = 2
 90    }

 91    public class LoginResponse
 92    {
 93        public UserStatus status;
 94        public string username;
 95    }

 96
 97    /// <summary>
 98    /// Summary description for AuthenticationWebService
 99    /// </summary>

100    [ScriptService]
101    public class AuthenticationService : System.Web.Services.WebService
102    {
103        static SHA1CryptoServiceProvider shaProvider = new SHA1CryptoServiceProvider();
104
105        public AuthenticationService()
106        {
107            //Uncomment the following line if using designed components 
108            //InitializeComponent(); 
109        }

110
111        Registration methods
187
188
189        Login methods
296
297        helper methods
412    }

413
414}

415
416
posted on 2008-01-05 18:10  蓝蓝的天2016  阅读(340)  评论(0)    收藏  举报