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

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

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

Time.currentTime介绍

[英]Returns current time in seconds adjusted by adding #offset) seconds.
[中]返回通过添加#偏移)秒调整的当前时间(以秒为单位)。

代码示例

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

/**
 * Set issuedAt to the current time
 */
@JsonIgnore
public JsonWebToken issuedNow() {
  issuedAt = Time.currentTime();
  return this;
}

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

@JsonIgnore
public boolean isExpired() {
  return Time.currentTime() > expiration;
}

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

@JsonIgnore
public boolean isNotBefore(int allowedTimeSkew) {
  return Time.currentTime() + allowedTimeSkew >= notBefore;
}

代码示例来源:origin: org.keycloak/keycloak-adapter-core

private boolean needRefreshRegistration(String registrationUri, KeycloakDeployment resolvedDeployment) {
  NodeRegistrationContext currentRegistration = nodeRegistrations.get(registrationUri);
  /// We don't yet have any registration for this node
  if (currentRegistration == null) {
    return true;
  }
  return currentRegistration.lastRegistrationTime + resolvedDeployment.getRegisterNodePeriod() < Time.currentTime();
}

代码示例来源:origin: org.keycloak/keycloak-adapter-core

@Override
public void reset(KeycloakDeployment deployment) {
  synchronized (this) {
    sendRequest(deployment);
    lastRequestTime = Time.currentTime();
  }
}

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

@Override
public ClientSessionModel createOfflineClientSession(ClientSessionModel clientSession) {
  ClientSessionAdapter offlineClientSession = importClientSession(clientSession, true);
  // update timestamp to current time
  offlineClientSession.setTimestamp(Time.currentTime());
  return offlineClientSession;
}

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

@Override
public ClientSessionModel createOfflineClientSession(ClientSessionModel clientSession) {
  ClientSessionAdapter offlineClientSession = importClientSession(clientSession, true);
  // update timestamp to current time
  offlineClientSession.setTimestamp(Time.currentTime());
  return offlineClientSession;
}

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

private LockEntry createLockEntry() {
  LockEntry lock = new LockEntry();
  lock.setNode(myAddress);
  lock.setTimestamp(Time.currentTime());
  return lock;
}

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

protected void setupPeriodicTimer(KeycloakSession kcSession, AbstractLastSessionRefreshStore store, long timerIntervalMs, String eventKey) {
    TimerProvider timer = kcSession.getProvider(TimerProvider.class);
    timer.scheduleTask((KeycloakSession keycloakSession) -> {

      store.checkSendingMessage(keycloakSession, Time.currentTime());

    }, timerIntervalMs, eventKey);
  }
}

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

private void removeExpiredClientInitialAccess(RealmModel realm) {
  Iterator<String> itr = sessionCache.entrySet().stream().filter(ClientInitialAccessPredicate.create(realm.getId()).expired(Time.currentTime())).map(Mappers.sessionId()).iterator();
  while (itr.hasNext()) {
    tx.remove(sessionCache, itr.next());
  }
}

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

@Override
public UserSessionModel createOfflineUserSession(UserSessionModel userSession) {
  UserSessionAdapter offlineUserSession = importUserSession(userSession, true);
  // started and lastSessionRefresh set to current time
  int currentTime = Time.currentTime();
  offlineUserSession.getEntity().setStarted(currentTime);
  offlineUserSession.setLastSessionRefresh(currentTime);
  return offlineUserSession;
}

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

@Override
public UserSessionModel createOfflineUserSession(UserSessionModel userSession) {
  UserSessionAdapter importedUserSession = importUserSession(userSession, true);
  // started and lastSessionRefresh set to current time
  int currentTime = Time.currentTime();
  importedUserSession.getEntity().setStarted(currentTime);
  importedUserSession.setLastSessionRefresh(currentTime);
  return importedUserSession;
}

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

@Override
public UserSessionModel createOfflineUserSession(UserSessionModel userSession) {
  UserSessionAdapter offlineUserSession = importUserSession(userSession, true);
  // started and lastSessionRefresh set to current time
  int currentTime = Time.currentTime();
  offlineUserSession.getEntity().setStarted(currentTime);
  offlineUserSession.setLastSessionRefresh(currentTime);
  return offlineUserSession;
}

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

