///
public override License GetLicense(LicenseContext context, Type type,
object instance, bool allowExceptions)
{
string attrGuid = "";
string publicKey = "";
// pull licensing data (guid/publickey) from custom attributes
// on the control
RsaLicenseDataAttribute licDataAttr = GetRsaLicenseDataAttribute(type);
if (licDataAttr == null)
return null;
publicKey = licDataAttr.PublicKey;
attrGuid = licDataAttr.Guid;
// if in Design mode create and return non-expiring license
// so design time ASP.NET is always working
if (context.UsageMode == LicenseUsageMode.Designtime)
{
return new RsaLicense(type, "", attrGuid, DateTime.MaxValue);
}
// check cache for cached license information
RsaLicense license = licenseCache.GetLicense(type);
string keyValue = "";
if (license == null)
{
// check the license folder under the web root for a
// license file and parse key data from it
keyValue = LoadLicenseData(type);
// validate the new license data key value
DateTime expireDate = new DateTime();
if (IsKeyValid(keyValue, publicKey, attrGuid, expireDate))
{
license = new RsaLicense(type, keyValue, attrGuid, expireDate);
licenseCache.AddLicense(type, license);
}
}
return license;
}
694 CHAPTER 13 ?– PACKAGING AND DEPLOYMENT
///
/// Method to look up custom licensing attribute on server control
/// ///
Control type for custom attribute lookup
///
private RsaLicenseDataAttribute GetRsaLicenseDataAttribute(System.
Pages:
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884