示例#1
0
        //Loads the named crypto provider
        public bool LoadCryptoProvider(string name)
        {
            string cryptoProviderFilename = Path.Combine(appDir, name + "_CryptoProvider.dll");
            string keyFilename            = Path.Combine(appDir, name + ".key");

            //load the specified crypto provider
            if (File.Exists(cryptoProviderFilename))
            {
                _cryptoProvider = LoadCryptoProviderDLL(cryptoProviderFilename);
            }
            else
            {
                throw new Exception(string.Format("Crypto Provider not found : {0}", cryptoProviderFilename));
            }

            //load the server node key pair (not currently used)
            if (File.Exists(keyFilename))
            {
                _cryptoProvider.ImportKeyPairFromFile(keyFilename);
            }
            else
            {
                _cryptoProvider.GenerateKeyPair();
                _cryptoProvider.ExportKeyPairToFile(keyFilename);
                Logger.Log("Key pair generated");
            }

            return(true);
        }
示例#2
0
        internal bool ExchangeKeysForEncryption(object lockObject)
        {
            this.isEncryptionAvailable = false;
            bool flag = this.CryptoProvider != null;

            if (flag)
            {
                this.CryptoProvider.Dispose();
                this.CryptoProvider = null;
            }
            bool flag2 = this.CryptoProvider == null;

            if (flag2)
            {
                this.CryptoProvider = new DiffieHellmanCryptoProvider();
            }
            Dictionary <byte, object> dictionary = new Dictionary <byte, object>(1);

            dictionary[PhotonCodes.ClientKey] = this.CryptoProvider.PublicKey;
            bool flag3 = lockObject != null;
            bool result;

            if (flag3)
            {
                lock (lockObject)
                {
                    result = this.EnqueueOperation(dictionary, PhotonCodes.InitEncryption, true, 0, false, PeerBase.EgMessageType.InternalOperationRequest);
                    return(result);
                }
            }
            result = this.EnqueueOperation(dictionary, PhotonCodes.InitEncryption, true, 0, false, PeerBase.EgMessageType.InternalOperationRequest);
            return(result);
        }
        /// <summary>
        /// Tries to parse an encrypted operation response.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="cryptoProvider">The crypto provider.</param>
        /// <param name="operationResponse">The operation response.</param>
        /// <returns> true if the operation response was parsed successfully; otherwise false.</returns>
        public bool TryParseOperationResponseEncrypted(byte[] data, ICryptoProvider cryptoProvider, out OperationResponse operationResponse)
        {
            object obj2;

            if (cryptoProvider == null)
            {
                operationResponse = null;
                return(false);
            }
            byte[] buffer = cryptoProvider.Decrypt(data, 2, data.Length - 2);
            if (buffer == null)
            {
                operationResponse = null;
                return(false);
            }
            if (operationDataLogger.IsDebugEnabled)
            {
                operationDataLogger.DebugFormat("Decrypted data: data=({0} bytes) {1}", new object[] { buffer.Length, BitConverter.ToString(buffer) });
            }
            int pos = 0;

            if (GpBinaryByteReaderV17.TryReadOperationResponse(buffer, ref pos, out obj2))
            {
                operationResponse = (OperationResponse)obj2;
                return(true);
            }
            operationResponse = null;
            return(false);
        }
示例#4
0
        public UserManager(
            ILoggerFactory loggerFactory,
            IServerConfigurationManager configurationManager,
            IUserRepository userRepository,
            IXmlSerializer xmlSerializer,
            INetworkManager networkManager,
            Func <IImageProcessor> imageProcessorFactory,
            Func <IDtoService> dtoServiceFactory,
            IServerApplicationHost appHost,
            IJsonSerializer jsonSerializer,
            IFileSystem fileSystem,
            ICryptoProvider cryptographyProvider)
        {
            _logger                = loggerFactory.CreateLogger(nameof(UserManager));
            UserRepository         = userRepository;
            _xmlSerializer         = xmlSerializer;
            _networkManager        = networkManager;
            _imageProcessorFactory = imageProcessorFactory;
            _dtoServiceFactory     = dtoServiceFactory;
            _appHost               = appHost;
            _jsonSerializer        = jsonSerializer;
            _fileSystem            = fileSystem;
            _cryptographyProvider  = cryptographyProvider;
            ConfigurationManager   = configurationManager;
            _users = Array.Empty <User>();

            DeletePinFile();
        }
 /// <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;
 }
