- Revenera Community
- :
- FlexNet Embedded
- :
- FlexNet Embedded Forum
- :
- Issue rehosting license
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Issue rehosting license
We are working on implementing secure rehosting of a Node locked license. We following the steps mentioned in the FNE_DotNetXTUserGuide_2019R1.pdf Page 98 Secure Re-hosting
Removing Capabilities from Host A:
- Step 1: Start License-Enabled Code on Host A
- Step 2: Submit Capability Request from Host A to the Back-Office Server
- Step 3: Back-Office Server Processes Request and Sends “Reduced” Response Back to Host A
- Step 4: Process “Reduced” Capability Response on Host A
- Step 5: Submit Another Capability Request from Host A to the Back-Office Server
- Step 6: Back-Office Server Processes Capability Request from Host A
We have processed the Step 1 to 4 successfully; we are sending the processed response back to serve for confirmation. But still the device show license is used and status as “waiting for confirmation”
We are using following code for the same:
/// <summary>
/// Deactivate license from the current machine and stores the
/// deactivation record on the current machine
/// </summary>
/// <param name="activationID">The activation identifier.</param>
/// <returns>Deactivation record if deactivation successful else null</returns>
public static bool DeactivateNodeLockLicense()
{
try
{
// get activation id from Custom Attributes injected in notice filed
var activationID = GetActivationIdFromNoticeField();
if (string.IsNullOrEmpty(activationID))
{
return false;
}
// return all licenses
ReturnAllLicenses();
// The optional host name is typically set by a user as a friendly name for the host
// The host name is not used for license enforcement
licensing.LicenseManager.HostName = Dns.GetHostName();
// The host type is typically a name set by the implementer, and is not modifiable by the user.
// While optional, the host type may be used in certain scenarios by some back-office systems such as FlexNet Operations.
licensing.LicenseManager.HostType = ClientHost;
// get the capability request for returning the license
var request = GenerateNodeCapabilityRequest(0,
activationID);
// send the capability request to the server and receive the server response
byte[] response = CommFactory.Create(serverUrl).SendBinaryMessage(request.ToArray(),
out response);
// write the response to binary file
File.WriteAllBytes(licenseStoragePath,
response);
// process the response in licensing object
var processResponse = licensing.LicenseManager.ProcessCapabilityResponse(response);
// send confirmation message to back office server
byte[] binCapResponse;
CommFactory.Create(BackOfficeURL). SendBinaryMessage(response,
out binCapResponse);
// delete the trusted storage as license is returned to back office server
licensing.Administration.Delete(DeleteOption.TrustedStorage);
// return true as deactivation is successful
return true;
}
catch (Exception e)
{
Singleton <Logger>.Instance.Write(SeverityType.Error,
"Exception during deactivation",
"LicenseData",
"DeactivateNodeLockLicense",
e.Message);
return false;
}
}
/// <summary>
/// Generates the node capability request for the passed-in feature count.
/// </summary>
/// <param name="count">Number of feature count for which request is to be generated</param>
/// <param name="activationID">The activation identifier against which feature to be acquired</param>
/// <returns>ICapabilityRequestData containing the capability request data</returns>
private static ICapabilityRequestData GenerateNodeCapabilityRequest(int count,
string activationID)
{
// log the capability request for the server
Singleton <Logger>.Instance.Write(SeverityType.Information,
"Generating license request to acquire license");
// create the capability request options object
var options = licensing.LicenseManager.CreateCapabilityRequestOptions();
// set request options to request & force the response
options.Operation = CapabilityRequestOperation.Request;
options.ForceResponse = true;
options.ServedBuffer = true;
// set the host ID for the current machine
licensing.LicenseManager.SetHostId(HostIdEnum.FLX_HOSTID_TYPE_ETHERNET,
MacAddress);
// add the desired right ID
options.AddRightsId(activationID,
count);
// create capability request
var capabilityRequestData = licensing.LicenseManager.CreateCapabilityRequest(options);
// write the request to binary file
if (WriteData(RequestFileName,
capabilityRequestData.ToArray()))
{
Singleton <Logger>.Instance.Write(SeverityType.Information,
string.Format("Capability request data written to: {0}",
RequestFileName));
}
return capabilityRequestData;
}
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi @ChrisMaeder1 ,
That is the expected behavior in FlexNet Operations following Steps 1-4. Host A "proves" the capability response with reduced quantity was successfully processed when it sends the second capability request to FlexNet Operations in Step 5. The status should change once this second capability request is received/processed by FlexNet Operations (Step 5-6).
Best Regards,
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
But status is not changing even after send second capability request.
We have shared the code, please suggest, if we are doing anything wrong in the code.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi @ChrisMaeder1 ,
I just ran a test with the CapabilityRequest Example provided in the .NET SDK with Confirmation enabled (Skip Confirmation disabled) in FNO. I first activated using an ACTID with Qty 1, then activated again with Qty 0 to return the license. The status (as expected) was "Waiting for confirmation" in FNO. I then re-submitted the same capability request with Qty 0 to FNO. After doing so FNO did not display any licenses on the device. The same results were achieved by sending an "empty" second capability request (commenting out options.AddRightsId("ACTID", 0) ). Please try out the provided CababilityRequest Example to see if you get the same results.
Thanks,
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
I tried both the things
1. Sending the 0 count request again
&
2. Sending request without options.AddRightsId
But in both the cases "Waiting For Confirmation" is shown on the device.
/// <summary>
/// Deactivate license from the current machine and stores the
/// deactivation record on the current machine
/// </summary>
/// <param name="activationID">The activation identifier.</param>
/// <returns>Deactivation record if deactivation successful else null</returns>
public static bool DeactivateNodeLockLicense()
{
try
{
// get licenses
var lic = licensing.LicenseManager.Licenses();
// get feature
var feature = lic.FirstOrDefault(f => f.Name != "CORE");
if (feature == null)
{
return false;
}
// get custom data
var customData = feature.Notice.Split(new[] { "#" },
StringSplitOptions.RemoveEmptyEntries);
// if there is no custom data then return
if (!customData.Any())
{
return false;
}
// get activation id
var activationID = customData[3];
if (string.IsNullOrEmpty(activationID))
{
return false;
}
// return all licenses
ReturnAllLicenses();
// The optional host name is typically set by a user as a friendly name for the host
// The host name is not used for license enforcement
licensing.LicenseManager.HostName = Dns.GetHostName();
// The host type is typically a name set by the implementer, and is not modifiable by
// the user. While optional, the host type may be used in certain scenarios by some
// back-office systems such as FlexNet Operations.
licensing.LicenseManager.HostType = ClientHost;
// get the capability request for returning the license
var request = GenerateNodeCapabilityRequest(0,
activationID);
// get the response from the back office server
var response = SendCapabilityRequest(request,
BackOfficeURL);
// write the response to binary file
File.WriteAllBytes(licenseStoragePath,
response);
// process the response in licensing object
var processedResponse = ProcessCapabilityResponse(response);
// confirmation needed then send a confirmation request to back server
if (processedResponse.ConfirmationRequestNeeded)
{
// Attempt 1: send the original 0 count response to the back office server
// for confirmation
var req = SendCapabilityRequest(request,
BackOfficeURL);
// Attempt 2: get the request with options.AddRightsId to be
// send to back office server for confirmation
var requestConfirm = GenerateNodeCapabilityRequest();
// get the response from the back office server
var responseConfirm = SendCapabilityRequest(requestConfirm,
BackOfficeURL);
// process the response in licensing object
var processedResponse2 = ProcessCapabilityResponse(response);
}
// delete the trusted storage as license is returned back to back office server
licensing.Administration.Delete(DeleteOption.TrustedStorage);
// return true as deactivation is successful
return true;
}
catch (Exception e)
{
Singleton <Logger>.Instance.Write(SeverityType.Error,
"Exception during deactivation",
"LicenseData",
"DeactivateNodeLockLicense",
e.Message);
return false;
}
}
/// <summary>
/// Generates the node capability request.
/// </summary>
/// <param name="count">The count.</param>
/// <param name="activationID">The activation identifier.</param>
/// <returns>ICapabilityRequestData.</returns>
private static ICapabilityRequestData GenerateNodeCapabilityRequest
(int count,
string activationID)
{
// log the capability request for the server
Singleton <Logger>.Instance.Write(SeverityType.Information,
"Generating license request to acquire license");
// create the capability request options object
var options = licensing.LicenseManager.CreateCapabilityRequestOptions();
// set request options to request & force the response
options.Operation = CapabilityRequestOperation.Request;
options.ForceResponse = true;
options.ServedBuffer = true;
// if count is < 1 then it is a confirmation request hence
// don't add rights ID
if (count >= 0)
{
// add the desired right ID
options.AddRightsId(activationID,
count);
}
// create capability request
var capabilityRequestData = licensing.LicenseManager
.CreateCapabilityRequest(options);
// write the request to binary file
if (WriteData(RequestFileName,
capabilityRequestData.ToArray()))
{
Singleton <Logger>.Instance
.Write(SeverityType.Information,
string.Format("Capability request data written to: {0}",
RequestFileName));
}
return capabilityRequestData;
}
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi @ChrisMaeder1 ,
Did you try the same test with the CapabilityRequest example in the SDK? If so and you are getting the same results I'd suggest creating a support ticket as something may not be configured properly.
Thanks,