Ejemplo n.º 1
0
        public static void AssemblySetupCrypto(CryptoImplementation cryptoImplementation)
        {
            switch (cryptoImplementation)
            {
            case CryptoImplementation.Mono:
                TypeMap.Register.New <AxCryptHMACSHA1>(() => PortableFactory.AxCryptHMACSHA1());
                TypeMap.Register.New <HMACSHA512>(() => PortableFactory.HMACSHA512());
                TypeMap.Register.New <Aes>(() => PortableFactory.AesManaged());
                TypeMap.Register.New <CryptoStreamBase>(() => PortableFactory.CryptoStream());
                TypeMap.Register.New <Sha1>(() => PortableFactory.SHA1Managed());
                TypeMap.Register.New <Sha256>(() => PortableFactory.SHA256Managed());
                break;

            case CryptoImplementation.WindowsDesktop:
                TypeMap.Register.New <AxCryptHMACSHA1>(() => PortableFactory.AxCryptHMACSHA1());
                TypeMap.Register.New <HMACSHA512>(() => new Mono.Cryptography.HMACSHA512Wrapper(new Axantum.AxCrypt.Desktop.Cryptography.HMACSHA512CryptoServiceProvider()));
                TypeMap.Register.New <Aes>(() => new Mono.Cryptography.AesWrapper(new System.Security.Cryptography.AesCryptoServiceProvider()));
                TypeMap.Register.New <CryptoStreamBase>(() => PortableFactory.CryptoStream());
                TypeMap.Register.New <Sha1>(() => PortableFactory.SHA1Managed());
                TypeMap.Register.New <Sha256>(() => PortableFactory.SHA256Managed());
                break;

            case CryptoImplementation.BouncyCastle:
                TypeMap.Register.New <AxCryptHMACSHA1>(() => BouncyCastleCryptoFactory.AxCryptHMACSHA1());
                TypeMap.Register.New <HMACSHA512>(() => BouncyCastleCryptoFactory.HMACSHA512());
                TypeMap.Register.New <Aes>(() => BouncyCastleCryptoFactory.Aes());
                TypeMap.Register.New <CryptoStreamBase>(() => BouncyCastleCryptoFactory.CryptoStream());
                TypeMap.Register.New <Sha1>(() => BouncyCastleCryptoFactory.Sha1());
                TypeMap.Register.New <Sha256>(() => BouncyCastleCryptoFactory.Sha256());
                break;
            }
        }
        public void SetUp()
        {
            IDataStore knownPublicKeysStore = new FakeInMemoryDataStoreItem("knownpublickeys.txt");

            TypeMap.Register.Singleton <IAsymmetricFactory>(() => new BouncyCastleAsymmetricFactory());
            TypeMap.Register.Singleton <IEmailParser>(() => new EmailParser());
            TypeMap.Register.Singleton <AxCryptOnlineState>(() => new AxCryptOnlineState());
            TypeMap.Register.Singleton <FileLocker>(() => new FileLocker());
            TypeMap.Register.Singleton <IPortableFactory>(() => new PortableFactory());
            TypeMap.Register.Singleton <INow>(() => new FakeNow());
            TypeMap.Register.Singleton <UserPublicKeyUpdateStatus>(() => new UserPublicKeyUpdateStatus());
            TypeMap.Register.Singleton <KnownIdentities>(() => new KnownIdentities(Resolve.FileSystemState, Resolve.SessionNotify));
            TypeMap.Register.Singleton <FileSystemState>(() => FileSystemState.Create(Resolve.WorkFolder.FileInfo.FileItemInfo("FileSystemState.txt")));
            TypeMap.Register.Singleton <WorkFolder>(() => new WorkFolder(Path.GetPathRoot(Environment.CurrentDirectory) + @"WorkFolder\"));
            TypeMap.Register.Singleton <SessionNotify>(() => new SessionNotify());
            TypeMap.Register.Singleton <UserSettingsVersion>(() => new UserSettingsVersion());
            TypeMap.Register.Singleton <ISettingsStore>(() => new SettingsStore(null));
            TypeMap.Register.Singleton <UserSettings>(() => (new FakeUserSettings(new IterationCalculator())).Initialize());

            TypeMap.Register.New <IStringSerializer>(() => new StringSerializer(New <IAsymmetricFactory>().GetSerializers()));
            TypeMap.Register.New <KnownPublicKeys>(() => KnownPublicKeys.Load(knownPublicKeysStore, Resolve.Serializer));
            TypeMap.Register.New <ILogging>(() => new Logging());
            TypeMap.Register.New <string, IDataStore>((path) => new FakeDataStore(path));
            TypeMap.Register.New <Sha256>(() => PortableFactory.SHA256Managed());
            TypeMap.Register.New <string, IDataContainer>((path) => new FakeDataContainer(path));

            New <AxCryptOnlineState>().IsOnline = true;
        }
 public void Setup()
 {
     TypeMap.Register.Singleton <IAsymmetricFactory>(() => new BouncyCastleAsymmetricFactory());
     TypeMap.Register.Singleton <IRandomGenerator>(() => new RandomGenerator());
     TypeMap.Register.New <IStringSerializer>(() => new StringSerializer(new BouncyCastleAsymmetricFactory().GetSerializers()));
     TypeMap.Register.Singleton <IEmailParser>(() => new EmailParser());
     TypeMap.Register.New <Sha256>(() => PortableFactory.SHA256Managed());
     TypeMap.Register.New <RandomNumberGenerator>(() => PortableFactory.RandomNumberGenerator());
     RuntimeEnvironment.RegisterTypeFactories();
 }
Ejemplo n.º 4
0
        private static void RegisterTypeFactories(string startPath)
        {
            IEnumerable <Assembly> extraAssemblies = LoadFromFiles(new DirectoryInfo(Path.GetDirectoryName(startPath)).GetFiles("*.dll"));

            Resolve.RegisterTypeFactories(_workFolderPath, extraAssemblies);
            RuntimeEnvironment.RegisterTypeFactories();
            DesktopFactory.RegisterTypeFactories();

            TypeMap.Register.New <IProtectedData>(() => new ProtectedDataImplementation(System.Security.Cryptography.DataProtectionScope.CurrentUser));
            TypeMap.Register.New <ILauncher>(() => new Launcher());
            TypeMap.Register.New <AxCryptHMACSHA1>(() => PortableFactory.AxCryptHMACSHA1());
            TypeMap.Register.New <HMACSHA512>(() => new Mono.Cryptography.HMACSHA512Wrapper(new Axantum.AxCrypt.Desktop.Cryptography.HMACSHA512CryptoServiceProvider()));
            TypeMap.Register.New <Aes>(() => new Axantum.AxCrypt.Mono.Cryptography.AesWrapper(new System.Security.Cryptography.AesCryptoServiceProvider()));
            TypeMap.Register.New <Sha1>(() => PortableFactory.SHA1Managed());
            TypeMap.Register.New <Sha256>(() => PortableFactory.SHA256Managed());
            TypeMap.Register.New <CryptoStreamBase>(() => PortableFactory.CryptoStream());
            TypeMap.Register.New <RandomNumberGenerator>(() => PortableFactory.RandomNumberGenerator());
            TypeMap.Register.New <LogOnIdentity, IAccountService>((LogOnIdentity identity) => new CachingAccountService(new DeviceAccountService(new LocalAccountService(identity, Resolve.WorkFolder.FileInfo), new ApiAccountService(new AxCryptApiClient(identity.ToRestIdentity(), Resolve.UserSettings.RestApiBaseUrl, Resolve.UserSettings.ApiTimeout)))));
            TypeMap.Register.New <GlobalApiClient>(() => new GlobalApiClient(Resolve.UserSettings.RestApiBaseUrl, Resolve.UserSettings.ApiTimeout));
            TypeMap.Register.New <AxCryptApiClient>(() => new AxCryptApiClient(Resolve.KnownIdentities.DefaultEncryptionIdentity.ToRestIdentity(), Resolve.UserSettings.RestApiBaseUrl, Resolve.UserSettings.ApiTimeout));
            TypeMap.Register.New <ISystemCryptoPolicy>(() => new ProCryptoPolicy());
            TypeMap.Register.New <ICryptoPolicy>(() => New <LicensePolicy>().Capabilities.CryptoPolicy);

            TypeMap.Register.Singleton <LicensePolicy>(() => new LicensePolicy());
            TypeMap.Register.Singleton <FontLoader>(() => new FontLoader());
            TypeMap.Register.Singleton <IEmailParser>(() => new EmailParser());
            TypeMap.Register.Singleton <KeyPairService>(() => new KeyPairService(0, 0, New <UserSettings>().AsymmetricKeyBits));
            TypeMap.Register.Singleton <ICache>(() => new ItemCache());
            TypeMap.Register.Singleton <DummyReferencedType>(() => new DummyReferencedType());
            TypeMap.Register.Singleton <AxCryptOnlineState>(() => new AxCryptOnlineState());
            TypeMap.Register.Singleton <IVersion>(() => new DesktopVersion());
            TypeMap.Register.Singleton <PasswordStrengthEvaluator>(() => new PasswordStrengthEvaluator(100, 8));
            TypeMap.Register.Singleton <IKnownFoldersDiscovery>(() => new KnownFoldersDiscovery());
            TypeMap.Register.Singleton <IBrowser>(() => new Browser());
            TypeMap.Register.Singleton <ILicenseAuthority>(() => new PublicLicenseAuthority());
            TypeMap.Register.Singleton <PremiumManager>(() => new PremiumManagerWithAutoTrial());
            TypeMap.Register.Singleton <AboutAssembly>(() => new AboutAssembly(Assembly.GetExecutingAssembly()));
            TypeMap.Register.Singleton <FileLocker>(() => new FileLocker());
            TypeMap.Register.Singleton <IProgressDialog>(() => new ProgressDialog());
            TypeMap.Register.Singleton <CultureNameMapper>(() => new CultureNameMapper(New <GlobalApiClient>().GetCultureInfoListAsync));
        }
Ejemplo n.º 5
0
        private static void InitializeTypeFactories()
        {
            RuntimeEnvironment.RegisterTypeFactories();

            IEnumerable <Assembly> assemblies = LoadFromFiles(GetExecutingDirectory().GetFiles("*.dll"));

            Resolve.RegisterTypeFactories(assemblies);

            TypeMap.Register.Singleton <IEmailParser>(() => new RegexEmailParser());
            TypeMap.Register.Singleton <ISettingsStore>(() => new TransientSettingsStore());
            TypeMap.Register.Singleton <INow>(() => new Now());
            TypeMap.Register.Singleton <IInternetState>(() => new AlwaysOnInternetState());

            TypeMap.Register.New <RandomNumberGenerator>(() => PortableFactory.RandomNumberGenerator());
            TypeMap.Register.New <AxCryptHMACSHA1>(() => PortableFactory.AxCryptHMACSHA1());
            TypeMap.Register.New <HMACSHA512>(() => PortableFactory.HMACSHA512());
            TypeMap.Register.New <Aes>(() => new Axantum.AxCrypt.Mono.Cryptography.AesWrapper(new System.Security.Cryptography.AesCryptoServiceProvider()));
            TypeMap.Register.New <Sha1>(() => PortableFactory.SHA1Managed());
            TypeMap.Register.New <Sha256>(() => PortableFactory.SHA256Managed());
            TypeMap.Register.New <CryptoStreamBase>(() => PortableFactory.CryptoStream());
        }