示例#6
0
 public LdapAuthenticationProviderPlugin(IUserManager userManager, ICryptoProvider cryptoProvider)
 {
     _config         = Plugin.Instance.Configuration;
     _logger         = Plugin.Logger;
     _userManager    = userManager;
     _cryptoProvider = cryptoProvider;
 }
 public PasswordRecoveryByRecoveryClue(IEmailSender eMailSender, ISystemContext systemContext, ICryptoProvider cryptoProvider, IConfigurationProvider configProvider)
 {
     this.eMailSender = eMailSender;
     this.systemContext = systemContext;
     this.cryptoProvider = cryptoProvider;
     this.configProvider = configProvider;
 }
 public PasswordRecoveryByRecoveryClue(IEmailSender eMailSender, ISystemContext systemContext, ICryptoProvider cryptoProvider, IConfigurationProvider configProvider)
 {
     this.eMailSender    = eMailSender;
     this.systemContext  = systemContext;
     this.cryptoProvider = cryptoProvider;
     this.configProvider = configProvider;
 }
示例#9
0
 public HttpListener(ILogger logger, X509Certificate certificate, ICryptoProvider cryptoProvider,
                     ISocketFactory socketFactory, INetworkManager networkManager, IStreamHelper streamHelper,
                     IFileSystem fileSystem, IEnvironmentInfo environmentInfo)
     : this(logger, cryptoProvider, socketFactory, networkManager, streamHelper, fileSystem, environmentInfo)
 {
     _certificate = certificate;
 }
 public EphemeralSessionProviderFaster(int numberOfKeys, ICryptoProvider provider, BulkCipherType cipherType, SecretSchedulePool secretPool)
 {
     _cryptoProvider = provider;
     _cipherType     = cipherType;
     _keyGuid        = Guid.NewGuid();
     GenerateKeys(secretPool, numberOfKeys);
 }
示例#11
0
        public InstallationManager(
            ILoggerFactory loggerFactory,
            IApplicationHost appHost,
            IApplicationPaths appPaths,
            IHttpClient httpClient,
            IJsonSerializer jsonSerializer,
            IServerConfigurationManager config,
            IFileSystem fileSystem,
            ICryptoProvider cryptographyProvider,
            IZipClient zipClient,
            string packageRuntime)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            CurrentInstallations           = new List <Tuple <InstallationInfo, CancellationTokenSource> >();
            CompletedInstallationsInternal = new ConcurrentBag <InstallationInfo>();

            _applicationHost      = appHost;
            _appPaths             = appPaths;
            _httpClient           = httpClient;
            _jsonSerializer       = jsonSerializer;
            _config               = config;
            _fileSystem           = fileSystem;
            _cryptographyProvider = cryptographyProvider;
            _zipClient            = zipClient;
            _packageRuntime       = packageRuntime;
            _logger               = loggerFactory.CreateLogger(nameof(InstallationManager));
        }
        public CheckScannerController(IConfigurationWrapper configuration,
                                      ICheckScannerService checkScannerService,
                                      IAuthenticationRepository authenticationService,
                                      ICommunicationRepository communicationService,
                                      ICryptoProvider cryptoProvider,
                                      IUserImpersonationService userImpersonationService,
                                      IMessageQueueFactory messageQueueFactory = null,
                                      IMessageFactory messageFactory           = null) : base(userImpersonationService)
        {
            _checkScannerService   = checkScannerService;
            _authenticationService = authenticationService;
            _communicationService  = communicationService;
            _cryptoProvider        = cryptoProvider;

            var b = configuration.GetConfigValue("CheckScannerDonationsAsynchronousProcessingMode");

            _asynchronous = b != null && bool.Parse(b);
            if (_asynchronous)
            {
                var donationsQueueName = configuration.GetConfigValue("CheckScannerDonationsQueueName");
                // ReSharper disable once PossibleNullReferenceException
                _donationsQueue = messageQueueFactory.CreateQueue(donationsQueueName, QueueAccessMode.Send);
                _messageFactory = messageFactory;
            }
        }
