Java Code Examples for org.jasig.cas.ticket.Ticket#getId()

The following examples show how to use org.jasig.cas.ticket.Ticket#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractTicketRegistry.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 * @throws IllegalArgumentException if class is null.
 * @throws ClassCastException if class does not match requested ticket
 * class.
 * @return specified ticket from the registry
 */
@Override
public final <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz) {
    Assert.notNull(clazz, "clazz cannot be null");

    final Ticket ticket = this.getTicket(ticketId);

    if (ticket == null) {
        return null;
    }

    if (!clazz.isAssignableFrom(ticket.getClass())) {
        throw new ClassCastException("Ticket [" + ticket.getId()
            + " is of type " + ticket.getClass()
            + " when we were expecting " + clazz);
    }

    return (T) ticket;
}
 
Example 2
Source File: AbstractTicketRegistry.java    From cas4.0.x-server-wechat with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * @throws IllegalArgumentException if class is null.
 * @throws ClassCastException if class does not match requested ticket
 * class.
 * @return specified ticket from the registry
 */
@Override
public final <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz) {
    Assert.notNull(clazz, "clazz cannot be null");

    final Ticket ticket = this.getTicket(ticketId);

    if (ticket == null) {
        return null;
    }

    if (!clazz.isAssignableFrom(ticket.getClass())) {
        throw new ClassCastException("Ticket [" + ticket.getId()
            + " is of type " + ticket.getClass()
            + " when we were expecting " + clazz);
    }

    return (T) ticket;
}
 
Example 3
Source File: EhCacheTicketRegistry.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
@Override
public void addTicket(final Ticket ticket) {
    final Element element = new Element(ticket.getId(), ticket);
    if (ticket instanceof ServiceTicket) {
        logger.debug("Adding service ticket {} to the cache {}", ticket.getId(), this.serviceTicketsCache.getName());
        this.serviceTicketsCache.put(element);
    } else if (ticket instanceof TicketGrantingTicket) {
        logger.debug("Adding ticket granting ticket {} to the cache {}", ticket.getId(),
                this.ticketGrantingTicketsCache.getName());
        this.ticketGrantingTicketsCache.put(element);
    } else {
        throw new IllegalArgumentException("Invalid ticket type " + ticket);
    }
}
 
Example 4
Source File: EhCacheTicketRegistry.java    From cas4.0.x-server-wechat with Apache License 2.0 5 votes vote down vote up
@Override
public void addTicket(final Ticket ticket) {
    final Element element = new Element(ticket.getId(), ticket);
    if (ticket instanceof ServiceTicket) {
        logger.debug("Adding service ticket {} to the cache", ticket.getId(), this.serviceTicketsCache.getName());
        this.serviceTicketsCache.put(element);
    } else if (ticket instanceof TicketGrantingTicket) {
        logger.debug("Adding ticket granting ticket {} to the cache {}", ticket.getId(),
                this.ticketGrantingTicketsCache.getName());
        this.ticketGrantingTicketsCache.put(element);
    } else {
        throw new IllegalArgumentException("Invalid ticket type " + ticket);
    }
}