public CachingCryptoService(string encryptionKey)
 {
     this._cryptoService = new CryptoService(encryptionKey);
     this._lockObj       = new object();
     this._encCache      = new ConcurrentDictionary<string, string>();
     this._decCache      = new ConcurrentDictionary<string, string>();
 }
 public MembershipService(IEntityRepository<User> userRepository, IEntityRepository<Role> roleRepository, IEntityRepository<UserInRole> userInRoleRepository, ICryptoService cryptoService)
 {
     _userRepository = userRepository;
     _roleRepository = roleRepository;
     _userInRoleRepository = userInRoleRepository;
     _cryptoService = cryptoService;
 }
 public void Init(HttpApplication context)
 {
     cryptoService = DependencyResolver.Current.GetService<ICryptoServiceFactory>().Create();
     settingService = DependencyResolver.Current.GetService<ISettingService>();
     context.AuthenticateRequest += ContextOnAuthenticateRequest;
     context.EndRequest += ContextOnEndRequest;
 }
        public LocalFileSystemVolume( Config.IConnectorConfig config, ICryptoService cryptoService,
			IImageEditorService imageEditorService )
        {
            _config = config;
            _cryptoService = cryptoService;
            _imageEditorService = imageEditorService;
        }
        public EntityContextProvider(IEntityProvider entityProvider, IStateProvider stateProvider, ICryptoService cryptoService)
        {
            _entityProvider = entityProvider;

            _entityContext = stateProvider.CookieState("authctx", TimeSpan.Zero, false, true)
                .Signed(cryptoService, TimeSpan.Zero)
                .Jsoned<EntityContext>();
        }
Exemplo n.º 6
0
        public virtual void SetPassword(ICryptoService cryptoService, string password)
        {
            Guard.AgainstNull(() => cryptoService);
            Guard.AgainstNullOrWhiteSpaceString(() => password);

            this.PasswordSalt = cryptoService.GenerateSalt(password);
            this.PasswordHash = cryptoService.ComputeHash(this.PasswordSalt, password);
        }
        public DefaultMembershipService(IMessangerRepository repository, ICryptoService cryptoServ)
        {
            System.Diagnostics.Contracts.Contract.Requires<ArgumentNullException>(repository != null);
            System.Diagnostics.Contracts.Contract.Requires<ArgumentNullException>(cryptoServ != null);

            _repository = repository;
            _crypto = cryptoServ;
        }
Exemplo n.º 8
0
 public LogManager(IDatabaseFactory databaseFactory, ICryptoService cryptoService)
 {
     _dbContext = databaseFactory.Get() as DiabDbContext;
     LogCommands = new LogCommands(databaseFactory);
     ModelReader = new ModelReader(databaseFactory);
     PersonCommands = new PersonCommands(databaseFactory);
     FriendCommands = new FriendCommands(databaseFactory);
     SecurityLinkCommands = new SecurityLinkCommands(databaseFactory, cryptoService);
 }
Exemplo n.º 9
0
 public PackageBuilder(ICryptoService cryptoService, 
                       IDateTimeService dateTimeService,
                       IGuidGenerator guidGenerator
     )
 {
     this.cryptoService = cryptoService;
     this.dateTimeService = dateTimeService;
     this.guidGenerator = guidGenerator;
 }
Exemplo n.º 10
0
 public PoemController(IPoemService poemService, IVerseService verseService, ISignalizerFactory signalizerFactory, ICryptoServiceFactory cryptoServiceFactory,  ILogger logger)
     : base(logger)
 {
     this.poemService = poemService;
     this.verseService = verseService;
     this.signalizerFactory = signalizerFactory;
     cryptoService = cryptoServiceFactory.Create();
     this.logger = logger;
 }
Exemplo n.º 11
0
        public virtual bool Login(ICryptoService cryptoService, string password)
        {
            Guard.AgainstNull(() => cryptoService);
            Guard.AgainstNullOrWhiteSpaceString(() => password);

            bool loggedIn = cryptoService.VerifyPassword(this.PasswordSalt, this.PasswordHash, password);

            return loggedIn;
        }
 public AppLicenseManager(
     ISettingsProvider settingsProvider, 
     ICryptoService cryptoService)
 {
     _settingsProvider = settingsProvider;
     _cryptoService = cryptoService;
     _licenseSettings = settingsProvider.GetSettings<LicenseSettings>();
     Initialize();
 }
Exemplo n.º 13
0
 public PendingClientService(
     IRepository<PendingClientEntity> pendingClientRepository,
     IStringEncryptor stringEncryptor,
     ICryptoService cryptoService,
     IMapper mapper)
 {
     _pendingClientRepository = pendingClientRepository;
     _stringEncryptor = stringEncryptor;
     _cryptoService = cryptoService;
     _mapper = mapper;
 }
Exemplo n.º 14
0
 public WebDavPlugin(IStorageAccountService accountService, 
     ICryptoService cryptoService,
     ISecurityConfiguration securityConfiguration)
 {
     AccountService = accountService;
     CryptoService = cryptoService;
     SecurityConfiguration = securityConfiguration;
     ConfigurationProviderReference = new WeakRefHolder<ConfigurationProvider>(() => new ConfigurationProvider(AccountService, CryptoService, SecurityConfiguration));
     FolderQueryReference = new WeakRefHolder<FolderQuery>(() => new FolderQuery());
     FileStreamQueryReference = new WeakRefHolder<FileStreamQuery>(() => new FileStreamQuery());
 }
