/// <summary>Initializes a new instance of the BaseTokenManager class.</summary> /// <param name="principalProvider">The principal provider.</param> /// <param name="cryptoProvider">The crypto provider.</param> /// <param name="tokenFactory">The token factory.</param> /// <param name="tokenRepository">The token repository.</param> protected BaseTokenManager(IPrincipalProvider principalProvider, ICryptoProvider cryptoProvider, ITokenFactory tokenFactory, ITokenRepository tokenRepository) { this.CryptoProvider = cryptoProvider; this.PrincipalProvider = principalProvider; this.TokenFactory = tokenFactory; this.tokenRepository = tokenRepository; }
public bool Initialize(DtoBase rootDto, IPrincipalProvider principalProvider) { if (ListenPort < 1024) { return(false); } _rootDto = rootDto; _principalProvider = principalProvider; try { _listener = new TcpListener(IPAddress.Any, ListenPort) { ExclusiveAddressUse = true }; _listenerThread = new Thread(ListenerThreadProc) { Name = $"Remote client session listener on port {ListenPort}", IsBackground = true }; _listenerThread.Start(); return(true); } catch (Exception e) { Logger.Error(e, "Initialization of {0} error.", this); } return(false); }
public AbstractPricipalToken(string name, IPrincipalProvider provider) { if (provider == null) throw new ArgumentNullException("principal's provider must not be null"); this.name = name; this.provider = provider; }
public CompanyService( IPrincipalProvider principalProvider, ICompanyStorage companyStorage) { this.principalProvider = principalProvider; this.companyStorage = companyStorage; }
/// <summary> /// Imports users and groups from active directory. /// </summary> /// <param name="provider">IPrincipalProvider</param> /// <param name="messageLog">Provides message logging</param> public static void Import(IPrincipalProvider provider, IMessageLog messageLog) { AutoResetEvent importFinished = new AutoResetEvent(false); ImportAsync(provider, messageLog, (sender, e) => importFinished.Set()); importFinished.WaitOne(); }
public override void SetUp() { base.SetUp(); _securityProviderStub = MockRepository.GenerateStub <ISecurityProvider>(); _principalProviderStub = MockRepository.GenerateStub <IPrincipalProvider>(); _securityPrincipalStub = MockRepository.GenerateStub <ISecurityPrincipal>(); _functionalSecurityStrategyStub = MockRepository.GenerateStub <IFunctionalSecurityStrategy>(); _principalProviderStub.Stub(stub => stub.GetPrincipal()).Return(_securityPrincipalStub); _securityContextStub = MockRepository.GenerateStub <ISecurityContext> (); _securityContextFactoryStub = MockRepository.GenerateStub <ISecurityContextFactory> (); _securityContextFactoryStub.Stub(mock => mock.CreateSecurityContext()).Return(_securityContextStub); _clientTransaction = ClientTransaction.CreateRootTransaction(); _clientTransaction.Extensions.Add(new SecurityClientTransactionExtension()); var serviceLocator = DefaultServiceLocator.Create(); serviceLocator.RegisterSingle(() => _securityProviderStub); serviceLocator.RegisterSingle(() => _principalProviderStub); serviceLocator.RegisterSingle(() => _functionalSecurityStrategyStub); _serviceLocatorScope = new ServiceLocatorScope(serviceLocator); _clientTransaction.EnterNonDiscardingScope(); }
public CustomAuthorizationServerOptions(IPrincipalProvider principalProvider) { this.principalProvider = principalProvider; this.Events.TokenIssued += this.OnTokenIssued; this.Events.PrincipalCreated += this.OnPrincipalCreated; this.Events.UnknownGrantTypeReceived += this.OnUnknownGrantTypeReceived; }
public CustomAuthorizationServerOptions(IPrincipalProvider principalProvider) { this.principalProvider = principalProvider; this.Events.TokenIssued += this.OnTokenIssued; this.Events.PrincipalCreated += this.OnPrincipalCreated; this.Events.UnknownGrantTypeReceived += this.OnUnknownGrantTypeReceived; }
public TenantOrganizationProvider(ApplicationDbContext dbContext, ITenantKeyManager tenantKeyManager, IPrincipalProvider principalProvider) { this.dbContext = dbContext; this.tenantKeyManager = tenantKeyManager; this.principalProvider = principalProvider; }
public ServerAuthenticationService( AuthenticationStateProvider authenticationStateProvider, IPrincipalStorageProvider principalStorageProvider, IPrincipalProvider principalProvider) { _authenticationStateProvider = authenticationStateProvider as DelayedAuthenticationStateProvider; _principalStorageProvider = principalStorageProvider; _principalProvider = principalProvider; }
/// <summary> /// Main constructor. /// </summary> /// <param name="principalProvider">Principal provider</param> public ADWizard(IPrincipalProvider principalProvider) : this() { if (principalProvider == null) { throw new ArgumentNullException("principalProvider"); } PrincipalProvider = principalProvider; }
public IdentityService(UserManager <IdentityUser> userManager, ITokenProvider tokenProvider, IPrincipalProvider principalProvider, JwtSettings jwtSettings, IdentityDb context) { _userManager = userManager; _tokenProvider = tokenProvider; _principalProvider = principalProvider; _jwtSettings = jwtSettings; _context = context; }
/// <summary> /// Initializes a new instance of the Sentinel.OAuth.Providers.OAuth.SentinelTicketFormat /// class. /// </summary> /// <exception cref="ArgumentNullException"> /// Thrown when one or more required arguments are null. /// </exception> /// <param name="principalProvider">The principal provider.</param> public SentinelTicketFormat(IPrincipalProvider principalProvider) { if (principalProvider == null) { throw new ArgumentNullException("principalProvider"); } this.principalProvider = principalProvider; }
public PrincipalAuthenticationService( IHttpContext httpContext, IPrincipalProvider principalProvider, IUserSession userSession) { _httpContext = httpContext; _principalProvider = principalProvider; _userSession = userSession; }
/// <summary>Initializes a new instance of the TokenManager class.</summary> /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are null.</exception> /// <param name="logger">The logger.</param> /// <param name="principalProvider">The principal provider.</param> /// <param name="tokenProvider">The token provider.</param> /// <param name="tokenRepository">The token repository.</param> public TokenManager(ILog logger, IPrincipalProvider principalProvider, ITokenProvider tokenProvider, ITokenRepository tokenRepository) : base(principalProvider, tokenProvider, tokenRepository) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } this.logger = logger; }
/// <summary>Initializes a new instance of the TokenManager class.</summary> /// <exception cref="ArgumentNullException"> /// Thrown when one or more required arguments are null. /// </exception> /// <param name="logger">The logger.</param> /// <param name="userManager">Manager for users.</param> /// <param name="principalProvider">The principal provider.</param> /// <param name="cryptoProvider">The crypto provider.</param> /// <param name="tokenFactory">The token factory.</param> /// <param name="tokenRepository">The token repository.</param> public TokenManager(ILog logger, IUserManager userManager, IPrincipalProvider principalProvider, ICryptoProvider cryptoProvider, ITokenFactory tokenFactory, ITokenRepository tokenRepository) : base(principalProvider, cryptoProvider, tokenFactory, tokenRepository) { if (logger == null) { throw new ArgumentNullException("logger"); } this.logger = logger; this.userManager = userManager; }
public void Init() { identity = Substitute.For <IIdentity>(); principal = Substitute.For <IPrincipal>(); principalProvider = Substitute.For <IPrincipalProvider>(); principal.Identity.Returns(identity); principalProvider.GetCurrent().Returns(principal); controller = new RootController(principalProvider) { Logger = Substitute.For <ILogger>() }; }
// construction and disposing public WebPermissionProviderTestHelper() { _mocks = new MockRepository(); _mockSecurityProvider = _mocks.StrictMock <ISecurityProvider>(); SetupResult.For(_mockSecurityProvider.IsNull).Return(false); _mockObjectSecurityStrategy = _mocks.StrictMock <IObjectSecurityStrategy>(); _mockFunctionalSecurityStrategy = _mocks.StrictMock <IFunctionalSecurityStrategy>(); _mockWxeSecurityAdapter = _mocks.StrictMock <IWxeSecurityAdapter>(); _stubUser = _mocks.Stub <ISecurityPrincipal>(); SetupResult.For(_stubUser.User).Return("user"); _mockPrincipalProvider = _mocks.StrictMock <IPrincipalProvider>(); SetupResult.For(_mockPrincipalProvider.GetPrincipal()).Return(_stubUser); }
public SecurityClientTestHelper() { _mocks = new MockRepository(); _mockSecurityProvider = _mocks.StrictMock <ISecurityProvider>(); _mockPermissionReflector = _mocks.StrictMock <IPermissionProvider>(); _mockObjectSecurityStrategy = _mocks.StrictMock <IObjectSecurityStrategy>(); _mockFunctionalSecurityStrategy = _mocks.StrictMock <IFunctionalSecurityStrategy>(); _mockMemberResolver = _mocks.StrictMock <IMemberResolver>(); _userStub = _mocks.Stub <ISecurityPrincipal>(); SetupResult.For(_userStub.User).Return("user"); _stubPrincipalProvider = _mocks.Stub <IPrincipalProvider>(); SetupResult.For(_stubPrincipalProvider.GetPrincipal()).Return(_userStub); _securableObject = new SecurableObject(_mockObjectSecurityStrategy); }
// construction and disposing public TestHelper() { _mocks = new MockRepository(); _mockSecurityProvider = _mocks.StrictMock <ISecurityProvider> (); _stubUser = _mocks.Stub <ISecurityPrincipal> (); SetupResult.For(_stubUser.User).Return("user"); _stubPrincipalProvider = _mocks.StrictMock <IPrincipalProvider> (); SetupResult.For(_stubPrincipalProvider.GetPrincipal()).Return(_stubUser); _mockFunctionalSecurityStrategy = _mocks.StrictMock <IFunctionalSecurityStrategy> (); _mockPermissionReflector = _mocks.StrictMock <IPermissionProvider> (); _mockMemberResolver = _mocks.StrictMock <IMemberResolver>(); _transaction = ClientTransaction.CreateRootTransaction(); SetupResult.For(_mockSecurityProvider.IsNull).Return(false); }
public ServerSession(TcpClient client, IDto initialObject, IPrincipalProvider principalProvider) : base(client, new ServerReferenceResolver()) { _initialObject = initialObject; if (!(client.Client.RemoteEndPoint is IPEndPoint)) { throw new UnauthorizedAccessException("Client RemoteEndpoint is invalid"); } _sessionUser = principalProvider.GetPrincipal(client); if (_sessionUser == null) { throw new UnauthorizedAccessException($"Client {Client.Client.RemoteEndPoint} not allowed"); } ((ServerReferenceResolver)ReferenceResolver).ReferencePropertyChanged += ReferenceResolver_ReferencePropertyChanged; StartThreads(); }
public void Init() { principalProvider = Substitute.For <IPrincipalProvider>(); principal = Substitute.For <IPrincipal>(); principalProvider.GetCurrent().Returns(principal); principal.Identity.Name.Returns("user"); interceptor = new AuditChangeInterceptor(principalProvider) { Logger = Substitute.For <ILogger>() }; context = TestDbContextFactory.Build(interceptors: new[] { interceptor }); }
public void SetUp() { _securityProviderStub = MockRepository.GenerateStub <ISecurityProvider>(); _securityPrincipalStub = MockRepository.GenerateStub <ISecurityPrincipal>(); _functionalSecurityStrategyStub = MockRepository.GenerateStub <IFunctionalSecurityStrategy>(); _principalProviderStub = MockRepository.GenerateStub <IPrincipalProvider>(); _principalProviderStub.Stub(stub => stub.GetPrincipal()).Return(_securityPrincipalStub); _securityClient = new SecurityClient( _securityProviderStub, new PermissionReflector(), _principalProviderStub, _functionalSecurityStrategyStub, new ReflectionBasedMemberResolver()); }
public override void SetUp() { base.SetUp(); _securityProviderStub = MockRepository.GenerateStub <ISecurityProvider> (); _principalProviderStub = MockRepository.GenerateStub <IPrincipalProvider> (); _securityPrincipalStub = MockRepository.GenerateStub <ISecurityPrincipal> (); _principalProviderStub.Stub(stub => stub.GetPrincipal()).Return(_securityPrincipalStub); var serviceLocator = DefaultServiceLocator.Create(); serviceLocator.RegisterSingle(() => _securityProviderStub); serviceLocator.RegisterSingle(() => _principalProviderStub); _serviceLocatorScope = new ServiceLocatorScope(serviceLocator); }
public ServerSession(TcpClient client, IDto initialObject, IPrincipalProvider principalProvider) : base(client, new ReferenceResolver()) { Serializer.SerializationBinder = new SerializationBinder(); _initialObject = initialObject; if (!(client.Client.RemoteEndPoint is IPEndPoint)) { throw new UnauthorizedAccessException("Client RemoteEndpoint is invalid"); } _sessionUser = principalProvider.GetPrincipal(client); if (_sessionUser == null) { throw new UnauthorizedAccessException($"Client {Client.Client.RemoteEndPoint} not allowed"); } Logger.Info("Client {0} from {1} successfully connected", _sessionUser.Identity, Client.Client.RemoteEndPoint); ((ReferenceResolver)ReferenceResolver).ReferencePropertyChanged += ReferenceResolver_ReferencePropertyChanged; StartThreads(); }
public void SetUp() { _stubSecurityProvider = MockRepository.GenerateStub <ISecurityProvider>(); _stubPrincipalProvider = MockRepository.GenerateStub <IPrincipalProvider>(); _stubPermissionProvider = MockRepository.GenerateStub <IPermissionProvider>(); _stubMemberResolver = MockRepository.GenerateStub <IMemberResolver>(); _stubFunctionalSecurityStrategy = MockRepository.GenerateStub <IFunctionalSecurityStrategy>(); var serviceLocator = DefaultServiceLocator.Create(); serviceLocator.RegisterSingle(() => _stubSecurityProvider); serviceLocator.RegisterSingle(() => _stubPrincipalProvider); serviceLocator.RegisterSingle(() => _stubPermissionProvider); serviceLocator.RegisterSingle(() => _stubMemberResolver); serviceLocator.RegisterSingle(() => _stubFunctionalSecurityStrategy); _serviceLocatorScope = new ServiceLocatorScope(serviceLocator); }
public void SetUp() { _securityAdapter = new WxeSecurityAdapter(); _mocks = new MockRepository(); _mockSecurityProvider = _mocks.StrictMock <ISecurityProvider> (); SetupResult.For(_mockSecurityProvider.IsNull).Return(false); _mockPrincipalProvider = _mocks.StrictMock <IPrincipalProvider> (); _mockFunctionalSecurityStrategy = _mocks.StrictMock <IFunctionalSecurityStrategy> (); var serviceLocator = DefaultServiceLocator.Create(); serviceLocator.RegisterSingle(() => _mockSecurityProvider); serviceLocator.RegisterSingle(() => _mockPrincipalProvider); serviceLocator.RegisterSingle(() => _mockFunctionalSecurityStrategy); _serviceLocatorScope = new ServiceLocatorScope(serviceLocator); }
public SecurityClient( ISecurityProvider securityProvider, IPermissionProvider permissionProvider, IPrincipalProvider principalProvider, IFunctionalSecurityStrategy functionalSecurityStrategy, IMemberResolver memberResolver) { ArgumentUtility.CheckNotNull("securityProvider", securityProvider); ArgumentUtility.CheckNotNull("permissionProvider", permissionProvider); ArgumentUtility.CheckNotNull("principalProvider", principalProvider); ArgumentUtility.CheckNotNull("functionalSecurityStrategy", functionalSecurityStrategy); ArgumentUtility.CheckNotNull("memberResolver", memberResolver); _securityProvider = securityProvider; _permissionProvider = permissionProvider; _principalProvider = principalProvider; _functionalSecurityStrategy = functionalSecurityStrategy; _memberResolver = memberResolver; }
private static bool ValidatePrincipalProvider(IPrincipalProvider principalProvider) { bool providerInitialized = false; try { principalProvider.InitializeDomainContext(); providerInitialized = true; } catch (LocalUserAccountException) { Console.WriteLine(ResHelper.GetString("Error_ConnectingAD") + AbstractResHelper.LINE_BREAK + ResHelper.GetString("Error_LocalUserAccountException")); } catch (DCConnectionException) { Console.WriteLine(ResHelper.GetString("Error_ConnectingAD") + AbstractResHelper.LINE_BREAK + ResHelper.GetString("Error_LocalUserAccountException")); } catch (Exception ex) { Console.WriteLine(ResHelper.GetString("Error_ConnectingAD") + AbstractResHelper.LINE_BREAK + ex.Message); } return(providerInitialized); }
public override void SetUp() { base.SetUp(); BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null); _securityProviderStub = MockRepository.GenerateStub <ISecurityProvider>(); _principalProviderStub = MockRepository.GenerateStub <IPrincipalProvider>(); _securityPrincipalStub = MockRepository.GenerateStub <ISecurityPrincipal>(); _principalProviderStub.Stub(stub => stub.GetPrincipal()).Return(_securityPrincipalStub); _clientTransaction = ClientTransaction.CreateRootTransaction(); _clientTransaction.Extensions.Add(new SecurityClientTransactionExtension()); _clientTransaction.EnterNonDiscardingScope(); var serviceLocator = DefaultServiceLocator.Create(); serviceLocator.RegisterSingle(() => _securityProviderStub); serviceLocator.RegisterSingle(() => _principalProviderStub); _serviceLocatorScope = new ServiceLocatorScope(serviceLocator); }
public override void SetUp() { base.SetUp(); _mocks = new MockRepository(); _mockSecurityProvider = (ISecurityProvider)_mocks.StrictMock(typeof(ISecurityProvider)); SetupResult.For(_mockSecurityProvider.IsNull).Return(false); _mockPrincipalProvider = (IPrincipalProvider)_mocks.StrictMock(typeof(IPrincipalProvider)); _stubFunctionalSecurityStrategy = _mocks.StrictMock <IFunctionalSecurityStrategy>(); var serviceLocator = DefaultServiceLocator.Create(); serviceLocator.RegisterSingle(() => _stubFunctionalSecurityStrategy); serviceLocator.RegisterSingle(() => _mockSecurityProvider); serviceLocator.RegisterSingle(() => _mockPrincipalProvider); _serviceLocatorScope = new ServiceLocatorScope(serviceLocator); _searchService = new RolePropertiesSearchService(); IBusinessObjectClass roleClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(Role)); _positionProperty = (IBusinessObjectReferenceProperty)roleClass.GetPropertyDefinition("Position"); Assert.That(_positionProperty, Is.Not.Null); }
/// <summary> /// Imports users and groups from active directory. /// </summary> /// <param name="provider">IPrincipalProvider</param> /// <param name="messageLog">Provides message logging</param> /// <param name="workerCompleted">Action to perform on worker completed.</param> public static void ImportAsync(IPrincipalProvider provider, IMessageLog messageLog, RunWorkerCompletedEventHandler workerCompleted = null) { if (!ImportWorker.IsBusy) { // Set AD provider PrincipalProvider = provider; // Set message logs MessageLog = messageLog; if (ImportProfile.LogImportProcess) { MessageLog = new FileMessageLog(MessageLog, Path.GetDirectoryName(ImportProfile.LogPath), Path.GetFileName(ImportProfile.LogPath)); } // Run import if (workerCompleted != null) { ImportWorker.RunWorkerCompleted += workerCompleted; } ImportWorker.RunWorkerAsync(); } }
/// <summary> /// Returns a service object given the specified <see cref="InstanceContext"/> object. /// </summary> /// <param name="instanceContext">The current InstanceContext object.</param> /// <param name="message">The message that triggered the creation of a service object.</param> /// <returns>The service object.</returns> public object GetInstance(InstanceContext instanceContext, Message message) { InstanceContextServiceScope ctxScope = instanceContext.Extensions.Find <InstanceContextServiceScope>(); if (ctxScope == null) { Trace.TraceError("InstanceContextServiceScope not registered for instance context. Using default service provider"); return(serviceProvider.GetService(contractType)); } IServiceScope scope = ctxScope.GetServiceScope(serviceProvider); // find and set the current principal on the principal provider for the current scope IPrincipalProvider principalProvider = scope.ServiceProvider.GetService <IPrincipalProvider>(); if (principalProvider != null) { if (ServiceSecurityContext.Current.AuthorizationContext.Properties.TryGetValue("ClaimsPrincipal", out object principal)) { principalProvider.CurrentPrincipal = principal as ClaimsPrincipal; } } return(scope.ServiceProvider.GetService(contractType)); }
public BasicAuthenticationMessageHandler(IPrincipalProvider principalProvider) { _principalProvider = principalProvider; }
/// <summary> /// Constructor for Active Directory object. /// </summary> /// <param name="provider">IPrincipalProvider</param> public ADObject(IPrincipalProvider provider) { PrincipalProvider = provider; }
public UserPasswordPrincipalToken(string name, string password, IPrincipalProvider provider) : base(name, provider) { this.password = password; }
public BasicAuthenticationHandler( IPrincipalProvider principalProvider ) { this.principalProvider = principalProvider; }
public AuthorizationInterceptor(ILogger logger, IPrincipalProvider principalProvider) : base(logger) { _principalProvider = principalProvider; }
private AnonyPrincipalToken(string name, IPrincipalProvider provider) : base(name, provider) { }
/// <summary> /// Initializes a new instance of the <see cref="EventListenerHelper" /> class. /// </summary> /// <param name="principalProvider">The principal provider.</param> public EventListenerHelper(IPrincipalProvider principalProvider) { this.principalProvider = principalProvider; }
public MembershipService(IPrincipalProvider[] principalProviders, IPrincipalLoginService principalLoginService) { this.principalProviders = principalProviders; this.principalLoginService = principalLoginService; }