From e60bf6da8017242aae988c8fdf74906b7a7d8338 Mon Sep 17 00:00:00 2001 From: icedream Date: Wed, 7 May 2014 21:54:41 +0200 Subject: [PATCH] Adding NP MOTD test tool. --- libnpsharp.sln | 6 +++ src/libnpsharp/Properties/AssemblyInfo.cs | 8 +-- src/npmotd/App.config | 6 +++ src/npmotd/Program.cs | 50 +++++++++++++++++ src/npmotd/Properties/AssemblyInfo.cs | 36 +++++++++++++ src/npmotd/npmotd.csproj | 65 +++++++++++++++++++++++ 6 files changed, 167 insertions(+), 4 deletions(-) create mode 100644 src/npmotd/App.config create mode 100644 src/npmotd/Program.cs create mode 100644 src/npmotd/Properties/AssemblyInfo.cs create mode 100644 src/npmotd/npmotd.csproj diff --git a/libnpsharp.sln b/libnpsharp.sln index 4adaf85..74eece0 100644 --- a/libnpsharp.sln +++ b/libnpsharp.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 12.0.21005.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libnpsharp", "src\libnpsharp\libnpsharp.csproj", "{1A5AC63A-250E-4BC8-B81A-822AC31F5E37}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "npmotd", "src\npmotd\npmotd.csproj", "{7887D77B-3C79-44C5-AB80-944B191321BB}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{587B7B8C-1605-46CF-BA39-AC9C72C1E860}" ProjectSection(SolutionItems) = preProject .nuget\NuGet.Config = .nuget\NuGet.Config @@ -22,6 +24,10 @@ Global {1A5AC63A-250E-4BC8-B81A-822AC31F5E37}.Debug|Any CPU.Build.0 = Debug|Any CPU {1A5AC63A-250E-4BC8-B81A-822AC31F5E37}.Release|Any CPU.ActiveCfg = Release|Any CPU {1A5AC63A-250E-4BC8-B81A-822AC31F5E37}.Release|Any CPU.Build.0 = Release|Any CPU + {7887D77B-3C79-44C5-AB80-944B191321BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7887D77B-3C79-44C5-AB80-944B191321BB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7887D77B-3C79-44C5-AB80-944B191321BB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7887D77B-3C79-44C5-AB80-944B191321BB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/libnpsharp/Properties/AssemblyInfo.cs b/src/libnpsharp/Properties/AssemblyInfo.cs index 1244116..7813e5b 100644 --- a/src/libnpsharp/Properties/AssemblyInfo.cs +++ b/src/libnpsharp/Properties/AssemblyInfo.cs @@ -4,11 +4,11 @@ using System.Runtime.InteropServices; // Allgemeine Informationen über eine Assembly werden über die folgenden // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, // die mit einer Assembly verknüpft sind. -[assembly: AssemblyTitle(".NET NP library")] +[assembly: AssemblyTitle("NPSharp Library")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Icedream")] -[assembly: AssemblyProduct(".NET NP library")] +[assembly: AssemblyProduct("NPSharp Library")] [assembly: AssemblyCopyright("© 2014 Icedream")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] +[assembly: AssemblyVersion("0.1.*")] +[assembly: AssemblyFileVersion("0.1")] diff --git a/src/npmotd/App.config b/src/npmotd/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/src/npmotd/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/npmotd/Program.cs b/src/npmotd/Program.cs new file mode 100644 index 0000000..b66d988 --- /dev/null +++ b/src/npmotd/Program.cs @@ -0,0 +1,50 @@ +using System; +using System.Text; +using NPSharp.Authentication; + +namespace NPSharp.CommandLine.MOTD +{ + class Program + { + static void Main(string[] args) + { + var hostname = args[0]; + var username = args[1]; + var password = args[2]; + + var ah = new AuthenticationHelper(hostname); + try + { + ah.Authenticate(username, password); + } + catch + { + Console.Error.WriteLine("Could not authenticate."); + return; + } + + var np = new NPClient(hostname); + try + { + np.AuthenticateWithToken(ah.SessionToken).Wait(); + } + catch + { + Console.Error.WriteLine("Authenticated but session token was invalid."); + return; + } + + try + { + Console.WriteLine(Encoding.UTF8.GetString(np.GetPublisherFile("motd-english.txt").Result)); + } + catch + { + Console.Error.WriteLine("Could not read MOTD from NP server."); + } + + + + } + } +} diff --git a/src/npmotd/Properties/AssemblyInfo.cs b/src/npmotd/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5340568 --- /dev/null +++ b/src/npmotd/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die mit einer Assembly verknüpft sind. +[assembly: AssemblyTitle("NPSharp MOTD test client")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Icedream")] +[assembly: AssemblyProduct("NPSharp Library")] +[assembly: AssemblyCopyright("© 2014 Icedream")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar +// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von +// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("b91f9ba4-757a-4c72-b12a-c3e1f1b05715")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("0.1.*")] +[assembly: AssemblyFileVersion("0.1")] diff --git a/src/npmotd/npmotd.csproj b/src/npmotd/npmotd.csproj new file mode 100644 index 0000000..dd55d3b --- /dev/null +++ b/src/npmotd/npmotd.csproj @@ -0,0 +1,65 @@ + + + + + Debug + AnyCPU + {7887D77B-3C79-44C5-AB80-944B191321BB} + Exe + Properties + NPSharp.CommandLine.MOTD + npmotd + v4.5 + 512 + + + true + full + false + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + TRACE + prompt + 4 + false + + + $(SolutionDir)\bin\$(Configuration)\$(Platform)\ + $(SolutionDir)\obj\$(TargetName)\$(Configuration)\$(Platform)\ + $(SolutionDir)\obj\$(TargetName)\$(Configuration)\$(Platform)\ + $(SolutionDir)\obj\$(TargetName)\$(Configuration)\$(Platform)\ + $(SolutionDir)\bin\$(Configuration)\$(Platform)\ + + + + + + + + + + + + + + + + {1a5ac63a-250e-4bc8-b81a-822ac31f5e37} + libnpsharp + + + + + \ No newline at end of file