Exemplo n.º 15
0
        public SocketConnector(BaseSocketConnectionHost host, string name, IPEndPoint remoteEndPoint, ProxyInfo proxyData, EncryptType encryptType, CompressionType compressionType, ICryptoService cryptoService, int reconnectAttempts, int reconnectAttemptInterval, IPEndPoint localEndPoint)
            : base(host, name, localEndPoint, encryptType, compressionType, cryptoService, remoteEndPoint)
        {
            FReconnectTimer = new Timer(new TimerCallback(ReconnectConnectionTimerCallBack));

            FReconnectAttempts = reconnectAttempts;
            FReconnectAttemptInterval = reconnectAttemptInterval;

            FReconnectAttempted = 0;

            FProxyInfo = proxyData;
        }
        public BaseSocketConnectionCreator(BaseSocketConnectionHost host, string name, IPEndPoint localEndPoint, EncryptType encryptType, CompressionType compressionType, ICryptoService cryptoService)
        {

            FHost = host;
            FName = name;
            FLocalEndPoint = localEndPoint;
            FCompressionType = compressionType;
            FEncryptType = encryptType;

            FCryptoService = cryptoService;

        }
Exemplo n.º 17
0
        public SocketListener AddListener(string name, IPEndPoint localEndPoint, EncryptType encryptType, CompressionType compressionType, ICryptoService cryptoService, byte backLog, byte acceptThreads)
        {
            SocketListener listener = null;

            if (!Disposed)
            {
                listener = new SocketListener(this, name, localEndPoint, encryptType, compressionType, cryptoService, backLog, acceptThreads);
                listener.AddCreator();
            }

            return listener;
        }
Exemplo n.º 18
0
        public SocketConnector AddConnector(string name, IPEndPoint remoteEndPoint, ProxyInfo proxyData, EncryptType encryptType, CompressionType compressionType, ICryptoService cryptoService, int reconnectAttempts, int reconnectAttemptInterval, IPEndPoint localEndPoint)
        {
            SocketConnector result = null;

            if (!Disposed)
            {
                result = new SocketConnector(this, name, remoteEndPoint, proxyData, encryptType, compressionType, cryptoService, reconnectAttempts, reconnectAttemptInterval, localEndPoint);
                result.AddCreator();
            }

            return result;
        }
        public MsSqlVolume(IConnectorConfig config, IImageEditorService imageEditorService,

             ICryptoService cryptoService,
            IUploadFile uploadFile, IKey key, IImageFile imageFile)
        {
            _config = config;
            _imageEditorService = imageEditorService;
            _cryptoService = cryptoService;
            _uploadFile = uploadFile;
            _key = key;
            _imageFile = imageFile;
        }
Exemplo n.º 20
0
 public LoginController(
     ICryptoServiceFactory cryptoServiceFactory,
     ILoginService loginService,
     IUserProfileService userProfileService,
     IFacebookProfileProxy facebookProfileProxy,
     ILogger logger)
     : base(logger)
 {
     cryptoService = cryptoServiceFactory.Create();
     this.loginService = loginService;
     this.userProfileService = userProfileService;
     this.facebookProfileProxy = facebookProfileProxy;
 }
 public MediaFireSessionBroker(
     ICryptoService cryptoService,
    MediaFireApiConfiguration configuration,
     string email,
     string password,
     MediaFireRequestController requestController
     )
 {
     _cryptoService = cryptoService;
     _configuration = configuration;
     _email = email;
     _password = password;
     _requestController = requestController;
 }
        public BaseSocketConnectionCreator(BaseSocketConnectionHost host, string name, IPEndPoint localEndPoint, EncryptType encryptType, CompressionType compressionType, ICryptoService cryptoService, IPEndPoint remoteEndPoint)
        {
            Context = new SocketCreatorContext
            {
                CompressionType = compressionType,
                CryptoService = cryptoService,
                Host = host,
                EncryptType = encryptType,
                Name = name,
                LocalEndPoint = localEndPoint,
                RemotEndPoint = remoteEndPoint
            };

            //fWaitCreatorsDisposing = new ManualResetEvent(false);
        }
Exemplo n.º 23
0
		public static CurrentStorage Create(
			string         fileName,
			ICryptoService cryptoService,
			bool           readOnly = false
		)
		{
			CurrentStorage storage = new CurrentStorage(fileName, readOnly)
			{
				CryptoService = cryptoService
			};

			storage.CreateTables();

			return storage;
		}
Exemplo n.º 24
0
        public MessagesManager(MessagingService messagingService, 
            ConnectionManager connectionManager,
            IMessageRepository messageRepository, 
            ICryptoService cryptoService, 
            IDeviceInfoProvider deviceInfoProvider)
        {
            this.messagingService = messagingService;
            this.messageRepository = messageRepository;
            this.cryptoService = cryptoService;
            this.deviceInfoProvider = deviceInfoProvider;

            connectionManager.Authenticated += OnAuthenticated;
            messagingService.DeliveryNotification += OnMessageDelivered;
            messagingService.IncomingMessage += msg => OnIncomingMessages(new [] { msg });
            messagingService.SeenNotification += OnMessageSeen;
            EncryptionEnabled = true;
        }
