/// <summary>
        /// Checks there's a Kerberos Ticket in current user's Windows Ticket Cache matched with the service principal name.
        /// If there's a valid ticket, then show the Ticket Information on the console.
        /// </summary>
        /// <returns></returns>
        public bool ShowCachedTicket()
        {
            try
            {
                byte[] ticket
                    = KerberosSupplementalTicketManager.GetKerberosTicketFromWindowsTicketCache(_kerberosServicePrincipalName, _logonId);
                if (ticket != null && ticket.Length > 32)
                {
                    var encode = Convert.ToBase64String(ticket);

                    AADKerberosLogger.PrintLines(2);
                    AADKerberosLogger.Save($"---Find cached Ticket: {ticket.Length} bytes");
                    AADKerberosLogger.PrintBinaryData(ticket);

                    TicketDecoder decoder = new TicketDecoder();
                    decoder.ShowApReqTicket(encode);
                    return(true);
                }

                Console.WriteLine($"There's no ticket associated with '{_kerberosServicePrincipalName}'");
            }
            catch (Win32Exception ex)
            {
                Console.WriteLine($"ERROR while finding Kerberos Ticket for '{_kerberosServicePrincipalName}': {ex.Message}");
            }
            return(false);
        }
 private void ShowAuthorizationData(string title, KrbAuthorizationData auth)
 {
     if (auth != null)
     {
         AADKerberosLogger.Save($"  {title}.Type: {auth.Type}");
         AADKerberosLogger.Save($"  {title}.Data.Length: {auth.Data.Length}");
         AADKerberosLogger.Save($"  {title}.Data.Value:");
         AADKerberosLogger.PrintBinaryData(auth.Data.ToArray());
     }
 }
 private void ShowEncrytionKey(string title, KrbEncryptionKey key)
 {
     if (key == null)
     {
         AADKerberosLogger.Save($"  {title}:");
     }
     else
     {
         AADKerberosLogger.Save($"  {title}.Usage: {key.Usage}");
         AADKerberosLogger.Save($"  {title}.EType: {key.EType}");
         AADKerberosLogger.Save($"  {title}.KeyValue.Length: {key.KeyValue.Length}");
         AADKerberosLogger.Save($"  {title}.KeyValue.Value:");
         AADKerberosLogger.PrintBinaryData(key.KeyValue.ToArray());
     }
 }
 private void ShowEncryptedDataPart(string title, KrbEncryptedData data)
 {
     if (data == null)
     {
         AADKerberosLogger.Save($"  {title}:");
     }
     else
     {
         AADKerberosLogger.Save($"  {title}.EType: " + data.EType);
         AADKerberosLogger.Save($"  {title}.KeyVersionNumber: " + data.KeyVersionNumber);
         AADKerberosLogger.Save($"  {title}.Cipher.Length: " + data.Cipher.Length);
         AADKerberosLogger.Save($"  {title}.Cipher.Value:");
         AADKerberosLogger.PrintBinaryData(data.Cipher.ToArray());
     }
 }