public DocumentDbHandler(IDocumentStore documentStore, ICryptographicService cryptographicService, IUserContextService userContextService) { _documentStore = documentStore; _documentStore.SetSession("Users"); _cryptographicService = cryptographicService; _userContextService = userContextService; }
public UsersController(UserContext context, ICryptographicService cryptographicServices, ILogger <UsersController> logger) { _context = context; _cryptographicServices = cryptographicServices; _logger = logger; }
public UserService(IUnitOfWork unitOfWork, IConfiguration configuration, ICryptographicService cryptographicService) { _unitOfWork = unitOfWork; _configuration = configuration; _cryptographicService = cryptographicService; _userRepository = unitOfWork.GetRepository <UserData>(); }
public WalletService(Client miyabiClient, TransactionService transactionService) { _cryptographicService = new Secp256k1EccService(); _transactionService = transactionService; var privateKey = _cryptographicService.CreatePrivateKey(); _keyPair = new KeyPair(privateKey); _assetClient = new AssetClient(miyabiClient); }
public AuthenticateHandler( IUserAccountService userAccountService, IMapper mapper, ICryptographicService cryptographicService) { _userAccountService = userAccountService; _mapper = mapper; _cryptographicService = cryptographicService; }
public AccountController(ICommandService commandService, IQueryService queryService, ICryptographicService cryptographicService, IIdentityServerInteractionService interactionService) { _commandService = commandService; _queryService = queryService; _cryptographicService = cryptographicService; _interactionService = interactionService; }
public static async Task <InitializationResult <AuthenticatedStream> > RegisterWithServerAsync( Stream serverStream, byte[] presharedKey, Guid ownGuid, Guid serverGuid, IAuthenticatedConnectionFactory authenticatedConnectionFactory, X509Certificate2 clientCertificate, X509Certificate serverCertificate, ICryptographicService otp, CancellationToken token) { InitializationResult <AuthenticatedStream> From(CommunicationResult res) => From <AuthenticatedStream>(res); if (!otp.CanEncrypt) { throw new ArgumentException("otp needs to be able to encrypt"); } token = token.AddTimeout(DefaultTimeout); await serverStream.WriteSafelyAsync(presharedKey, token); var serverGuidResult = await serverStream.ReceiveGuidSafelyAsync(token); if (!serverGuidResult.Successful) { return(From(serverGuidResult)); } if (!serverGuidResult.Result.Equals(serverGuid)) { return(new InitializationResult <AuthenticatedStream> { Successful = false, Error = new InitializationError { ErrorType = InitializationErrorType.Identification, Message = $"Expected server to be '{serverGuid}', but instead found '{serverGuidResult.Result}'", }, }); } await serverStream.WriteSafelyAsync( ownGuid, (int)InitiationMode.Otp, token); var exportCertificate = clientCertificate.Export(X509ContentType.Cert); var encryptedCertificate = otp.Encrypt(exportCertificate); await serverStream.WriteSafelyAsync( (int)CommunicationData.PublicKey, encryptedCertificate.Length, encryptedCertificate, token); return(await EstablishEncryptedCommunication(false, serverGuid, authenticatedConnectionFactory, serverStream, token)); }
public UserManagementService( IUserContext applicationContext, IUserAccountRepository userAccountRepository, ICryptographicService cryptographicService, IQueueDispatcher <IMessage> dispatcher) : base(applicationContext, dispatcher) { Check.NotNull(userAccountRepository, "userAccountRepository cannot be null"); _userAccountRepository = userAccountRepository; _cryptographicService = cryptographicService; _userAccountValidator = new UserAccountValidator(_userAccountRepository); }
public SignUpHandler( IUserAccountService userAccountService, IMapper mapper, IUnitOfWork unitOfWork, ICryptographicService cryptographicService) { _userAccountService = userAccountService; _mapper = mapper; _unitOfWork = unitOfWork; _cryptographicService = cryptographicService; }
public DataController(IAppDataService appDataService, IAccountService accountService, IWebStorageService webStorageService, ICryptographicService cryptographicService, IMessageService messageService, IResourceService resourceService) { this.appDataService = appDataService; this.accountService = accountService; this.webStorageService = webStorageService; this.cryptographicService = cryptographicService; this.messageService = messageService; this.resourceService = resourceService; feedManagerCompletion = new TaskCompletionSource <FeedManager>(); }
public DataController(IAppDataService appDataService, IAccountService accountService, IWebStorageService webStorageService, ICryptographicService cryptographicService, IMessageService messageService, IResourceService resourceService) { this.appDataService = appDataService; this.accountService = accountService; this.webStorageService = webStorageService; this.cryptographicService = cryptographicService; this.messageService = messageService; this.resourceService = resourceService; feedManagerCompletion = new TaskCompletionSource<FeedManager>(); }
public UserManagementService( IUserContext applicationContext, IRepositorySessionFactory repositorySessionFactory, IUserAccountRepository userAccountRepository, ICryptographicService cryptographicService, IQueueDispatcher<IMessage> dispatcher) : base(applicationContext, repositorySessionFactory, dispatcher) { Check.NotNull(userAccountRepository, "userAccountRepository cannot be null"); _userAccountRepository = userAccountRepository; _cryptographicService = cryptographicService; _userAccountValidator = new UserAccountValidator(_userAccountRepository); }
public CryptographicServiceTests() { _cryptographicService = new CryptographicService(); }
public LoginService(BudgetContext context, ICryptographicService crypto, ICredentialHoldingService creds) { _context = context; _crypto = crypto; _creds = creds; }
public UserStore(IUserContextService contextService, ILogger logger, ICryptographicService cryptographicService) { _contextService = contextService; _logger = logger; _cryptographicService = cryptographicService; }
public UserService(ICryptographicService cryptographicService, IUserRepository userRepository) { _cryptographicService = cryptographicService; _userRepository = userRepository; }
public SqlUserAccountRepository(ICryptographicService cryptographicService) { _cryptographicService = cryptographicService; }
public static async Task <InitializationResult> HandleInitializationOfClient( Stream clientStream, byte[] presharedKey, Guid serverGuid, IAuthenticatedConnectionFactory authenticatedConnectionFactory, ICryptographicService otp, Action <Guid, AuthenticatedStream> onClientConnected, Action <Guid, X509Certificate> onClientRegistered, Func <Guid, X509Certificate> getClientPublicKey, CancellationToken token) { token = token.AddTimeout(DefaultTimeout); if (token.IsCancellationRequested) { return(new InitializationResult { Successful = false, Error = new InitializationError { ErrorType = InitializationErrorType.CancellationRequested, } }); } if (!await GetAndVerifyPresharedKey(clientStream, presharedKey, token)) { return(new InitializationResult { Successful = false, Error = new InitializationError { ErrorType = InitializationErrorType.Protocol, Message = "The received pre-shared key did not match the pre-shared key for this application", }, }); } await clientStream.WriteSafelyAsync(serverGuid, token); var clientGuidResult = await clientStream.ReceiveGuidSafelyAsync(token); if (!clientGuidResult.Successful) { return(InitializationResult.From(clientGuidResult)); } var clientGuid = clientGuidResult.Result; var initiationModeResult = await clientStream.ReceiveInt32SafelyAsync(token); if (!initiationModeResult.Successful) { return(InitializationResult.From(initiationModeResult)); } switch ((InitiationMode)initiationModeResult.Result) { case InitiationMode.Otp: var clientRegistrationResult = await HandleClientRegistrationSafelyAsync(clientStream, serverGuid, authenticatedConnectionFactory, otp, token); if (clientRegistrationResult.Successful) { var(certificate, stream) = clientRegistrationResult.Result; onClientRegistered(clientGuid, certificate); onClientConnected(clientGuid, stream); } else { return(clientRegistrationResult); } return(new InitializationResult { Successful = true, }); case InitiationMode.Standard: var clientCertificate = getClientPublicKey(clientGuid); if (clientCertificate == null) { return(InitializationResult.Failed); } //var sessionKey = SymmetricKey.GenerateNewKey(symmetric.KeyLength); var encryptedStreamResult = await EstablishEncryptedCommunication(true, serverGuid, authenticatedConnectionFactory, clientStream, token); if (!encryptedStreamResult.Successful) { return(encryptedStreamResult); } onClientConnected(clientGuid, encryptedStreamResult.Result); return(new InitializationResult { Successful = true, }); case InitiationMode.None: return(new InitializationResult() { Successful = false, Error = new InitializationError() { ErrorType = InitializationErrorType.Protocol, Message = "Client did not send a valid initiation mode", }, }); default: throw new ProtocolException($"invalid initiation mode {initiationModeResult.Result}"); } }
protected void AnAesCryptographicServiceWithValidKey() { CryptographicService = new AesCryptographicService(TestData.TestSymmetricKey); }
public void CryptographicServiceSetUp() { var rngCryptoServiceProvider = new RNGCryptoServiceProvider(); _cryptographicService = new CryptographicService(rngCryptoServiceProvider); }
public static async Task <InitializationResult <(X509Certificate, AuthenticatedStream)> > HandleClientRegistrationSafelyAsync( Stream clientStream, Guid serverGuid, IAuthenticatedConnectionFactory authenticatedConnectionFactory, ICryptographicService otp, CancellationToken token) { InitializationResult <(X509Certificate, AuthenticatedStream)> From(CommunicationResult res) => From <(X509Certificate, AuthenticatedStream)>(res); if (!otp.CanDecrypt) { throw new ArgumentException("otp needs to be able to decrypt"); } var dataTypeResult = await clientStream.ReceiveInt32SafelyAsync(token); if (!dataTypeResult.Successful) { return(From(dataTypeResult)); } if ((CommunicationData)dataTypeResult.Result != CommunicationData.PublicKey) { return(new InitializationResult <(X509Certificate, AuthenticatedStream)> { Successful = false, Error = new InitializationError { ErrorType = InitializationErrorType.Protocol, Message = $"Client sent unexpected data", }, }); } var encryptedLengthResult = await clientStream.ReceiveInt32SafelyAsync(token); if (!encryptedLengthResult.Successful) { return(From(encryptedLengthResult)); } var encryptedCertificateResult = await clientStream.ReadSafelyAsync(encryptedLengthResult.Result, token); if (!encryptedCertificateResult.Successful) { return(From(encryptedCertificateResult)); } var clientCertificate = new X509Certificate(otp.Decrypt(encryptedCertificateResult.Result)); var authenticationResult = await EstablishEncryptedCommunication(true, serverGuid, authenticatedConnectionFactory, clientStream, token); if (authenticationResult.Successful) { return(new InitializationResult <(X509Certificate, AuthenticatedStream)> { Successful = true, Result = (clientCertificate, authenticationResult.Result), }); } else { return(InitializationResult <(X509Certificate, AuthenticatedStream)> .From(authenticationResult)); } }