Exemplo n.º 25
0
 public UserModule(ICryptoService crypto)
     : base("user")
 {
     //Get a list of all the users in the same organization as you.
     Get["/"] = _ =>
     {
         if (!IsAuthenticated)
         {
             return HttpStatusCode.Unauthorized;
         }
         var user =
             DocumentSession.Load<EmailUser>(Principal.GetUserId());
         var users =
             DocumentSession.Query<EmailUser>()
                 .Where(u => u.Organization.Id == user.Organization.Id)
                 .Select(c => new UserViewModel {Name = c.Name, Organization = c.Organization.Name}).ToList();
         return Response.AsJson(users);
     };
     Post["/"] = _ =>
     {
         //If User is authenticated and is the org admin.
         if (IsAuthenticated && Principal.HasClaim(EmailRClaimTypes.Admin))
         {
             return HttpStatusCode.Unauthorized;
         }
         var user =
             DocumentSession.Load<EmailUser>(Principal.GetUserId());
         var createUser = this.Bind<CreateUserViewModel>();
         var salt = crypto.CreateSalt();
         var newUser = new EmailUser
         {
             Email = createUser.Email,
             FriendlyName = createUser.FriendlyName,
             //Id = Guid.NewGuid(),
             Password = createUser.Password.ToSha256(salt),
             Salt = salt,
             LoginType = "Default",
             Organization = user.Organization,
             Name = createUser.UserName,
             IsAdmin = false
         };
         DocumentSession.Store(newUser);
         return HttpStatusCode.OK;
     };
 }
Exemplo n.º 26
0
		public void DecryptFrom(ITableRow encryptedRow, ICryptoService cryptoService)
		{
			encryptedRow.CopyValues(this);

			foreach (string encryptedField in EncryptedStringFields)
			{
				if (this.TableDefinition.Fields.ContainsKey(encryptedField))
				{
					FieldDefinition def = this.TableDefinition.Fields[encryptedField];

					if (def.SqlType == SqlDbType.NVarChar)
					{
						string decryptedValue = cryptoService.Decrypt(GetValue<string>(encryptedField));

						SetValue(encryptedField, decryptedValue);
					}
				}
			}
		}
Exemplo n.º 27
0
        /////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////
        // Decrypt and get the auth ticket

        /// <devdoc>
        ///    <para>Given an encrypted authenitcation ticket as
        ///       obtained from an HTTP cookie, this method returns an instance of a
        ///       FormsAuthenticationTicket class.</para>
        /// </devdoc>
        public static FormsAuthenticationTicket Decrypt(string encryptedTicket)
        {
            if (String.IsNullOrEmpty(encryptedTicket) || encryptedTicket.Length > MAX_TICKET_LENGTH)
            {
                throw new ArgumentException(SR.GetString(SR.InvalidArgumentValue, "encryptedTicket"));
            }

            Initialize();
            byte[] bBlob = null;
            if ((encryptedTicket.Length % 2) == 0)   // Could be a hex string
            {
                try {
                    bBlob = CryptoUtil.HexToBinary(encryptedTicket);
                } catch { }
            }
            if (bBlob == null)
            {
                bBlob = HttpServerUtility.UrlTokenDecode(encryptedTicket);
            }
            if (bBlob == null || bBlob.Length < 1)
            {
                throw new ArgumentException(SR.GetString(SR.InvalidArgumentValue, "encryptedTicket"));
            }

            int ticketLength;

            if (AspNetCryptoServiceProvider.Instance.IsDefaultProvider)
            {
                // If new crypto routines are enabled, call them instead.
                ICryptoService cryptoService   = AspNetCryptoServiceProvider.Instance.GetCryptoService(Purpose.FormsAuthentication_Ticket);
                byte[]         unprotectedData = cryptoService.Unprotect(bBlob);
                ticketLength = unprotectedData.Length;
                bBlob        = unprotectedData;
            }
            else
            {
#pragma warning disable 618 // calling obsolete methods
                // Otherwise call into MachineKeySection routines.

                if (_Protection == FormsProtectionEnum.All || _Protection == FormsProtectionEnum.Encryption)
                {
                    // DevDiv Bugs 137864: Include a random IV if under the right compat mode
                    // for improved encryption semantics
                    bBlob = MachineKeySection.EncryptOrDecryptData(false, bBlob, null, 0, bBlob.Length, false, false, IVType.Random);
                    if (bBlob == null)
                    {
                        return(null);
                    }
                }

                ticketLength = bBlob.Length;

                if (_Protection == FormsProtectionEnum.All || _Protection == FormsProtectionEnum.Validation)
                {
                    if (!MachineKeySection.VerifyHashedData(bBlob))
                    {
                        return(null);
                    }
                    ticketLength -= MachineKeySection.HashSize;
                }
#pragma warning restore 618 // calling obsolete methods
            }

            //////////////////////////////////////////////////////////////////////
            // Step 4: Change binary ticket to managed struct

            // ** MSRC 11838 **
            // Framework20 / Framework40 ticket generation modes are insecure. We should use a
            // secure serialization mode by default.
            if (!AppSettings.UseLegacyFormsAuthenticationTicketCompatibility)
            {
                return(FormsAuthenticationTicketSerializer.Deserialize(bBlob, ticketLength));
            }

            // ** MSRC 11838 **
            // If we have reached this point of execution, the developer has explicitly elected
            // to continue using the insecure code path instead of the secure one. We removed
            // the Framework40 serialization mode, so everybody using the legacy code path is
            // forced to Framework20.

            int           iSize  = ((ticketLength > MAX_TICKET_LENGTH) ? MAX_TICKET_LENGTH : ticketLength);
            StringBuilder name   = new StringBuilder(iSize);
            StringBuilder data   = new StringBuilder(iSize);
            StringBuilder path   = new StringBuilder(iSize);
            byte []       pBin   = new byte[4];
            long []       pDates = new long[2];

            int iRet = UnsafeNativeMethods.CookieAuthParseTicket(bBlob, ticketLength,
                                                                 name, iSize,
                                                                 data, iSize,
                                                                 path, iSize,
                                                                 pBin, pDates);

            if (iRet != 0)
            {
                return(null);
            }

            DateTime dt1 = DateTime.FromFileTime(pDates[0]);
            DateTime dt2 = DateTime.FromFileTime(pDates[1]);

            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket((int)pBin[0],
                                                                             name.ToString(),
                                                                             dt1,
                                                                             dt2,
                                                                             (bool)(pBin[1] != 0),
                                                                             data.ToString(),
                                                                             path.ToString());
            return(ticket);
        }
