01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package edu.yale.its.tp.cas.ticket;
17:
18: /**
19: * Represents a CAS service ticket (ST).
20: */
21: public class ServiceTicket extends Ticket {
22:
23: // *********************************************************************
24: // Private, ticket state
25:
26: private TicketGrantingTicket grantor;
27: private String service;
28: private boolean fromNewLogin;
29:
30: // *********************************************************************
31: // Constructor
32:
33: /** Constructs a new, immutable service ticket. */
34: public ServiceTicket(TicketGrantingTicket t, String service,
35: boolean fromNewLogin) {
36: this .grantor = t;
37: this .service = service;
38: this .fromNewLogin = fromNewLogin;
39: }
40:
41: // *********************************************************************
42: // Public interface
43:
44: /** Retrieves the ticket's username. */
45: public String getUsername() {
46: return grantor.getUsername();
47: }
48:
49: /** Retrieves the ticket's service. */
50: public String getService() {
51: return service;
52: }
53:
54: /**
55: * Returns true if this service ticket was generated in response to a dialogue with a user during which the user supplied
56: * primary credentials. (Returns false, by contrast, if the ticket was generated in response to a request where a TGC was used.)
57: */
58: public boolean isFromNewLogin() {
59: return fromNewLogin;
60: }
61:
62: /**
63: * Returns true if it would be appropriate to confer access to the service returned by getService() at the present point in
64: * time, false otherwise.
65: */
66: public boolean isValid() {
67: return (!grantor.isExpired());
68: }
69:
70: /** Returns the ticket's grantor. */
71: public TicketGrantingTicket getGrantor() {
72: return grantor;
73: }
74: }
|