public App()
        {
            InitializeComponent();

            Directory.CreateDirectory(Paths.ROOT_DIRECTORY);

            DependencyService.Register <MockDataStore>();

            // Register transient types:
            container.RegisterType <IUserService, UserService>();
            container.RegisterType <IConvoService, ConvoService>();
            container.RegisterType <ICompressionUtility, BrotliUtility>();
            container.RegisterType <ICompressionUtilityAsync, BrotliUtilityAsync>();
            container.RegisterType <IAsymmetricKeygenRSA, AsymmetricKeygenRSA>();
            container.RegisterType <ISymmetricCryptography, SymmetricCryptography>();
            container.RegisterType <IAsymmetricCryptographyRSA, AsymmetricCryptographyRSA>();
            container.RegisterType <IServerConnectionTest, ServerConnectionTest>();
            container.RegisterType <IMessageSender, MessageSender>();
            container.RegisterType <ITotpProvider, TotpProvider>();
            container.RegisterType <IKeyExchange, KeyExchange>();
            container.RegisterType <IPasswordChanger, PasswordChanger>();
            container.RegisterType <IRegistrationService, RegistrationService>();

            // Register IoC singletons:
            container.RegisterType <User>(new ContainerControlledLifetimeManager()); // This is the application's user.
            container.RegisterType <IMethodQ, MethodQ>(new ContainerControlledLifetimeManager());
            container.RegisterType <ILogger, TextLogger>(new ContainerControlledLifetimeManager());
            container.RegisterType <IAppSettings, AppSettingsJson>(new ContainerControlledLifetimeManager());
            container.RegisterType <IUserSettings, UserSettingsJson>(new ContainerControlledLifetimeManager());
            container.RegisterType <IEventAggregator, EventAggregator>(new ContainerControlledLifetimeManager());
            container.RegisterType <IViewModelFactory, ViewModelFactory>(new ContainerControlledLifetimeManager());
            container.RegisterType <IConvoPasswordProvider, ConvoPasswordProvider>(new ContainerControlledLifetimeManager());
            container.RegisterType <IMessageFetcher, MessageFetcher>(new ContainerControlledLifetimeManager());

            user                  = container.Resolve <User>();
            logger                = container.Resolve <ILogger>();
            methodQ               = container.Resolve <IMethodQ>();
            userService           = container.Resolve <IUserService>();
            appSettings           = container.Resolve <IAppSettings>();
            userSettings          = container.Resolve <IUserSettings>();
            convoService          = container.Resolve <IConvoService>();
            totpProvider          = container.Resolve <ITotpProvider>();
            eventAggregator       = container.Resolve <IEventAggregator>();
            crypto                = container.Resolve <IAsymmetricCryptographyRSA>();
            viewModelFactory      = container.Resolve <IViewModelFactory>();
            connectionTest        = container.Resolve <IServerConnectionTest>();
            convoPasswordProvider = container.Resolve <IConvoPasswordProvider>();

            // Subscribe to important IEventAggregator PubSubEvents.
            eventAggregator.GetEvent <LogoutEvent>().Subscribe(Logout);
            eventAggregator.GetEvent <ClickedRegisterButtonEvent>().Subscribe(ShowRegistrationPage);
            eventAggregator.GetEvent <ClickedConfigureServerUrlButtonEvent>().Subscribe(ShowConfigServerUrlPage);
            eventAggregator.GetEvent <UserCreationSucceededEvent>().Subscribe(OnUserCreationSuccessful);
            eventAggregator.GetEvent <UserCreationVerifiedEvent>().Subscribe(() => ShowLoginPage(false));
            eventAggregator.GetEvent <LoginSucceededEvent>().Subscribe(OnLoginSuccessful);
            eventAggregator.GetEvent <JoinedConvoEvent>().Subscribe(OnJoinedConvo);
        }
#pragma warning disable 1591
        public PasswordChanger(User user, IUserService userService, ILogger logger, ICompressionUtilityAsync compressionUtility, IAsymmetricCryptographyRSA crypto, IKeyExchange keyExchange)
        {
            this.user               = user;
            this.crypto             = crypto;
            this.logger             = logger;
            this.keyExchange        = keyExchange;
            this.userService        = userService;
            this.compressionUtility = compressionUtility;
        }
Exemplo n.º 3
0
#pragma warning disable 1591
        public MessageSender(User user, IUserService userService, IConvoPasswordProvider convoPasswordProvider, IConvoService convoService, IAsymmetricCryptographyRSA rsa, IUserSettings userSettings, IKeyExchange keyExchange, ISymmetricCryptography aes, ICompressionUtilityAsync compressionUtility)
        {
            this.aes                   = aes;
            this.rsa                   = rsa;
            this.user                  = user;
            this.keyExchange           = keyExchange;
            this.userService           = userService;
            this.userSettings          = userSettings;
            this.convoService          = convoService;
            this.compressionUtility    = compressionUtility;
            this.convoPasswordProvider = convoPasswordProvider;
        }
Exemplo n.º 4
0
#pragma warning disable 1591
        public ProfilePictureChanger(User user, IAsymmetricCryptographyRSA rsa)
        {
            this.rsa  = rsa;
            this.user = user;
            UrlUtility.ChangedEpistleServerUrl += UrlUtility_ChangedEpistleServerUrl;
        }
 /// <summary>
 /// Fluent way to sign an <see cref="EpistleRequestBody"/>.<para> </para>
 /// Assigns the calculated signature to <see cref="Signature"/> and returns itself.
 /// </summary>
 /// <param name="crypto">The <see cref="IAsymmetricCryptographyRSA"/> implementation to use for signing.</param>
 /// <param name="privateSigningKeyPem">The private RSA signing key (PEM-formatted).</param>
 public EpistleRequestBody Sign(IAsymmetricCryptographyRSA crypto, string privateSigningKeyPem)
 {
     Signature = crypto.Sign(this, privateSigningKeyPem);
     return(this);
 }
 /// <summary>
 /// Verifies the <see cref="Signature"/> using the provided <paramref name="crypto"/> instance.
 /// </summary>
 /// <param name="crypto">The <see cref="IAsymmetricCryptographyRSA"/> instance to use for signature verification.</param>
 /// <param name="publicRsaKeyPem">The public RSA key (PEM-formatted) to use for verifying the signature.</param>
 /// <returns>Whether the <see cref="Signature"/> could be verified or not.</returns>
 /// <seealso cref="IAsymmetricCryptographyRSA.Verify(string,string,string)"/>
 public bool VerifySignature(IAsymmetricCryptographyRSA crypto, string publicRsaKeyPem)
 {
     return(crypto.Verify(this, Signature, publicRsaKeyPem));
 }