Beispiel #1
0
        public static EncryptedProperties Create(Stream stream, LogOnIdentity identity)
        {
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }
            if (identity == LogOnIdentity.Empty)
            {
                return(Invalid);
            }

            EncryptedProperties properties = new EncryptedProperties(null);

            using (IAxCryptDocument document = New <AxCryptFactory>().CreateDocument(identity.DecryptionParameters(), stream))
            {
                if (!document.PassphraseIsValid)
                {
                    return(Invalid);
                }

                properties = new EncryptedProperties(document.FileName);
                properties.SharedKeyHolders               = document.AsymmetricRecipients;
                properties.DecryptionParameter            = document.DecryptionParameter;
                properties.FileMetaData.CreationTimeUtc   = document.CreationTimeUtc;
                properties.FileMetaData.LastWriteTimeUtc  = document.LastWriteTimeUtc;
                properties.FileMetaData.LastAccessTimeUtc = document.LastAccessTimeUtc;
                properties.IsValid = true;
            }

            return(properties);
        }
Beispiel #2
0
        private static async Task AddSharingParameters(EncryptionParameters parameters, ActiveFile activeFile, FileLock encryptedFileLock)
        {
            if (New <LicensePolicy>().Capabilities.Has(LicenseCapability.KeySharing))
            {
                EncryptedProperties properties = EncryptedProperties.Create(encryptedFileLock.DataStore);
                await parameters.AddAsync(properties.SharedKeyHolders);

                return;
            }

            if (activeFile.IsShared)
            {
                await New <IPopup>().ShowAsync(PopupButtons.Ok, Texts.InformationTitle, Texts.KeySharingRemovedInFreeModeWarningText, Common.DoNotShowAgainOptions.KeySharingRemovedInFreeModeWarning);
            }
        }
Beispiel #3
0
        public static EncryptedProperties Create(IAxCryptDocument document)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }

            if (!document.PassphraseIsValid)
            {
                return(Invalid);
            }

            EncryptedProperties properties = new EncryptedProperties(document.FileName);

            properties.DecryptionParameter            = document.DecryptionParameter;
            properties.IsValid                        = document.PassphraseIsValid;
            properties.FileMetaData.CreationTimeUtc   = document.CreationTimeUtc;
            properties.FileMetaData.LastAccessTimeUtc = document.LastAccessTimeUtc;
            properties.FileMetaData.LastWriteTimeUtc  = document.LastWriteTimeUtc;

            return(properties);
        }