示例#13
0
        public XElement WriteSection(string sectionXmlName, object sectionSource, ICryptoProvider cryptoProvider, bool encryptAll)
        {
            _errors = new List<ConfigError>();

            var o = sectionSource as ConfigWithCustomHandler;

            if (o.ThrowOnWrite)
            {
                throw new Exception("Custom handler write error");
            }

            if (o.ErrorsNullOnWrite)
            {
                _errors = null;
            }

            if (o.HasErrorOnWrite)
            {
                _errors.Add(new ConfigError(ConfigErrorCode.InvalidConfigType, string.Empty));
            }

            return new XElement(
                sectionXmlName,
                new XElement("ErrorsNullOnRead", o.ErrorsNullOnRead.ToString()),
                new XElement("ErrorsNullOnWrite", o.ErrorsNullOnWrite.ToString()),
                new XElement("HasErrorOnRead", o.HasErrorOnRead.ToString()),
                new XElement("HasErrorOnWrite", o.HasErrorOnWrite.ToString()),
                new XElement("ReadByHandler", o.ReadByHandler.ToString()),
                new XElement("ThrowOnRead", o.ThrowOnRead.ToString()),
                new XElement("ThrowOnWrite", o.ThrowOnWrite.ToString()),
                new XElement("WrittenByHandler", true.ToString()));
        }
示例#14
0
 public RsaConvertTextDialog(ActionType actionType, ICryptoProvider cryptoProvider)
 {
     InitializeComponent();
     this.actionType     = actionType;
     this.cryptoProvider = cryptoProvider;
     this.actionBtn.Text = this.actionType == ActionType.Encrypt ? "Encrypt" : "Decrypt";
 }
示例#15
0
        public object ReadSection(XElement section, ICryptoProvider cryptoProvider, bool decryptAll)
        {
            _errors = new List<ConfigError>();

            var res = new ConfigWithCustomHandler
            {
                ErrorsNullOnRead = GetVal(section, "ErrorsNullOnRead"),
                ErrorsNullOnWrite = GetVal(section, "ErrorsNullOnWrite"),
                HasErrorOnRead = GetVal(section, "HasErrorOnRead"),
                HasErrorOnWrite = GetVal(section, "HasErrorOnWrite"),
                ReadByHandler = true,
                ThrowOnRead = GetVal(section, "ThrowOnRead"),
                ThrowOnWrite = GetVal(section, "ThrowOnWrite"),
                WrittenByHandler = GetVal(section, "WrittenByHandler")
            };

            if (res.ThrowOnRead)
            {
                throw new Exception("Custom handler write error");
            }

            if (res.ErrorsNullOnRead)
            {
                _errors = null;
            }

            if (res.HasErrorOnRead)
            {
                _errors.Add(new ConfigError(ConfigErrorCode.InvalidConfigType, string.Empty));
            }

            return res;
        }
        public static async Task <string> DecryptAsync(this ICryptoProvider cryptoProvider, string encryptedValue)
        {
            var encryptedData = Convert.FromBase64String(encryptedValue);
            var result        = await cryptoProvider.DecryptAsync(encryptedData);

            return(Encoding.UTF8.GetString(result));
        }
