Skip to content

Commit 67479c1

Browse files
authored
NLIC-2392: Allow custom properties for auto created licensee
* allow custom properties for auto-created licensee * Allow custom properties for auto-created licensee
1 parent b13f539 commit 67479c1

File tree

2 files changed

+98
-90
lines changed

2 files changed

+98
-90
lines changed
Lines changed: 91 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,91 @@
1-
using System;
2-
using System.Collections.Generic;
3-
4-
namespace NetLicensingClient.Entities
5-
{
6-
public class ValidationParameters : IEntity
7-
{
8-
private String productNumber;
9-
private String licenseeName;
10-
private String licenseeSecret;
11-
private Dictionary<String, Dictionary<String, String>> parameters;
12-
13-
public void setProductNumber(String productNumber)
14-
{
15-
this.productNumber = productNumber;
16-
}
17-
18-
public String getProductNumber ()
19-
{
20-
return productNumber;
21-
}
22-
23-
public void setLicenseeName (String licenseeName)
24-
{
25-
this.licenseeName = licenseeName;
26-
}
27-
28-
public String getLicenseeName ()
29-
{
30-
return licenseeName;
31-
}
32-
33-
[System.Obsolete("setLicenseeSecret() is obsolete, use NodeLocked licensing model instead")]
34-
public void setLicenseeSecret (String licenseeSecret)
35-
{
36-
this.licenseeSecret = licenseeSecret;
37-
}
38-
39-
[System.Obsolete("getLicenseeSecret() is obsolete, use NodeLocked licensing model instead")]
40-
public String getLicenseeSecret ()
41-
{
42-
return licenseeSecret;
43-
}
44-
45-
public ValidationParameters ()
46-
{
47-
parameters = new Dictionary<String, Dictionary<String, String>>();
48-
}
49-
50-
public Dictionary<String, Dictionary<String, String>> getParameters()
51-
{
52-
return parameters;
53-
}
54-
55-
public Dictionary<String, String> getProductModuleValidationParameters(String productModuleNumber) {
56-
try
57-
{
58-
return parameters[productModuleNumber];
59-
}
60-
catch (KeyNotFoundException)
61-
{
62-
Dictionary<String, String> productModuleValidationParametes = new Dictionary<String, String> ();
63-
parameters.Add(productModuleNumber, productModuleValidationParametes);
64-
return productModuleValidationParametes;
65-
}
66-
}
67-
68-
internal void setProductModuleValidation(String productModuleNumber, Dictionary<String, String> productModuleValidationParametes)
69-
{
70-
parameters.Add(productModuleNumber, productModuleValidationParametes);
71-
}
72-
73-
public void put(String productModuleNumber, String key, String value)
74-
{
75-
getProductModuleValidationParameters(productModuleNumber).Add(key, value);
76-
}
77-
}
78-
}
79-
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace NetLicensingClient.Entities
5+
{
6+
public class ValidationParameters : IEntity
7+
{
8+
private String productNumber;
9+
private Dictionary<String, String> licenseeProperties;
10+
private Dictionary<String, Dictionary<String, String>> parameters;
11+
12+
public void setProductNumber(String productNumber)
13+
{
14+
this.productNumber = productNumber;
15+
}
16+
17+
public String getProductNumber ()
18+
{
19+
return productNumber;
20+
}
21+
22+
public Dictionary<String, String> getLicenseeProperties() {
23+
return licenseeProperties;
24+
}
25+
26+
public void setLicenseeProperty(String key, String value) {
27+
licenseeProperties.Add(key, value);
28+
}
29+
30+
public void setLicenseeName (String licenseeName)
31+
{
32+
setLicenseeProperty(Constants.Licensee.PROP_LICENSEE_NAME, licenseeName);
33+
}
34+
35+
public String getLicenseeName ()
36+
{
37+
return licenseeProperties.TryGetValue(Constants.Licensee.PROP_LICENSEE_NAME, out string value)
38+
? value
39+
: null;
40+
}
41+
42+
[System.Obsolete("setLicenseeSecret() is obsolete, use NodeLocked licensing model instead")]
43+
public void setLicenseeSecret (String licenseeSecret)
44+
{
45+
setLicenseeProperty(Constants.Licensee.PROP_LICENSEE_SECRET, licenseeSecret);
46+
}
47+
48+
[System.Obsolete("getLicenseeSecret() is obsolete, use NodeLocked licensing model instead")]
49+
public String getLicenseeSecret ()
50+
{
51+
return licenseeProperties.TryGetValue(Constants.Licensee.PROP_LICENSEE_SECRET, out string value)
52+
? value
53+
: null;
54+
}
55+
56+
public ValidationParameters ()
57+
{
58+
parameters = new Dictionary<String, Dictionary<String, String>>();
59+
licenseeProperties = new Dictionary<String, String>();
60+
}
61+
62+
public Dictionary<String, Dictionary<String, String>> getParameters()
63+
{
64+
return parameters;
65+
}
66+
67+
public Dictionary<String, String> getProductModuleValidationParameters(String productModuleNumber) {
68+
try
69+
{
70+
return parameters[productModuleNumber];
71+
}
72+
catch (KeyNotFoundException)
73+
{
74+
Dictionary<String, String> productModuleValidationParametes = new Dictionary<String, String> ();
75+
parameters.Add(productModuleNumber, productModuleValidationParametes);
76+
return productModuleValidationParametes;
77+
}
78+
}
79+
80+
internal void setProductModuleValidation(String productModuleNumber, Dictionary<String, String> productModuleValidationParametes)
81+
{
82+
parameters.Add(productModuleNumber, productModuleValidationParametes);
83+
}
84+
85+
public void put(String productModuleNumber, String key, String value)
86+
{
87+
getProductModuleValidationParameters(productModuleNumber).Add(key, value);
88+
}
89+
}
90+
}
91+

NetLicensingClient/LicenseeService.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,15 @@ public static ValidationResult validate(Context context, String number, Validati
105105
if (!String.IsNullOrEmpty(validationParameters.getProductNumber()))
106106
{
107107
parameters.Add(Constants.Product.PRODUCT_NUMBER, validationParameters.getProductNumber());
108-
}
109-
if (!String.IsNullOrEmpty(validationParameters.getLicenseeName()))
110-
{
111-
parameters.Add(Constants.Licensee.PROP_LICENSEE_NAME, validationParameters.getLicenseeName());
112-
}
113-
#pragma warning disable 0618
114-
// This section is only left to verify backwards compatibility.
115-
// Don't use LicenseeSecret, use Node-Locked licensing model instead.
116-
if (!String.IsNullOrEmpty(validationParameters.getLicenseeSecret()))
108+
}
109+
110+
foreach (KeyValuePair<String, String> property in validationParameters.getLicenseeProperties())
117111
{
118-
parameters.Add(Constants.Licensee.PROP_LICENSEE_SECRET, validationParameters.getLicenseeSecret());
112+
if (!String.IsNullOrEmpty(property.Key))
113+
{
114+
parameters.Add(property.Key, property.Value);
115+
}
119116
}
120-
#pragma warning restore 0618
121117

122118
int pmIndex = 0;
123119
foreach (KeyValuePair<String, Dictionary<String, String>> productModuleValidationParams in validationParameters.getParameters ()) {

0 commit comments

Comments
 (0)