/** * 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()); }
/** * 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); }