Exemplo n.º 28
0
 public UserService(IUserRepository userRepository, ICryptoService cryptoService)
 {
     _userRepository = userRepository;
     _cryptoService  = cryptoService;
 }
Exemplo n.º 29
0
 public SignupService(DbContextBase db, ICryptoService crypto, IVerificationProvider verificationProvider)
 {
     this.db     = db;
     this.crypto = crypto;
     this.verificationProvider = verificationProvider;
 }
        public override async void ViewDidLoad()
        {
            _vaultTimeoutService  = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService");
            _cryptoService        = ServiceContainer.Resolve <ICryptoService>("cryptoService");
            _deviceActionService  = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
            _stateService         = ServiceContainer.Resolve <IStateService>("stateService");
            _secureStorageService = ServiceContainer.Resolve <IStorageService>("secureStorageService");
            _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService");
            _biometricService     = ServiceContainer.Resolve <IBiometricService>("biometricService");
            _keyConnectorService  = ServiceContainer.Resolve <IKeyConnectorService>("keyConnectorService");
            _accountManager       = ServiceContainer.Resolve <IAccountsManager>("accountsManager");

            // We re-use the lock screen for autofill extension to verify master password
            // when trying to access protected items.
            if (autofillExtension && await _stateService.GetPasswordRepromptAutofillAsync())
            {
                _passwordReprompt      = true;
                _isPinProtected        = false;
                _isPinProtectedWithKey = false;
                _pinLock       = false;
                _biometricLock = false;
            }
            else
            {
                (_isPinProtected, _isPinProtectedWithKey) = await _vaultTimeoutService.IsPinLockSetAsync();

                _pinLock = (_isPinProtected && await _stateService.GetPinProtectedKeyAsync() != null) ||
                           _isPinProtectedWithKey;
                _biometricLock = await _vaultTimeoutService.IsBiometricLockSetAsync() &&
                                 await _cryptoService.HasKeyAsync();

                _biometricIntegrityValid = await _biometricService.ValidateIntegrityAsync(BiometricIntegrityKey);

                _usesKeyConnector = await _keyConnectorService.GetUsesKeyConnector();

                _biometricUnlockOnly = _usesKeyConnector && _biometricLock && !_pinLock;
            }

            if (_pinLock)
            {
                BaseNavItem.Title = AppResources.VerifyPIN;
            }
            else if (_usesKeyConnector)
            {
                BaseNavItem.Title = AppResources.UnlockVault;
            }
            else
            {
                BaseNavItem.Title = AppResources.VerifyMasterPassword;
            }

            BaseCancelButton.Title = AppResources.Cancel;

            if (_biometricUnlockOnly)
            {
                BaseSubmitButton.Title   = null;
                BaseSubmitButton.Enabled = false;
            }
            else
            {
                BaseSubmitButton.Title = AppResources.Submit;
            }

            var descriptor = UIFontDescriptor.PreferredBody;

            if (!_biometricUnlockOnly)
            {
                MasterPasswordCell.Label.Text = _pinLock ? AppResources.PIN : AppResources.MasterPassword;
                MasterPasswordCell.TextField.SecureTextEntry = true;
                MasterPasswordCell.TextField.ReturnKeyType   = UIReturnKeyType.Go;
                MasterPasswordCell.TextField.ShouldReturn   += (UITextField tf) =>
                {
                    CheckPasswordAsync().GetAwaiter().GetResult();
                    return(true);
                };
                if (_pinLock)
                {
                    MasterPasswordCell.TextField.KeyboardType = UIKeyboardType.NumberPad;
                }
                MasterPasswordCell.Button.TitleLabel.Font = UIFont.FromName("bwi-font", 28f);
                MasterPasswordCell.Button.SetTitle(BitwardenIcons.Eye, UIControlState.Normal);
                MasterPasswordCell.Button.TouchUpInside += (sender, e) =>
                {
                    MasterPasswordCell.TextField.SecureTextEntry = !MasterPasswordCell.TextField.SecureTextEntry;
                    MasterPasswordCell.Button.SetTitle(MasterPasswordCell.TextField.SecureTextEntry ? BitwardenIcons.Eye : BitwardenIcons.EyeSlash, UIControlState.Normal);
                };
            }

            if (TableView != null)
            {
                TableView.BackgroundColor    = ThemeHelpers.BackgroundColor;
                TableView.SeparatorColor     = ThemeHelpers.SeparatorColor;
                TableView.RowHeight          = UITableView.AutomaticDimension;
                TableView.EstimatedRowHeight = 70;
                TableView.Source             = new TableSource(this);
                TableView.AllowsSelection    = true;
            }

            base.ViewDidLoad();

            if (_biometricLock)
            {
                if (!_biometricIntegrityValid)
                {
                    return;
                }
                var tasks = Task.Run(async() =>
                {
                    await Task.Delay(500);
                    NSRunLoop.Main.BeginInvokeOnMainThread(async() => await PromptBiometricAsync());
                });
            }
        }
Exemplo n.º 31
0
        public SocketListener AddListener(string name, IPEndPoint localEndPoint, EncryptType encryptType, CompressionType compressionType, ICryptoService cryptoService, byte backLog, byte acceptThreads)
        {
            SocketListener listener = null;

            if (!Disposed)
            {
                listener = new SocketListener(this, name, localEndPoint, encryptType, compressionType, cryptoService, backLog, acceptThreads);
                AddCreator(listener);
            }

            return(listener);
        }
Exemplo n.º 32
0
        internal static String Encrypt(FormsAuthenticationTicket ticket, bool hexEncodedTicket)
        {
            if (ticket == null)
            {
                throw new ArgumentNullException("ticket");
            }

            Initialize();
            //////////////////////////////////////////////////////////////////////
            // Step 1a: Make it into a binary blob
            byte[] bBlob = MakeTicketIntoBinaryBlob(ticket);
            if (bBlob == null)
            {
                return(null);
            }

            //////////////////////////////////////////////////////////////////////
            // Step 1b: If new crypto routines are enabled, call them instead.
            if (AspNetCryptoServiceProvider.Instance.IsDefaultProvider)
            {
                ICryptoService cryptoService = AspNetCryptoServiceProvider.Instance.GetCryptoService(Purpose.FormsAuthentication_Ticket);
                byte[]         protectedData = cryptoService.Protect(bBlob);
                bBlob = protectedData;
            }
            else
            {
#pragma warning disable 618 // calling obsolete methods
                // otherwise..

                //////////////////////////////////////////////////////////////////////
                // Step 2: Get the MAC and add to the blob
                if (_Protection == FormsProtectionEnum.All || _Protection == FormsProtectionEnum.Validation)
                {
                    byte[] bMac = MachineKeySection.HashData(bBlob, null, 0, bBlob.Length);
                    if (bMac == null)
                    {
                        return(null);
                    }
                    byte[] bAll = new byte[bMac.Length + bBlob.Length];
                    Buffer.BlockCopy(bBlob, 0, bAll, 0, bBlob.Length);
                    Buffer.BlockCopy(bMac, 0, bAll, bBlob.Length, bMac.Length);
                    bBlob = bAll;
                }

                if (_Protection == FormsProtectionEnum.All || _Protection == FormsProtectionEnum.Encryption)
                {
                    //////////////////////////////////////////////////////////////////////
                    // Step 3: Do the actual encryption
                    // DevDiv Bugs 137864: Include a random IV if under the right compat mode
                    // for improved encryption semantics
                    bBlob = MachineKeySection.EncryptOrDecryptData(true, bBlob, null, 0, bBlob.Length, false, false, IVType.Random);
                }
#pragma warning restore 618 // calling obsolete methods
            }

            if (!hexEncodedTicket)
            {
                return(HttpServerUtility.UrlTokenEncode(bBlob));
            }
            else
            {
                return(CryptoUtil.BinaryToHex(bBlob));
            }
        }
Exemplo n.º 33
0
 public MembershipService(IJabbrRepository repository, ICryptoService crypto)
 {
     _repository = repository;
     _crypto = crypto;
 }
 public BaseSocketConnectionCreator(BaseSocketConnectionHost host, string name, IPEndPoint localEndPoint, ICryptoService cryptoService)
     : this(host, name, localEndPoint, EncryptType.etNone, CompressionType.ctNone, cryptoService, null)
 {
 }
Exemplo n.º 35
0
 /// <summary>
 /// Sets the crypto service.
 /// </summary>
 /// <param name="value">The value.</param>
 public void SetCryptoService(ICryptoService value)
 {
     cryptoServiceOverride = value;
 }
