⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractticket.java

📁 CAS在Tomcat中实现单点登录项目,单点登录(Single Sign On , 简称 SSO )是目前比较流行的服务于企业业务整合的解决方案之一
💻 JAVA
字号:
/* * Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license * distributed with this file and available online at * http://www.ja-sig.org/products/cas/overview/license/ */package org.jasig.cas.ticket;import org.springframework.util.Assert;/** * Abstract implementation of a ticket that handles all ticket state for * policies. Also incorporates properties common among all tickets. As this is * an abstract class, it cannnot be instanciated. It is recommended that * implementations of the Ticket interface extend the AbstractTicket as it * handles common functionality amongst different ticket types (such as state * updating). *  * @author Scott Battaglia * @version $Revision: 42067 $ $Date: 2007-06-12 15:55:40 -0400 (Tue, 12 Jun 2007) $ * @since 3.0 */public abstract class AbstractTicket implements Ticket, TicketState {    /** The ExpirationPolicy this ticket will be following. */    private final ExpirationPolicy expirationPolicy;    /** The unique identifier for this ticket. */    private final String id;    /** The TicketGrantingTicket this is associated with. */    private final TicketGrantingTicket ticketGrantingTicket;    /** The last time this ticket was used. */    private long lastTimeUsed;    /** The previous last time this ticket was used. */    private long previousLastTimeUsed;    /** The time the ticket was created. */    private long creationTime;    /** The number of times this was used. */    private int countOfUses;    /**     * Constructs a new Ticket with a unqiue id, a possible parent Ticket (can     * be null) and a specified Expiration Policy.     *      * @param id the unique identifier for the ticket     * @param ticket the parent TicketGrantingTicket     * @param expirationPolicy the expirartion policy for the ticket.     * @throws IllegalArgumentException if the id or expiration policy is null.     */    public AbstractTicket(final String id, final TicketGrantingTicket ticket,        final ExpirationPolicy expirationPolicy) {        Assert.notNull(expirationPolicy, "expirationPolicy cannot be null");        Assert.notNull(id, "id cannot be null");        this.id = id;        this.creationTime = System.currentTimeMillis();        this.lastTimeUsed = System.currentTimeMillis();        this.expirationPolicy = expirationPolicy;        this.ticketGrantingTicket = ticket;    }    public final String getId() {        return this.id;    }    protected final void updateState() {        this.previousLastTimeUsed = this.lastTimeUsed;        this.lastTimeUsed = System.currentTimeMillis();        this.countOfUses++;    }    public final int getCountOfUses() {        return this.countOfUses;    }    public final long getCreationTime() {        return this.creationTime;    }    public final TicketGrantingTicket getGrantingTicket() {        return this.ticketGrantingTicket;    }    public final long getLastTimeUsed() {        return this.lastTimeUsed;    }    public final long getPreviousTimeUsed() {        return this.previousLastTimeUsed;    }    public final boolean isExpired() {        return this.expirationPolicy.isExpired(this) || (getGrantingTicket() != null && getGrantingTicket().isExpired()) || isExpiredInternal();    }    protected boolean isExpiredInternal() {        return false;    }    public final int hashCode() {        return 34 ^ this.getId().hashCode();    }    public final String toString() {        return this.id;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -