CSJCurrent 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 Activate QUICK Access.

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 Getting Started guide on the current client

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

Expand to reveal source code...  Expand source

import com.cryptshare.api.*;

import java.nio.file.Paths;
import java.util.Locale;
import java.util.Scanner;

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

	public static void main(String[] args) {
		try {
			client = new Client(
					 "john.doe@example.com",
					new CryptshareConnection(new WebServiceUri("https://cryptshare.example.com")),
					Paths.get("C:\\Tmp"));

			checkVerificationResult = client.checkVerification();

			// Do not proceed if the user is not already verified.
			if (!checkVerificationResult.isUserVerified()) {
				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.isActivationRequired()) {
				displayActivationMenu();
				System.out.println("Please enter the QUICK activation code below and press [Enter]:");
				client.applyQuickActivationCode(new Scanner(System.in).next().trim());
			} else {
				String inlineText = checkVerificationResult.isQuickEnabled() ? "is enabled for QUICK" : "has not used QUICK before";
				System.out.printf("The user %s; no action required.%n", inlineText);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			System.out.println("Press any key to terminate the program.");
			new Scanner(System.in).next();
		}
	}

	private static void displayActivationMenu() throws CryptshareServerException, ClientException {
		System.out.println("A QUICK activation is required; please choose an option below:");
		System.out.println("(1) Request QUICK activation code via the Cryptshare Server Administrator");
		System.out.println("(2) Enter a QUICK activation code generated from another QUICK-enabled client");
		boolean invalidInput;
		do {
			invalidInput = false;
			final int choice = new Scanner(System.in).nextInt();
			switch (choice) {
				case 1:
					performActivationViaAdministrator();
					break;
				case 2:
					performActivationViaOtherClient();
					break;
				default:
					System.out.println("Invalid choice; please repeat your input:");
					invalidInput = true;
					break;
			}
		} while (invalidInput);
	}

	private static void performActivationViaAdministrator() throws CryptshareServerException, ClientException {
		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}".
		System.out.println(checkVerificationResult.getAdministratorActivationContactDetails().get(Locale.ENGLISH));
	}

	private static void performActivationViaOtherClient() throws CryptshareServerException, ClientException {
		checkVerificationResult = client.checkVerification();
		if (checkVerificationResult.getQuickEnabledClients().size() > 0) {
			System.out.println(
					"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:");
			for (ClientInformation clientInformation : checkVerificationResult.getQuickEnabledClients()) {
				System.out.println("Name: " + clientInformation.getName());
				System.out.println("Platform: " + clientInformation.getPlatform());
				System.out.println("Last use: " + clientInformation.getLastUse());
				System.out.println("Last IP address: " + clientInformation.getLastIpAddress() + "\\n");
			}
		} else {
			System.out.println(
					"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.");
		}
	}
}