Click or drag to resize
weroSoft AG, Software
EncryptedDataProvider Class
The documentation is integral part of the weroSoft product documentation. This part is intended to be used by developers only.
Provides methods for accessing secured data from within the encrypted data store.
Inheritance Hierarchy
SystemObject
  WeroSoft.SecurityEncryptedDataProvider

Namespace:  WeroSoft.Security
Assembly:  WeroSoft.Core.Library (in WeroSoft.Core.Library.dll) Version: 2.5
Syntax
C#
public sealed class EncryptedDataProvider : IEncryptedDataProvider, 
	IDisposable, IEncryptedDataCipherImplementation
Remarks
The secured data provider allows accessing the data stored as nodes within the encrypted data store. Due to the goal keeping the information also encrypted in the memory, the provider does not allow to read out all data from the store by only one single operation.

Note that after creating an instance of this class, you must initialize the provider using a name and a password before accessing data from the store.

This encrypted data provider implementation supports multiple instances having their data in a store without be able to decrypt the data from another provider. The store returns only the data which is fitting to the appropriate provider asking for data.

Examples
The following example shows some code for creating and using a data provider.
// Create the store and a provider for accessing data in the store
// Note that you may use one single combination for user name and password
// or different combination for each of the element.
using (EncryptedDataStore encryptedDataStore = new EncryptedDataStore())
{
    encryptedDataStore.Initialize("<userName>", "<password>");
    using (IEncryptedDataProvider encryptedDataProvider = encryptedDataStore.GetDataProvider("providerUserName", "providerPassword"))
    {
        // Create a new data object (node)
        Guid node = encryptedDataProvider.CreateNode(Guid.Empty, "Demo object");

        // Change a standard property
        string expectedName = "Demo object with updated name";
        encryptedDataProvider.SetProperty(node, EncryptedDataKeyDefinitions.Name, expectedName);

        // Add a new custom property
        Guid property = Guid.NewGuid();
        string content = "This content may be any serializable type. Note that this data is serialized binary";
        encryptedDataProvider.SetProperty(node, property, content);

        // Get a property content of a standard property
        DateTime created = encryptedDataProvider.GetProperty<DateTime>(
            node,
            EncryptedDataKeyDefinitions.Created,
            DateTime.MinValue);

        // Change an existing custom property
        encryptedDataProvider.SetProperty(node, property, "New content!");

        // Create a second element as subordinated node of the first node
        Guid subNode = encryptedDataProvider.CreateNode(node, "Demo object");

        // Save the data store
        encryptedDataStore.Save("DemoDataStore.bin");
    }
}

// Access the saved file
using (EncryptedDataStore encryptedDataStore = new EncryptedDataStore())
{
    // Create a second instance of the store and read some values from it
    encryptedDataStore.Initialize("<userName>", "<password>");
    // Load the data
    encryptedDataStore.Open("DemoDataStore.bin");
    using (IEncryptedDataProvider encryptedDataProvider = encryptedDataStore.GetDataProvider("providerUserName", "providerPassword"))
    {
        // Get all root nodes of this particular provider
        Dictionary<Guid, string> nodeCollection = encryptedDataProvider.GetNodes(Guid.Empty);

        // Get the collection of nodes contained in the first node of the root collection
        Dictionary<Guid, string> subnodeCollection = encryptedDataProvider.GetNodes(nodeCollection.Keys.First());
    }
}

The EncryptedDataProvider type exposes the following members.

Constructors
  NameDescription
Public methodEncryptedDataProvider
Initializes a new instance of the type EncryptedDataProvider.
Top
Properties
  NameDescription
Public propertyCipherImplementation
Gets the cipher implementation this provider is using.
Public propertyCount
Gets the count of nodes for which this provider is responsible for.
Public propertyEncryptedDataStore
Gets the secured data store behind the provider.
Public propertyProviderId
Gets the identifier of the provider.
Public propertyProviderName
Gets or sets the name of the provider.
Public propertyTotalCount
Gets the total count of nodes independent of the provider.
Top
Methods
  NameDescription
Public methodClear
Clears the content of this particular provider.
Public methodCreateNode
Create a new node (a data object) in the store.
Public methodDecrypt
Decrypt a data object.
Public methodDispose
Implement the disposing behavior.
Public methodEncrypt
Encrypts a data object.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetNodes
Gets a collection of nodes from the store.
Public methodGetProperty(Guid, Guid, Object)
Gets the decrypted content of one particular property.
Public methodGetPropertyT(Guid, Guid, T)
Gets the decrypted content of one particular property.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInitialize
Initializes the data provider by a name and its corresponding password.
Public methodMove
Moves a node to a new parent.
Public methodMoveContent
Moves the nodes contained within the source node to the target node.
Public methodRemove
Removes a node from the store.
Public methodSetProperty
Sets the value of a particular property of a node.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodClone(CloneWorkingMode, IEnumerableType)Overloaded.
Clones an object by serialization.
(Defined by RuntimeExtensions.)
Public Extension MethodCloneT(CloneWorkingMode, IEnumerableType)Overloaded.
Clones an object by serialization.
(Defined by RuntimeExtensions.)
Public Extension MethodConvert (Defined by DataConverterExtensions.)
Public Extension MethodDynamicCast
Dynamically casts a reference to another type.
(Defined by TypeManagerHelper.)
Public Extension MethodExtractSystemParametersFromTrigger
Extracts the system parameters from a collection of trigger parameter and transform them to a dictionary using string keys and string values.
(Defined by TriggerExtensions.)
Public Extension MethodGetFieldValue(String)Overloaded.
Gets the data object held by a defined field of a particular type.
(Defined by UnitTest.)
Public Extension MethodGetFieldValueT(String)Overloaded.
Gets the data object held by a defined field of a particular type.
(Defined by UnitTest.)
Public Extension MethodGetPropertyValue(String)Overloaded.
Gets the data object held by a defined property of a particular type.
(Defined by UnitTest.)
Public Extension MethodGetPropertyValueT(String)Overloaded.
Gets the data object held by a defined property of a particular type.
(Defined by UnitTest.)
Public Extension MethodInject(Type, Object)Overloaded.
Injects all fields or properties which are marked with the defined attribute type name.
(Defined by DataInjection.)
Public Extension MethodInject(Type, Object, Boolean)Overloaded.
Injects all fields or properties which are marked with the defined attribute type name.
(Defined by DataInjection.)
Public Extension MethodInjectField
Injects a value to a property within a data object.
(Defined by DataInjection.)
Public Extension MethodInjectProperty(String, Object)Overloaded.
Injects a value to a property within a data object.
(Defined by DataInjection.)
Public Extension MethodInjectProperty(String, Type, Object)Overloaded.
Injects a value to a property within a data object.
(Defined by DataInjection.)
Public Extension MethodInvoke(String, Object)Overloaded.
Invokes a method on an object by reflection.
(Defined by UnitTest.)
Public Extension MethodInvokeTResult(String, Object)Overloaded.
Invokes a method on an object by reflection.
(Defined by UnitTest.)
Public Extension MethodSetFieldValue
Sets the data object on a defined field of a particular type.
(Defined by UnitTest.)
Public Extension MethodSetPropertyValue
Sets the data object on a defined property of a particular type.
(Defined by UnitTest.)
Public Extension MethodSetReadOnlyFieldValue
Sets the data object on a defined field of a particular type.
(Defined by UnitTest.)
Public Extension MethodTryInjectProperty
Tries to Inject a value to a property within a data object.
(Defined by DataInjection.)
Top
See Also