@Test public void validateToken() { String bearer = sut.publishToken(server, new SUser(vutUserId)); UserToken fromBearer = UserToken.fromBearerToken(bearer); sut.validateToken(fromBearer); }
public void validateToken(UserToken token) { UserToken tokenTrusted = UserTokenCache.getInstance().get(token); if (tokenTrusted == null) { tokenTrusted = getStoredMatchedToken(token); if (tokenTrusted != null) { UserTokenCache.getInstance().put(tokenTrusted); } } if (tokenTrusted == null || tokenTrusted.isExpired(sessionExpireSec)) { throw ErrorState.SESSION_EXPIRED.newBizException(); } if (tokenTrusted.needToBeRenewed(SessionTouchThresholdSec)) { touchToken(token); } }
UserTokenService { public void validateToken(UserToken token) { UserToken tokenTrusted = UserTokenCache.getInstance().get(token); if (tokenTrusted == null) { tokenTrusted = getStoredMatchedToken(token); if (tokenTrusted != null) { UserTokenCache.getInstance().put(tokenTrusted); } } if (tokenTrusted == null || tokenTrusted.isExpired(sessionExpireSec)) { throw ErrorState.SESSION_EXPIRED.newBizException(); } if (tokenTrusted.needToBeRenewed(SessionTouchThresholdSec)) { touchToken(token); } } }
UserTokenService { public void validateToken(UserToken token) { UserToken tokenTrusted = UserTokenCache.getInstance().get(token); if (tokenTrusted == null) { tokenTrusted = getStoredMatchedToken(token); if (tokenTrusted != null) { UserTokenCache.getInstance().put(tokenTrusted); } } if (tokenTrusted == null || tokenTrusted.isExpired(sessionExpireSec)) { throw ErrorState.SESSION_EXPIRED.newBizException(); } if (tokenTrusted.needToBeRenewed(SessionTouchThresholdSec)) { touchToken(token); } }  }
UserTokenService { public void validateToken(UserToken token) { UserToken tokenTrusted = UserTokenCache.getInstance().get(token); if (tokenTrusted == null) { tokenTrusted = getStoredMatchedToken(token); if (tokenTrusted != null) { UserTokenCache.getInstance().put(tokenTrusted); } } if (tokenTrusted == null || tokenTrusted.isExpired(sessionExpireSec)) { throw ErrorState.SESSION_EXPIRED.newBizException(); } if (tokenTrusted.needToBeRenewed(SessionTouchThresholdSec)) { touchToken(token); } }  String publishToken(final Server server, final SUser user); void validateToken(UserToken token); }
UserTokenService { public void validateToken(UserToken token) { UserToken tokenTrusted = UserTokenCache.getInstance().get(token); if (tokenTrusted == null) { tokenTrusted = getStoredMatchedToken(token); if (tokenTrusted != null) { UserTokenCache.getInstance().put(tokenTrusted); } } if (tokenTrusted == null || tokenTrusted.isExpired(sessionExpireSec)) { throw ErrorState.SESSION_EXPIRED.newBizException(); } if (tokenTrusted.needToBeRenewed(SessionTouchThresholdSec)) { touchToken(token); } }  String publishToken(final Server server, final SUser user); void validateToken(UserToken token); public int sessionExpireSec; public int SessionTouchThresholdSec; }