Activation Service Endpoints
By default, activation requests from the Software Potential Runtime on end-user machines are sent (on port 80) to http://srv.softwarepotential.com/SLMServerWS/ActivationWS.svc.
It is also possible to configure the SpAgent runtime to send activation requests over a secure HTTPS channel (on port 443) to https://srv.softwarepotential.com/SLMServerWS/ActivationWS.svc/SSL.
It is thus important that client firewalls, proxies etc. are configured to allow outbound connections to http://srv.softwarepotential.com [on port 80 and 443].
These endpoints do NOT require authentication.
Activation Over HTTPS (Port 443)
To configure SpAgent to send activation request over HTTP you need to set the correct EndPointSelectionPolicy in the ConfigureProduct method in the SpAgent.ProductCustomizations.cs file. You need to replace .WithEndpointSelectionPolicyDefault() with .WithEndpointSelectionPolicyHttpsOnly. When this is done the method should look as follows as follows:
static partial void ConfigureProduct( IProductContext productContext ) { productContext.Configure( configure => configure .Activation.Customize( activation => activation .WithTagging( AddActivationTags ) .WithTransmission( activationTransmission => activationTransmission .WithRetryPolicyDefault() .WithEndpointSelectionPolicyHttpsOnly .BeforeEachAttempt( WhenActivating ) .CompleteWithDefaults() ) .WithDeviceLabelPolicy( SetDeviceLabelPolicy ) .CompleteWithDefaults() ) .CompleteWithDefaults() ); }
Adding Custom Tags
To add one or more custom tags to an activation request you need to use the AddActivationTags method in the SpAgent.ProductCustomizations.cs file.
static void AddActivationTags( IActivationTaggingContext context ) { context.AddTag("MYKEY","MYVALUE"); }
You can limit activations using using Custom Tags added to the activation request - see Control License Activation. Tags used to control activation must have the prefix "A:" added. For example if you want to control activation of a license based on the machine domain (e.g., inishtech.com) you will add the tag using contextAddTag("ADomain", "inishtech.com"). The custom tag {"A:Domain", "inishtech.com"} will be then be added to the license on a successful activation.
Adding a Device Label
To add a device label to an activation request, use the SetDeviceLabelPolicy method in the SpAgent.ProductCustomizations.cs file. By default this sets the DeviceLabel to the value of machine's MachineName or HostName as you can see in the following snippet.
static void SetDeviceLabelPolicy( IActivationDeviceLabelContext context ) { // e.g. context.SetDeviceLabel("My custom label"); #if NETCOREAPP || NETSTANDARD context.SetDeviceLabel( Dns.GetHostName() ); #else context.SetDeviceLabel( Environment.MachineName ); #endif Debug.WriteLine( "DeviceLabel passed to Activate() method: " + context.DeviceLabel ); }
Adding a custom proxy
If you wish to add a custom proxy to an activation request please see Proxy configuration for an activation request.
Generating Activation Requests
Activation Key Checks
In your activation UI you should check the following before allowing the user to create an Activation Request, in either online or offline mode:
- Activation Key is of the correct length
- Activation Key is well formed
- There is no pending activation request (activation requests are submitted asynchronously).
An Activation Key should be 29 characters in length. It is best to check this before enabling the Activate button to to generate/submit the activation request.
To check the Activation Key is well formed:
bool IsActivationKeyWellFormed() { return SpAgent.Product.Activation.IsWellFormedKey( ActivationKey ); }
One approach to the above checks is to call CanActivate before attempting to activate the key:
bool CanActivate() { return !string.IsNullOrEmpty( ActivationKey ) && ActivationKey.Length == ActivationKeyRequiredLength && IsActivationKeyWellFormed() && !IsActivationInProgress; }
Online Activation Request
To submit an online Activation Request call the asynch method SpAgent.Product.Activation.OnlineActivateAsync( ActivationKey )
bool _activationInProgress; public bool IsActivationInProgress { get { return _activationInProgress; } set { _activationInProgress = value; } } void ActivateOnline() { SetActivationInProgress( true ); LastActivationResultMessage = string.Empty; var uiContext = TaskScheduler.FromCurrentSynchronizationContext(); SpAgent.Product.Activation.OnlineActivateAsync( ActivationKey ) .ContinueWith( task => OnActivationComplete( task, ActivationKey ), CancellationToken.None, TaskContinuationOptions.None, uiContext ); } void OnActivationComplete( Task task, string activationKey ) { SetActivationInProgress( false ); if ( task.IsFaulted ) { string errorMessage = task.Exception.Flatten().InnerException.Message; LastActivationResultMessage = "Error: " + errorMessage; } else { LastActivationResultMessage = "Successfully activated license with activation key " + activationKey; LastActivationSucceeded = true; ActivationKey = string.Empty; } } void SetActivationInProgress( bool isInProgress ) { IsActivationInProgress = isInProgress; }
Manual (Offline) Activation Request
To create a Manual Activation request you first need to create an Activation Request string, and then save that in a text file that can be submitted to the Software Potential Activation service.
string requestString = SpAgent.Product.Activation.Advanced().CreateManualActivationRequest(activationKey, null);
On successful activation on the Software Potential Activation Service a license file must be downloaded and copied to the device on which the activation request was generated.
To install the license from the license file:
//Read the license file into byte[] var licenseBlob = File.ReadAllBytes(licenseFilePathName); //Install the license file "file.bin" SpAgent.Product.Stores.Install(licenseBlob);
Comments
0 comments
Article is closed for comments.