Commit 087ac446 authored by Maxence MOHR's avatar Maxence MOHR 😄
Browse files

Added treeview, cleaner UI, dialog and loading boxes

parent afda4528

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29209.62
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PKCS11Explorer", "PKCS11Explorer\PKCS11Explorer.csproj", "{F986591E-1874-4D6D-909F-39912117096E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F986591E-1874-4D6D-909F-39912117096E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F986591E-1874-4D6D-909F-39912117096E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F986591E-1874-4D6D-909F-39912117096E}.Debug|x64.ActiveCfg = Debug|x64
{F986591E-1874-4D6D-909F-39912117096E}.Debug|x64.Build.0 = Debug|x64
{F986591E-1874-4D6D-909F-39912117096E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F986591E-1874-4D6D-909F-39912117096E}.Release|Any CPU.Build.0 = Release|Any CPU
{F986591E-1874-4D6D-909F-39912117096E}.Release|x64.ActiveCfg = Release|x64
{F986591E-1874-4D6D-909F-39912117096E}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5962405E-4289-4C72-A00C-43DA5A433CA8}
EndGlobalSection
EndGlobal
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="PKCS11Explorer.App">
<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml"/>
</Application.Styles>
</Application>
using Avalonia;
using Avalonia.Markup.Xaml;
namespace PKCS11Explorer
{
public class App : Application
{
public string Version
{
get
{
return "0.0.2";
}
}
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
}
}
Copyright 2019 Maxence MOHR (fladnaG.net)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<Platforms>AnyCPU;x64</Platforms>
<ApplicationIcon>app_icon.ico</ApplicationIcon>
<Version>0.0.2</Version>
<Authors>Maxence MOHR</Authors>
<Product>PKCS11 Explorer</Product>
<Copyright>PKCS11 Explorer under Apache 2.0 Licensee</Copyright>
<PackageLicenseExpression>Apache 2.0</PackageLicenseExpression>
<Description>A cross platform desktop app, written in .NETCore, to explore and interact with PKCS11 tokens.</Description>
</PropertyGroup>
<ItemGroup>
<Compile Update="**\*.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<AvaloniaResource Include="**\*.xaml">
<SubType>Designer</SubType>
</AvaloniaResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.8.2" />
<PackageReference Include="Avalonia.Desktop" Version="0.8.2" />
<PackageReference Include="Pkcs11Interop" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<EmbeddedRessources Include="Assets\*" />
</ItemGroup>
<ItemGroup>
<None Remove="Views\DialogBox.xaml" />
<None Remove="Views\LoadingBox.xaml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Assets\*" />
</ItemGroup>
<ItemGroup>
<AvaloniaResource Remove="Views\DialogBox.xaml" />
<AvaloniaResource Remove="Views\LoadingBox.xaml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Views\DialogBox.xaml">
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Views\LoadingBox.xaml">
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Compile Update="Views\DialogBox.xaml.cs">
<DependentUpon>DialogBox.xaml</DependentUpon>
</Compile>
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>C:\Users\fladnaG\Desktop\pcks11test-avalonia-master\PKCS11Test\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
</Project>
\ No newline at end of file
using System;
using Avalonia;
using Avalonia.Logging.Serilog;
using PKCS11Explorer.Views;
namespace PKCS11Explorer
{
class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
public static void Main(string[] args) => BuildAvaloniaApp().Start(AppMain, args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToDebug();
// Your application's entry point. Here you can initialize your MVVM framework, DI
// container, etc.
private static void AppMain(Application app, string[] args)
{
app.Run(new MainWindow());
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<TargetFramework>netcoreapp2.1</TargetFramework>
<PublishDir>bin\Release\netcoreapp2.1\publish\</PublishDir>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
\ No newline at end of file
using Avalonia;
using Avalonia.Data.Converters;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
namespace PKCS11Explorer.Tools
{
public class BitmapValueConverter : IValueConverter
{
public static BitmapValueConverter Instance = new BitmapValueConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string && targetType == typeof(IBitmap))
{
var uri = new Uri((string)value, UriKind.RelativeOrAbsolute);
var scheme = uri.IsAbsoluteUri ? uri.Scheme : "file";
switch (scheme)
{
case "file":
return new Bitmap((string)value);
default:
var assets = AvaloniaLocator.Current.GetService<IAssetLoader>();
return new Bitmap(assets.Open(uri));
}
}
throw new NotSupportedException();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}
using Avalonia;
using Avalonia.Platform;
using Net.Pkcs11Interop.Common;
using Net.Pkcs11Interop.HighLevelAPI;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using static PKCS11Explorer.Views.MainWindow;
namespace PKCS11Explorer.Tools
{
static class PKCS11Lister
{
public async static Task<Node> ListForTreeview(string PKCS11LibraryFilePath)
{
// Create factories used by Pkcs11Interop library
Pkcs11InteropFactories factories = new Pkcs11InteropFactories();
Node Tree = new Node();
// Load unmanaged PKCS#11 library
using (IPkcs11Library pkcs11Library = factories.Pkcs11LibraryFactory.LoadPkcs11Library(factories, PKCS11LibraryFilePath, AppType.SingleThreaded))
{
// Show general information about loaded library
ILibraryInfo libraryInfo = pkcs11Library.GetInfo();
Node Library = new Node() { Header = "PKCS11 Library " + libraryInfo.LibraryDescription, IconURI = "resm:PKCS11Explorer.Assets.baseline_layers_black_18dp.png" };
Library.Children.Add(new Node() { Header = "Filepath: " + PKCS11LibraryFilePath, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_black_18dp.png" });
Library.Children.Add(new Node() { Header = "Manufacturer: " + libraryInfo.ManufacturerId, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_black_18dp.png" });
Library.Children.Add(new Node() { Header = "Description: " + libraryInfo.LibraryDescription, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_black_18dp.png" });
Library.Children.Add(new Node() { Header = "Version: " + libraryInfo.LibraryVersion, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_black_18dp.png" });
var assets = AvaloniaLocator.Current.GetService<IAssetLoader>();
Tree.Children.Add(Library);
// Get list of all available slots
foreach (ISlot slot in pkcs11Library.GetSlotList(SlotsType.WithOrWithoutTokenPresent))
{
// Show basic information about slot
ISlotInfo slotInfo = slot.GetSlotInfo();
Node Slot = new Node() { Header = "Slot " + slot.GetSlotInfo().SlotId, IconURI = "resm:PKCS11Explorer.Assets.baseline_scanner_black_18dp.png" };
Slot.Children.Add(new Node() { Header = "Manufacturer: " + slotInfo.ManufacturerId, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_black_18dp.png" });
Slot.Children.Add(new Node() { Header = "Description: " + slotInfo.SlotDescription, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_black_18dp.png" });
Slot.Children.Add(new Node() { Header = "Token present: " + slotInfo.SlotFlags.TokenPresent, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_black_18dp.png" });
if (slotInfo.SlotFlags.TokenPresent)
{
// Show basic information about token present in the slot
ITokenInfo tokenInfo = slot.GetTokenInfo();
Node Token = new Node() { Header = "Token " + tokenInfo.SerialNumber, IconURI = "resm:PKCS11Explorer.Assets.baseline_sim_card_black_18dp.png" };
Token.Children.Add(new Node() { Header = "Manufacturer: " + tokenInfo.ManufacturerId, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_black_18dp.png" });
Token.Children.Add(new Node() { Header = "Model: " + tokenInfo.Model, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_black_18dp.png" });
Token.Children.Add(new Node() { Header = "Serial number: " + tokenInfo.SerialNumber, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_black_18dp.png" });
Token.Children.Add(new Node() { Header = "Label: " + tokenInfo.Label, IconURI = "resm:PKCS11Explorer.Assets.baseline_info_black_18dp.png" });
Node SupportedMechanisms = new Node() { Header = "Supported mechanisms", IconURI = "resm:PKCS11Explorer.Assets.baseline_check_circle_black_18dp.png" };
// Show list of mechanisms (algorithms) supported by the token
foreach (CKM mechanism in slot.GetMechanismList())
{
SupportedMechanisms.Children.Add(new Node() { Header = mechanism.ToString(), IconURI = "resm:PKCS11Explorer.Assets.baseline_check_circle_black_18dp.png" });
}
Token.Children.Add(SupportedMechanisms);
Slot.Children.Add(Token);
}
Tree.Children.Add(Slot);
}
}
return Tree;
}
}
}
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="PKCS11Explorer.Views.DialogBox"
Title="DialogBox">
<StackPanel
Orientation="Vertical"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Margin="15">
<StackPanel
Orientation="Horizontal"
HorizontalAlignment="Stretch"
VerticalAlignment="Center">
<Image Name="Image" Margin="5" VerticalAlignment="Center"/>
<TextBlock Name="Text" Margin="5" VerticalAlignment="Center" />
</StackPanel>
<Button Name="Button" HorizontalAlignment="Center" />
</StackPanel>
</Window>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment