Example usage for org.springframework.security.core.token Token getKeyCreationTime

List of usage examples for org.springframework.security.core.token Token getKeyCreationTime

Introduction

In this page you can find the example usage for org.springframework.security.core.token Token getKeyCreationTime.

Prototype

long getKeyCreationTime();

Source Link

Document

The time the token key was initially created is available from this method.

Usage

From source file:ro.cs.om.utils.security.SecurityTokenMonitor.java

@Override
public void run() {
    Token t = null;
    try {//from   w ww  .  j a v a 2s.co m
        while (true) {
            Thread.currentThread().sleep(sleepDuration);
            Enumeration<String> keys = tokenRepository.keys();
            while (keys.hasMoreElements()) {
                t = tokenRepository.get(keys.nextElement());
                if ((System.currentTimeMillis() - t.getKeyCreationTime()) > AVAILABILITY) {
                    tokenRepository.remove(t.getKey());
                    logger.debug("\ttoken ".concat(t.getKey().concat(" removed!")));
                }
            }
        }
    } catch (Exception e) {
        logger.error("", e);
    }
}