001: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
002: *
003: * Licensed under the Apache License, Version 2.0 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at
006: *
007: * http://www.apache.org/licenses/LICENSE-2.0
008: *
009: * Unless required by applicable law or agreed to in writing, software
010: * distributed under the License is distributed on an "AS IS" BASIS,
011: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: * See the License for the specific language governing permissions and
013: * limitations under the License.
014: */
015:
016: package org.acegisecurity.providers.cas.ticketvalidator;
017:
018: import org.acegisecurity.providers.cas.TicketValidator;
019:
020: import org.acegisecurity.ui.cas.ServiceProperties;
021:
022: import org.apache.commons.logging.Log;
023: import org.apache.commons.logging.LogFactory;
024:
025: import org.springframework.beans.factory.InitializingBean;
026:
027: import org.springframework.util.Assert;
028:
029: /**
030: * Convenience abstract base for <code>TicketValidator</code>s.
031: *
032: * @author Ben Alex
033: * @version $Id: AbstractTicketValidator.java 1730 2006-11-12 23:10:09Z benalex $
034: */
035: public abstract class AbstractTicketValidator implements
036: TicketValidator, InitializingBean {
037: //~ Static fields/initializers =====================================================================================
038:
039: private static final Log logger = LogFactory
040: .getLog(AbstractTicketValidator.class);
041:
042: //~ Instance fields ================================================================================================
043:
044: private ServiceProperties serviceProperties;
045: private String casValidate;
046: private String trustStore;
047:
048: //~ Methods ========================================================================================================
049:
050: public void afterPropertiesSet() throws Exception {
051: Assert.hasLength(casValidate, "A casValidate URL must be set");
052: Assert.notNull(serviceProperties,
053: "serviceProperties must be specified");
054:
055: if ((trustStore != null) && (!"".equals(trustStore))) {
056: if (logger.isDebugEnabled()) {
057: logger
058: .debug("Setting system property 'javax.net.ssl.trustStore'"
059: + " to value [" + trustStore + "]");
060: }
061:
062: System.setProperty("javax.net.ssl.trustStore", trustStore);
063: }
064: }
065:
066: /**
067: * Mandatory URL to CAS' proxy ticket valiation service.<P>This is usually something like
068: * <code>https://www.mycompany.com/cas/proxyValidate</code>.</p>
069: *
070: * @return the CAS proxy ticket validation URL
071: */
072: public String getCasValidate() {
073: return casValidate;
074: }
075:
076: public ServiceProperties getServiceProperties() {
077: return serviceProperties;
078: }
079:
080: /**
081: * Optional property which will be used to set the system property <code>javax.net.ssl.trustStore</code>.
082: *
083: * @return the <code>javax.net.ssl.trustStore</code> that will be set during bean initialization, or
084: * <code>null</code> to leave the system property unchanged
085: */
086: public String getTrustStore() {
087: return trustStore;
088: }
089:
090: public void setCasValidate(String casValidate) {
091: this .casValidate = casValidate;
092: }
093:
094: public void setServiceProperties(ServiceProperties serviceProperties) {
095: this .serviceProperties = serviceProperties;
096: }
097:
098: public void setTrustStore(String trustStore) {
099: this.trustStore = trustStore;
100: }
101: }
|