示例#17
0
        public DonorRepository(IMinistryPlatformService ministryPlatformService, IMinistryPlatformRestRepository ministryPlatformRestRepository, IProgramRepository programService, ICommunicationRepository communicationService, IAuthenticationRepository authenticationService, IContactRepository contactService, IConfigurationWrapper configuration, ICryptoProvider crypto)
            : base(authenticationService, configuration)
        {
            _ministryPlatformService        = ministryPlatformService;
            _ministryPlatformRestRepository = ministryPlatformRestRepository;
            _programService       = programService;
            _communicationService = communicationService;
            _contactService       = contactService;
            _crypto = crypto;

            _donorPageId                          = configuration.GetConfigIntValue("Donors");
            _donationPageId                       = configuration.GetConfigIntValue("Donations");
            _donationDistributionPageId           = configuration.GetConfigIntValue("Distributions");
            _donorAccountsPageId                  = configuration.GetConfigIntValue("DonorAccounts");
            _findDonorByAccountPageViewId         = configuration.GetConfigIntValue("FindDonorByAccountPageView");
            _donationStatusesPageId               = configuration.GetConfigIntValue("DonationStatus");
            _donorLookupByEncryptedAccount        = configuration.GetConfigIntValue("DonorLookupByEncryptedAccount");
            _myHouseholdDonationDistributions     = configuration.GetConfigIntValue("MyHouseholdDonationDistributions");
            _recurringGiftBySubscription          = configuration.GetConfigIntValue("RecurringGiftBySubscription");
            _recurringGiftPageId                  = configuration.GetConfigIntValue("RecurringGifts");
            _myDonorPageId                        = configuration.GetConfigIntValue("MyDonor");
            _myHouseholdDonationRecurringGifts    = configuration.GetConfigIntValue("MyHouseholdDonationRecurringGifts");
            _myHouseholdRecurringGiftsApiPageView = configuration.GetConfigIntValue("MyHouseholdRecurringGiftsApiPageView");
            _myHouseholdPledges                   = configuration.GetConfigIntValue("MyHouseholdPledges");

            _dateTimeFormat = new DateTimeFormatInfo
            {
                AMDesignator = "am",
                PMDesignator = "pm"
            };
        }
示例#18
0
 public TokenIssuer(ICryptoProvider cryptoProvider, IIssuerConfig config)
 {
     _cryptoProvider = cryptoProvider;
     _config         = config;
     claims          = new Dictionary <string, IJsonSerializable>();
     Set(KnownClaims.Issuer, config.IssuerName);
 }
示例#19
0
        public HttpListenerHost(IServerApplicationHost applicationHost,
                                ILogger logger,
                                IServerConfigurationManager config,
                                string serviceName,
                                string defaultRedirectPath, INetworkManager networkManager, IMemoryStreamFactory memoryStreamProvider, ITextEncoding textEncoding, ISocketFactory socketFactory, ICryptoProvider cryptoProvider, IJsonSerializer jsonSerializer, IXmlSerializer xmlSerializer, IEnvironmentInfo environment, ICertificate certificate, IStreamFactory streamFactory, Func <Type, Func <string, object> > funcParseFn, bool enableDualModeSockets, IFileSystem fileSystem)
        {
            Instance = this;

            _appHost               = applicationHost;
            DefaultRedirectPath    = defaultRedirectPath;
            _networkManager        = networkManager;
            _memoryStreamProvider  = memoryStreamProvider;
            _textEncoding          = textEncoding;
            _socketFactory         = socketFactory;
            _cryptoProvider        = cryptoProvider;
            _jsonSerializer        = jsonSerializer;
            _xmlSerializer         = xmlSerializer;
            _environment           = environment;
            _certificate           = certificate;
            _streamFactory         = streamFactory;
            _funcParseFn           = funcParseFn;
            _enableDualModeSockets = enableDualModeSockets;
            _fileSystem            = fileSystem;
            _config = config;

            _logger = logger;

            RequestFilters  = new List <Action <IRequest, IResponse, object> >();
            ResponseFilters = new List <Action <IRequest, IResponse, object> >();
        }
示例#20
0
 internal static void AttachFile(string path, ICryptoProvider cryptoProvider)
 {
     lock (handles_)
     {
         paths_[Path.GetFullPath(path)] = cryptoProvider;
     }
 }
 /// <summary>
 ///     Create a hashed representation of the plain text.
 /// </summary>
 /// <param name="plainText">The text to hash</param>
 /// <param name="supportedHashAlgorithm">If supplied the algorithm to hash the plain text with. Otherwise default.</param>
 /// <param name="complexityThrottle">
 ///     Offers the ability to tune the algorithm in order to increase the complexity. 1 being
 ///     the lowest value and 100 being very large.
 /// </param>
 /// <param name="saltProvider">Provider of the salt used for creating the hash.</param>
 private HashedValue(string plainText, SupportedHashAlgorithm supportedHashAlgorithm, int complexityThrottle, ICryptoProvider saltProvider)
 {
     _algorithm          = supportedHashAlgorithm;
     _complexityThrottle = complexityThrottle;
     _saltProvider       = saltProvider;
     ComputeHashWorker(plainText, supportedHashAlgorithm, complexityThrottle);
 }
