Create an NAE Session
Initializing an NAE Session
Initializing an NAE Session is an optional step. If you want to load the properties file through the environment variable, you need to call the initialize function before creating an NAE session. You can also directly create a session by following the steps mentioned in the Creating an NAE Session section.
The initialization can be done from the sources such as a file or an environment variable.
NaeSession.Initialize(PropFileSource source, string path);
To initialize a session from a file:
NaeSession.Initialize(NaeSession.PropFileSource.file, @"C:\CADP\CADP.NETCore_Properties.xml");
Here, the source
is the file from which the initialization takes place. The path
is the absolute path of the properties file.
To initialize a session from an environment variable:
NaeSession.Initialize(NaeSession.PropFileSource.environmentVariable, "CADP.NetCoreConfig");
In the above snippet, the CADP.NetCoreConfig
is the environment variable name.
Note
While initializing through an environment, change the environment variable and re-open the Visual Studio.
After initialization, the library cannot be reinitialized through other sources. To reinitialize, first, you need to unload the library.
Creating an NAE Session
A session is a connection between your client and the Key CipherTrust Manager. You can create either a global or an authenticated NAE session with the CipherTrust Manager.
Creating a Global NAE Session with CipherTrust Manager
You can connect to the server by creating a session object with arguments. This creates an unauthenticated (global) session, which gives the client application the ability to create and access global keys. Whether your client can use global sessions is determined by the CipherTrust Manager settings. If password authentication is required, then global sessions are effectively disallowed.
NaeSession naeSession = new NaeSession(propFilePath);
OR
NaeSession naeSession = new NaeSession(null, null, propFilePath);
Note
If the NAE session is already initialized (as mentioned in the Initializing an NAE Session), the propFilePath
must be passed as null.
Creating an Authenticated NAE Session with CipherTrust Manager
To create an authenticated NAE session, pass username and password to the session object either as string or char array.
If the username and password are valid, the client application gets authenticated and has the ability to:
create keys
access keys owned by the user
access keys available to any groups to which the user belongs to
NaeSession naeSession = new NaeSession(username, password, propFilePath);
The username can be specified in the following formats:
username
- A user in the root domain. For example, joe.domain||username
- A user in a specific domain. For example, thales||joe.
Note
The supported characters for password are:
( ) ! & \ ` | ; > $ + , - . / : = [ ] ^ _ { } ~ ' # " ? <
Creating an Authenticated NAE Session using Persistent Cache
To create an authenticated NAE session that can use the persistent key cache, create a NaeSession
object as mentioned below in the code. The passphrase is a string set by the client application when the CADP for .NET Core creates the persistent key cache. Whenever a key is stored in or retrieved from the key cache, the CADP for .NET Core validates the passphrase. If the passphrase is invalid, the key cache can't be accessed. To create an authenticated NAE session, you need the following parameters:
username - name of the user.
password - password of the user.
passphrase - to access persistent cache file data.
propFilePath - path of the properties file.
Syntax
NaeSession naeSession = new NaeSession(username, password, passphrase, propFilePath);
Creating a Global NAE Session using Persistent Cache
To create a global NAE session using persistent key cache, the username or password should be either set to null
or string.empty
.
To create a global NAE session, you need the following parameters:
passphrase - to access persistent cache file data.
propFilePath - path of the properties file.
Syntax
NaeSession naeSession = new NaeSession(null, null, passphrase, propFilePath);