当前位置: 首页>>代码示例>>Java>>正文


Java Ticket.isExpired方法代码示例

本文整理汇总了Java中org.jasig.cas.ticket.Ticket.isExpired方法的典型用法代码示例。如果您正苦于以下问题:Java Ticket.isExpired方法的具体用法?Java Ticket.isExpired怎么用?Java Ticket.isExpired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jasig.cas.ticket.Ticket的用法示例。


在下文中一共展示了Ticket.isExpired方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doExecute

import org.jasig.cas.ticket.Ticket; //导入方法依赖的package包/类
/**
 * Determines whether the TGT in the flow request context is valid.
 *
 * @param requestContext Flow request context.
 *
 * @throws Exception in case ticket cannot be retrieved from the service layer
 * @return {@link #NOT_EXISTS}, {@link #INVALID}, or {@link #VALID}.
 */
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
    final String tgtId = WebUtils.getTicketGrantingTicketId(requestContext);
    if (!StringUtils.hasText(tgtId)) {
        return new Event(this, NOT_EXISTS);
    }

    String eventId = INVALID;
    try {
        final Ticket ticket = this.centralAuthenticationService.getTicket(tgtId, Ticket.class);
        if (ticket != null && !ticket.isExpired()) {
            eventId = VALID;
        }
    } catch (final AbstractTicketException e) {
        logger.trace("Could not retrieve ticket id {} from registry.", e);
    }
    return new Event(this,  eventId);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:TicketGrantingTicketCheckAction.java

示例2: getTicket