示例#22
0
        public DonorService(IMinistryPlatformService ministryPlatformService, IProgramService programService, ICommunicationService communicationService, IAuthenticationService authenticationService, IContactService contactService,  IConfigurationWrapper configuration, ICryptoProvider crypto)
            : base(authenticationService, configuration)
        {
            _ministryPlatformService = ministryPlatformService;
            _programService = programService;
            _communicationService = communicationService;
            _contactService = contactService;
            _crypto = crypto;

            _donorPageId = configuration.GetConfigIntValue("Donors");
            _donationPageId = configuration.GetConfigIntValue("Donations");
            _donationDistributionPageId = configuration.GetConfigIntValue("Distributions");
            _donorAccountsPageId = configuration.GetConfigIntValue("DonorAccounts");
            _findDonorByAccountPageViewId = configuration.GetConfigIntValue("FindDonorByAccountPageView");
            _donationStatusesPageId = configuration.GetConfigIntValue("DonationStatus");
            _donorLookupByEncryptedAccount = configuration.GetConfigIntValue("DonorLookupByEncryptedAccount");
            _myHouseholdDonationDistributions = configuration.GetConfigIntValue("MyHouseholdDonationDistributions");
            _recurringGiftBySubscription = configuration.GetConfigIntValue("RecurringGiftBySubscription");
            _recurringGiftPageId = configuration.GetConfigIntValue("RecurringGifts");
            _myDonorPageId = configuration.GetConfigIntValue("MyDonor");
            _myHouseholdDonationRecurringGifts = configuration.GetConfigIntValue("MyHouseholdDonationRecurringGifts");
            _myHouseholdRecurringGiftsApiPageView = configuration.GetConfigIntValue("MyHouseholdRecurringGiftsApiPageView");
            _myHouseholdPledges = configuration.GetConfigIntValue("MyHouseholdPledges");

            _dateTimeFormat = new DateTimeFormatInfo
            {
                AMDesignator = "am",
                PMDesignator = "pm"
            };

        }
        public static async Task <string> EncryptAsync(this ICryptoProvider cryptoProvider, string plainValue)
        {
            var plainData = Encoding.UTF8.GetBytes(plainValue);
            var result    = await cryptoProvider.EncryptAsync(plainData);

            return(Convert.ToBase64String(result));
        }
 public DigitalWalletController(ISettingsBase settingsBase, ICryptoProvider cryptoProvider, ILog logger)
 {
     _settings       = new Settings(settingsBase);
     _cryptoProvider = cryptoProvider;
     _logger         = logger;
     _securityKey    = _settings.MobileConfiguration.DigitalWallet.EncryptionSecurityKey;
 }
示例#25
0
 public UsersController(IUserServices userServices,
                        IAccountServices accountServices,
                        ICategoryServices categoryServices,
                        ITransactionServices transactionServices,
                        IBudgetServices budgetServices,
                        IHttpContextProvider context,
                        ISiteConfiguration config,
                        ICryptoProvider crypto,
                        IUrlHelper urlHelper,
                        IModelCache cache,
                        ICachingHelpers cachingHelpers,
                        ISessionServices sessionServices)
     : base(userServices,
                                                                 accountServices,
                                                                 categoryServices,
                                                                 transactionServices, 
                                                                 budgetServices,
                                                                 context,
                                                                 config,
                                                                 urlHelper,
                                                                 cache,
                                                                 cachingHelpers)
 {
     _crypto = crypto;
     _sessionServices = sessionServices;
 }
 public AdminServiceProvider(ChatContext context, ChatServiceContext serviceDb,
                             ICryptoProvider cryptoProvider, IJoinService joinService)
 {
     _db             = context;
     _serviceDb      = serviceDb;
     _cryptoProvider = cryptoProvider;
     _joinService    = joinService;
 }
示例#27
0
        public MBLicenseFile(IApplicationPaths appPaths, IFileSystem fileSystem, ICryptoProvider cryptographyProvider)
        {
            _appPaths             = appPaths;
            _fileSystem           = fileSystem;
            _cryptographyProvider = cryptographyProvider;

            Load();
        }
