📄 serviceticketimpl.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 java.util.concurrent.atomic.AtomicBoolean;import org.jasig.cas.authentication.Authentication;import org.jasig.cas.authentication.principal.Service;import org.springframework.util.Assert;/** * Domain object representing a Service Ticket. A service ticket grants specific * access to a particular service. It will only work for a particular service. * Generally, it is a one time use Ticket, but the specific expiration policy * can be anything. * * @author Scott Battaglia * @version $Revision: 42265 $ $Date: 2007-08-01 13:53:53 -0400 (Wed, 01 Aug 2007) $ * @since 3.0 */public final class ServiceTicketImpl extends AbstractTicket implements ServiceTicket { /** Unique ID for serializing. */ private static final long serialVersionUID = 1296808733190507408L; /** The service this ticket is valid for. */ private final Service service; /** Is this service ticket the result of a new login. */ private final boolean fromNewLogin; private AtomicBoolean grantedTicketAlready = new AtomicBoolean(false); /** * Constructs a new ServiceTicket with a Unique Id, a TicketGrantingTicket, * a Service, Expiration Policy and a flag to determine if the ticket * creation was from a new Login or not. * * @param id the unique identifier for the ticket. * @param ticket the TicketGrantingTicket parent. * @param service the service this ticket is for. * @param fromNewLogin is it from a new login. * @param policy the expiration policy for the Ticket. * @throws IllegalArgumentException if the TicketGrantingTicket or the * Service are null. */ protected ServiceTicketImpl(final String id, final TicketGrantingTicket ticket, final Service service, final boolean fromNewLogin, final ExpirationPolicy policy) { super(id, ticket, policy); Assert.notNull(ticket, "ticket cannot be null"); Assert.notNull(service, "service cannot be null"); this.service = service; this.fromNewLogin = fromNewLogin; } public boolean isFromNewLogin() { return this.fromNewLogin; } public Service getService() { return this.service; } public boolean isValidFor(final Service serviceToValidate) { updateState(); return serviceToValidate.matches(this.service); } public TicketGrantingTicket grantTicketGrantingTicket( final String id, final Authentication authentication, final ExpirationPolicy expirationPolicy) { if (this.grantedTicketAlready.getAndSet(true)) { throw new IllegalStateException( "TicketGrantingTicket already generated for this ServiceTicket. Cannot grant more than one TGT for ServiceTicket"); } return new TicketGrantingTicketImpl(id, this.getGrantingTicket(), authentication, expirationPolicy); } public Authentication getAuthentication() { return null; } public final boolean equals(final Object object) { if (object == null || !(object instanceof ServiceTicket)) { return false; } final Ticket serviceTicket = (Ticket) object; return serviceTicket.getId().equals(this.getId()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -