示例#1
0
  /**
   * Log out token.
   *
   * @param tokenId token id
   * @throws Exception if an error occurs
   */
  @Command(description = "Log out token", abbrev = "lo")
  public void logoutToken(@Param(name = "tokenId", description = "Token ID") String tokenId)
      throws Exception {
    Map<String, Object> logData = new LinkedHashMap<>();
    logData.put(TOKEN_ID_PARAM, tokenId);

    try {
      PasswordStore.storePassword(tokenId, null);
      SignerClient.execute(new ActivateToken(tokenId, false));

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

      throw e;
    }
  }
示例#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;
    }
  }
示例#3
0
  /**
   * Deactivates the token with the given ID.
   *
   * @param tokenId ID of the token
   * @throws Exception if any errors occur
   */
  public static void deactivateToken(String tokenId) throws Exception {
    PasswordStore.storePassword(tokenId, null);

    LOG.trace("Deactivating token '{}'", tokenId);
    execute(new ActivateToken(tokenId, false));
  }
示例#4
0
  /**
   * Activates the token with the given ID using the provided password.
   *
   * @param tokenId ID of the token
   * @param password token password
   * @throws Exception if any errors occur
   */
  public static void activateToken(String tokenId, char[] password) throws Exception {
    PasswordStore.storePassword(tokenId, password);

    LOG.trace("Activating token '{}'", tokenId);
    execute(new ActivateToken(tokenId, true));
  }