示例#28
0
        public CryptoProviderBackgroundService(ICryptoProvider cryptoProvider, IHubContext <OrderBookHub, IOrderBookClient> orderBookHub, IServiceScopeFactory factory, IOptions <BackgroundServiceConfig> config)
        {
            _orderBookHub   = orderBookHub;
            _cryptoProvider = cryptoProvider;
            _config         = config.Value;

            _dbContext = factory.CreateScope().ServiceProvider.GetRequiredService <CryptoExchangeContext>();
        }
示例#29
0
 public CertificateMatcher(ICryptoProvider cryptoProvider)
 {
     if (cryptoProvider == null)
     {
         throw new ArgumentNullException(nameof(cryptoProvider));
     }
     _cryptoProvider = cryptoProvider;
 }
示例#31
0
 public UserService(IUserManager userManager, ISignInManager signInManager, IDbContextProvider contextProvider, ICryptoProvider cryptoProvider, IEmailService emailService)
 {
     _userManager     = userManager;
     _signInManager   = signInManager;
     _contextProvider = contextProvider;
     _cryptoProvider  = cryptoProvider;
     _emailService    = emailService;
 }
示例#32
0
 public JoinService(ChatContext db, ICryptoProvider cryptoProvider,
                    IHttpContextAccessor contextAccessor, ILogger <JoinService> logger)
 {
     _db             = db;
     _cryptoProvider = (CryptoProvider)cryptoProvider;
     _contextAcessor = contextAccessor;
     _logger         = logger;
 }
示例#33
0
		private async Task TestSendAndReceiveAsync(
			ICryptoProvider senderCrypto, OwnEndpoint senderEndpoint, ICryptoProvider receiverCrypto, OwnEndpoint receiverEndpoint) {
			var inboxMock = new Mocks.InboxHttpHandlerMock(new[] { receiverEndpoint.PublicEndpoint });
			var cloudStorage = new Mocks.CloudBlobStorageProviderMock();

			await this.SendMessageAsync(cloudStorage, inboxMock, senderCrypto, senderEndpoint, receiverEndpoint.PublicEndpoint);
			await this.ReceiveMessageAsync(cloudStorage, inboxMock, receiverCrypto, receiverEndpoint);
		}
 public AccountService(ILogProvider log, IAccountDal dal, IAccountValidator validator, IAccountChangeHandler changeHandler, ICryptoProvider cryptoProvider)
 {
     this.log            = log;
     this.dal            = dal;
     this.changeHandler  = changeHandler;
     this.validator      = validator;
     this.cryptoProvider = cryptoProvider;
 }
示例#35
0
 internal virtual void InitEncryption(byte[] secret)
 {
     if (this.CryptoProvider == null)
     {
         this.CryptoProvider        = new DiffieHellmanCryptoProvider(secret);
         this.isEncryptionAvailable = true;
     }
 }
示例#36
0
		/// <summary>
		/// Sets this security level's key lengths to the specified crypto provider.
		/// </summary>
		/// <param name="cryptoProvider">The crypto provider.</param>
		public void Apply(ICryptoProvider cryptoProvider) {
			Requires.NotNull(cryptoProvider, "cryptoProvider");

			cryptoProvider.HashAlgorithmName = this.HashAlgorithmName;
			cryptoProvider.SymmetricEncryptionConfiguration = this.SymmetricEncryptionConfiguration;
			cryptoProvider.EncryptionAsymmetricKeySize = this.EncryptionAsymmetricKeySize;
			cryptoProvider.SignatureAsymmetricKeySize = this.SignatureAsymmetricKeySize;
			cryptoProvider.SymmetricEncryptionKeySize = this.BlobSymmetricKeySize;
		}
        /// <summary>
        ///     Initializes a new instance of the Sentinel.OAuth.Implementation.PrincipalProvider
        ///     class.
        /// </summary>
        /// <param name="cryptoProvider">The crypto provider.</param>
        public PrincipalProvider(ICryptoProvider cryptoProvider)
        {
            if (cryptoProvider == null)
            {
                throw new ArgumentNullException("cryptoProvider");
            }

            this.cryptoProvider = cryptoProvider;
        }
示例#38
0

        
        /// <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 AccountManager(
            IAccountContext accountContext, ICryptoProvider cryptoProvider, 
            ISystemContext systemContext, IDependencyResolver dependencyResolver)
        {
            this.accountContext = accountContext;
            this.cryptoProvider = cryptoProvider;
            this.systemContext = systemContext;
            this.dependencyResolver = dependencyResolver;

            //This resolved instance is delayed until here because we want to make sure the user validator also uses the same DB Access instances
            this.userValidator = dependencyResolver.Resolve<IUserValidator>(DependencyOverride.CreateNew<IUsersRepository>(accountContext.Users));
        }
        public AwsProfileController(
			IRepository<AwsProfile> profileRepository,
			IRepository<IPRange> ipRangeRepository,
			ICryptoProvider cryptoProvider,
			IBackgroundJobClient backgroundJobClient,
			IAuthenticatedUserClient userClient,
			IAwsClientFactory awsClientFactory)
        {
            _profileRepository = profileRepository;
            _ipRangeRepository = ipRangeRepository;
            _cryptoProvider = cryptoProvider;
            _backgroundJobClient = backgroundJobClient;
            _userClient = userClient;
            _awsClientFactory = awsClientFactory;
        }
示例#42
0
		internal static OwnEndpoint GenerateOwnEndpoint(ICryptoProvider cryptoProvider = null) {
			cryptoProvider = cryptoProvider ?? new Mocks.MockCryptoProvider();

			var inboxFactory = new Mock<IEndpointInboxFactory>();
			inboxFactory.Setup(f => f.CreateInboxAsync(CancellationToken.None)).Returns(
				Task.FromResult(
					new InboxCreationResponse
					{ InboxOwnerCode = "some owner code", MessageReceivingEndpoint = MessageReceivingEndpoint.AbsoluteUri }));
			var endpointServices = new OwnEndpointServices {
				CryptoProvider = cryptoProvider,
				EndpointInboxFactory = inboxFactory.Object,
			};

			var ownContact = endpointServices.CreateAsync().Result;
			return ownContact;
		}
示例#43
0
        public ProgressFileDownloader(IDev2WebClient webClient, IFile file, ICryptoProvider cryptoProvider)
        {
            VerifyArgument.IsNotNull("webClient", webClient);
            VerifyArgument.IsNotNull("file", file);
            VerifyArgument.IsNotNull("cryptoProvider", cryptoProvider);
            _webClient = webClient;

            ProgressDialog = GetProgressDialogViewModel(_owner, Cancel);
            _file = file;
            _cryptoProvider = cryptoProvider;
            _webClient.DownloadProgressChanged += OnDownloadProgressChanged;
            _dontStartUpdate = false;
            ShutDownAction = ShutdownAndInstall;
            if (!Directory.Exists("Installers"))
                Directory.CreateDirectory("Installers");

        }
示例#44
0
		/// <summary>
		/// Deserializes an endpoint from an address book entry and validates that the signatures are correct.
		/// </summary>
		/// <param name="cryptoProvider">The cryptographic provider that will be used to verify the signature.</param>
		/// <returns>The deserialized endpoint.</returns>
		/// <exception cref="BadAddressBookEntryException">Thrown if the signatures are invalid.</exception>
		public Endpoint ExtractEndpoint(ICryptoProvider cryptoProvider) {
			Requires.NotNull(cryptoProvider, "cryptoProvider");

			var reader = new BinaryReader(new MemoryStream(this.SerializedEndpoint));
			Endpoint endpoint;
			try {
				endpoint = reader.DeserializeDataContract<Endpoint>();
			} catch (SerializationException ex) {
				throw new BadAddressBookEntryException(ex.Message, ex);
			}

			try {
				if (!cryptoProvider.VerifySignature(endpoint.SigningKeyPublicMaterial, this.SerializedEndpoint, this.Signature)) {
					throw new BadAddressBookEntryException(Strings.AddressBookEntrySignatureDoesNotMatch);
				}
			} catch (Exception ex) { // all those platform-specific exceptions that aren't available to portable libraries.
				throw new BadAddressBookEntryException(Strings.AddressBookEntrySignatureDoesNotMatch, ex);
			}

			return endpoint;
		}
        public CheckScannerController(IConfigurationWrapper configuration,
                                      ICheckScannerService checkScannerService,
                                      IAuthenticationService authenticationService,
                                      ICommunicationService communicationService,
                                      ICryptoProvider cryptoProvider,
                                      IMessageQueueFactory messageQueueFactory = null,
                                      IMessageFactory messageFactory = null)
        {
            _checkScannerService = checkScannerService;
            _authenticationService = authenticationService;
            _communicationService = communicationService;
            _cryptoProvider = cryptoProvider;

            var b = configuration.GetConfigValue("CheckScannerDonationsAsynchronousProcessingMode");
            _asynchronous = b != null && bool.Parse(b);
            if (_asynchronous)
            {
                var donationsQueueName = configuration.GetConfigValue("CheckScannerDonationsQueueName");
                // ReSharper disable once PossibleNullReferenceException
                _donationsQueue = messageQueueFactory.CreateQueue(donationsQueueName, QueueAccessMode.Send);
                _messageFactory = messageFactory;
            }
        }
