ZeroInstall.Publish.FeedUtils.GetKey C# (CSharp) Method

GetKey() private method

private GetKey ( [ path, [ openPgp ) : OpenPgpSecretKey
path [
openPgp [
return OpenPgpSecretKey
        public static OpenPgpSecretKey GetKey([NotNull] string path, [NotNull] IOpenPgp openPgp)
        {
            #region Sanity checks
            if (string.IsNullOrEmpty(path)) throw new ArgumentNullException(nameof(path));
            if (openPgp == null) throw new ArgumentNullException(nameof(openPgp));
            #endregion

            try
            {
                var signature = Store.Feeds.FeedUtils.GetSignatures(openPgp, File.ReadAllBytes(path))
                    .OfType<ValidSignature>().FirstOrDefault();
                if (signature == null) return null;

                return openPgp.GetSecretKey(signature);
            }
                #region Error handling
            catch (KeyNotFoundException)
            {
                Log.Info(Resources.SecretKeyNotInKeyring);
                return null;
            }
            catch (SignatureException ex)
            {
                // Unable to parse the signature
                Log.Error(ex);
                return null;
            }
            #endregion
        }
    }

Usage Example

示例#1
0
        public static SignedCatalog Load([NotNull] string path)
        {
            #region Sanity checks
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }
            #endregion

            return(new SignedCatalog(XmlStorage.LoadXml <Catalog>(path), FeedUtils.GetKey(path, OpenPgpFactory.CreateDefault())));
        }
All Usage Examples Of ZeroInstall.Publish.FeedUtils::GetKey