/** * Parse the given text into a DelegationToken object. * * @param text The token string. * @param requestURI The HTTP Request URI * @return DelegationToken instance. Never null. * @throws InvalidDelegationTokenException If the given token cannot be parsed. */ public static DelegationToken parse(String text, String requestURI) throws InvalidDelegationTokenException { return parse(text, requestURI, null); }
/** * Builds a DelegationToken from a text string * * @param text Token to parse * @param requestURI The HTTP Request URI * @param sv ScopeValidator instance. * @return corresponding DelegationToken * @throws InvalidDelegationTokenException If the given token cannot be parsed. */ public static DelegationToken parse(String text, String requestURI, ScopeValidator sv) throws InvalidDelegationTokenException { if (text.startsWith(DelegationToken.EXPIRY_LABEL)) { final String[] fields = text.split(FIELD_DELIM); return parse(fields, text, requestURI, sv); } else { return parseEncoded(URI.create(text), requestURI, sv); } }
private static DelegationToken parseEncoded(final URI encodedURI, final String requestURI, final ScopeValidator scopeValidator) throws InvalidDelegationTokenException { if (!StringUtil.hasLength(encodedURI.getScheme())) { throw new InvalidDelegationTokenException("Wrong format for encoded token."); } else { final TokenEncoding tokenEncoding = TokenEncoding.valueOf(encodedURI.getScheme().toUpperCase()); final byte[] decodedBytes = TOKEN_ENCODER_DECODER.decode(encodedURI.getSchemeSpecificPart(), tokenEncoding); final String decodedString = new String(decodedBytes); return parse(decodedString.split(FIELD_DELIM), decodedString, requestURI, scopeValidator); } }
token = DelegationToken.parse(value, SCOPE_URI.toASCIIString(), new CookieScopeValidator());
/** * Generate a list of cookies based on the original credentials passed in, one for each * of the supported domains. * * @param cookieValue * @param requestURI * @return cookieList */ public List<SSOCookieCredential> getSSOCookieCredentials(final String cookieValue, final String requestURI) throws InvalidDelegationTokenException, IOException { List<SSOCookieCredential> cookieList = new ArrayList<>(); DelegationToken cookieToken = DelegationToken.parse(cookieValue, requestURI, new CookieScopeValidator()); for (String domain: cookieToken.getDomains()) { SSOCookieCredential nextCookie = new SSOCookieCredential(cookieValue, domain, cookieToken.getExpiryTime()); cookieList.add(nextCookie); } return cookieList; }
this.token = DelegationToken.parse(tokenValue, request.getRequestURI());
if (StringUtil.hasText(tokenValue)) { try { this.token = DelegationToken.parse(tokenValue, request.getResourceRef().getPath()); } catch (InvalidDelegationTokenException ex) { log.debug("invalid DelegationToken: " + tokenValue, ex);