MoriaTicket proxyTicket = new MoriaTicket(MoriaTicketType.PROXY_TICKET, targetServicePrincipal, proxyTicketTTL, cachedUserData);
final Long expiryTime = new Long(((Long) ticketTTLs.get(MoriaTicketType.PROXY_TICKET)).longValue() + new Date().getTime()); MoriaTicket proxyTicket = new MoriaTicket(MoriaTicketType.PROXY_TICKET, targetServicePrincipal, expiryTime, cachedUserData);
    public String createProxyTicket(final String tgTicketId, final String servicePrincipal, final String targetServicePrincipal)            throws InvalidTicketException, NonExistentTicketException, MoriaStoreException {        /* Validate arguments. */        if (tgTicketId == null || tgTicketId.equals("")) {            throw new IllegalArgumentException("tgTicketId must be a non-empty string.");        }        if (servicePrincipal == null || servicePrincipal.equals("")) {            throw new IllegalArgumentException("servicePrincipal must be a non-empty string.");        }        if (targetServicePrincipal == null || targetServicePrincipal.equals("")) {            throw new IllegalArgumentException("targetServicePrincipal must be a non-empty string.");        }        MoriaTicket tgTicket = getFromStore(MoriaTicketType.TICKET_GRANTING_TICKET, tgTicketId);        if (tgTicket == null) {            throw new NonExistentTicketException(tgTicketId);        }        /* Primarily to check timestamp. */        validateTicket(tgTicket, MoriaTicketType.TICKET_GRANTING_TICKET, servicePrincipal);        /*         * Create new ticket granting ticket and associate it with the same         * user data as the TG ticket.         */        CachedUserData cachedUserData = null;        MoriaStoreData data = tgTicket.getData();        if (data != null && data instanceof CachedUserData) {            cachedUserData = (CachedUserData) data;        } else {            throw new InvalidTicketException("No user data associated with ticket granting ticket. [" + tgTicketId + "]");        }        MoriaTicket proxyTicket = new MoriaTicket(MoriaTicketType.PROXY_TICKET, targetServicePrincipal, proxyTicketTTL,                cachedUserData);        insertIntoStore(proxyTicket);        return proxyTicket.getTicketId();    }