Example usage for com.amazonaws SDKGlobalConfiguration getGlobalTimeOffset

List of usage examples for com.amazonaws SDKGlobalConfiguration getGlobalTimeOffset

Introduction

In this page you can find the example usage for com.amazonaws SDKGlobalConfiguration getGlobalTimeOffset.

Prototype

@Deprecated
public static int getGlobalTimeOffset() 

Source Link

Usage

From source file:io.fineo.client.auth.CognitoCredentialsProvider.java

License:Open Source License

/**
 * Returns true if a new STS session needs to be started. A new STS session
 * is needed when no session has been started yet, or if the last session is
 * within the configured refresh threshold.
 *
 * @return True if a new STS session needs to be started.
 *///from www . j av  a  2 s  . c o m
protected boolean needsNewSession() {
    if (sessionCredentials == null) {
        return true;
    }
    long currentTime = System.currentTimeMillis() - SDKGlobalConfiguration.getGlobalTimeOffset() * 1000;
    long timeRemaining = sessionCredentialsExpiration.getTime() - currentTime;
    return timeRemaining < (refreshThreshold * 1000);
}