GetMetaData OK
This commit is contained in:
@ -26,7 +26,6 @@ namespace isn
|
||||
{
|
||||
Settings= Settings.Create();
|
||||
}
|
||||
rsa = RSA.Create(Settings.RSAParameters);
|
||||
}
|
||||
static readonly OptionSet storeoptions = new OptionSet {
|
||||
{ "s|source=", "use source", val => Settings.CurrentSourceKey ??= val },
|
||||
@ -47,7 +46,7 @@ namespace isn
|
||||
};
|
||||
|
||||
static readonly OptionSet pushoptions = new OptionSet {
|
||||
{ "k|api-key=", "use api key", val => Settings.CurrentSource.SetApiKey(rsa, val)},
|
||||
{ "k|api-key=", "use api key", val => Settings.CurrentSource.SetApiKey(val)},
|
||||
{ "s|source=", "use source", val => Settings.CurrentSourceKey = val },
|
||||
{ "h|help", "show this message and exit", h => shouldShowPushHelp = h != null },
|
||||
};
|
||||
@ -63,7 +62,6 @@ namespace isn
|
||||
private static bool shouldShowVersion;
|
||||
private static bool shouldShowSourceHelp;
|
||||
private static bool shouldShowPushHelp;
|
||||
public static RSA rsa;
|
||||
|
||||
public static Settings Settings
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ namespace isn
|
||||
/// Protected API Key
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string ProtectedApiKey { get; set; }
|
||||
public string ApiKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Key alias
|
||||
@ -26,16 +26,14 @@ namespace isn
|
||||
{
|
||||
}
|
||||
|
||||
public string GetClearApiKey(RSA rsa)
|
||||
public string GetClearApiKey()
|
||||
{
|
||||
var decrypted = rsa.Decrypt(System.Convert.FromBase64String(ProtectedApiKey), RSAEncryptionPadding.Pkcs1);
|
||||
return Encoding.Default.GetString(decrypted);
|
||||
return ApiKey;
|
||||
}
|
||||
|
||||
public void SetApiKey(RSA rsa, string key)
|
||||
public void SetApiKey(string key)
|
||||
{
|
||||
var ciphered =rsa.Encrypt(Encoding.Default.GetBytes(key), RSAEncryptionPadding.Pkcs1);
|
||||
ProtectedApiKey = System.Convert.ToBase64String(ciphered);
|
||||
ApiKey = key;
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,14 +46,11 @@ namespace isn
|
||||
|
||||
public static Settings Create()
|
||||
{
|
||||
var rsaParams = CreateCipheringParameters();
|
||||
return new Settings {
|
||||
RSAParameters = rsaParams,
|
||||
Sources = new Dictionary<string, SourceSettings>()
|
||||
};
|
||||
}
|
||||
|
||||
public RSAParameters RSAParameters { get; set; }
|
||||
public Dictionary<string, SourceSettings> Sources { get; set; }
|
||||
|
||||
private string defSourceKey;
|
||||
@ -77,16 +72,19 @@ namespace isn
|
||||
[JsonIgnore, NotMapped]
|
||||
public string CurrentSourceKey {get; set;}
|
||||
|
||||
private static RSAParameters CreateCipheringParameters()
|
||||
{
|
||||
var provider = new RSACryptoServiceProvider(2048);
|
||||
return provider.ExportParameters(true);
|
||||
}
|
||||
|
||||
[JsonIgnore, NotMapped]
|
||||
public SourceSettings CurrentSource
|
||||
{
|
||||
get => this.Sources[CurrentSourceKey];
|
||||
get
|
||||
{
|
||||
if (CurrentSourceKey==null) return null;
|
||||
if (!Sources.ContainsKey(CurrentSourceKey))
|
||||
{
|
||||
Sources.Add(CurrentSourceKey, new SourceSettings());
|
||||
}
|
||||
return Sources[CurrentSourceKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ namespace isn
|
||||
))
|
||||
try
|
||||
{
|
||||
return client.UploadFilesToServer(new Uri(pubRes.Id), fi, settings.Sources[source].GetClearApiKey(Program.rsa));
|
||||
return client.UploadFilesToServer(new Uri(pubRes.Id), fi, settings.Sources[source].ApiKey);
|
||||
}
|
||||
catch (HttpRequestException httpEx)
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ namespace isn
|
||||
var source = Settings.CurrentSource;
|
||||
foreach (string pkg in pkgs)
|
||||
{
|
||||
var report = cmd.Run(pkg, source.Url, source.GetClearApiKey(rsa));
|
||||
var report = cmd.Run(pkg, source.Url, source.ApiKey);
|
||||
pushReports.Add(report);
|
||||
}
|
||||
return pushReports;
|
||||
|
@ -25,7 +25,7 @@ namespace isn
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Sources[Settings.CurrentSourceKey].SetApiKey(Program.rsa, args[0]);
|
||||
Settings.CurrentSource.SetApiKey(args[0]);
|
||||
SaveConfig();
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,7 @@ namespace isnd.Data.Catalog
|
||||
IsListed = !pkg.IsDeleted && pkg.Package.Public;
|
||||
if (pkg.DependencyGroups!=null)
|
||||
{
|
||||
DependencySets = pkg.DependencyGroups.ToDepSetInfo();
|
||||
|
||||
DependencySets = pkg.DependencyGroups;
|
||||
}
|
||||
PackageDetailsUrl = new Uri(this.id);
|
||||
|
||||
@ -210,7 +209,8 @@ namespace isnd.Data.Catalog
|
||||
|
||||
public LicenseMetadata LicenseMetadata { get; set; }
|
||||
|
||||
public IEnumerable<PackageDependencyGroupInfo> DependencySets {get; set;}
|
||||
[JsonProperty("dependencyGroups")]
|
||||
public IEnumerable<PackageDependencyGroup> DependencySets {get; set;}
|
||||
|
||||
IEnumerable<NuGet.Packaging.PackageDependencyGroup> IPackageSearchMetadata.DependencySets => throw new NotImplementedException();
|
||||
|
||||
@ -225,13 +225,4 @@ namespace isnd.Data.Catalog
|
||||
}
|
||||
}
|
||||
|
||||
public class PackageDependencyGroupInfo
|
||||
{
|
||||
private PackageDependencyGroup group;
|
||||
|
||||
public PackageDependencyGroupInfo(PackageDependencyGroup group)
|
||||
{
|
||||
this.group = group;
|
||||
}
|
||||
}
|
||||
}
|
@ -14,13 +14,6 @@ using NuGet.Versioning;
|
||||
|
||||
namespace isnd.Data
|
||||
{
|
||||
static class Helpers
|
||||
{
|
||||
public static PackageDependencyGroupInfo[] ToDepSetInfo(this IEnumerable<PackageDependencyGroup> groups)
|
||||
{
|
||||
return groups.Select(group => new PackageDependencyGroupInfo(group)).ToArray();
|
||||
}
|
||||
}
|
||||
public class PackageDependencyGroup
|
||||
{
|
||||
[JsonIgnore]
|
||||
@ -28,7 +21,7 @@ namespace isnd.Data
|
||||
public string Id { get ; set;}
|
||||
|
||||
[Required]
|
||||
[JsonProperty("id")]
|
||||
[JsonIgnore]
|
||||
public string PackageId { get ; set;}
|
||||
|
||||
[Required]
|
||||
@ -39,7 +32,7 @@ namespace isnd.Data
|
||||
[Required]
|
||||
public string TargetFramework { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[JsonProperty("dependencies")]
|
||||
[ForeignKey("DependencyGroupId")]
|
||||
public virtual List<Dependency> Dependencies { get; set; }
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class ApiKeyProvider : IApiKeyProvider
|
||||
{
|
||||
var newKey = new ApiKey{
|
||||
UserId = model.UserId,
|
||||
CreationDate = DateTime.Now,
|
||||
CreationDate = DateTime.Now.ToUniversalTime(),
|
||||
Name = model.Name,
|
||||
ValidityPeriodInDays = model.ValidityPeriodInDays
|
||||
};
|
||||
|
@ -13,14 +13,11 @@ using isnd.Data;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Data.Packages;
|
||||
using isnd.Entities;
|
||||
using isnd.Helpers;
|
||||
using isnd.Interfaces;
|
||||
using isnd.ViewModels;
|
||||
using NuGet.Packaging.Core;
|
||||
using NuGet.Versioning;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using System.Threading;
|
||||
using NuGet.Protocol;
|
||||
|
||||
namespace isnd.Services
|
||||
@ -241,6 +238,7 @@ namespace isnd.Services
|
||||
&& v.LatestCommit != null
|
||||
&& (pkgType == null || pkgType == v.Type)
|
||||
).SingleOrDefaultAsync();
|
||||
if (version==null) return null;
|
||||
foreach (var g in version.DependencyGroups)
|
||||
{
|
||||
g.Dependencies = dbContext.Dependencies.Where(d => d.DependencyGroupId == g.Id).ToList();
|
||||
|
@ -34,16 +34,20 @@ namespace isnd.ViewModels
|
||||
private static PackageHit NewPackageHit(string apiBase, Package package)
|
||||
{
|
||||
string regId = $"{apiBase}{ApiConfig.Registration}/{package.Id}/index.json";
|
||||
return new PackageHit(regId, package.Id)
|
||||
|
||||
var pkgHit = new PackageHit(regId, package.Id)
|
||||
{
|
||||
version = package.GetLatestVersion(),
|
||||
description = package.Description,
|
||||
versions = package.Versions.Select(v => new SearchVersionInfo(apiBase, v)).ToArray(),
|
||||
packageTypes = package.Versions.Select(v=>new PackageType(v.Type, new System.Version(v.Major,v.Minor,v.Patch, v.Revision)))
|
||||
.ToArray(),
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
if (package.Versions!=null)
|
||||
{
|
||||
pkgHit.versions = package.Versions
|
||||
.Select(v => new SearchVersionInfo(apiBase, v)).ToArray();
|
||||
pkgHit.packageTypes = package.Versions
|
||||
.Select(v=>new PackageType(v.Type ?? "Legacy", new System.Version(v.Major,v.Minor,v.Patch, v.Revision)))?.ToArray();
|
||||
}
|
||||
return pkgHit;
|
||||
}
|
||||
|
||||
public PackageHit[] data { get; protected set; }
|
||||
|
Reference in New Issue
Block a user