public boolean isExpired() { Long expiresAt = getExpiresAt(); return (expiresAt == null) ? false : (System.currentTimeMillis() >expiresAt); }
public BasicSecurityToken(String owner, String viewer, String app, String domain, String appUrl, String moduleId, String container, String activeUrl, Long expiresAt) { setOwnerId(owner).setViewerId(viewer).setAppId(app).setDomain(domain).setAppUrl(appUrl); if (moduleId != null) setModuleId(Long.parseLong(moduleId)); setContainer(container).setActiveUrl(activeUrl).setExpiresAt(expiresAt); }
public void loadFromMap(AbstractSecurityToken token, Map<String, String> map) { token.setContainer(map.get(key)); } },
public AnonymousSecurityToken(String container, Long moduleId, String appUrl) { setContainer(container).setModuleId(moduleId).setAppUrl(appUrl) .setOwnerId(ANONYMOUS_ID) .setViewerId(ANONYMOUS_ID) .setDomain("*") .setTrustedJson(""); }
/** * Compute and set the expiration time for this token using the provided TTL. * * @param tokenTTL the time to live (in seconds) of the token * @return This security token. */ protected AbstractSecurityToken setExpires(int tokenTTL) { this.tokenTTL = tokenTTL; return setExpiresAt((getTimeSource().currentTimeMillis() / 1000) + getMaxTokenTTL()); }
public static BlobCrypterSecurityToken fromToken(SecurityToken token) { BlobCrypterSecurityToken interpretedToken = new BlobCrypterSecurityToken(token.getContainer(), token.getDomain(), token.getActiveUrl(), null); interpretedToken .setAppId(token.getAppId()) .setAppUrl(token.getAppUrl()) .setExpiresAt(token.getExpiresAt()) .setModuleId(token.getModuleId()) .setOwnerId(token.getOwnerId()) .setTrustedJson(token.getTrustedJson()) .setViewerId(token.getViewerId()); return interpretedToken; } }
/** * Create a new security token. * * @param container container that is issuing the token * @param domain domain to use for signed fetch with default signed fetch key. * @param activeUrl * @param values Other values to init into the token. */ public BlobCrypterSecurityToken(String container, String domain, String activeUrl, Map<String, String> values) { if (values != null) { loadFromMap(values); } setContainer(container).setDomain(domain).setActiveUrl(activeUrl); }
public AbstractSecurityToken enforceNotExpired() throws BlobExpiredException { Long expiresAt = getExpiresAt(); if (expiresAt != null) { long maxTime = expiresAt + CLOCK_SKEW_ALLOWANCE; long now = getTimeSource().currentTimeMillis() / 1000; if (!(now < maxTime)) { throw new BlobExpiredException(now, maxTime); } } return this; }
if (token instanceof AbstractSecurityToken) { if (tokenTTL != null) { ((AbstractSecurityToken) token).setExpires(tokenTTL); } else { ((AbstractSecurityToken) token).setExpires(); localToken.setExpires(tokenTTL); } else { localToken.setExpires(); expires = localToken.getExpiresAt();
public void loadFromMap(AbstractSecurityToken token, Map<String, String> map) { String value = map.get(key); if (value != null) { token.setModuleId(Long.parseLong(value, 10)); } } },
public void loadFromMap(AbstractSecurityToken token, Map<String, String> map) { String value = map.get(key); if (value != null) { token.setExpiresAt(Long.parseLong(value, 10)); } } },
public void loadFromMap(AbstractSecurityToken token, Map<String, String> map) { token.setAppId(map.get(key)); } },
public void loadFromMap(AbstractSecurityToken token, Map<String, String> map) { token.setAppUrl(map.get(key)); } },
public void loadFromMap(AbstractSecurityToken token, Map<String, String> map) { token.setDomain(map.get(key)); } },
public void loadFromMap(AbstractSecurityToken token, Map<String, String> map) { token.setTrustedJson(map.get(key)); } };
public void loadFromMap(AbstractSecurityToken token, Map<String, String> map) { token.setOwnerId(map.get(key)); } },
public FakeGadgetToken setActiveUrl(String activeUrl) { return (FakeGadgetToken)super.setActiveUrl(activeUrl); } }
public AnonymousSecurityToken(String container, Long moduleId, String appUrl) { setContainer(container).setModuleId(moduleId).setAppUrl(appUrl) .setOwnerId(ANONYMOUS_ID) .setViewerId(ANONYMOUS_ID) .setDomain("*") .setTrustedJson(""); }
public static BlobCrypterSecurityToken fromToken(SecurityToken token) { BlobCrypterSecurityToken interpretedToken = new BlobCrypterSecurityToken(token.getContainer(), token.getDomain(), token.getActiveUrl(), null); interpretedToken .setAppId(token.getAppId()) .setAppUrl(token.getAppUrl()) .setExpiresAt(token.getExpiresAt()) .setModuleId(token.getModuleId()) .setOwnerId(token.getOwnerId()) .setTrustedJson(token.getTrustedJson()) .setViewerId(token.getViewerId()); return interpretedToken; } }
/** * Compute and set the expiration time for this token using the provided TTL. * * @param tokenTTL the time to live (in seconds) of the token * @return This security token. */ protected AbstractSecurityToken setExpires(int tokenTTL) { this.tokenTTL = tokenTTL; return setExpiresAt((getTimeSource().currentTimeMillis() / 1000) + getMaxTokenTTL()); }