Exemplo n.º 36
0
 public ReplaceFileContentCommandTest()
 {
     _cryptoServiceMock = new CryptoServiceMock();
     _loggerServiceMock = new LoggerServiceMock();
 }
 public ExternalAuthenticationService(DbContextBase db, ICryptoService crypto, IList <IExternalAuthenticationProvider> providers)
 {
     this.db        = db;
     this.crypto    = crypto;
     this.providers = providers;
 }
Exemplo n.º 38
0
 public DevInfoService(IEntityRepository <DevInfo, Guid> devInfoRepository, IEntityRepository <DevData, Guid> devDataRepository, IParameterValidateService parameterValidateService, ICryptoService cryptoService)
 {
     _devInfoRepository        = devInfoRepository;
     _devDataRepository        = devDataRepository;
     _parameterValidateService = parameterValidateService;
     _cryptoService            = cryptoService;
 }
 public ExchangeSynchronizationProvider(ISynchronizationManager synchronizationManager, ICryptoService crypto)
     : base(synchronizationManager, new ExchangeSyncService(Constants.AzureExchangeServiceAdress), crypto)
 {
 }
 public HomogenizingCryptoServiceWrapper(ICryptoService wrapped)
 {
     WrappedCryptoService = wrapped;
 }
Exemplo n.º 41
0
 public AccountController(UserContext context, ICryptoService cryptoService, ICaptcha captcha)
 {
     db = context;
     this.cryptoService = cryptoService;
     this.captcha       = captcha;
 }
Exemplo n.º 42
0
 public AddTemplateCommandTest()
 {
     _cryptoServiceMock   = new CryptoServiceMock();
     _registryServiceMock = new RegistryServiceMock();
     _loggerServiceMock   = new LoggerServiceMock();
 }
Exemplo n.º 43
0
 public LoginManager(CurrentStorage storage)
 {
     this._storage       = storage;
     this._cryptoService = storage.CryptoService;
 }
Exemplo n.º 44
0
 public AuthService(UserManager <User> userManager, SignInManager <User> signInManager, IDatabase database,
                    IHttpContextAccessor httpContext, IConfiguration configuration, ICryptoService cryptoService)
 {
     this.userManager   = userManager;
     this.signInManager = signInManager;
     this.database      = database;
     this.httpContext   = httpContext;
     this.cryptoService = cryptoService;
     this.Configuration = configuration;
 }
Exemplo n.º 45
0
        public AuthService(
            ICryptoService cryptoService,
            IApiService apiService,
            IUserService userService,
            ITokenService tokenService,
            IAppIdService appIdService,
            II18nService i18nService,
            IPlatformUtilsService platformUtilsService,
            IMessagingService messagingService,
            IVaultTimeoutService vaultTimeoutService,
            bool setCryptoKeys = true)
        {
            _cryptoService        = cryptoService;
            _apiService           = apiService;
            _userService          = userService;
            _tokenService         = tokenService;
            _appIdService         = appIdService;
            _i18nService          = i18nService;
            _platformUtilsService = platformUtilsService;
            _messagingService     = messagingService;
            _vaultTimeoutService  = vaultTimeoutService;
            _setCryptoKeys        = setCryptoKeys;

            TwoFactorProviders = new Dictionary <TwoFactorProviderType, TwoFactorProvider>();
            TwoFactorProviders.Add(TwoFactorProviderType.Authenticator, new TwoFactorProvider
            {
                Type     = TwoFactorProviderType.Authenticator,
                Priority = 1,
                Sort     = 1
            });
            TwoFactorProviders.Add(TwoFactorProviderType.YubiKey, new TwoFactorProvider
            {
                Type     = TwoFactorProviderType.YubiKey,
                Priority = 3,
                Sort     = 2,
                Premium  = true
            });
            TwoFactorProviders.Add(TwoFactorProviderType.Duo, new TwoFactorProvider
            {
                Type     = TwoFactorProviderType.Duo,
                Name     = "Duo",
                Priority = 2,
                Sort     = 3,
                Premium  = true
            });
            TwoFactorProviders.Add(TwoFactorProviderType.OrganizationDuo, new TwoFactorProvider
            {
                Type     = TwoFactorProviderType.OrganizationDuo,
                Name     = "Duo (Organization)",
                Priority = 10,
                Sort     = 4
            });
            TwoFactorProviders.Add(TwoFactorProviderType.Fido2WebAuthn, new TwoFactorProvider
            {
                Type     = TwoFactorProviderType.Fido2WebAuthn,
                Priority = 4,
                Sort     = 5,
                Premium  = true
            });
            TwoFactorProviders.Add(TwoFactorProviderType.Email, new TwoFactorProvider
            {
                Type     = TwoFactorProviderType.Email,
                Priority = 0,
                Sort     = 6,
            });
        }
Exemplo n.º 46
0
        /// <summary>
        /// Construct a new instance of SecureDatabase.
        /// </summary>
        /// <param name="platform">The platform specific engine of SQLite (ISQLitePlatform)</param>
        /// <param name="dbfile">The sqlite db file path</param>

        /*protected SecureDatabase(ISQLitePlatform platform, string dbfile) : this(platform, dbfile, new CryptoService("MY-TEMP-SALT"))
         * {
         * }*/

        /// <summary>
        /// Construct a new instance of SecureDatabase.
        /// This ctor allows you pass an instance of the CryptoService. You could use the one provided by SQLite.Net.Cipher or build and pass your own.
        /// </summary>
        /// <param name="platform">The platform specific engine of SQLite (ISQLitePlatform)</param>
        /// <param name="dbfile">The sqlite db file path</param>
        /// <param name="cryptoService">An instance of the Crypto Service</param>
        protected SecureDatabase(ISQLitePlatform platform, string dbfile, ICryptoService cryptoService) : base(platform, dbfile)
        {
            _cryptoService = cryptoService;
            CreateTables();
        }
