/** * Serializes and signs the object into a string of attribute-value pairs. * * @param token the token to format * the returned string * @return String with DelegationToken information * @throws IOException Any IO Errors. * @throws InvalidKeyException If the signature cannot be completed. */ public static String format(DelegationToken token) throws InvalidKeyException, IOException { return format(token, TokenEncoding.BASE64); }
/** * 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); }