public SessionNotification(SessionNotificationType notificationType, LogOnIdentity identity, IEnumerable <string> fullNames, LicenseCapabilities capabilities)
 {
     NotificationType = notificationType;
     Identity         = identity;
     FullNames        = fullNames.Select(fn => fn.NormalizeFilePath());
     Capabilities     = capabilities;
 }
Пример #2
0
        public virtual async Task SetDefaultEncryptionIdentity(LogOnIdentity value)
        {
            if (Object.ReferenceEquals(value, null))
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (value == LogOnIdentity.Empty)
            {
                Clear();
            }

            if (_defaultEncryptionIdentity == value)
            {
                return;
            }

            if (_defaultEncryptionIdentity != LogOnIdentity.Empty)
            {
                await _notificationMonitor.NotifyAsync(new SessionNotification(SessionNotificationType.EncryptPendingFiles)).Free();

                await _notificationMonitor.SynchronizeAsync().Free();

                LicenseCapabilities oldCapabilities = New <LicensePolicy>().Capabilities;
                Clear();
                LogOnIdentity oldIdentity = _defaultEncryptionIdentity;
                _defaultEncryptionIdentity = LogOnIdentity.Empty;
                await _notificationMonitor.NotifyAsync(new SessionNotification(SessionNotificationType.SignOut, oldIdentity, oldCapabilities)).Free();

                await _notificationMonitor.SynchronizeAsync().Free();
            }

            if (value == LogOnIdentity.Empty)
            {
                return;
            }

            _defaultEncryptionIdentity = value;
            bool knownKeysChanged = AddInternal(_defaultEncryptionIdentity);
            await _notificationMonitor.NotifyAsync(new SessionNotification(SessionNotificationType.SignIn, _defaultEncryptionIdentity)).Free();

            await _notificationMonitor.SynchronizeAsync().Free();

            if (knownKeysChanged)
            {
                await _notificationMonitor.NotifyAsync(new SessionNotification(SessionNotificationType.KnownKeyChange, _defaultEncryptionIdentity)).Free();
            }
        }
Пример #3
0
 /// <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;
 }
Пример #4
0
    /// <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;
    }
 public SessionNotification(SessionNotificationType notificationType, LogOnIdentity identity, LicenseCapabilities capabilities)
     : this(notificationType, identity, new string[0], capabilities)
 {
 }
        private async Task EncryptWatchedFoldersIfSupportedAsync(LogOnIdentity identity, LicenseCapabilities capabilities, IProgressContext progress)
        {
            if (!capabilities.Has(LicenseCapability.SecureFolders))
            {
                return;
            }
            foreach (WatchedFolder watchedFolder in _fileSystemState.WatchedFolders.Where(wf => wf.Tag.Matches(identity.Tag)))
            {
                EncryptionParameters encryptionParameters = new EncryptionParameters(Resolve.CryptoFactory.Default(New <ICryptoPolicy>()).CryptoId, identity);
                await encryptionParameters.AddAsync(await watchedFolder.KeyShares.ToAvailableKnownPublicKeysAsync(identity));

                IDataContainer folder = New <IDataContainer>(watchedFolder.Path);
                progress.Display = folder.Name;
                await _axCryptFile.EncryptFoldersUniqueWithBackupAndWipeAsync(new IDataContainer[] { folder }, encryptionParameters, progress);
            }
        }