/// <summary> /// Verifies that there is a valid product license for your plug-in, using /// the Rhino licensing system. If the plug-in is installed as a standalone /// node, the locally installed license will be validated. If the plug-in /// is installed as a network node, a loaner license will be requested by /// the system's assigned Zoo server. If the Zoo server finds and returns /// a license, then this license will be validated. If no license is found, /// then the user will be prompted to provide a license key, which will be /// validated. /// </summary> /// <param name="licenseCapabilities"> /// In the event that a license was not found, or if the user wants to change /// the way your plug-in is licenses, then provide what capabilities your /// license has by using this enumeration flag. /// </param> /// <param name="textMask"> /// In the event that the user needs to be asked for a license, then you can /// provide a text mask, which helps the user to distinguish between proper /// and improper user input of your license code. Note, if you do not want /// to use a text mask, then pass in a null value for this parameter. /// For more information on text masks, search MSDN for the System.Windows.Forms.MaskedTextBox class. /// </param> /// <param name="validateDelegate"> /// Since the Rhino licensing system knows nothing about your product license, /// you will need to validate the product license provided by the Rhino /// licensing system. This is done by supplying a callback function, or delegate, /// that can be called to perform the validation. /// </param> /// <returns> /// true if a valid license was found. false otherwise. /// </returns> public bool GetLicense(LicenseCapabilities licenseCapabilities, string textMask, ValidateProductKeyDelegate validateDelegate) { string productPath = this.Assembly.Location; Guid productId = this.Id; string productTitle = this.Name; bool rc = LicenseUtils.GetLicense(productPath, productId, productTitle, licenseCapabilities, textMask, validateDelegate); return rc; }
/// <summary> /// Verifies that there is a valid product license for your plug-in, using /// the Rhino licensing system. If the plug-in is installed as a standalone /// node, the locally installed license will be validated. If the plug-in /// is installed as a network node, a loaner license will be requested by /// the system's assigned Zoo server. If the Zoo server finds and returns /// a license, then this license will be validated. If no license is found, /// then the user will be prompted to provide a license key, which will be /// validated. /// </summary> /// <param name="productBuildType"> /// The product build contentType required by your plug-in. /// </param> /// <param name="validateDelegate"> /// Since the Rhino licensing system knows nothing about your product license, /// you will need to validate the product license provided by the Rhino /// licensing system. This is done by supplying a callback function, or delegate, /// that can be called to perform the validation. /// </param> /// <returns> /// true if a valid license was found. false otherwise. /// </returns> public bool GetLicense(LicenseBuildType productBuildType, ValidateProductKeyDelegate validateDelegate) { string productPath = this.Assembly.Location; Guid productId = this.Id; string productTitle = this.Name; bool rc = LicenseUtils.GetLicense(productPath, productId, (int)productBuildType, productTitle, validateDelegate); return rc; }
public bool AskUserForLicense(LicenseBuildType productBuildType, bool standAlone, string textMask, System.Windows.Forms.IWin32Window parent, ValidateProductKeyDelegate validateDelegate) { string productPath = this.Assembly.Location; Guid productId = this.Id; string productTitle = this.Name; bool rc = LicenseUtils.AskUserForLicense(productPath, standAlone, parent, productId, (int)productBuildType, productTitle, textMask, validateDelegate); return rc; }
/// <summary> /// This version of Rhino.PlugIns.LicenseUtils.AskUserForLicense /// is used by Rhino C++ plug-ins. /// </summary> public static bool AskUserForLicense(int productType, bool standAlone, System.Windows.Forms.IWin32Window parentWindow, string textMask, ValidateProductKeyDelegate validateDelegate) { if (null == validateDelegate) return false; // 26 Jan 2012 - S. Baer (RR 97943) // We were able to get this function to thrown exceptions with a bogus license file, but // don't quite understand exactly where the problem was occuring. Adding a ExceptionReport // to this function in order to try and log the exception before Rhino goes down in a blaze // of glory try { System.Reflection.Assembly zooAss = GetLicenseClientAssembly(); if (null == zooAss) return false; System.Type t = zooAss.GetType("ZooClient.ZooClientUtilities", false); if (t == null) return false; System.Reflection.MethodInfo mi = t.GetMethod("AskUserForLicense"); if (mi == null) return false; // If this delegate is defined in a C++ plug-in, find the plug-in's descriptive // information from the Rhino_DotNet wrapper class which is the delegate's target. System.Reflection.MethodInfo delegate_method = validateDelegate.Method; System.Reflection.Assembly rhCommon = typeof(HostUtils).Assembly; if (delegate_method.Module.Assembly != rhCommon) return false; object wrapper_class = validateDelegate.Target; if (null == wrapper_class) return false; Type wrapper_type = wrapper_class.GetType(); System.Reflection.MethodInfo get_path_method = wrapper_type.GetMethod("Path"); System.Reflection.MethodInfo get_id_method = wrapper_type.GetMethod("ProductId"); System.Reflection.MethodInfo get_title_method = wrapper_type.GetMethod("ProductTitle"); string productPath = get_path_method.Invoke(wrapper_class, null) as string; string productTitle = get_title_method.Invoke(wrapper_class, null) as string; Guid productId = (Guid)get_id_method.Invoke(wrapper_class, null); var args = new object[] { new VerifyFromZooCommon(), productPath, standAlone, parentWindow, productId, productType, productTitle, textMask, validateDelegate, null }; object invoke_rc = mi.Invoke(null, args); if (null == invoke_rc) return false; return (bool)invoke_rc; } catch (Exception ex) { Rhino.Runtime.HostUtils.ExceptionReport(ex); } return false; }
/// <summary> /// This (internal) version of Rhino.PlugIns.LicenseUtils.ReturnLicense is used /// is used by Rhino C++ plug-ins. /// </summary> public static bool ReturnLicense(ValidateProductKeyDelegate validateDelegate) { if (null == validateDelegate) return false; try { System.Reflection.Assembly zooAss = GetLicenseClientAssembly(); if (null == zooAss) return false; System.Type t = zooAss.GetType("ZooClient.ZooClientUtilities", false); if (t == null) return false; System.Reflection.MethodInfo mi = t.GetMethod("ReturnLicense"); if (mi == null) return false; // If this delegate is defined in a C++ plug-in, find the plug-in's descriptive // information from the Rhino_DotNet wrapper class which is the delegate's target. System.Reflection.MethodInfo delegate_method = validateDelegate.Method; System.Reflection.Assembly rhDotNet = HostUtils.GetRhinoDotNetAssembly(); if (delegate_method.Module.Assembly != rhDotNet) return false; object wrapper_class = validateDelegate.Target; if (null == wrapper_class) return false; Type wrapper_type = wrapper_class.GetType(); System.Reflection.MethodInfo get_path_method = wrapper_type.GetMethod("Path"); System.Reflection.MethodInfo get_id_method = wrapper_type.GetMethod("ProductId"); System.Reflection.MethodInfo get_title_method = wrapper_type.GetMethod("ProductTitle"); string productPath = get_path_method.Invoke(wrapper_class, null) as string; string productTitle = get_title_method.Invoke(wrapper_class, null) as string; Guid productId = (Guid)get_id_method.Invoke(wrapper_class, null); var args = new object[] { new VerifyFromZooCommon(), productId }; object invoke_rc = mi.Invoke(null, args); if (null == invoke_rc) return false; return (bool)invoke_rc; } catch (Exception ex) { Rhino.Runtime.HostUtils.ExceptionReport(ex); } return false; }
/// <summary> /// This version of Rhino.PlugIns.LicenseUtils.GetLicense /// is used by Rhino C++ plug-ins. /// </summary> public static bool GetLicense(ValidateProductKeyDelegate validateDelegate, int capabilities, string textMask) { // 20-May-2013 Dale Fugier if (null == validateDelegate) return false; try { System.Reflection.Assembly zooAss = GetLicenseClientAssembly(); if (null == zooAss) return false; System.Type t = zooAss.GetType("ZooClient.ZooClientUtilities", false); if (t == null) return false; System.Reflection.MethodInfo mi = t.GetMethod("GetLicense"); if (mi == null) return false; // If this delegate is defined in a C++ plug-in, find the plug-in's descriptive // information from the Rhino_DotNet wrapper class which is the delegate's target. System.Reflection.MethodInfo delegate_method = validateDelegate.Method; System.Reflection.Assembly rhCommon = typeof (HostUtils).Assembly; if (delegate_method.Module.Assembly != rhCommon) return false; object wrapper_class = validateDelegate.Target; if (null == wrapper_class) return false; Type wrapper_type = wrapper_class.GetType(); System.Reflection.MethodInfo get_path_method = wrapper_type.GetMethod("Path"); System.Reflection.MethodInfo get_id_method = wrapper_type.GetMethod("ProductId"); System.Reflection.MethodInfo get_title_method = wrapper_type.GetMethod("ProductTitle"); string productPath = get_path_method.Invoke(wrapper_class, null) as string; string productTitle = get_title_method.Invoke(wrapper_class, null) as string; Guid productId = (Guid)get_id_method.Invoke(wrapper_class, null); // 20-May-2013 Dale Fugier, 0 == any build int productBuildType = 0; // Convert int to enum LicenseCapabilities licenseCapabilities = GetLicenseCapabilities(capabilities); var args = new object[] { new VerifyFromZooCommon(), productPath, productId, productBuildType, productTitle, licenseCapabilities, textMask, validateDelegate }; object invoke_rc = mi.Invoke(null, args); if (null == invoke_rc) return false; return (bool)invoke_rc; } catch (Exception ex) { Rhino.Runtime.HostUtils.ExceptionReport(ex); } return false; }
internal static bool AskUserForLicense(string productPath, bool standAlone, System.Windows.Forms.IWin32Window parentWindow, Guid productId, int productBuildType, string productTitle, string textMask, ValidateProductKeyDelegate validateDelegate) { // 10-Jul-2013 Dale Fugier - don't test for validation function if (/*null == validateDelegate ||*/ string.IsNullOrEmpty(productPath) || string.IsNullOrEmpty(productTitle) || productId.Equals(Guid.Empty) ) return false; try { System.Reflection.Assembly zooAss = GetLicenseClientAssembly(); if (null == zooAss) return false; Type t = zooAss.GetType("ZooClient.ZooClientUtilities", false); if (t == null) return false; System.Reflection.MethodInfo mi = t.GetMethod("AskUserForLicense"); if (mi == null) return false; var args = new object[] { new VerifyFromZooCommon(), productPath, standAlone, parentWindow, productId, productBuildType, productTitle, textMask, validateDelegate, null }; object invoke_rc = mi.Invoke(null, args); if (null == invoke_rc) return false; return (bool)invoke_rc; } catch (Exception ex) { Rhino.Runtime.HostUtils.ExceptionReport(ex); } return false; }
/// <summary> /// 20-May-2013 Dale Fugier /// This (internal) version of Rhino.PlugIns.LicenseUtils.GetLicense /// is used by Rhino.PlugIns.PlugIn objects. /// </summary> internal static bool GetLicense(string productPath, Guid productId, string productTitle, LicenseCapabilities licenseCapabilities, string textMask, ValidateProductKeyDelegate validateDelegate) { if (null == validateDelegate || string.IsNullOrEmpty(productPath) || string.IsNullOrEmpty(productTitle) || productId.Equals(Guid.Empty) ) return false; try { System.Reflection.Assembly zooAss = GetLicenseClientAssembly(); if (null == zooAss) return false; System.Type t = zooAss.GetType("ZooClient.ZooClientUtilities", false); if (t == null) return false; System.Reflection.MethodInfo mi = t.GetMethod("GetLicense"); if (mi == null) return false; // 20-May-2013 Dale Fugier, 0 == any build int productBuildType = 0; var args = new object[] { new VerifyFromZooCommon(), productPath, productId, productBuildType, productTitle, licenseCapabilities, textMask, validateDelegate }; object invoke_rc = mi.Invoke(null, args); if (null == invoke_rc) return false; return (bool)invoke_rc; } catch (Exception ex) { Rhino.Runtime.HostUtils.ExceptionReport(ex); } return false; }
/// <summary> /// This (internal) version of Rhino.PlugIns.LicenseUtils.GetLicense /// is used by Rhino.PlugIns.PlugIn objects. /// </summary> internal static bool GetLicense(string productPath, Guid productId, int productBuildType, string productTitle, ValidateProductKeyDelegate validateDelegate) { if (null == validateDelegate || string.IsNullOrEmpty(productPath) || string.IsNullOrEmpty(productTitle) || productId.Equals(Guid.Empty) ) return false; try { System.Reflection.Assembly zooAss = GetLicenseClientAssembly(); if (null == zooAss) return false; System.Type t = zooAss.GetType("ZooClient.ZooClientUtilities", false); if (t == null) return false; System.Reflection.MethodInfo mi = t.GetMethod("GetLicense"); if (mi == null) return false; object invoke_rc = mi.Invoke(null, new object[] { productPath, productId, productBuildType, productTitle, validateDelegate }); if (null == invoke_rc) return false; return (bool)invoke_rc; } catch (Exception ex) { Rhino.Runtime.HostUtils.ExceptionReport(ex); } return false; }
/// <summary> /// This (internal) version of Rhino.PlugIns.LicenseUtils.ReturnLicense is used /// is used by Rhino C++ plug-ins. /// </summary> public static bool ReturnLicense(ValidateProductKeyDelegate validateDelegate) { if (null == validateDelegate) return false; try { var method_info = GetReturnLicenseMethod(); if (method_info == null) return false; // If this delegate is defined in a C++ plug-in, find the plug-in's descriptive // information from the Rhino_DotNet wrapper class which is the delegate's target. var delegate_method = validateDelegate.Method; var rhino_dot_net_assembly = HostUtils.GetRhinoDotNetAssembly(); if (delegate_method.Module.Assembly != rhino_dot_net_assembly) return false; var wrapper_class = validateDelegate.Target; if (null == wrapper_class) return false; var wrapper_type = wrapper_class.GetType(); var get_id_method = wrapper_type.GetMethod("ProductId"); var product_id = (Guid)get_id_method.Invoke(wrapper_class, null); var args = new object[] { new VerifyFromZooCommon(), product_id }; var invoke_rc = method_info.Invoke(null, args); if (null == invoke_rc) return false; return (bool)invoke_rc; } catch (Exception ex) { HostUtils.ExceptionReport(ex); } return false; }