Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

SSLConfiguration.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Marc Wick.
00022  * Contributor(s): ______________________.
00023  */
00024 
00025 package org.objectweb.cjdbc.common.net;
00026 
00027 import java.io.File;
00028 import java.io.Serializable;
00029 
00030 /**
00031  * This class defines a SSLConfiguration
00032  * 
00033  * @author <a href="mailto:marc.wick@monte-bre.ch">Marc Wick </a>
00034  * @version 1.0
00035  */
00036 public class SSLConfiguration implements Serializable
00037 {
00038   /** kestore file */
00039   private File    keyStore;
00040   /** keystore password */
00041   private String  keyStorePassword;
00042   /** key password */
00043   private String  keyStoreKeyPassword;
00044 
00045   //TODO : provide support for naming aliases
00046 
00047   /** need client authentication */
00048   private boolean isClientAuthenticationRequired = false;
00049 
00050   /** truststore file */
00051   private File    trustStore;
00052   /** truststore password */
00053   private String  trustStorePassword;
00054 
00055   /**
00056    * Returns the isClientAuthenticationRequired value.
00057    * 
00058    * @return Returns the isClientAuthenticationRequired.
00059    */
00060   public boolean isClientAuthenticationRequired()
00061   {
00062     return isClientAuthenticationRequired;
00063   }
00064 
00065   /**
00066    * Sets the isClientAuthenticationRequired value.
00067    * 
00068    * @param isClientAuthenticationRequired The isClientAuthenticationRequired to
00069    *          set.
00070    */
00071   public void setClientAuthenticationRequired(
00072       boolean isClientAuthenticationRequired)
00073   {
00074     this.isClientAuthenticationRequired = isClientAuthenticationRequired;
00075   }
00076 
00077   /**
00078    * Returns the keyStore value.
00079    * 
00080    * @return Returns the keyStore.
00081    */
00082   public File getKeyStore()
00083   {
00084     return keyStore;
00085   }
00086 
00087   /**
00088    * Sets the keyStore value.
00089    * 
00090    * @param keyStore The keyStore to set.
00091    */
00092   public void setKeyStore(File keyStore)
00093   {
00094     this.keyStore = keyStore;
00095   }
00096 
00097   /**
00098    * Returns the keyStoreKeyPassword value.
00099    * 
00100    * @return Returns the keyStoreKeyPassword.
00101    */
00102   public String getKeyStoreKeyPassword()
00103   {
00104     if (keyStoreKeyPassword != null)
00105       return keyStoreKeyPassword;
00106     return getKeyStorePassword();
00107   }
00108 
00109   /**
00110    * Sets the keyStoreKeyPassword value.
00111    * 
00112    * @param keyStoreKeyPassword The keyStoreKeyPassword to set.
00113    */
00114   public void setKeyStoreKeyPassword(String keyStoreKeyPassword)
00115   {
00116     this.keyStoreKeyPassword = keyStoreKeyPassword;
00117   }
00118 
00119   /**
00120    * Returns the keyStorePassword value.
00121    * 
00122    * @return Returns the keyStorePassword.
00123    */
00124   public String getKeyStorePassword()
00125   {
00126     return keyStorePassword;
00127   }
00128 
00129   /**
00130    * Sets the keyStorePassword value.
00131    * 
00132    * @param keyStorePassword The keyStorePassword to set.
00133    */
00134   public void setKeyStorePassword(String keyStorePassword)
00135   {
00136     this.keyStorePassword = keyStorePassword;
00137   }
00138 
00139   /**
00140    * Returns the trustStore value.
00141    * 
00142    * @return Returns the trustStore.
00143    */
00144   public File getTrustStore()
00145   {
00146     if (trustStore != null)
00147       return trustStore;
00148 
00149     return getKeyStore();
00150   }
00151 
00152   /**
00153    * Sets the trustStore value.
00154    * 
00155    * @param trustStore The trustStore to set.
00156    */
00157   public void setTrustStore(File trustStore)
00158   {
00159     this.trustStore = trustStore;
00160   }
00161 
00162   /**
00163    * Returns the trustStorePassword value.
00164    * 
00165    * @return Returns the trustStorePassword.
00166    */
00167   public String getTrustStorePassword()
00168   {
00169     if (trustStorePassword != null)
00170       return trustStorePassword;
00171 
00172     return getKeyStorePassword();
00173   }
00174 
00175   /**
00176    * Sets the trustStorePassword value.
00177    * 
00178    * @param trustStorePassword The trustStorePassword to set.
00179    */
00180   public void setTrustStorePassword(String trustStorePassword)
00181   {
00182     this.trustStorePassword = trustStorePassword;
00183   }
00184 
00185   /**
00186    * create a SSLConfiguration with the java default behaviour (using System
00187    * properties)
00188    * 
00189    * @return config
00190    */
00191   public static SSLConfiguration getDefaultConfig()
00192   {
00193     SSLConfiguration config = new SSLConfiguration();
00194     config.keyStore = new File(System.getProperty("javax.net.ssl.keyStore"));
00195     config.keyStorePassword = System
00196         .getProperty("javax.net.ssl.keyStorePassword");
00197     config.keyStoreKeyPassword = System
00198         .getProperty("javax.net.ssl.keyStorePassword");
00199     config.trustStore = new File(System.getProperty("javax.net.ssl.trustStore"));
00200     config.trustStorePassword = System
00201         .getProperty("javax.net.ssl.trustStorePassword");
00202     return config;
00203   }
00204 
00205 }

Generated on Mon Apr 11 22:01:35 2005 for C-JDBC by  doxygen 1.3.9.1