001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019 package org.apache.geronimo.tomcat.connector;
020
021 import java.util.Map;
022
023 import org.apache.geronimo.gbean.GBeanInfo;
024 import org.apache.geronimo.gbean.GBeanInfoBuilder;
025 import org.apache.geronimo.management.geronimo.WebManager;
026 import org.apache.geronimo.system.serverinfo.ServerInfo;
027 import org.apache.geronimo.tomcat.TomcatContainer;
028
029 public class Http11APRConnectorGBean extends BaseHttp11ConnectorGBean implements Http11APRProtocol {
030
031 private String certificateFile;
032 private String certificateKeyFile;
033 private String caCertificateFile;
034 private String caCertificatePath;
035 private String certificateChainFile;
036 private String revocationPath;
037 private String revocationFile;
038
039 public Http11APRConnectorGBean(String name, Map initParams, String host, int port, TomcatContainer container, ServerInfo serverInfo) throws Exception {
040 super(name, initParams, "org.apache.coyote.http11.Http11AprProtocol", host, port, container, serverInfo);
041 }
042
043 @Override
044 public int getDefaultPort() {
045 return 80;
046 }
047
048 @Override
049 public String getGeronimoProtocol() {
050 return WebManager.PROTOCOL_HTTP;
051 }
052
053 public int getPollTime() {
054 Object value = connector.getAttribute("pollTime");
055 return value == null ? 2000 : new Integer(value.toString()).intValue();
056 }
057
058 public int getPollerSize() {
059 Object value = connector.getAttribute("pollerSize");
060 return value == null ? 8192 : new Integer(value.toString()).intValue();
061 }
062
063 public int getSendfileSize() {
064 Object value = connector.getAttribute("sendfileSize");
065 return value == null ? 8192 : new Integer(value.toString()).intValue();
066 }
067
068 public String getSslCACertificateFile() {
069 return caCertificateFile;
070 }
071
072 public String getSslCACertificatePath() {
073 return caCertificatePath;
074 }
075
076 public String getSslCertificateChainFile() {
077 return certificateChainFile;
078 }
079
080 public String getSslCertificateFile() {
081 return certificateFile;
082 }
083
084 public String getSslCertificateKeyFile() {
085 return certificateKeyFile;
086 }
087
088 public String getSslCipherSuite() {
089 return (String) connector.getAttribute("SSLCipherSuite");
090 }
091
092 public String getSslProtocol() {
093 return (String) connector.getAttribute("SSLProtocol");
094 }
095
096 public String getSslCARevocationFile() {
097 return revocationFile;
098 }
099
100 public String getSslCARevocationPath() {
101 return revocationPath;
102 }
103
104 public String getSslVerifyClient() {
105 return (String) connector.getAttribute("SSLVerifyClient");
106 }
107
108 public int getSslVerifyDepth() {
109 Object value = connector.getAttribute("SSLVerifyDepth");
110 return value == null ? 10 : new Integer(value.toString()).intValue();
111 }
112
113 public boolean getUseSendfile() {
114 Object value = connector.getAttribute("useSendfile");
115 return value == null ? true : new Boolean(value.toString()).booleanValue();
116 }
117
118 public String getSslPassword() {
119 return (String) connector.getAttribute("SSLPassword");
120 }
121
122 public void setPollTime(int pollTime) {
123 connector.setAttribute("pollTime", pollTime);
124 }
125
126 public void setPollerSize(int pollerSize) {
127 connector.setAttribute("pollerSize", pollerSize);
128 }
129
130 public void setSendfileSize(int sendfileSize) {
131 connector.setAttribute("sendfileSize", sendfileSize);
132 }
133
134 public void setSslCACertificateFile(String sslCACertificateFile) {
135 if (sslCACertificateFile != null && sslCACertificateFile.equals(""))
136 sslCACertificateFile = null;
137 caCertificateFile = sslCACertificateFile;
138 if (caCertificateFile == null)
139 connector.setAttribute("SSLCACertificateFile", null);
140 else
141 connector.setAttribute("SSLCACertificateFile", serverInfo.resolveServerPath(caCertificateFile));
142 }
143
144 public void setSslCACertificatePath(String sslCACertificatePath) {
145 if (sslCACertificatePath != null && sslCACertificatePath.equals(""))
146 sslCACertificatePath = null;
147 caCertificatePath = sslCACertificatePath;
148 if (caCertificatePath == null)
149 connector.setAttribute("SSLCACertificatePath", null);
150 else
151 connector.setAttribute("SSLCACertificatePath", serverInfo.resolveServerPath(caCertificatePath));
152 }
153
154 public void setSslCertificateChainFile(String sslCertificateChainFile) {
155 if (sslCertificateChainFile != null && sslCertificateChainFile.equals(""))
156 sslCertificateChainFile = null;
157 certificateChainFile = sslCertificateChainFile;
158 if (certificateChainFile == null)
159 connector.setAttribute("SSLCertificateChainFile", null);
160 else
161 connector.setAttribute("SSLCertificateChainFile", serverInfo.resolveServerPath(certificateChainFile));
162 }
163
164 public void setSslCertificateFile(String sslCertificateFile) {
165 if (sslCertificateFile != null && sslCertificateFile.equals(""))
166 sslCertificateFile = null;
167 certificateFile = sslCertificateFile;
168 if (certificateFile == null)
169 connector.setAttribute("SSLCertificateFile", null);
170 else
171 connector.setAttribute("SSLCertificateFile", serverInfo.resolveServerPath(certificateFile));
172 }
173
174 public void setSslCertificateKeyFile(String sslCertificateKeyFile) {
175 if (sslCertificateKeyFile != null && sslCertificateKeyFile.equals(""))
176 sslCertificateKeyFile = null;
177 certificateKeyFile = sslCertificateKeyFile;
178 if (certificateKeyFile == null)
179 connector.setAttribute("SSLCertificateKeyFile", null);
180 else
181 connector.setAttribute("SSLCertificateKeyFile", serverInfo.resolveServerPath(certificateKeyFile));
182 }
183
184 public void setSslCipherSuite(String sslCipherSuite) {
185 connector.setAttribute("SSLCipherSuite", sslCipherSuite);
186 }
187
188 public void setSslPassword(String sslPassword) {
189 if (sslPassword != null && sslPassword.equals(""))
190 sslPassword = null;
191 connector.setAttribute("SSLPassword", sslPassword);
192 }
193
194 public void setSslProtocol(String sslProtocol) {
195 connector.setAttribute("SSLProtocol", sslProtocol);
196 }
197
198 public void setSslCARevocationFile(String sslCARevocationFile) {
199 if (sslCARevocationFile!= null && sslCARevocationFile.equals(""))
200 sslCARevocationFile = null;
201 revocationFile = sslCARevocationFile;
202 if (revocationFile == null)
203 connector.setAttribute("SSLCARevocationFile", null);
204 else
205 connector.setAttribute("SSLCARevocationFile", serverInfo.resolveServerPath(revocationFile));
206 }
207
208 public void setSslCARevocationPath(String sslCARevocationPath) {
209 if (sslCARevocationPath!= null && sslCARevocationPath.equals(""))
210 sslCARevocationPath = null;
211 revocationPath = sslCARevocationPath;
212 if (revocationPath == null)
213 connector.setAttribute("SSLCARevocationPath", null);
214 else
215 connector.setAttribute("SSLCARevocationPath", serverInfo.resolveServerPath(revocationPath));
216
217 }
218
219 public void setSslVerifyClient(String sslVerifyClient) {
220 connector.setAttribute("SSLVerifyClient", sslVerifyClient);
221 }
222
223 public void setSslVerifyDepth(int sslVerifyDepth) {
224 connector.setAttribute("SSLVerifyDepth", sslVerifyDepth);
225 }
226
227 public void setUseSendfile(boolean useSendfile) {
228 connector.setAttribute("useSendfile", useSendfile);
229 }
230
231 public static final GBeanInfo GBEAN_INFO;
232
233 static {
234 GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("Tomcat Connector HTTP APR", Http11APRConnectorGBean.class, BaseHttp11ConnectorGBean.GBEAN_INFO);
235 infoFactory.addInterface(Http11APRProtocol.class,
236 new String[] {
237 //APR Attributes
238 "pollTime",
239 "pollerSize",
240 "useSendfile",
241 "sendfileSize",
242 //SSL Attributes
243 "sslProtocol",
244 "sslCipherSuite",
245 "sslCertificateFile",
246 "sslCertificateKeyFile",
247 "sslPassword",
248 "sslVerifyClient",
249 "sslVerifyDepth",
250 "sslCACertificateFile",
251 "sslCACertificatePath",
252 "sslCertificateChainFile",
253 "sslCARevocationFile",
254 "sslCARevocationPath"
255 },
256 new String[] {
257 //APR Attributes
258 "pollTime",
259 "pollerSize",
260 "useSendfile",
261 "sendfileSize",
262 //SSL Attributes
263 "sslProtocol",
264 "sslCipherSuite",
265 "sslCertificateFile",
266 "sslCertificateKeyFile",
267 "sslPassword",
268 "sslVerifyClient",
269 "sslVerifyDepth",
270 "sslCACertificateFile",
271 "sslCACertificatePath",
272 "sslCertificateChainFile",
273 "sslCARevocationFile",
274 "sslCARevocationPath"
275 }
276 );
277 infoFactory.setConstructor(new String[] { "name", "initParams", "host", "port", "TomcatContainer", "ServerInfo"});
278 GBEAN_INFO = infoFactory.getBeanInfo();
279 }
280
281 public static GBeanInfo getGBeanInfo() {
282 return GBEAN_INFO;
283 }
284
285 }