org.keycloak.common.util.Time.toDate()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(209)

本文整理了Java中org.keycloak.common.util.Time.toDate()方法的一些代码示例,展示了Time.toDate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Time.toDate()方法的具体详情如下:
包路径:org.keycloak.common.util.Time
类名称:Time
方法名:toDate

Time.toDate介绍

[英]Returns Date object, its value set to time
[中]返回日期对象,其值设置为时间

代码示例

代码示例来源:origin: org.keycloak/keycloak-account-freemarker

public Date getLastAccess() {
  return Time.toDate(session.getLastSessionRefresh());
}

代码示例来源:origin: org.keycloak/keycloak-account-freemarker

public Date getStarted() {
  return Time.toDate(session.getStarted());
}

代码示例来源:origin: org.keycloak/keycloak-account-freemarker

public Date getExpires() {
  int max = session.getStarted() + realm.getSsoSessionMaxLifespan();
  return Time.toDate(max);
}

代码示例来源:origin: org.keycloak/keycloak-model-infinispan

protected int initClusterStartupTime(KeycloakSession session) {
  Integer existingClusterStartTime = (Integer) crossDCAwareCacheFactory.getCache().get(InfinispanClusterProvider.CLUSTER_STARTUP_TIME_KEY);
  if (existingClusterStartTime != null) {
    logger.debugf("Loaded cluster startup time: %s", Time.toDate(existingClusterStartTime).toString());
    return existingClusterStartTime;
  } else {
    // clusterStartTime not yet initialized. Let's try to put our startupTime
    int serverStartTime = (int) (session.getKeycloakSessionFactory().getServerStartupTimestamp() / 1000);
    existingClusterStartTime = putIfAbsentWithRetries(crossDCAwareCacheFactory, InfinispanClusterProvider.CLUSTER_STARTUP_TIME_KEY, serverStartTime, -1);
    if (existingClusterStartTime == null) {
      logger.debugf("Initialized cluster startup time to %s", Time.toDate(serverStartTime).toString());
      return serverStartTime;
    } else {
      logger.debugf("Loaded cluster startup time: %s", Time.toDate(existingClusterStartTime).toString());
      return existingClusterStartTime;
    }
  }
}

代码示例来源:origin: org.keycloak/keycloak-model-mongo

@Override
public void waitForLock() {
  boolean locked = false;
  long startTime = Time.toMillis(Time.currentTime());
  long timeToGiveUp = startTime + (factory.getLockWaitTimeoutMillis());
  while (!locked && Time.toMillis(Time.currentTime()) < timeToGiveUp) {
    locked = acquireLock();
    if (!locked) {
      int remainingTime = ((int)(timeToGiveUp / 1000)) - Time.currentTime();
      logger.debugf("Waiting for changelog lock... Remaining time: %d seconds", remainingTime);
      try {
        Thread.sleep(factory.getLockRecheckTimeMillis());
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
  if (!locked) {
    DBObject query = new BasicDBObject("_id", 1);
    DBCursor cursor = db.getCollection(DB_LOCK_COLLECTION).find(query);
    String lockedBy;
    if (cursor.hasNext()) {
      DBObject dbObj = cursor.next();
      lockedBy = dbObj.get("lockedBy") + " since " + Time.toDate(((int)((long) dbObj.get("lockedSince") / 1000)));
    } else {
      lockedBy = "UNKNOWN";
    }
    throw new IllegalStateException("Could not acquire change log lock.  Currently locked by " + lockedBy);
  }
}

相关文章