View Javadoc

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.ticketvalidator;
17  
18  import org.acegisecurity.providers.cas.TicketValidator;
19  
20  import org.acegisecurity.ui.cas.ServiceProperties;
21  
22  import org.apache.commons.logging.Log;
23  import org.apache.commons.logging.LogFactory;
24  
25  import org.springframework.beans.factory.InitializingBean;
26  
27  import org.springframework.util.Assert;
28  
29  
30  /**
31   * Convenience abstract base for <code>TicketValidator</code>s.
32   *
33   * @author Ben Alex
34   * @version $Id: AbstractTicketValidator.java 1730 2006-11-12 23:10:09Z benalex $
35   */
36  public abstract class AbstractTicketValidator implements TicketValidator, InitializingBean {
37      //~ Static fields/initializers =====================================================================================
38  
39      private static final Log logger = LogFactory.getLog(AbstractTicketValidator.class);
40  
41      //~ Instance fields ================================================================================================
42  
43      private ServiceProperties serviceProperties;
44      private String casValidate;
45      private String trustStore;
46  
47      //~ Methods ========================================================================================================
48  
49      public void afterPropertiesSet() throws Exception {
50          Assert.hasLength(casValidate, "A casValidate URL must be set");
51          Assert.notNull(serviceProperties, "serviceProperties must be specified");
52  
53          if ((trustStore != null) && (!"".equals(trustStore))) {
54              if (logger.isDebugEnabled()) {
55                  logger.debug("Setting system property 'javax.net.ssl.trustStore'" + " to value [" + trustStore + "]");
56              }
57  
58              System.setProperty("javax.net.ssl.trustStore", trustStore);
59          }
60      }
61  
62      /**
63       * Mandatory URL to CAS' proxy ticket valiation service.<P>This is usually something like
64       * <code>https://www.mycompany.com/cas/proxyValidate</code>.</p>
65       *
66       * @return the CAS proxy ticket validation URL
67       */
68      public String getCasValidate() {
69          return casValidate;
70      }
71  
72      public ServiceProperties getServiceProperties() {
73          return serviceProperties;
74      }
75  
76      /**
77       * Optional property which will be used to set the system property <code>javax.net.ssl.trustStore</code>.
78       *
79       * @return the <code>javax.net.ssl.trustStore</code> that will be set during bean initialization, or
80       *         <code>null</code> to leave the system property unchanged
81       */
82      public String getTrustStore() {
83          return trustStore;
84      }
85  
86      public void setCasValidate(String casValidate) {
87          this.casValidate = casValidate;
88      }
89  
90      public void setServiceProperties(ServiceProperties serviceProperties) {
91          this.serviceProperties = serviceProperties;
92      }
93  
94      public void setTrustStore(String trustStore) {
95          this.trustStore = trustStore;
96      }
97  }