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