コード例 #1
0
ファイル: Helper.cs プロジェクト: stantoxt/octokit.net
 public static void DeleteGpgKey(IConnection connection, GpgKey key)
 {
     if (key != null)
     {
         DeleteGpgKey(connection, key.Id);
     }
 }
コード例 #2
0
ファイル: GpgKeyContext.cs プロジェクト: x5a/octokit.net
 internal GpgKeyContext(IConnection connection, GpgKey key)
 {
     _connection   = connection;
     Key           = key;
     GpgKeyId      = key.Id;
     KeyId         = key.KeyId;
     PublicKeyData = key.PublicKey;
 }
コード例 #3
0
        public GpgAuth(ApiSession session, GpgKey clientKey, GpgKey serverKey)
        {
            _pgp       = new PGP();
            _clientKey = clientKey;
            _serverKey = serverKey;

            _session = session;
        }
コード例 #4
0
 internal GpgKeyContext(IConnection connection, GpgKey key)
 {
     _connection = connection;
     Key = key;
     GpgKeyId = key.Id;
     KeyId = key.KeyId;
     PublicKeyData = key.PublicKey;
 }
コード例 #5
0
        public void TestGpgKeyList1()
        {
            GpgKey k = new GpgKey(KEY_LIST_1);

            Assert.IsTrue(k.Raw == KEY_LIST_1);
            Assert.IsTrue(k.UserId == "*****@*****.**");
            Assert.IsTrue(k.UserName == "Firstname Lastname");
            Assert.IsTrue(k.Key == "1024D/543C3595");
            Assert.IsTrue(DateTime.Compare(k.KeyExpiration, new DateTime(2016, 12, 10, 0, 0, 0)) == 0);
            Assert.IsNull(k.SubKey);
            Assert.IsTrue(DateTime.Compare(k.SubKeyExpiration, DateTime.MinValue) == 0);
        }
コード例 #6
0
        public void TestGpgKeyList2()
        {
            GpgKey k = new GpgKey(KEY_LIST_2);

            Assert.IsTrue(k.Raw == KEY_LIST_2);
            Assert.IsTrue(k.UserId == "*****@*****.**");
            Assert.IsTrue(k.UserName == "ultimate John Jones (this is a long long long comment that I want to see what happens when the commen tis very long and and does something to the ui)");
            Assert.IsTrue(k.Key == "rsa2048/028ECE89");
            Assert.IsTrue(DateTime.Compare(k.KeyCreation, new DateTime(2016, 6, 7, 0, 0, 0)) == 0);
            Assert.IsTrue(DateTime.Compare(k.KeyExpiration, new DateTime(2018, 6, 7, 0, 0, 0)) == 0);
            Assert.IsNull(k.SubKey);
            Assert.IsTrue(DateTime.Compare(k.SubKeyExpiration, DateTime.MinValue) == 0);
        }
コード例 #7
0
 internal static async Task <string> EncryptStringAsync(this PGP pgp, string data, GpgKey key)
 {
     return(await EncryptStringAsync(pgp, data, Encoding.UTF8.GetBytes(key.ArmoredKey)));
 }
コード例 #8
0
 internal static async Task <string> DecryptStringAsync(this PGP pgp, string data, GpgKey key, SecureString password)
 {
     return(await DecryptStringAsync(pgp, data, Encoding.UTF8.GetBytes(key.PrivateKey), password));
 }
コード例 #9
0
ファイル: Helper.cs プロジェクト: daveaglick/octokit.net
 public static void DeleteGpgKey(IConnection connection, GpgKey key)
 {
     if (key != null)
         DeleteGpgKey(connection, key.Id);
 }
コード例 #10
0
 private void PrintKey(GpgKey key)
 {
     Debug.WriteLine(key.ToString());
 }
コード例 #11
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Running API test");
            var clientKey = GpgKey.FromFile(@"C:\Users\josephmarsden\Documents\Development\Test\passbolt_client_public.asc",
                                            @"C:\Users\josephmarsden\Documents\Development\Test\passbolt_client_private.asc");
            var serverKey = GpgKey.FromFile(@"C:\Users\josephmarsden\Documents\Development\Test\passbolt_server_public.asc");

            clientKey.Fingerprint = "92BCE51A7AB62E5B60631C6C68397B90B85B546A";
            serverKey.Fingerprint = "A876BCFE2406F19ADB6C81A45C2B1175950963B4";

            var client = new ApiClient(new Uri("https://passbolt.internal.arctarus.co.uk"));

            using (var session = client.GetSession())
            {
                var auth = new GpgAuth(session, clientKey, serverKey);
                GpgAuthSessionState result;

                while (true)
                {
                    Console.Write("Password: "******"Enter your MFA token: ");
                        var token = Console.ReadLine();
                        if (!await mfa.VerifyMfaChallenge(token))
                        {
                            Console.Write("Invalid token.");
                            continue;
                        }

                        break;
                    }

                    if (await auth.VerifySession() != GpgAuthSessionState.Valid)
                    {
                        Console.WriteLine("MFA error occurred");
                        return;
                    }

                    break;

                case GpgAuthSessionState.Valid:
                    return;
                }

                Console.WriteLine("Authentication successful.");
            }
        }