1 /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 package org.acegisecurity.providers.cas;
17
18 import java.util.List;
19 import java.util.Vector;
20
21
22 /**
23 * Represents a CAS service ticket in native CAS form.
24 *
25 * @author Ben Alex
26 * @version $Id: TicketResponse.java 1496 2006-05-23 13:38:33Z benalex $
27 */
28 public class TicketResponse {
29 //~ Instance fields ================================================================================================
30
31 private List proxyList;
32 private String proxyGrantingTicketIou;
33 private String user;
34
35 //~ Constructors ===================================================================================================
36
37 /**
38 * Constructor.
39 *
40 * <P>
41 * If <code>null</code> is passed into the <code>proxyList</code> or
42 * <code>proxyGrantingTicketIou</code>, suitable defaults are established.
43 * However, <code>null</code> cannot be passed for the <code>user</code>
44 * argument.
45 * </p>
46 *
47 * @param user the user as indicated by CAS (cannot be <code>null</code> or
48 * an empty <code>String</code>)
49 * @param proxyList as provided by CAS (may be <code>null</code>)
50 * @param proxyGrantingTicketIou as provided by CAS (may be
51 * <code>null</code>)
52 *
53 * @throws IllegalArgumentException DOCUMENT ME!
54 */
55 public TicketResponse(String user, List proxyList, String proxyGrantingTicketIou) {
56 if (proxyList == null) {
57 proxyList = new Vector();
58 }
59
60 if (proxyGrantingTicketIou == null) {
61 proxyGrantingTicketIou = "";
62 }
63
64 if ((user == null) || "".equals(user)) {
65 throw new IllegalArgumentException("Cannot pass null or empty String for User");
66 }
67
68 this.user = user;
69 this.proxyList = proxyList;
70 this.proxyGrantingTicketIou = proxyGrantingTicketIou;
71 }
72
73 //~ Methods ========================================================================================================
74
75 public String getProxyGrantingTicketIou() {
76 return proxyGrantingTicketIou;
77 }
78
79 public List getProxyList() {
80 return proxyList;
81 }
82
83 public String getUser() {
84 return user;
85 }
86
87 public String toString() {
88 StringBuffer sb = new StringBuffer();
89 sb.append(super.toString());
90 sb.append(": User: " + this.user);
91 sb.append("; Proxy-Granting Ticket IOU: " + this.proxyGrantingTicketIou);
92 sb.append("; Proxy List: " + this.proxyList.toString());
93
94 return sb.toString();
95 }
96 }