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; }
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); } } }
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; }
public OAuthServerProvider(IUserValidate userValidate) { this._userValidate = userValidate; }
public UserController(IUserValidate iUserValidate) { _iUserValidate = iUserValidate; }
public TokenGenerator(TokenGenerateOption option, IUserValidate validator) { _Option = option; UserValidator = validator; }
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; }
public PlayerManager(IUserValidateService userValidateService) { _userValidateService = userValidateService; }
public CasServer(IUserValidate userValidate, ICasAuthenticator casAuthenticator) { this._userValidate = userValidate; this._casAuthenticator = casAuthenticator; }