示例#1
0
        public CasController(IUserValidate UserValidate, ICasAuthenticator CasAuthenticator, CasServer CasServer,
                             IUserService userService)
        {
            if (UserValidate == null) throw new ArgumentNullException("UserValidate");
            if (CasAuthenticator == null) throw new ArgumentNullException("CasAuthenticator");
            this.casAuthenticator = CasAuthenticator;

            this.userValidate = UserValidate;

            this.casServer = CasServer;
            this._userService = userService;
        }
示例#2
0
 public override void OnAuthorization(HttpActionContext actionContext)
 {
     //If the Authorization header is empty or null
     //then return Unauthorized
     if (actionContext.Request.Headers.Authorization == null)
     {
         actionContext.Response = actionContext.Request
                                  .CreateResponse(HttpStatusCode.Unauthorized);
         // If the request was unauthorized, add the WWW-Authenticate header
         // to the response which indicates that it require basic authentication
         if (actionContext.Response.StatusCode == HttpStatusCode.Unauthorized)
         {
             actionContext.Response.Headers.Add("WWW-Authenticate",
                                                string.Format("Basic realm=\"{0}\"", Realm));
         }
     }
     else
     {
         //Get the authentication token from the request header
         string authenticationToken = actionContext.Request.Headers
                                      .Authorization.Parameter;
         //Decode the string
         string decodedAuthenticationToken = Encoding.UTF8.GetString(
             Convert.FromBase64String(authenticationToken));
         //Convert the string into an string array
         string[] usernamePasswordArray = decodedAuthenticationToken.Split(':');
         //First element of the array is the username
         string username = usernamePasswordArray[0];
         //Second element of the array is the password
         string password = usernamePasswordArray[1];
         //call the login method to check the username and password
         IUserValidate uv = factory();
         if (uv.Login(username, password))
         {
             var        identity  = new GenericIdentity(username);
             IPrincipal principal = new GenericPrincipal(identity, null);
             Thread.CurrentPrincipal = principal;
             if (HttpContext.Current != null)
             {
                 HttpContext.Current.User = principal;
             }
         }
         else
         {
             actionContext.Response = actionContext.Request
                                      .CreateResponse(HttpStatusCode.Unauthorized);
         }
     }
 }
示例#3
0
        public CasController(IUserValidate UserValidate, ICasAuthenticator CasAuthenticator, CasServer CasServer,
                             IUserService userService)
        {
            if (UserValidate == null)
            {
                throw new ArgumentNullException("UserValidate");
            }
            if (CasAuthenticator == null)
            {
                throw new ArgumentNullException("CasAuthenticator");
            }
            this.casAuthenticator = CasAuthenticator;

            this.userValidate = UserValidate;

            this.casServer    = CasServer;
            this._userService = userService;
        }
示例#4
0
 public OAuthServerProvider(IUserValidate userValidate)
 {
     this._userValidate = userValidate;
 }
示例#5
0
 public UserController(IUserValidate iUserValidate)
 {
     _iUserValidate = iUserValidate;
 }
示例#6
0
 public TokenGenerator(TokenGenerateOption option, IUserValidate validator)
 {
     _Option       = option;
     UserValidator = validator;
 }
示例#7
0
 public HomeController(IAuthenticateService authService, IUserValidate userValidate, ICartService cartService)
 {
     _authService  = authService;
     _userValidate = userValidate;
     _cartService  = cartService;
 }
 public RegisterController(ICrudService <RegisterUser> regUserService, IAuthenticateService authService, IUserValidate userValidate)
 {
     _regUserService = regUserService;
     _authService    = authService;
     _userValidate   = userValidate;
 }
示例#9
0
 public PlayerManager(IUserValidateService userValidateService)
 {
     _userValidateService = userValidateService;
 }
示例#10
0
 public CasServer(IUserValidate userValidate, ICasAuthenticator casAuthenticator)
 {
     this._userValidate     = userValidate;
     this._casAuthenticator = casAuthenticator;
 }
示例#11
0
 public CasServer(IUserValidate userValidate, ICasAuthenticator casAuthenticator)
 {
     this._userValidate = userValidate;
     this._casAuthenticator = casAuthenticator;
 }