示例#46
0
 public XElement WriteSection(string sectionXmlName, object sectionSource, ICryptoProvider cryptoProvider, bool encryptAll)
 {
     throw new NotImplementedException();
 }
示例#47
0
 public object ReadSection(XElement section, ICryptoProvider cryptoProvider, bool decryptAll)
 {
     throw new NotImplementedException();
 }
示例#48
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="graphType"></param>
 /// <param name="provider"></param>
 /// <param name="useEncryption"></param>
 /// <param name="fileName"></param>
 public XmlFilePersister(Type graphType, ICryptoProvider provider, bool useEncryption, string fileName)
     : base(graphType, provider, useEncryption)
 {
     Filename = fileName;
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="DirectEntryAddressBook" /> class.
		/// </summary>
		/// <param name="cryptoProvider">The crypto provider.</param>
		/// <param name="httpClient">The HTTP client.</param>
		public DirectEntryAddressBook(ICryptoProvider cryptoProvider, HttpClient httpClient)
			: base(httpClient) {
			this.CryptoServices = cryptoProvider;
		}
示例#50
0
 public UserService(IRepository repository, ICryptoProvider crypto, IMailProvider mail)
 {
     _repository = repository;
     _crypto = crypto;
     _mail = mail;
 }
示例#51
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="graphType"></param>
 /// <param name="provider"></param>
 /// <param name="fileName"></param>
 public XmlFilePersister(Type graphType, ICryptoProvider provider, string fileName)
     : this(graphType, provider, true, fileName)
 {
 }
 /// <summary>Initializes a new instance of the SqlServerUserManager class.</summary>
 /// <param name="configuration">The connection string.</param>
 /// <param name="cryptoProvider">The crypto provider.</param>
 public SqlServerUserManager(SqlServerUserManagerConfiguration configuration, ICryptoProvider cryptoProvider)
     : base (cryptoProvider)
 {
     this.configuration = configuration;
 }
示例#53
0
 public AccountService(AccountRule accountRule, ICryptoProvider cryptoProvider)
 {
     _accountRule = accountRule;
     _cryptoProvider = cryptoProvider;
 }
示例#54
0
 public LicenseService(IMachineCodeProvider machineCodeProvider, ICryptoProvider cryptoProvider) {
     this._machineCodeProvider = machineCodeProvider;
     this._cryptoProvider = cryptoProvider;
 }
 public CalendarMembershipProvider(ICryptoProvider crypto, ISaltProvider salt)
 {
     _crypto = crypto;
     _salt = salt;
 }
 public TestProgressFileDownloader(IDev2WebClient webClient,IFile file,ICryptoProvider crypt)
     : base(webClient, file,crypt)
 {
 }
示例#57
0
 public AccountController(ChanContext dContext, ICryptoProvider cryptoProvider)
 {
     _dContext = dContext;
     _cryptoProvider = cryptoProvider;
 }
 /// <summary>
 /// Initializes a new instance of the BaseUserManager class.
 /// </summary>
 /// <param name="cryptoProvider">The crypto provider.</param>
 protected BaseUserManager(ICryptoProvider cryptoProvider)
 {
     this.CryptoProvider = cryptoProvider;
 }
 public UserProcessor(IUserRepository userRepository, ICryptoProvider cryptoProvider, ITaskProcessor taskProcessor)
 {
     this.userRepository = userRepository;
     this.cryptoProvider = cryptoProvider;
     this.taskProcessor = taskProcessor;
 }
示例#60
0
 public void Setup()
 {
     _cryptoProvider = new KeccakCryptoProvider();
 }