Added additional methods
This commit is contained in:
parent
8508df42ac
commit
6d3b27ed2b
2 changed files with 46 additions and 0 deletions
|
|
@ -49,6 +49,7 @@ public class Timer {
|
|||
reset();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Will start or restart the timer if it is already running
|
||||
*
|
||||
|
|
@ -73,6 +74,15 @@ public class Timer {
|
|||
return timestamp + period < System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the timestamp in the future based on epoc in milliseconds where the timer will timeout or -1 if the timer has already timeout.
|
||||
*/
|
||||
public long getTimeoutTimeMillis() {
|
||||
if (hasTimedOut())
|
||||
return -1;
|
||||
return timestamp + period;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (hasTimedOut())
|
||||
return "Timed out";
|
||||
|
|
|
|||
|
|
@ -235,6 +235,42 @@ public class OAuth2Registry implements Serializable {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clientId is the client_id string
|
||||
* @return all the authorization codes assigned to the given clientID or empty list if client does not exist
|
||||
*/
|
||||
public List<String> getAuthenticationCodes(String clientId) {
|
||||
OAuth2ClientRegister clientRegister = getClientRegister(clientId);
|
||||
|
||||
if (clientRegister != null)
|
||||
return new ArrayList<>(clientRegister.authCodes.keySet());
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clientId is the client_id string
|
||||
* @return all the access tokens assigned to the given clientID or empty list if client does not exist
|
||||
*/
|
||||
public List<String> getAccessTokens(String clientId) {
|
||||
OAuth2ClientRegister clientRegister = getClientRegister(clientId);
|
||||
|
||||
if (clientRegister != null)
|
||||
return new ArrayList<>(clientRegister.accessTokens.keySet());
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param token is the access token to get timeout value for.
|
||||
* @return an epic based value in milliseconds where the token stops being valid or -1 if token is already invalid or does not exist.
|
||||
*/
|
||||
public long getAccessTokenTimeout(String token) {
|
||||
OAuth2ClientRegister clientRegister = getClientRegisterForToken(token);
|
||||
|
||||
if (clientRegister != null)
|
||||
return clientRegister.accessTokens.get(token).getTimeoutTimeMillis();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
// Listeners
|
||||
// ------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue