KeyMaster.NET
GenerateToken Method (authParameters, formatter)
KeyMaster.NETCaplin.KeyMasterIKeyMasterGenerateToken(IAuthenticationParameters, IKeyMasterFormatter)
Generates a KeyMaster token for the given IAuthenticationParameters.
Declaration Syntax
C#Visual BasicVisual C++
string GenerateToken(
	IAuthenticationParameters authParameters,
	IKeyMasterFormatter formatter
)
Function GenerateToken ( _
	authParameters As IAuthenticationParameters, _
	formatter As IKeyMasterFormatter _
) As String
String^ GenerateToken(
	IAuthenticationParameters^ authParameters, 
	IKeyMasterFormatter^ formatter
)
Parameters
authParameters (IAuthenticationParameters)
The authentication parameters.
formatter (IKeyMasterFormatter)
The formatter to apply to the token.
Return Value
The token as formatted by the given IKeyMasterFormatter
Thread Safety

KeyMaster offers no guarantees regarding thread safety, if there is a possibility that multiple calls to this method could be made at the same time, then the calling code should take steps to ensure that only once call can be in progress at a given point in time.

Examples

This example generates a token and formats it using the StandardKeyMasterFormatter which is suitable for use by StreamLink.NET, StreamLink for Silverlight and StreamLink for Java.

CopyC#
using System;
using System.Collections.Generic;
using System.Text;
using Caplin.KeyMaster;
using Caplin.KeyMaster.Configuration;

namespace KeyMasterSnippets
{
    class CreatingKeyMasterInstance
    {
        const string PEM_FILE_LOCATION = "c:\\myprivatekey.pem";

        IKeyMaster CreateKeyMasterInstance()
        {
            // Create a KeyMaster configuration using a private key stored as a PEM format file.
            // This constructor may throw an exception; handling of it has been omitted for clarity.
            IKeyMasterConfiguration configuration = new PEMKeyMasterConfiguration(PEM_FILE_LOCATION);

            // Create a keymaster instance.
            IKeyMaster keymaster = new KeyMaster(configuration);

            return keymaster;
        }
    }
}

Assembly: Caplin.KeyMaster (Module: Caplin.KeyMaster) Version: 5.0.2.0 (5.0.2.0)