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