@Override public Map<String, String> toMap() { Map<String, String> map = super.toMap(); map.put(REAL_CALLBACK_URL_KEY, getRealCallbackUrl()); return map; } }
@Override public Map<String, String> toMap() { final Map<String, String> map = super.toMap(); final String g = this.getGadgetUri(); if (g != null) { map.put(OAuth2CallbackStateToken.GADGET_URI, g); } final String sn = this.getServiceName(); if (sn != null) { map.put(OAuth2CallbackStateToken.SERVICE_NAME, sn); } final String u = this.getUser(); if (u != null) { map.put(OAuth2CallbackStateToken.USER, u); } final String sc = this.getScope(); if (sc != null) { map.put(OAuth2CallbackStateToken.SCOPE, sc); } return map; } }
/** * Encrypt and sign the token. The returned value is *not* web safe, it should be URL * encoded before being used as a form parameter. */ public String encodeToken(SecurityToken token) throws SecurityTokenException { if (!token.getAuthenticationMode().equals( AuthenticationMode.SECURITY_TOKEN_URL_PARAMETER.name())) { throw new SecurityTokenException("Can only encode BlobCrypterSecurityTokens"); } // Test code sends in real AbstractTokens, they have modified time sources in them so // that we can test token expiration, production tokens are proxied via the SecurityToken interface. AbstractSecurityToken aToken = token instanceof AbstractSecurityToken ? (AbstractSecurityToken)token : BlobCrypterSecurityToken.fromToken(token); BlobCrypter crypter = crypters.get(aToken.getContainer()); if (crypter == null) { throw new SecurityTokenException("Unknown container " + aToken.getContainer()); } try { Integer tokenTTL = this.tokenTTLs.get(aToken.getContainer()); if (tokenTTL != null) { aToken.setExpires(tokenTTL); } else { aToken.setExpires(); } return aToken.getContainer() + ':' + crypter.wrap(aToken.toMap()); } catch (BlobCrypterException e) { throw new SecurityTokenException(e); } }
/** * Encrypt and sign the token. The returned value is *not* web safe, it should be URL * encoded before being used as a form parameter. */ public String encodeToken(SecurityToken token) throws SecurityTokenException { if (!token.getAuthenticationMode().equals( AuthenticationMode.SECURITY_TOKEN_URL_PARAMETER.name())) { throw new SecurityTokenException("Can only encode BlobCrypterSecurityTokens"); } // Test code sends in real AbstractTokens, they have modified time sources in them so // that we can test token expiration, production tokens are proxied via the SecurityToken interface. AbstractSecurityToken aToken = token instanceof AbstractSecurityToken ? (AbstractSecurityToken)token : BlobCrypterSecurityToken.fromToken(token); BlobCrypter crypter = crypters.get(aToken.getContainer()); if (crypter == null) { throw new SecurityTokenException("Unknown container " + aToken.getContainer()); } try { Integer tokenTTL = this.tokenTTLs.get(aToken.getContainer()); if (tokenTTL != null) { aToken.setExpires(tokenTTL); } else { aToken.setExpires(); } return aToken.getContainer() + ':' + crypter.wrap(aToken.toMap()); } catch (BlobCrypterException e) { throw new SecurityTokenException(e); } }
/** * Encrypt and sign the token. The returned value is *not* web safe, it should be URL * encoded before being used as a form parameter. */ public String encodeToken(SecurityToken token) throws SecurityTokenException { if (!token.getAuthenticationMode().equals( AuthenticationMode.SECURITY_TOKEN_URL_PARAMETER.name())) { throw new SecurityTokenException("Can only encode BlobCrypterSecurityTokens"); } // Test code sends in real AbstractTokens, they have modified time sources in them so // that we can test token expiration, production tokens are proxied via the SecurityToken interface. AbstractSecurityToken aToken = token instanceof AbstractSecurityToken ? (AbstractSecurityToken)token : BlobCrypterSecurityToken.fromToken(token); BlobCrypter crypter = crypters.get(aToken.getContainer()); if (crypter == null) { throw new SecurityTokenException("Unknown container " + aToken.getContainer()); } try { Integer tokenTTL = this.tokenTTLs.get(aToken.getContainer()); if (tokenTTL != null) { aToken.setExpires(tokenTTL); } else { aToken.setExpires(); } return aToken.getContainer() + ':' + crypter.wrap(aToken.toMap()); } catch (BlobCrypterException e) { throw new SecurityTokenException(e); } }