private void removeExpiredOfflineClientSessions(RealmModel realm) {
  UserSessionPersisterProvider persister = session.getProvider(UserSessionPersisterProvider.class);
  int expiredOffline = Time.currentTime() - realm.getOfflineSessionIdleTimeout();
  Iterator<String> itr = offlineSessionCache.entrySet().stream().filter(ClientSessionPredicate.create(realm.getId()).expiredRefresh(expiredOffline)).map(Mappers.sessionId()).iterator();
  while (itr.hasNext()) {
    String sessionId = itr.next();
    tx.remove(offlineSessionCache, sessionId);
    persister.removeClientSession(sessionId, true);
  }
}

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

private void removeExpiredOfflineUserSessions(RealmModel realm) {
  UserSessionPersisterProvider persister = session.getProvider(UserSessionPersisterProvider.class);
  int expiredOffline = Time.currentTime() - realm.getOfflineSessionIdleTimeout();
  Iterator<Map.Entry<String, SessionEntity>> itr = offlineSessionCache.entrySet().stream().filter(UserSessionPredicate.create(realm.getId()).expired(null, expiredOffline)).iterator();
  while (itr.hasNext()) {
    UserSessionEntity entity = (UserSessionEntity) itr.next().getValue();
    tx.remove(offlineSessionCache, entity.getId());
    persister.removeUserSession(entity.getId(), true);
    for (String clientSessionId : entity.getClientSessions()) {
      tx.remove(offlineSessionCache, clientSessionId);
    }
  }
}

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

@Override
public ClientSessionModel createClientSession(RealmModel realm, ClientModel client) {
  ClientSessionEntity entity = new ClientSessionEntity();
  entity.setId(KeycloakModelUtils.generateId());
  entity.setTimestamp(Time.currentTime());
  entity.setClientId(client.getId());
  entity.setRealmId(realm.getId());
  clientSessions.put(entity.getId(), entity);
  return new ClientSessionAdapter(session, this, realm, entity);
}

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

@Override
public RootAuthenticationSessionModel createRootAuthenticationSession(String id, RealmModel realm) {
  RootAuthenticationSessionEntity entity = new RootAuthenticationSessionEntity();
  entity.setId(id);
  entity.setRealmId(realm.getId());
  entity.setTimestamp(Time.currentTime());
  tx.put(cache, id, entity);
  return wrap(realm, entity);
}

代码示例来源:origin: org.keycloak/keycloak-adapter-core

protected JsonWebToken createRequestToken(String clientId, String realmInfoUrl) {
    JsonWebToken reqToken = new JsonWebToken();
    reqToken.id(AdapterUtils.generateId());
    reqToken.issuer(clientId);
    reqToken.subject(clientId);
    reqToken.audience(realmInfoUrl);

    int now = Time.currentTime();
    reqToken.issuedAt(now);
    reqToken.expiration(now + this.tokenTimeout);
    reqToken.notBefore(now);

    return reqToken;
  }
}

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

@Override
public ClientSessionModel createClientSession(RealmModel realm, ClientModel client) {
  String id = KeycloakModelUtils.generateId();
  ClientSessionEntity entity = new ClientSessionEntity();
  entity.setId(id);
  entity.setRealm(realm.getId());
  entity.setTimestamp(Time.currentTime());
  entity.setClient(client.getId());
  tx.put(sessionCache, id, entity);
  return wrap(realm, entity, false);
}

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

void updateSessionEntity(UserSessionEntity entity, RealmModel realm, UserModel user, String loginUsername, String ipAddress, String authMethod, boolean rememberMe, String brokerSessionId, String brokerUserId) {
  entity.setRealmId(realm.getId());
  entity.setUser(user.getId());
  entity.setLoginUsername(loginUsername);
  entity.setIpAddress(ipAddress);
  entity.setAuthMethod(authMethod);
  entity.setRememberMe(rememberMe);
  entity.setBrokerSessionId(brokerSessionId);
  entity.setBrokerUserId(brokerUserId);
  int currentTime = Time.currentTime();
  entity.setStarted(currentTime);
  entity.setLastSessionRefresh(currentTime);
}

相关文章