CSDNCurrent en:Activate QUICK access

Aus Cryptshare Documentation
Wechseln zu:Navigation, Suche



General information about the QUICK activation process
If you want to learn more about the QUICK activation process, please head over to the article Activation of QUICK.

When attempting to perform a QUICK transfer, it's important to make sure that no QUICK activation is required. A QUICK activation may be required if the user has either sent or retrieved a transfer using QUICK in the past and doesn't have access to their QUICK access credentials anymore, e.g. because they have cleared their browser cookies or switched to a different device. QUICK access can be activated by either requesting a QUICK activation code via the Cryptshare Server Administrator or by generating a QUICK activation code yourself on any device that has a valid QUICK access. The requested code then needs to be provided to the Cryptshare Server, which in turn will activate QUICK access on the client in use. Our goal is to activate a previously used QUICK access on the currently used client. In the following example, we will write a small program that offers you to activate QUICK access when a recovery is required. In order to simulate a scenario in which a recovery is required, you can simply

  • perform a QUICK transfer using the same email address on a different client, e.g. Outlook
  • delete the `client.store` file on the current client
  • perform a sender verification using the Quick Start Guide guide on the current client

This will make sure that a QUICK activation is required on the client this program is running on.

using Cryptshare.API;
using System;
using System.Globalization;

namespace QuickTransfer
{
    class Program
    {
        private static Client client;
        private static CheckVerificationResult checkVerificationResult;

        static void Main(string[] args)
        {
            try
            {
                client = new Client(
                    "john.doe@example.com",
                    new CryptshareConnection(new WebServiceUri("https://cryptshare.example.com")),
                    @"C:\Temp"
                );

                checkVerificationResult = client.CheckVerification();

                // Do not proceed if the user is not already verified.
                if (!checkVerificationResult.Verified)
                {
                    throw new Exception("Cannot perform a QUICK activation if the client is not verified.");
                }

                // If the user already has a personal key on this server, display options to recover QUICK access.
                if (checkVerificationResult.ActivationRequired)
                {
                    DisplayActivationMenu();
                    Console.WriteLine("Please enter the QUICK activation code below and press [Enter]:");
                    client.ApplyQuickActivationCode(Console.ReadLine().Trim());
                }
                else
                {
                    string inlineText = checkVerificationResult.QuickEnabled
                        ? "is enabled for QUICK"
                        : "has not used QUICK before";
                    Console.WriteLine($"The user {inlineText}; no action required.");
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("An error has occurred: " + e);
            }
            finally
            {
                Console.WriteLine("Press any key to terminate the program.");
                Console.ReadKey();
            }
        }

        private static void DisplayActivationMenu()
        {
            Console.WriteLine("A QUICK activation is required; please choose an option below:");
            Console.WriteLine("(1) Request QUICK activation code via the Cryptshare Server Administrator");
            Console.WriteLine("(2) Enter a QUICK activation code generated from another QUICK-enabled client");
            int choice;
            bool invalidInput;
            do
            {
                invalidInput = false;
                int.TryParse(Console.ReadLine(), out choice);
                switch (choice)
                {
                    case 1:
                        PerformActivationViaAdministrator();
                        break;
                    case 2:
                        PerformActivationViaOtherClient();
                        break;
                    default:
                        Console.WriteLine("Invalid choice; please repeat your input:");
                        invalidInput = true;
                        break;
                }
            } while (invalidInput);
        }

        private static void PerformActivationViaAdministrator()
        {
            checkVerificationResult = client.CheckVerification();
            // We choose to display the English QUICK recovery instructions. The texts can be freely defined on the
            // Cryptshare Administration Interface via "QUICK" > "Recovery Settings" > "{Your language}".
            Console.WriteLine(checkVerificationResult.AdministratorActivationContactDetails[new CultureInfo("en")]);
        }
        
        private static void PerformActivationViaOtherClient()
        {
            checkVerificationResult = client.CheckVerification();
            if (checkVerificationResult.QuickEnabledClients.Count > 0)
            {
                Console.WriteLine("The server has reported that QUICK has been last used on the following clients. Please generate a QUICK activation code using one of these clients:");
                foreach (var clientInformation in checkVerificationResult.QuickEnabledClients)
                {
                    Console.WriteLine("Name: " + clientInformation.Name);
                    Console.WriteLine("Platform: " + clientInformation.Platform);
                    Console.WriteLine("Last use: " + clientInformation.LastUse);
                    Console.WriteLine("Last IP address: " + clientInformation.LastIpAddress + "\n");
                }
            }
            else
            {
                Console.WriteLine("No other QUICK-enabled client has been reported by the server. Please choose option (1) to obtain a QUICK activation code via the Cryptshare Server Administrator.");
            }
        }
    }
}

The resulting program's functionality is demonstrated in the video below:

Datei:QUICK activation.mp4