Exemplo n.º 47
0
        public App(AppOptions appOptions)
        {
            _appOptions                = appOptions ?? new AppOptions();
            _userService               = ServiceContainer.Resolve <IUserService>("userService");
            _broadcasterService        = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService");
            _messagingService          = ServiceContainer.Resolve <IMessagingService>("messagingService");
            _stateService              = ServiceContainer.Resolve <IStateService>("stateService");
            _lockService               = ServiceContainer.Resolve <ILockService>("lockService");
            _syncService               = ServiceContainer.Resolve <ISyncService>("syncService");
            _tokenService              = ServiceContainer.Resolve <ITokenService>("tokenService");
            _cryptoService             = ServiceContainer.Resolve <ICryptoService>("cryptoService");
            _cipherService             = ServiceContainer.Resolve <ICipherService>("cipherService");
            _folderService             = ServiceContainer.Resolve <IFolderService>("folderService");
            _settingsService           = ServiceContainer.Resolve <ISettingsService>("settingsService");
            _collectionService         = ServiceContainer.Resolve <ICollectionService>("collectionService");
            _searchService             = ServiceContainer.Resolve <ISearchService>("searchService");
            _authService               = ServiceContainer.Resolve <IAuthService>("authService");
            _platformUtilsService      = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService");
            _storageService            = ServiceContainer.Resolve <IStorageService>("storageService");
            _secureStorageService      = ServiceContainer.Resolve <IStorageService>("secureStorageService");
            _passwordGenerationService = ServiceContainer.Resolve <IPasswordGenerationService>(
                "passwordGenerationService");
            _i18nService         = ServiceContainer.Resolve <II18nService>("i18nService") as MobileI18nService;
            _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");

            Bootstrap();
            _broadcasterService.Subscribe(nameof(App), async(message) =>
            {
                if (message.Command == "showDialog")
                {
                    var details     = message.Data as DialogDetails;
                    var confirmed   = true;
                    var confirmText = string.IsNullOrWhiteSpace(details.ConfirmText) ?
                                      AppResources.Ok : details.ConfirmText;
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        if (!string.IsNullOrWhiteSpace(details.CancelText))
                        {
                            confirmed = await Current.MainPage.DisplayAlert(details.Title, details.Text, confirmText,
                                                                            details.CancelText);
                        }
                        else
                        {
                            await Current.MainPage.DisplayAlert(details.Title, details.Text, confirmText);
                        }
                        _messagingService.Send("showDialogResolve", new Tuple <int, bool>(details.DialogId, confirmed));
                    });
                }
                else if (message.Command == "locked")
                {
                    await _stateService.PurgeAsync();
                    var autoPromptFingerprint = !(message.Data as bool?).GetValueOrDefault();
                    if (autoPromptFingerprint && Device.RuntimePlatform == Device.iOS)
                    {
                        var lockOptions = await _storageService.GetAsync <int?>(Constants.LockOptionKey);
                        if (lockOptions == 0)
                        {
                            autoPromptFingerprint = false;
                        }
                    }
                    var lockPage = new LockPage(_appOptions, autoPromptFingerprint);
                    Device.BeginInvokeOnMainThread(() => Current.MainPage = new NavigationPage(lockPage));
                }
                else if (message.Command == "lockVault")
                {
                    await _lockService.LockAsync(true);
                }
                else if (message.Command == "logout")
                {
                    if (Migration.MigrationHelpers.Migrating)
                    {
                        return;
                    }
                    Device.BeginInvokeOnMainThread(async() => await LogOutAsync(false));
                }
                else if (message.Command == "loggedOut")
                {
                    // Clean up old migrated key if they ever log out.
                    await _secureStorageService.RemoveAsync("oldKey");
                }
                else if (message.Command == "resumed")
                {
                    if (Device.RuntimePlatform == Device.iOS)
                    {
                        ResumedAsync();
                    }
                }
                else if (message.Command == "migrated")
                {
                    await Task.Delay(1000);
                    await SetMainPageAsync();
                }
                else if (message.Command == "popAllAndGoToTabGenerator" ||
                         message.Command == "popAllAndGoToTabMyVault")
                {
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        if (Current.MainPage is TabsPage tabsPage)
                        {
                            while (tabsPage.Navigation.ModalStack.Count > 0)
                            {
                                await tabsPage.Navigation.PopModalAsync(false);
                            }
                            if (message.Command == "popAllAndGoToTabMyVault")
                            {
                                _appOptions.MyVaultTile = false;
                                tabsPage.ResetToVaultPage();
                            }
                            else
                            {
                                _appOptions.GeneratorTile = false;
                                tabsPage.ResetToGeneratorPage();
                            }
                        }
                    });
                }
            });
        }
