/** * Generate a new cookie value for the set of Principals. * * @param principalSet The HttpPrincipal to generate the value from. * @return string of the value. never null. * @throws IOException Any errors with writing and generation. * @throws InvalidKeyException Signing key is invalid */ public final String generate(final Set<Principal> principalSet, URI scope) throws InvalidKeyException, IOException { return generate(principalSet, scope, getExpirationDate()); }
/** * Produce an expiration date. The default is forty-eight (48) hours. * * @return Date of expiration. Never null. */ public Date getExpirationDate() { final Calendar cal = getCurrentCalendar(); cal.add(Calendar.HOUR, (SSO_COOKIE_LIFETIME_HOURS * offsetExpiryHours)); return cal.getTime(); }
&& StringUtil.hasText(ssoCookie.getValue())) SSOCookieManager ssoCookieManager = new SSOCookieManager(); try DelegationToken cookieToken = ssoCookieManager.parse( ssoCookie.getValue()); principals.addAll(cookiePrincipals); cookieCredentialList = ssoCookieManager.getSSOCookieCredentials(ssoCookie.getValue(), NetUtil.getDomainName(request.getServerName()));
/** * Backward-compatible generate function. * @param principal * @return * @throws InvalidKeyException * @throws IOException */ public final String generate(final HttpPrincipal principal) throws InvalidKeyException, IOException { Set<Principal> principalSet = new HashSet<>(); principalSet.add(principal); return generate(principalSet, null); }
/** * Generate a new cookie value for the set of Principals, scope and expiryDate. * Sets a default scope and expiry if either not supplied * @param principalSet * @param scope * @param expiryDate * @return * @throws InvalidKeyException * @throws IOException */ public final String generate(final Set<Principal> principalSet, URI scope, Date expiryDate) throws InvalidKeyException, IOException { if (scope == null) { scope = SCOPE_URI; } if (expiryDate == null) { expiryDate = getExpirationDate(); } List<String> domainList = null; PropertiesReader propReader = new PropertiesReader(DOMAINS_PROP_FILE); List<String> domainValues = propReader.getPropertyValues("domains"); if (domainValues != null && (domainValues.size() > 0)) { domainList = Arrays.asList(domainValues.get(0).split(" ")); } DelegationToken token = new DelegationToken(principalSet, scope, expiryDate, domainList); return DelegationToken.format(token); }
ssoCookie.getName()) && StringUtil.hasText(ssoCookie.getValue())) { SSOCookieManager ssoCookieManager = new SSOCookieManager(); try { DelegationToken cookieToken = ssoCookieManager.parse( ssoCookie.getValue()); principals.addAll(cookiePrincipals); cookieCredentialList = ssoCookieManager.getSSOCookieCredentials(ssoCookie.getValue(), NetUtil.getDomainName(getRequest().getResourceRef().toUrl())); } catch (InvalidDelegationTokenException | IOException e) {
/** * Generate a new cookie value for the given HttpPrincipal. * Format of the value is: * HttpPrincipal-ExpirationDateUTC-Base64SignatureToken * where: * HttpPrincipal - principal of the user * ExpirationDateUTC - long representing the expiration Java date in UTC * Base64SignatureToken - The signature token of the 2 fields above in * Base64 format. * * @param principal The HttpPrincipal to generate the value from. * @return string of the value. never null. * @throws IOException Any errors with writing and generation. * @throws InvalidKeyException Signing key is invalid */ public final String generate(final HttpPrincipal principal, URI scope) throws InvalidKeyException, IOException { Set<Principal> principalSet = new HashSet<>(); principalSet.add(principal); return generate(principalSet, scope); }