MoriaTicket serviceTicket = new MoriaTicket(MoriaTicketType.SERVICE_TICKET, loginTicket.getServicePrincipal(), serviceTicketTTL, authnAttempt);
final Long expiryTime = new Long(((Long) ticketTTLs.get(MoriaTicketType.SERVICE_TICKET)).longValue() + new Date().getTime()); MoriaTicket serviceTicket = new MoriaTicket(MoriaTicketType.SERVICE_TICKET, loginTicket.getServicePrincipal(), expiryTime, authnAttempt);
    public String createServiceTicket(final String loginTicketId) throws InvalidTicketException, NonExistentTicketException,            MoriaStoreException {        /* Validate argument. */        if (loginTicketId == null || loginTicketId.equals("")) {            throw new IllegalArgumentException("loginTicketId must be a non-empty string");        }        MoriaTicket loginTicket = getFromStore(MoriaTicketType.LOGIN_TICKET, loginTicketId);        if (loginTicket == null) {            throw new NonExistentTicketException(loginTicketId);        }        /* Primarily to check timestamp. */        validateTicket(loginTicket, MoriaTicketType.LOGIN_TICKET, null);        /*         * Create new service ticket and associate it with the same authentication         * attempt as the login ticket.         */        MoriaAuthnAttempt authnAttempt = null;        MoriaStoreData data = loginTicket.getData();        if (data != null && data instanceof MoriaAuthnAttempt) {            authnAttempt = (MoriaAuthnAttempt) data;        } else {            throw new InvalidTicketException("No authentication attempt associated with login ticket. [" + loginTicketId + "]");        }        MoriaTicket serviceTicket = new MoriaTicket(MoriaTicketType.SERVICE_TICKET, loginTicket.getServicePrincipal(),                serviceTicketTTL, authnAttempt);        insertIntoStore(serviceTicket);        /*  Delete the now used login ticket. */        removeFromStore(loginTicket);        return serviceTicket.getTicketId();    }