StreamLink.NET
StandardKeyMasterCredentialsProvider Class
StreamLink.NETCaplin.StreamLink.Authentication.KeyMasterStandardKeyMasterCredentialsProvider
An implementation of ICredentialsProvider that will get Liberator login tokens from a HTTP server that does not require authentication and, optionally (if configured), can 'keep-alive' HTTP sessions associated with that HTTP authentication (so avoiding the need for the instance to login again under error-free conditions). Liberator login tokens that are obtained via instances of this class are returned in the standard KeyMaster format.
Declaration Syntax
C#Visual BasicVisual C++
public class StandardKeyMasterCredentialsProvider : KeyMasterCredentialsProvider, IConnectionListener
Public Class StandardKeyMasterCredentialsProvider _
	Inherits KeyMasterCredentialsProvider _
	Implements IConnectionListener
public ref class StandardKeyMasterCredentialsProvider : public KeyMasterCredentialsProvider, 
	IConnectionListener
Members
All MembersConstructorsMethods



IconMemberDescription
StandardKeyMasterCredentialsProvider(String, ICredentials, Int32)
Constructs a StandardKeyMasterCredentialsProvider with a specified KeyMaster URI, credentials and request timeout period. If this constructor is used then the StandardKeyMasterCredentialsProvider will not do any polling.

StandardKeyMasterCredentialsProvider(String, ICredentials)
Constructs a StandardKeyMasterCredentialsProvider with a specified KeyMaster URI, credentials and the default request timeout of 10 seconds. If this constructor is used then the StandardKeyMasterCredentialsProvider will not do any polling.

StandardKeyMasterCredentialsProvider(String, ICredentials, Int32, StreamLink, Uri, Int64)
Constructs a StandardKeyMasterCredentialsProvider with a specified KeyMaster URI, credentials and request timeout period that performs polling. Polling is used to keep the KeyMaster session alive so that if StreamLink reconnects and requests another token it does not have to reauthenticate.

StandardKeyMasterCredentialsProvider(String, ICredentials, StreamLink, Uri, Int64)
Constructs a StandardKeyMasterCredentialsProvider with a specified KeyMaster URI, credentials and the default request timeout period of 10 seconds that performs polling. Polling is used to keep the KeyMaster session alive so that if StreamLink reconnects and requests another token it does not have to reauthenticate.

Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Finalize()()()
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
GetHashCode()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetType()()()
Gets the Type of the current instance.
(Inherited from Object.)
MemberwiseClone()()()
Creates a shallow copy of the current Object.
(Inherited from Object.)
ToString()()()
Returns a String that represents the current Object.
(Inherited from Object.)
Remarks

In a typical setup, the Keymaster web application sits behind a login page or other authentication mechanism. The user logs into the Keymaster using the credentials required by the authentication mechanism. Once logged in, the user is able to access KeyMaster tokens. If required, the user may obtain further tokens from the KeyMaster, so long as they remain logged in (that is, so long as the the associated HTTP session remains valid).

If the additional polling requests that are typically required for HTTP session keep-alive are not desired or not required (because the user's session will not time out) use the overloaded constructors that does not have a

CopyC#
pollingInterval
parameter) or pass the value
CopyC#
0
(zero) in
CopyC#
pollingInterval
.

If the product in use is StreamLink for Silverlight then the application server that hosts KeyMaster must provide a valid clientaccesspolicy.xml/crossdomain.xml file in order to satisfy Silverlight security restrictions.

Examples
CopyC#
using System;
using System.Collections.Generic;
using System.Text;
using Caplin.StreamLink;
using Caplin.StreamLink.Authentication;
using Caplin.StreamLink.Authentication.KeyMaster;
using System.Threading;
using Caplin.StreamLink.Configuration;

namespace StreamLinkExamples.Authentication
{
    class StandardKeyMaster : IExceptionHandler
    {
        public void StandardKeyMasterExample()
        {
            // set up a StreamLink and add a connection listener
            StreamLink myStreamLink = new StreamLink(SimpleConfiguration.CreateType2HttpConnection("myliberatorserver", 80));
            IConnectionListener connectionListener = new ExampleConnectionListener();
            myStreamLink.StreamLinkProvider.AddConnectionListener(connectionListener);

            // add this class as an ExceptionHandler so that we can see any failures
            myStreamLink.ExceptionHandler = this;

            // set up KeyMaster configuration
            String keyMasterURI = "http://mykeymasterserver.mydomain.com:1234/keymaster-basic/servlet/StandardKeyMaster";
            ICredentials keyMasterCredentials = new Credentials("keymasteruser", null);
            myStreamLink.CredentialsProvider = new StandardKeyMasterCredentialsProvider(keyMasterURI, keyMasterCredentials);

            // log in
            myStreamLink.StreamLinkProvider.Connect();
        }

        #region IExceptionHandler Members

        void IExceptionHandler.HandleException(Exception ex)
        {
            string exceptionMessage = ex.InnerException == null ? ex.Message : ex.InnerException.Message;
            Console.WriteLine(exceptionMessage);
        }

        #endregion
    }

    class ExampleConnectionListener : IConnectionListener
    {
        #region IConnectionListener Members

        void IConnectionListener.ConnectionStatusUpdated(IConnectionStatusEvent ev)
        {
            Console.WriteLine("Connection Status Updated: " + ev.Status);
        }

        void IConnectionListener.SourceStatusUpdated(ISourceStatusEvent ev)
        {
            Console.WriteLine("Source Status Updated: " + ev.Name + "=" + ev.Status);
        }

        void IConnectionListener.ServiceStatusUpdated(IServiceStatusEvent ev)
        {
            Console.WriteLine("Service Status Updated: " + ev.Name + "=" + ev.Status);
        }

        #endregion
    }
}
Inheritance Hierarchy
Object
KeyMasterCredentialsProvider
 StandardKeyMasterCredentialsProvider

Assembly: Caplin.StreamLink (Module: Caplin.StreamLink) Version: 5.0.14.0 (5.0.14.0)