public boolean hasLostContact() { return (clock.currentTimeMillis() - lastPingTime) >= (pingInterval * 2); }
public void pingSuccess() { this.lastPingTime = clock.currentTimeMillis(); }
private void start() { startTime = clock.currentTimeMillis(); }
public Stage(String name, JobInstances jobInstances, String approvedBy, String cancelledBy, String approvalType, boolean fetchMaterials, boolean cleanWorkingDir, final Clock clock) { this.name = name; this.jobInstances = jobInstances; this.approvedBy = approvedBy; this.cancelledBy = cancelledBy; this.approvalType = approvalType; this.fetchMaterials = fetchMaterials; this.cleanWorkingDir = cleanWorkingDir; this.createdTime = new Timestamp(clock.currentTimeMillis()); }
private void updateLastChangedTime() { LOGGER.info("[Configuration Changed] Security Configuration is changed. Updating the last changed time."); lastChangedTime = clock.currentTimeMillis(); }
private Long timeSinceLastLine(TimeUnit unit) { long now = clock.currentTimeMillis(); return unit.convert(now - lastHeard, TimeUnit.MILLISECONDS); }
private boolean isReportingInProgress() { if (reportingStartedTime == null) { return false; } DateTime halfHourAgo = new DateTime(clock.currentTimeMillis() - 30 * 60 * 1000); return reportingStartedTime.isAfter(halfHourAgo); }
@Autowired public TimeStampBasedCounter(Clock clock) { this.counter = new AtomicLong(clock.currentTimeMillis()); }
@Override protected AuthenticationToken<AccessToken> createAuthenticationToken(GoUserPrinciple userPrinciple, AccessToken credentials, String pluginId, String authConfigId) { return new AuthenticationToken<>(userPrinciple, credentials, pluginId, clock.currentTimeMillis(), authConfigId); }
public void stop() { if (startTime == 0) return; elapsed = elapsed + (clock.currentTimeMillis() - startTime); startTime = 0; LOG.info("Performance: {} took {}ms", message, elapsed()); }
@Override protected AuthenticationToken<UsernamePassword> createAuthenticationToken(GoUserPrinciple userPrinciple, UsernamePassword credentials, String pluginId, String authConfigId) { return new AuthenticationToken<>(userPrinciple, credentials, pluginId, clock.currentTimeMillis(), authConfigId); } }
public File createUniqueFolder(String folder) { return mkdir(folder + clock.currentTimeMillis()); }
private boolean isExpired(Clock clock, SystemEnvironment systemEnvironment) { return systemEnvironment.isReAuthenticationEnabled() && (clock.currentTimeMillis() - authenticatedAt) > systemEnvironment.getReAuthenticationTimeInterval(); }
private AuthenticationToken<AnonymousCredential> createNewToken() { GoUserPrinciple anonymous = new GoUserPrinciple("anonymous", "anonymous", authorityGranter.authorities("anonymous")); AuthenticationToken<AnonymousCredential> authenticationToken = new AuthenticationToken<>(anonymous, AnonymousCredential.INSTANCE, null, clock.currentTimeMillis(), null); LOGGER.debug("Authenticating as anonymous user with role(s) {}", anonymous.getAuthorities()); return authenticationToken; }
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { final X509Certificate x509Certificate = extractClientCertificate(request); if (x509Certificate == null) { LOGGER.debug("Denying access, certificate is not provided."); response.setStatus(403); } else { LOGGER.debug("Adding agent user to current session and proceeding."); String subjectDN = (String) subjectDnX509PrincipalExtractor.extractPrincipal(x509Certificate); final GoUserPrinciple agentUser = new GoUserPrinciple("_go_agent_" + subjectDN, "", GoAuthority.ROLE_AGENT.asAuthority()); final AuthenticationToken<X509Credential> authentication = new AuthenticationToken<>(agentUser, new X509Credential(x509Certificate), null, clock.currentTimeMillis(), null); SessionUtils.setAuthenticationTokenAfterRecreatingSession(authentication, request); filterChain.doFilter(request, response); } }