Exemplo n.º 48
0
 public UserService(IGenericRepository <User> genericUserRepo, IGenericRepository <WaniKaniUser> genericWKUserRepo, ICryptoService cryServ)
 {
     _userRepo      = genericUserRepo;
     _wkUserRepo    = genericWKUserRepo;
     _cryptoService = cryServ;
 }
Exemplo n.º 49
0
        public VercorsSynchronizationProvider(ISynchronizationManager synchronizationManager, ICryptoService cryptoService, IVercorsService vercorsService)
            : base(synchronizationManager, cryptoService)
        {
            if (vercorsService == null)
            {
                throw new ArgumentNullException("vercorsService");
            }

            this.service = vercorsService;
        }
Exemplo n.º 50
0
 public AuthenticationService(IRepository <User> repository, ICryptoService cryptoService)
 {
     _cryptoService = cryptoService;
     _repository    = repository;
 }
Exemplo n.º 51
0
 public ShowParametersCommandTest()
 {
     _cryptoServiceMock = new CryptoServiceMock();
     _loggerServiceMock = new LoggerServiceMock();
 }
Exemplo n.º 52
0
 public ReportInfoService(IEntityRepository <SYS_USER, Guid> userRepository, IEntityRepository <Report_Energy, long> report_Energy, IEntityRepository <VT_SYSTEM, Guid> systemRepository, IEntityRepository <SYS_USERSERVICEAREA, Guid> sysUserservicearea, IEntityRepository <Sys_ResellerLicense, long> sys_ResellerLicense, IEntityRepository <Sys_ServicePartnerSn, long> sys_ServicePartnerSn, IEntityRepository <SYS_SN, Guid> snRepository, IEntityRepository <SYS_ROLE, Guid> sys_ROLE, IEntityRepository <SYS_ROLEUSER, Guid> sys_ROLEUSER, IParameterValidateService parameterValidateService, ICryptoService cryptoService, IEntityRepository <SYS_LOG, Guid> sysLogService)
 {
     _userRepository           = userRepository;
     _report_Energy            = report_Energy;
     _systemRepository         = systemRepository;
     _sysUserservicearea       = sysUserservicearea;
     _sys_ResellerLicense      = sys_ResellerLicense;
     _sys_ServicePartnerSn     = sys_ServicePartnerSn;
     _snRepository             = snRepository;
     _sys_ROLE                 = sys_ROLE;
     _sys_ROLEUSER             = sys_ROLEUSER;
     _parameterValidateService = parameterValidateService;
     _cryptoService            = cryptoService;
     _sysLogService            = sysLogService;
 }
Exemplo n.º 53
0
 public TemplateCommandTest()
 {
     _cryptoServiceMock = new CryptoServiceMock();
     _storedDataService = new StoredDataServiceMock();
     _loggerServiceMock = new LoggerServiceMock();
 }
Exemplo n.º 54
0
 public SocketListener AddListener(string name, IPEndPoint localEndPoint, EncryptType encryptType, CompressionType compressionType, ICryptoService cryptoService)
 {
     return(AddListener(name, localEndPoint, encryptType, compressionType, cryptoService, 5, 2));
 }
Exemplo n.º 55
0
 public ClientState(ICryptoService cryptoService, IHashCalculationsRepository hashCalculationsRepository)
 {
     _cryptoService          = cryptoService;
     _defaultHashCalculation = hashCalculationsRepository.Create(Globals.DEFAULT_HASH);
 }
Exemplo n.º 56
0
 public ShowPipelinesCommandTest()
 {
     _cryptoServiceMock   = new CryptoServiceMock();
     _registryServiceMock = new RegistryServiceMock();
     _loggerServiceMock   = new LoggerServiceMock();
 }
Exemplo n.º 57
0
		public MyDatabase(ISQLitePlatform platform, string dbfile, ICryptoService cryptoService) : base(platform, dbfile, cryptoService)
		{
		}
Exemplo n.º 58
0
 public SocketConnector AddConnector(string name, IPEndPoint remoteEndPoint, ProxyInfo proxyData, EncryptType encryptType, CompressionType compressionType, ICryptoService cryptoService, int reconnectAttempts, int reconnectAttemptInterval)
 {
     return(AddConnector(name, remoteEndPoint, proxyData, encryptType, compressionType, cryptoService, reconnectAttempts, reconnectAttemptInterval, new IPEndPoint(IPAddress.Any, 0)));
 }
Exemplo n.º 59
0
 public ChatService(IJabbrRepository repository, ICryptoService crypto)
 {
     _repository = repository;
     _crypto = crypto;
 }
Exemplo n.º 60
0
        public SocketConnector AddConnector(string name, IPEndPoint remoteEndPoint, ProxyInfo proxyData, EncryptType encryptType, CompressionType compressionType, ICryptoService cryptoService, int reconnectAttempts, int reconnectAttemptInterval, IPEndPoint localEndPoint)
        {
            SocketConnector result = null;

            if (!Disposed)
            {
                result = new SocketConnector(this, name, remoteEndPoint, proxyData, encryptType, compressionType, cryptoService, reconnectAttempts, reconnectAttemptInterval, localEndPoint);
                AddCreator(result);
            }

            return(result);
        }