View Javadoc

    1   /* Copyright 2004 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,v 1.2 2005/11/17 00:55:47 benalex Exp $
    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,
    56          String proxyGrantingTicketIou) {
    57          if (proxyList == null) {
    58              proxyList = new Vector();
    59          }
    60
    61          if (proxyGrantingTicketIou == null) {
    62              proxyGrantingTicketIou = "";
    63          }
    64
    65          if ((user == null) || "".equals(user)) {
    66              throw new IllegalArgumentException(
    67                  "Cannot pass null or empty String for User");
    68          }
    69
    70          this.user = user;
    71          this.proxyList = proxyList;
    72          this.proxyGrantingTicketIou = proxyGrantingTicketIou;
    73      }
    74
    75      protected TicketResponse() {
    76          throw new IllegalArgumentException("Cannot use default constructor");
    77      }
    78
    79      //~ Methods ================================================================
    80
    81      public String getProxyGrantingTicketIou() {
    82          return proxyGrantingTicketIou;
    83      }
    84
    85      public List getProxyList() {
    86          return proxyList;
    87      }
    88
    89      public String getUser() {
    90          return user;
    91      }
    92
    93      public String toString() {
    94          StringBuffer sb = new StringBuffer();
    95          sb.append(super.toString());
    96          sb.append(": User: " + this.user);
    97          sb.append("; Proxy-Granting Ticket IOU: " + this.proxyGrantingTicketIou);
    98          sb.append("; Proxy List: " + this.proxyList.toString());
    99
    100         return sb.toString();
    101     }
    102 }