import org.jasig.cas.ticket.Ticket; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Timed(name = "GET_TICKET_TIMER")
@Metered(name = "GET_TICKET_METER")
@Counted(name="GET_TICKET_COUNTER", monotonic=true)
@Override
public <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz)
        throws InvalidTicketException {
    Assert.notNull(ticketId, "ticketId cannot be null");
    final Ticket ticket = this.ticketRegistry.getTicket(ticketId, clazz);

    if (ticket == null) {
        logger.debug("Ticket [{}] by type [{}] cannot be found in the ticket registry.", ticketId, clazz.getSimpleName());
        throw new InvalidTicketException(ticketId);
    }

    if (ticket instanceof TicketGrantingTicket) {
        synchronized (ticket) {
            if (ticket.isExpired()) {
                this.ticketRegistry.deleteTicket(ticketId);
                logger.debug("Ticket [{}] has expired and is now deleted from the ticket registry.", ticketId);
                throw new InvalidTicketException(ticketId);
            }
        }
    }
    return (T) ticket;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:29,代码来源:CentralAuthenticationServiceImpl.java

示例3: doExecute

import org.jasig.cas.ticket.Ticket; //导入方法依赖的package包/类
/**
 * Determines whether the TGT in the flow request context is valid.
 *
 * @param requestContext Flow request context.
 *
 * @throws Exception in case ticket cannot be retrieved from the service layer
 * @return {@link #NOT_EXISTS}, {@link #INVALID}, or {@link #VALID}.
 */
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
    final String tgtId = WebUtils.getTicketGrantingTicketId(requestContext);
    if (!StringUtils.hasText(tgtId)) {
        return new Event(this, NOT_EXISTS);
    }

    String eventId = INVALID;
    try {
        final Ticket ticket = this.centralAuthenticationService.getTicket(tgtId, Ticket.class);
        if (ticket != null && !ticket.isExpired()) {
            eventId = VALID;
        }
    } catch (final TicketException e) {
        logger.trace("Could not retrieve ticket id {} from registry.", e);
    }
    return new Event(this,  eventId);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:TicketGrantingTicketCheckAction.java

示例4: getTicket

import org.jasig.cas.ticket.Ticket; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * Note:
 * Synchronization on ticket object in case of cache based registry doesn't serialize
 * access to critical section. The reason is that cache pulls serialized data and
 * builds new object, most likely for each pull. Is this synchronization needed here?
 */
@Timed(name = "GET_TICKET_TIMER")
@Metered(name = "GET_TICKET_METER")
@Counted(name="GET_TICKET_COUNTER", monotonic=true)
@Override
public <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz)
        throws InvalidTicketException {
    Assert.notNull(ticketId, "ticketId cannot be null");
    final Ticket ticket = this.ticketRegistry.getTicket(ticketId, clazz);

    if (ticket == null) {
        logger.debug("Ticket [{}] by type [{}] cannot be found in the ticket registry.", ticketId, clazz.getSimpleName());
        throw new InvalidTicketException(ticketId);
    }

    if (ticket instanceof TicketGrantingTicket) {
        synchronized (ticket) {
            if (ticket.isExpired()) {
                this.ticketRegistry.deleteTicket(ticketId);
                logger.debug("Ticket [{}] has expired and is now deleted from the ticket registry.", ticketId);
                throw new InvalidTicketException(ticketId);
            }
        }
    }
    return (T) ticket;
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:34,代码来源:AbstractCentralAuthenticationService.java

示例5: getTicket

import org.jasig.cas.ticket.Ticket; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * Note:
 * Synchronization on ticket object in case of cache based registry doesn't serialize
 * access to critical section. The reason is that cache pulls serialized data and
 * builds new object, most likely for each pull. Is this synchronization needed here?
 */
@Transactional(readOnly = true, transactionManager = "ticketTransactionManager")
@Timed(name = "GET_TICKET_TIMER")
@Metered(name = "GET_TICKET_METER")
@Counted(name="GET_TICKET_COUNTER", monotonic=true)
@Override
public <T extends Ticket> T getTicket(final String ticketId, final Class<? extends Ticket> clazz)
        throws InvalidTicketException {
    Assert.notNull(ticketId, "ticketId cannot be null");
    final Ticket ticket = this.ticketRegistry.getTicket(ticketId, clazz);

    if (ticket == null) {
        logger.debug("Ticket [{}] by type [{}] cannot be found in the ticket registry.", ticketId, clazz.getSimpleName());
        throw new InvalidTicketException(ticketId);
    }

    if (ticket instanceof TicketGrantingTicket) {
        synchronized (ticket) {
            if (ticket.isExpired()) {
                this.ticketRegistry.deleteTicket(ticketId);
                logger.debug("Ticket [{}] has expired and is now deleted from the ticket registry.", ticketId);
                throw new InvalidTicketException(ticketId);
            }
        }
    }
    return (T) ticket;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:35,代码来源:AbstractCentralAuthenticationService.java

示例6: checkValidity

import org.jasig.cas.ticket.Ticket; //导入方法依赖的package包/类
/**
 * Determines whether the TGT in the flow request context is valid.
 *
 * @param requestContext Flow request context.
 *
 * @return {@link #NOT_EXISTS}, {@link #INVALID}, or {@link #VALID}.
 */
public Event checkValidity(final RequestContext requestContext) {

    final String tgtId = WebUtils.getTicketGrantingTicketId(requestContext);
    if (!StringUtils.hasText(tgtId)) {
        return new Event(this, NOT_EXISTS);
    }

    final Ticket ticket = this.ticketRegistry.getTicket(tgtId);
    return new Event(this, ticket != null && !ticket.isExpired() ? VALID : INVALID);
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:18,代码来源:TicketGrantingTicketCheckAction.java

示例7: handleRequestInternal

import org.jasig.cas.ticket.Ticket; //导入方法依赖的package包/类
/**
 * Handles the request.
 *
 * @param httpServletRequest the http servlet request
 * @param httpServletResponse the http servlet response
 * @return the model and view
 * @throws Exception the exception
 */
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse)
            throws Exception {
    final ModelAndView modelAndView = new ModelAndView(MONITORING_VIEW_STATISTICS);
    modelAndView.addObject("startTime", this.upTimeStartDate);
    final double difference = System.currentTimeMillis() - this.upTimeStartDate.getTime();

    modelAndView.addObject("upTime", calculateUptime(difference, new LinkedList<Integer>(
                    Arrays.asList(NUMBER_OF_MILLISECONDS_IN_A_DAY, NUMBER_OF_MILLISECONDS_IN_AN_HOUR,
                    NUMBER_OF_MILLISECONDS_IN_A_MINUTE, NUMBER_OF_MILLISECONDS_IN_A_SECOND, 1)),
                    new LinkedList<String>(Arrays.asList("day", "hour", "minute", "second", "millisecond"))));

    modelAndView.addObject("totalMemory", convertToMegaBytes(Runtime.getRuntime().totalMemory()));
    modelAndView.addObject("maxMemory", convertToMegaBytes(Runtime.getRuntime().maxMemory()));
    modelAndView.addObject("freeMemory", convertToMegaBytes(Runtime.getRuntime().freeMemory()));
    modelAndView.addObject("availableProcessors", Runtime.getRuntime().availableProcessors());
    modelAndView.addObject("serverHostName", httpServletRequest.getServerName());
    modelAndView.addObject("serverIpAddress", httpServletRequest.getLocalAddr());
    modelAndView.addObject("casTicketSuffix", this.casTicketSuffix);

    int unexpiredTgts = 0;
    int unexpiredSts = 0;
    int expiredTgts = 0;
    int expiredSts = 0;

    try {
        final Collection<Ticket> tickets = this.centralAuthenticationService.getTickets(Predicates.<Ticket>alwaysTrue());

        for (final Ticket ticket : tickets) {
            if (ticket instanceof ServiceTicket) {
                if (ticket.isExpired()) {
                    expiredSts++;
                } else {
                    unexpiredSts++;
                }
            } else {
                if (ticket.isExpired()) {
                    expiredTgts++;
                } else {
                    unexpiredTgts++;
                }
            }
        }
    } catch (final UnsupportedOperationException e) {
        logger.trace("The ticket registry doesn't support this information.");
    }

    modelAndView.addObject("unexpiredTgts", unexpiredTgts);
    modelAndView.addObject("unexpiredSts", unexpiredSts);
    modelAndView.addObject("expiredTgts", expiredTgts);
    modelAndView.addObject("expiredSts", expiredSts);
    modelAndView.addObject("pageTitle", modelAndView.getViewName());

    return modelAndView;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:64,代码来源:StatisticsController.java

示例8: handleRequestInternal

import org.jasig.cas.ticket.Ticket; //导入方法依赖的package包/类
/**
 * Handles the request.
 *
 * @param httpServletRequest the http servlet request
 * @param httpServletResponse the http servlet response
 * @return the model and view
 * @throws Exception the exception
 */
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse)
            throws Exception {
    final ModelAndView modelAndView = new ModelAndView(MONITORING_VIEW_STATISTICS);
    modelAndView.addObject("startTime", this.upTimeStartDate);
    final double difference = System.currentTimeMillis() - this.upTimeStartDate.getTime();

    modelAndView.addObject("upTime", calculateUptime(difference, new LinkedList<Integer>(
                    Arrays.asList(NUMBER_OF_MILLISECONDS_IN_A_DAY, NUMBER_OF_MILLISECONDS_IN_AN_HOUR,
                    NUMBER_OF_MILLISECONDS_IN_A_MINUTE, NUMBER_OF_MILLISECONDS_IN_A_SECOND, 1)),
                    new LinkedList<String>(Arrays.asList("day", "hour", "minute", "second", "millisecond"))));

    modelAndView.addObject("totalMemory", convertToMegaBytes(Runtime.getRuntime().totalMemory()));
    modelAndView.addObject("maxMemory", convertToMegaBytes(Runtime.getRuntime().maxMemory()));
    modelAndView.addObject("freeMemory", convertToMegaBytes(Runtime.getRuntime().freeMemory()));
    modelAndView.addObject("availableProcessors", Runtime.getRuntime().availableProcessors());
    modelAndView.addObject("serverHostName", httpServletRequest.getServerName());
    modelAndView.addObject("serverIpAddress", httpServletRequest.getLocalAddr());
    modelAndView.addObject("casTicketSuffix", this.casTicketSuffix);

    int unexpiredTgts = 0;
    int unexpiredSts = 0;
    int expiredTgts = 0;
    int expiredSts = 0;

    try {
        final Collection<Ticket> tickets = this.centralAuthenticationService.getTickets(TruePredicate.INSTANCE);

        for (final Ticket ticket : tickets) {
            if (ticket instanceof ServiceTicket) {
                if (ticket.isExpired()) {
                    expiredSts++;
                } else {
                    unexpiredSts++;
                }
            } else {
                if (ticket.isExpired()) {
                    expiredTgts++;
                } else {
                    unexpiredTgts++;
                }
            }
        }
    } catch (final UnsupportedOperationException e) {
        logger.trace("The ticket registry doesn't support this information.");
    }

    modelAndView.addObject("unexpiredTgts", unexpiredTgts);
    modelAndView.addObject("unexpiredSts", unexpiredSts);
    modelAndView.addObject("expiredTgts", expiredTgts);
    modelAndView.addObject("expiredSts", expiredSts);
    modelAndView.addObject("pageTitle", modelAndView.getViewName());

    return modelAndView;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:64,代码来源:StatisticsController.java

示例9: handleRequestInternal

import org.jasig.cas.ticket.Ticket; //导入方法依赖的package包/类
@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse)
            throws Exception {
    final ModelAndView modelAndView = new ModelAndView("viewStatisticsView");
    modelAndView.addObject("startTime", this.upTimeStartDate);
    final double difference = System.currentTimeMillis() - this.upTimeStartDate.getTime();

    modelAndView.addObject("upTime", calculateUptime(difference, new LinkedList<Integer>(
                    Arrays.asList(NUMBER_OF_MILLISECONDS_IN_A_DAY, NUMBER_OF_MILLISECONDS_IN_AN_HOUR,
                    NUMBER_OF_MILLISECONDS_IN_A_MINUTE, NUMBER_OF_MILLISECONDS_IN_A_SECOND, 1)),
                    new LinkedList<String>(Arrays.asList("day", "hour", "minute", "second", "millisecond"))));
    modelAndView.addObject("totalMemory", Runtime.getRuntime().totalMemory() / 1024 / 1024);
    modelAndView.addObject("maxMemory", Runtime.getRuntime().maxMemory() / 1024 / 1024);
    modelAndView.addObject("freeMemory", Runtime.getRuntime().freeMemory() / 1024 / 1024);
    modelAndView.addObject("availableProcessors", Runtime.getRuntime().availableProcessors());
    modelAndView.addObject("serverHostName", httpServletRequest.getServerName());
    modelAndView.addObject("serverIpAddress", httpServletRequest.getLocalAddr());
    modelAndView.addObject("casTicketSuffix", this.casTicketSuffix);

    int unexpiredTgts = 0;
    int unexpiredSts = 0;
    int expiredTgts = 0;
    int expiredSts = 0;

    try {
        final Collection<Ticket> tickets = this.ticketRegistry.getTickets();

        for (final Ticket ticket : tickets) {
            if (ticket instanceof ServiceTicket) {
                if (ticket.isExpired()) {
                    expiredSts++;
                } else {
                    unexpiredSts++;
                }
            } else {
                if (ticket.isExpired()) {
                    expiredTgts++;
                } else {
                    unexpiredTgts++;
                }
            }
        }
    } catch (final UnsupportedOperationException e) {
        logger.trace("The ticket registry doesn't support this information.");
    }

    final Collection<GraphingStatisticsAppender> appenders = GraphingStatisticsAppender.getAllGraphingStatisticsAppenders();

    modelAndView.addObject("unexpiredTgts", unexpiredTgts);
    modelAndView.addObject("unexpiredSts", unexpiredSts);
    modelAndView.addObject("expiredTgts", expiredTgts);
    modelAndView.addObject("expiredSts", expiredSts);
    modelAndView.addObject("pageTitle", modelAndView.getViewName());
    modelAndView.addObject("graphingStatisticAppenders", appenders);

    return modelAndView;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:58,代码来源:StatisticsController.java


注:本文中的org.jasig.cas.ticket.Ticket.isExpired方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。