예제 #1
0
  public ApiToken refreshToken(ApiToken apiToken) {
    Calendar expiration = Calendar.getInstance();
    expiration.add(Calendar.HOUR, TOKEN_LIFETIME_HOURS);

    apiToken.setExpiration(expiration.getTime());
    apiToken = entityManager.merge(apiToken);
    WebSocketServerLogger.LOG.refreshValidTokenDebug(
        apiToken.getToken(), apiToken.getExpiration().toString());

    return apiToken;
  }
예제 #2
0
  public ApiToken createToken(Customer customer) {
    Calendar expiration = Calendar.getInstance();
    expiration.add(Calendar.HOUR, TOKEN_LIFETIME_HOURS);

    ApiToken apiToken = new ApiToken();
    apiToken.setCustomer(customer);
    apiToken.setToken(UUID.randomUUID().toString());
    apiToken.setExpiration(expiration.getTime());
    entityManager.persist(apiToken);
    WebSocketServerLogger.LOG.newTokenCreatedDebug(
        apiToken.getToken(), apiToken.getExpiration().toString());

    return apiToken;
  }