Esempio n. 1
0
  /**
   * Initialize software token
   *
   * @throws Exception if an error occurs
   */
  @Command(description = "Initialize software token")
  public void initSoftwareToken() throws Exception {
    char[] pin = System.console().readPassword("PIN: ");
    char[] pin2 = System.console().readPassword("retype PIN: ");

    if (!Arrays.equals(pin, pin2)) {
      System.out.println("ERROR: PINs do not match");
      return;
    }

    try {
      SignerClient.execute(new InitSoftwareToken(pin));

      AuditLogger.log(INITIALIZE_THE_SOFTWARE_TOKEN_EVENT, XROAD_USER, null);
    } catch (Exception e) {
      AuditLogger.log(INITIALIZE_THE_SOFTWARE_TOKEN_EVENT, XROAD_USER, e.getMessage(), null);

      throw e;
    }
  }
Esempio n. 2
0
  /**
   * Log in token.
   *
   * @param tokenId token id
   * @throws Exception if an error occurs
   */
  @Command(description = "Log in token", abbrev = "li")
  public void loginToken(@Param(name = "tokenId", description = "Token ID") String tokenId)
      throws Exception {
    char[] pin = System.console().readPassword("PIN: ");

    Map<String, Object> logData = new LinkedHashMap<>();
    logData.put(TOKEN_ID_PARAM, tokenId);

    try {
      PasswordStore.storePassword(tokenId, pin);
      SignerClient.execute(new ActivateToken(tokenId, true));

      AuditLogger.log(LOG_INTO_THE_TOKEN, XROAD_USER, logData);
    } catch (Exception e) {
      AuditLogger.log(LOG_INTO_THE_TOKEN, XROAD_USER, e.getMessage(), logData);

      throw e;
    }
  }