public void OneTimeSetUp() { salt = "Example_Salt1"; loginValidatorMock = new Mock <ILoginValidator>(); newUserCredentials = new LoginRequest { LoginData = "User_login_example", Password = "******" }; validationResultError = new ValidationResult( new List <ValidationFailure> { new ValidationFailure("error", "something", null) }); validationResultIsValidMock = new Mock <ValidationResult>(); validationResultIsValidMock .Setup(x => x.IsValid) .Returns(true); BrokerSetUp(); tokenEngineMock = new Mock <ITokenEngine>(); autoMocker = new AutoMocker(); command = autoMocker.CreateInstance <LoginCommand>(); }
public Controller(IExitCommand exitCommand, IHelpCommand helpCommand, ICd cdCommand, IDirCommand dirCommand, IInitCommand initComman, IStatusCommand statusCommand, IListCommand listCommand, IRegisterCommand registerCommand, ILoginCommand logInCommand, IAddCommand addCommand, IRemoveCommand removeCommand, ITestHttp testHttp, ICommitCommand commitCommand) { this.exitCommand = exitCommand; this.helpCommand = helpCommand; this.cdCommand = cdCommand; this.dirCommand = dirCommand; this.initComman = initComman; this.statusCommand = statusCommand; this.listCommand = listCommand; this.registerCommand = registerCommand; this.loginCommand = logInCommand; this.addCommand = addCommand; this.removeCommand = removeCommand; this.testHttp = testHttp; this.commitCommand = commitCommand; }
internal override IPrincipal RestorePrincipal(ILoginCommand loginCommand, string key) { IPrincipal attribute = this._connection.GetAttribute(key) as IPrincipal; if (attribute != null) { Thread.CurrentPrincipal = attribute; } return(attribute); }
public override IPrincipal RestorePrincipal(ILoginCommand loginCommand) { IPrincipal attribute = this._connection.GetAttribute("__@fluorineprincipal") as IPrincipal; if (attribute != null) { Thread.CurrentPrincipal = attribute; } return(attribute); }
public override IPrincipal RestorePrincipal(ILoginCommand loginCommand) { IPrincipal currentPrincipal = null; if ((HttpContext.Current != null) && HttpContext.Current.Request.IsAuthenticated) { if (!(HttpContext.Current.User.Identity is FormsIdentity)) { return(HttpContext.Current.User); } FormsIdentity identity = HttpContext.Current.User.Identity as FormsIdentity; if (!((identity.Ticket.UserData != null) && identity.Ticket.UserData.StartsWith("fluorineauthticket"))) { return(HttpContext.Current.User); } } HttpCookie cookie = HttpContext.Current.Request.Cookies.Get(GetFormsAuthCookieName()); if (cookie != null) { FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value); if (ticket != null) { currentPrincipal = HttpContext.Current.Cache[ticket.UserData] as IPrincipal; if ((currentPrincipal == null) && ((ticket.UserData != null) && ticket.UserData.StartsWith("fluorineauthticket"))) { string[] strArray = ticket.UserData.Split(new char[] { '|' }); string username = strArray[2]; string password = strArray[3]; if (loginCommand == null) { throw new UnauthorizedAccessException(__Res.GetString("Security_LoginMissing")); } Hashtable credentials = new Hashtable(1); credentials["password"] = password; currentPrincipal = loginCommand.DoAuthentication(username, credentials); if (currentPrincipal == null) { throw new UnauthorizedAccessException(__Res.GetString("Security_AuthenticationFailed")); } this.StorePrincipal(currentPrincipal, username, password); } } else { currentPrincipal = Thread.CurrentPrincipal; } } if (currentPrincipal != null) { this.User = currentPrincipal; Thread.CurrentPrincipal = currentPrincipal; } return(currentPrincipal); }
public RegisterUserCommand( IConfiguration config, IUserService <User> userService, IApplicationValidator <IUserCredentialsInput> validator, IJwtAuthManager jwtAuthManager, ILoginCommand loginCommand, ILinkUserAndRoleCommand linkUserAndRoleCommand, IGenericRepository <Patient> patientRepo, IGenericRepository <DentalWorker> dentalWorkerRepo, IUnitOfWork uoW) { Config = config; UserService = userService; Validator = validator; JwtAuthManager = jwtAuthManager; LoginCommand = loginCommand; LinkUserAndRoleCommand = linkUserAndRoleCommand; PatientRepo = patientRepo; DentalWorkerRepo = dentalWorkerRepo; UoW = uoW; }
internal override IPrincipal RestorePrincipal(ILoginCommand loginCommand, string key) { IPrincipal principal = null; if (key != null) { principal = HttpContext.Current.Cache[key] as IPrincipal; if (principal == null) { FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(key); if (ticket == null) { throw new UnauthorizedAccessException(__Res.GetString("Security_AuthenticationFailed")); } string[] strArray = ticket.UserData.Split(new char[] { '|' }); string username = strArray[2]; string str2 = strArray[3]; if (loginCommand == null) { throw new UnauthorizedAccessException(__Res.GetString("Security_LoginMissing")); } Hashtable credentials = new Hashtable(1); credentials["password"] = str2; principal = loginCommand.DoAuthentication(username, credentials); if (principal == null) { throw new UnauthorizedAccessException(__Res.GetString("Security_AuthenticationFailed")); } this.StorePrincipal(principal, key); } } if (principal != null) { this.User = principal; Thread.CurrentPrincipal = principal; } return(principal); }
internal override IPrincipal RestorePrincipal(ILoginCommand loginCommand, string key) { throw new NotImplementedException("The method or operation is not implemented."); }
public abstract IPrincipal RestorePrincipal(ILoginCommand loginCommand);
/// <summary> /// This method supports the Fluorine infrastructure and is not intended to be used directly from your code. /// </summary> /// <param name="configFolderPaths">Possible configuration file locations.</param> /// <param name="serviceBrowserAvailable">Indicates whether the service browser is avaliable.</param> public void Init(string[] configFolderPaths, bool serviceBrowserAvailable) { _messageBroker = new MessageBroker(this); string servicesConfigFile = null; for (int i = 0; i < configFolderPaths.Length; i++) { servicesConfigFile = Path.Combine(configFolderPaths[i], "services-config.xml"); if (log.IsDebugEnabled) { log.Debug(__Res.GetString(__Res.MessageServer_TryingServiceConfig, servicesConfigFile)); } if (File.Exists(servicesConfigFile)) { break; } } if (servicesConfigFile != null && File.Exists(servicesConfigFile)) { if (log.IsDebugEnabled) { log.Debug(__Res.GetString(__Res.MessageServer_LoadingServiceConfig, servicesConfigFile)); } _servicesConfiguration = ServicesConfiguration.Load(servicesConfigFile); } else { if (log.IsDebugEnabled) { log.Debug(__Res.GetString(__Res.MessageServer_LoadingConfigDefault)); } _servicesConfiguration = ServicesConfiguration.CreateDefault(); } foreach (ChannelDefinition channelDefinition in _servicesConfiguration.Channels) { Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(channelDefinition.Endpoint.Class)); if (type != null) { IEndpoint endpoint = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, channelDefinition }) as IEndpoint; if (endpoint != null) { _messageBroker.AddEndpoint(endpoint); } } else { log.Error(__Res.GetString(__Res.Type_InitError, channelDefinition.Class)); } } ChannelDefinition rtmptChannelDefinition = new ChannelDefinition(); rtmptChannelDefinition.Id = RtmptEndpoint.FluorineRtmptEndpointId; IEndpoint rtmptEndpoint = new RtmptEndpoint(_messageBroker, rtmptChannelDefinition); _messageBroker.AddEndpoint(rtmptEndpoint); if (_servicesConfiguration.Factories != null) { foreach (Factory factory in _servicesConfiguration.Factories) { Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(factory.Class)); if (type != null) { IFlexFactory flexFactory = ObjectFactory.CreateInstance(type, new object[0]) as IFlexFactory; if (flexFactory != null) { _messageBroker.AddFactory(factory.Id, flexFactory); } } else { log.Error(__Res.GetString(__Res.Type_InitError, factory.Class)); } } } //Add the dotnet Factory _messageBroker.AddFactory(DotNetFactory.Id, new DotNetFactory()); if (serviceBrowserAvailable) { ServiceDefinition serviceConfiguration = _servicesConfiguration.GetServiceByClass("flex.messaging.services.RemotingService"); if (serviceConfiguration != null) { AdapterDefinition adapter = serviceConfiguration.GetAdapterByClass(typeof(Remoting.RemotingAdapter).FullName); if (adapter != null) { InstallServiceBrowserDestinations(serviceConfiguration, adapter); } else { adapter = serviceConfiguration.GetDefaultAdapter(); if (adapter != null) { InstallServiceBrowserDestinations(serviceConfiguration, adapter); } } } } if (_servicesConfiguration.Services.ServiceDefinitions != null) { foreach (ServiceDefinition serviceDefinition in _servicesConfiguration.Services.ServiceDefinitions) { Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(serviceDefinition.Class));//current assembly only if (type != null) { IService service = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, serviceDefinition }) as IService; if (service != null) { _messageBroker.AddService(service); } } else { log.Error(__Res.GetString(__Res.Type_InitError, serviceDefinition.Class)); } } } if (_servicesConfiguration.Services.Includes != null) { foreach (ServiceInclude include in _servicesConfiguration.Services.Includes) { ServiceDefinition serviceDefinition = include.ServiceDefinition; Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(serviceDefinition.Class));//current assembly only if (type != null) { IService service = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, serviceDefinition }) as IService; if (service != null) { _messageBroker.AddService(service); } } else { log.Error(__Res.GetString(__Res.Type_InitError, serviceDefinition.Class)); } } } if (_servicesConfiguration.Security != null) { if (_servicesConfiguration.Security.LoginCommands != null && _servicesConfiguration.Security.LoginCommands.Length > 0) { LoginCommand loginCommand = _servicesConfiguration.Security.GetLoginCommand(LoginCommand.FluorineLoginCommand); if (loginCommand != null) { Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(loginCommand.Class)); if (type != null) { ILoginCommand loginCommandObj = ObjectFactory.CreateInstance(type, new object[] { }) as ILoginCommand; _messageBroker.LoginManager.LoginCommand = loginCommandObj; _messageBroker.LoginManager.IsPerClientAuthentication = loginCommand.IsPerClientAuthentication; } else { log.Error(__Res.GetString(__Res.Type_InitError, loginCommand.Class)); } } else { log.Error(__Res.GetString(__Res.Type_InitError, "<<LoginCommand class>>")); } } } InitAuthenticationService(); try { if (FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings != null && FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.Enable) { IResource resource; if (FluorineContext.Current != null) { resource = FluorineContext.Current.GetResource(FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile); } else { resource = new FileSystemResource(FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile); } if (resource.Exists) { log.Info(__Res.GetString(__Res.Silverlight_StartPS, resource.File.FullName)); _policyServer = new PolicyServer(resource.File.FullName); } else { throw new FileNotFoundException("Policy file not found", FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile); } } } catch (Exception ex) { log.Error(__Res.GetString(__Res.Silverlight_PSError), ex); } }
public void Init(string configPath, bool serviceBrowserAvailable) { Type type; this._messageBroker = new FluorineFx.Messaging.MessageBroker(this); this._serviceConfigSettings = FluorineFx.Messaging.Config.ServiceConfigSettings.Load(configPath, "services-config.xml"); foreach (ChannelSettings settings in this._serviceConfigSettings.ChannelsSettings) { type = ObjectFactory.Locate(settings.Class); if (type != null) { IEndpoint endpoint = ObjectFactory.CreateInstance(type, new object[] { this._messageBroker, settings }) as IEndpoint; if (endpoint != null) { this._messageBroker.AddEndpoint(endpoint); } } else { log.Error(__Res.GetString("Type_InitError", new object[] { settings.Class })); } ChannelSettings channelSettings = new ChannelSettings("__@fluorinertmpt", null); IEndpoint endpoint2 = new RtmptEndpoint(this._messageBroker, channelSettings); this._messageBroker.AddEndpoint(endpoint2); } foreach (FactorySettings settings3 in this._serviceConfigSettings.FactoriesSettings) { type = ObjectFactory.Locate(settings3.ClassId); if (type != null) { IFlexFactory factory = ObjectFactory.CreateInstance(type, new object[0]) as IFlexFactory; if (factory != null) { this._messageBroker.AddFactory(settings3.Id, factory); } } else { log.Error(__Res.GetString("Type_InitError", new object[] { settings3.ClassId })); } } this._messageBroker.AddFactory("dotnet", new DotNetFactory()); if (serviceBrowserAvailable && (this._serviceConfigSettings.ServiceSettings["remoting-service"] != null)) { ServiceSettings serviceSettings = this._serviceConfigSettings.ServiceSettings["remoting-service"]; AdapterSettings adapterSettings = this._serviceConfigSettings.ServiceSettings["remoting-service"].AdapterSettings["dotnet"]; this.InstallServiceBrowserDestinations(serviceSettings, adapterSettings); } foreach (ServiceSettings settings6 in this._serviceConfigSettings.ServiceSettings) { type = ObjectFactory.Locate(settings6.Class); if (type != null) { IService service = ObjectFactory.CreateInstance(type, new object[] { this._messageBroker, settings6 }) as IService; if (service != null) { this._messageBroker.AddService(service); } } else { log.Error(__Res.GetString("Type_InitError", new object[] { settings6.Class })); } } if ((this._serviceConfigSettings.SecuritySettings != null) && ((this._serviceConfigSettings.SecuritySettings.LoginCommands != null) && (this._serviceConfigSettings.SecuritySettings.LoginCommands.Count > 0))) { string loginCommand = this._serviceConfigSettings.SecuritySettings.LoginCommands.GetLoginCommand("asp.net"); type = ObjectFactory.Locate(loginCommand); if (type != null) { ILoginCommand command = ObjectFactory.CreateInstance(type, new object[0]) as ILoginCommand; this._messageBroker.LoginCommand = command; } else { log.Error(__Res.GetString("Type_InitError", new object[] { loginCommand })); } } this.InitAuthenticationService(); try { if ((FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings != null) && FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.Enable) { IResource resource = FluorineContext.Current.GetResource(FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile); if (!resource.Exists) { throw new FileNotFoundException("Policy file not found", FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile); } log.Info(__Res.GetString("Silverlight_StartPS", new object[] { resource.File.FullName })); this._policyServer = new PolicyServer(resource.File.FullName); } } catch (Exception exception) { log.Error(__Res.GetString("Silverlight_PSError"), exception); } }
internal abstract IPrincipal RestorePrincipal(ILoginCommand loginCommand, string key);
public async Task <LoginResult> LoginUser( [FromServices] ILoginCommand command, [FromBody] LoginRequest userCredentials) { return(await command.Execute(userCredentials)); }
public override void Invoke(AMFContext context) { IPrincipal principal = null; int num; ErrorResponseBody body2; MessageBroker messageBroker = this._endpoint.GetMessageBroker(); try { string str3; AMFHeader header = context.AMFMessage.GetHeader("Credentials"); if ((header != null) && (header.Content != null)) { string username = ((ASObject)header.Content)["userid"] as string; string password = ((ASObject)header.Content)["password"] as string; ASObject content = new ASObject(); content["name"] = "Credentials"; content["mustUnderstand"] = false; content["data"] = null; AMFHeader header2 = new AMFHeader("RequestPersistentHeader", true, content); context.MessageOutput.AddHeader(header2); ILoginCommand loginCommand = this._endpoint.GetMessageBroker().LoginCommand; if (loginCommand == null) { throw new UnauthorizedAccessException(__Res.GetString("Security_LoginMissing")); } Hashtable credentials = new Hashtable(1); credentials["password"] = password; principal = loginCommand.DoAuthentication(username, credentials); if (principal == null) { throw new UnauthorizedAccessException(__Res.GetString("Security_AccessNotAllowed")); } FluorineContext.Current.StorePrincipal(principal, username, password); str3 = FluorineContext.Current.EncryptCredentials(this._endpoint, principal, username, password); FluorineContext.Current.StorePrincipal(principal, str3); ASObject obj3 = new ASObject(); obj3["name"] = "CredentialsId"; obj3["mustUnderstand"] = false; obj3["data"] = str3; AMFHeader header3 = new AMFHeader("RequestPersistentHeader", true, obj3); context.MessageOutput.AddHeader(header3); } else { header = context.AMFMessage.GetHeader("CredentialsId"); if (header != null) { str3 = header.Content as string; if (str3 != null) { FluorineContext.Current.RestorePrincipal(messageBroker.LoginCommand, str3); } } else { principal = FluorineContext.Current.RestorePrincipal(messageBroker.LoginCommand); } } } catch (UnauthorizedAccessException exception) { for (num = 0; num < context.AMFMessage.BodyCount; num++) { body2 = new ErrorResponseBody(context.AMFMessage.GetBodyAt(num), exception); context.MessageOutput.AddBody(body2); } } catch (Exception exception2) { if ((log != null) && log.get_IsErrorEnabled()) { log.Error(exception2.Message, exception2); } for (num = 0; num < context.AMFMessage.BodyCount; num++) { body2 = new ErrorResponseBody(context.AMFMessage.GetBodyAt(num), exception2); context.MessageOutput.AddBody(body2); } } FluorineContext.Current.User = principal; Thread.CurrentPrincipal = principal; }
public LoginViewModel(ILoginCommand command) : base(command) { }
public AuthController(ILoginCommand loginCommand, Encryption enc) { _loginCommand = loginCommand; _enc = enc; }
public LoginModel(ILoginCommand loginCommand) { this.loginCommand = loginCommand; }
public AuthController(Encryption enc, ILoginCommand login) { _enc = enc; _login = login; }