Esempio n. 1
0
        /// <summary>
        /// Configures user persistence. If you need to call this, be sure to do so before accessing any other Realm API.
        /// </summary>
        /// <param name="mode">The persistence mode.</param>
        /// <param name="encryptionKey">The key to encrypt the persistent user store with.</param>
        /// <param name="resetOnError">If set to <c>true</c> reset the persistent user store on error.</param>
        /// <remarks>
        /// Users are persisted in a realm file within the application's sandbox.
        /// <para>
        /// By default <see cref="User"/> objects are persisted and are additionally protected with an encryption key stored
        /// in the iOS Keychain when running on an iOS device (but not on a Simulator).
        /// On Android users are persisted in plaintext, because the AndroidKeyStore API is only supported on API level 18 and up.
        /// You might want to provide your own encryption key on Android or disable persistence for security reasons.
        /// </para>
        /// </remarks>
        public static void ConfigurePersistence(UserPersistenceMode mode, byte[] encryptionKey = null, bool resetOnError = false)
        {
            if (mode == UserPersistenceMode.Encrypted && encryptionKey != null && encryptionKey.Length != 64)
            {
                throw new ArgumentException("The encryption key must be 64 bytes long", nameof(encryptionKey));
            }

            SharedRealmHandleExtensions.ConfigureFileSystem(mode, encryptionKey, resetOnError);
        }
Esempio n. 2
0
 public static void ConfigurePersistence(UserPersistenceMode mode, byte[] encryptionKey = null, bool resetOnError = false, string basePath = null)
 {
     SyncConfigurationBase.Initialize(mode, encryptionKey, resetOnError, basePath);
 }
Esempio n. 3
0
 /// <summary>
 /// Configures user persistence. If you need to call this, be sure to do so before accessing any other Realm API.
 /// </summary>
 /// <param name="mode">The persistence mode.</param>
 /// <param name="encryptionKey">The key to encrypt the persistent user store with.</param>
 /// <param name="resetOnError">If set to <c>true</c> reset the persistent user store on error.</param>
 /// <remarks>
 /// Users are persisted in a realm file within the application's sandbox.
 /// <para>
 /// By default <see cref="User"/> objects are persisted and are additionally protected with an encryption key stored
 /// in the iOS Keychain when running on an iOS device (but not on a Simulator).
 /// On Android users are persisted in plaintext, because the AndroidKeyStore API is only supported on API level 18 and up.
 /// You might want to provide your own encryption key on Android or disable persistence for security reasons.
 /// </para>
 /// </remarks>
 public static void ConfigurePersistence(UserPersistenceMode mode, byte[] encryptionKey = null, bool resetOnError = false)
 {
     RealmPCLHelpers.ThrowProxyShouldNeverBeUsed();
 }
        public static unsafe void ConfigureFileSystem(UserPersistenceMode? userPersistenceMode, byte[] encryptionKey, bool resetMetadataOnError)
        {
            // mark the file system as configured in case this is called directly
            // so that it isn't reconfigured with default values in DoInitialFileSystemConfiguration
            Interlocked.Exchange(ref _fileSystemConfigured, 1);

            var basePath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

            UserPersistenceMode mode;
            UserPersistenceMode* modePtr = null;
            if (userPersistenceMode.HasValue)
            {
                mode = userPersistenceMode.Value;
                modePtr = &mode;
            }

            NativeException ex;
            NativeMethods.configure_file_system(basePath, (IntPtr)basePath.Length, modePtr, encryptionKey, resetMetadataOnError, out ex);
            ex.ThrowIfNecessary();
        }
 public static extern unsafe void configure_file_system([MarshalAs(UnmanagedType.LPWStr)] string base_path, IntPtr base_path_leth, 
                                                        UserPersistenceMode* userPersistence, byte[] encryptionKey,
                                                        [MarshalAs(UnmanagedType.I1)] bool resetMetadataOnError,
                                                        out NativeException exception);
 public static void ResetForTesting(UserPersistenceMode? userPersistenceMode = null)
 {
     NativeCommon.reset_for_testing();
     ConfigureFileSystem(userPersistenceMode, null, false);
 }
 /// <summary>
 /// Configures various parameters of the sync system, such as the way users are persisted or the base
 /// path relative to which files will be saved.
 /// </summary>
 /// <param name="mode">The user persistence mode.</param>
 /// <param name="encryptionKey">The key to encrypt the persistent user store with.</param>
 /// <param name="resetOnError">If set to <c>true</c> reset the persistent user store on error.</param>
 /// <param name="basePath">The base folder relative to which Realm files will be stored.</param>
 /// <remarks>
 /// Users are persisted in a realm file within the application's sandbox.
 /// <para>
 /// By default <see cref="User"/> objects are persisted and are additionally protected with an encryption key stored
 /// in the iOS Keychain when running on an iOS device (but not on a Simulator).
 /// On Android users are persisted in plaintext, because the AndroidKeyStore API is only supported on API level 18 and up.
 /// You might want to provide your own encryption key on Android or disable persistence for security reasons.
 /// </para>
 /// </remarks>
 public static void Initialize(UserPersistenceMode mode, byte[] encryptionKey = null, bool resetOnError = false, string basePath = null)
 {
     RealmPCLHelpers.ThrowProxyShouldNeverBeUsed();
 }