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
030: implements Http11APRProtocol {
031:
032: private String certificateFile;
033: private String certificateKeyFile;
034: private String caCertificateFile;
035: private String caCertificatePath;
036: private String certificateChainFile;
037: private String revocationPath;
038: private String revocationFile;
039:
040: public Http11APRConnectorGBean(String name, Map initParams,
041: String host, int port, TomcatContainer container,
042: ServerInfo serverInfo) throws Exception {
043: super (name, initParams,
044: "org.apache.coyote.http11.Http11AprProtocol", host,
045: port, container, serverInfo);
046: }
047:
048: @Override
049: public int getDefaultPort() {
050: return 80;
051: }
052:
053: @Override
054: public String getGeronimoProtocol() {
055: return WebManager.PROTOCOL_HTTP;
056: }
057:
058: public int getPollTime() {
059: Object value = connector.getAttribute("pollTime");
060: return value == null ? 2000 : new Integer(value.toString())
061: .intValue();
062: }
063:
064: public int getPollerSize() {
065: Object value = connector.getAttribute("pollerSize");
066: return value == null ? 8192 : new Integer(value.toString())
067: .intValue();
068: }
069:
070: public int getSendfileSize() {
071: Object value = connector.getAttribute("sendfileSize");
072: return value == null ? 8192 : new Integer(value.toString())
073: .intValue();
074: }
075:
076: public String getSslCACertificateFile() {
077: return caCertificateFile;
078: }
079:
080: public String getSslCACertificatePath() {
081: return caCertificatePath;
082: }
083:
084: public String getSslCertificateChainFile() {
085: return certificateChainFile;
086: }
087:
088: public String getSslCertificateFile() {
089: return certificateFile;
090: }
091:
092: public String getSslCertificateKeyFile() {
093: return certificateKeyFile;
094: }
095:
096: public String getSslCipherSuite() {
097: return (String) connector.getAttribute("SSLCipherSuite");
098: }
099:
100: public String getSslProtocol() {
101: return (String) connector.getAttribute("SSLProtocol");
102: }
103:
104: public String getSslCARevocationFile() {
105: return revocationFile;
106: }
107:
108: public String getSslCARevocationPath() {
109: return revocationPath;
110: }
111:
112: public String getSslVerifyClient() {
113: return (String) connector.getAttribute("SSLVerifyClient");
114: }
115:
116: public int getSslVerifyDepth() {
117: Object value = connector.getAttribute("SSLVerifyDepth");
118: return value == null ? 10 : new Integer(value.toString())
119: .intValue();
120: }
121:
122: public boolean getUseSendfile() {
123: Object value = connector.getAttribute("useSendfile");
124: return value == null ? true : new Boolean(value.toString())
125: .booleanValue();
126: }
127:
128: public void setPollTime(int pollTime) {
129: connector.setAttribute("pollTime", pollTime);
130: }
131:
132: public void setPollerSize(int pollerSize) {
133: connector.setAttribute("pollerSize", pollerSize);
134: }
135:
136: public void setSendfileSize(int sendfileSize) {
137: connector.setAttribute("sendfileSize", sendfileSize);
138: }
139:
140: public void setSslCACertificateFile(String sslCACertificateFile) {
141: if (sslCACertificateFile != null
142: && sslCACertificateFile.equals(""))
143: sslCACertificateFile = null;
144: caCertificateFile = sslCACertificateFile;
145: if (caCertificateFile == null)
146: connector.setAttribute("SSLCACertificateFile", null);
147: else
148: connector.setAttribute("SSLCACertificateFile", serverInfo
149: .resolveServerPath(caCertificateFile));
150: }
151:
152: public void setSslCACertificatePath(String sslCACertificatePath) {
153: if (sslCACertificatePath != null
154: && sslCACertificatePath.equals(""))
155: sslCACertificatePath = null;
156: caCertificatePath = sslCACertificatePath;
157: if (caCertificatePath == null)
158: connector.setAttribute("SSLCACertificatePath", null);
159: else
160: connector.setAttribute("SSLCACertificatePath", serverInfo
161: .resolveServerPath(caCertificatePath));
162: }
163:
164: public void setSslCertificateChainFile(
165: String sslCertificateChainFile) {
166: if (sslCertificateChainFile != null
167: && sslCertificateChainFile.equals(""))
168: sslCertificateChainFile = null;
169: certificateChainFile = sslCertificateChainFile;
170: if (certificateChainFile == null)
171: connector.setAttribute("SSLCertificateChainFile", null);
172: else
173: connector.setAttribute("SSLCertificateChainFile",
174: serverInfo.resolveServerPath(certificateChainFile));
175: }
176:
177: public void setSslCertificateFile(String sslCertificateFile) {
178: if (sslCertificateFile != null && sslCertificateFile.equals(""))
179: sslCertificateFile = null;
180: certificateFile = sslCertificateFile;
181: if (certificateFile == null)
182: connector.setAttribute("SSLCertificateFile", null);
183: else
184: connector.setAttribute("SSLCertificateFile", serverInfo
185: .resolveServerPath(certificateFile));
186: }
187:
188: public void setSslCertificateKeyFile(String sslCertificateKeyFile) {
189: if (sslCertificateKeyFile != null
190: && sslCertificateKeyFile.equals(""))
191: sslCertificateKeyFile = null;
192: certificateKeyFile = sslCertificateKeyFile;
193: if (certificateKeyFile == null)
194: connector.setAttribute("SSLCertificateKeyFile", null);
195: else
196: connector.setAttribute("SSLCertificateKeyFile", serverInfo
197: .resolveServerPath(certificateKeyFile));
198: }
199:
200: public void setSslCipherSuite(String sslCipherSuite) {
201: connector.setAttribute("SSLCipherSuite", sslCipherSuite);
202: }
203:
204: public void setSslPassword(String sslPassword) {
205: if (sslPassword != null && sslPassword.equals(""))
206: sslPassword = null;
207: connector.setAttribute("SSLPassword", sslPassword);
208: }
209:
210: public void setSslProtocol(String sslProtocol) {
211: connector.setAttribute("SSLProtocol", sslProtocol);
212: }
213:
214: public void setSslCARevocationFile(String sslCARevocationFile) {
215: if (sslCARevocationFile != null
216: && sslCARevocationFile.equals(""))
217: sslCARevocationFile = null;
218: revocationFile = sslCARevocationFile;
219: if (revocationFile == null)
220: connector.setAttribute("SSLCARevocationFile", null);
221: else
222: connector.setAttribute("SSLCARevocationFile", serverInfo
223: .resolveServerPath(revocationFile));
224: }
225:
226: public void setSslCARevocationPath(String sslCARevocationPath) {
227: if (sslCARevocationPath != null
228: && sslCARevocationPath.equals(""))
229: sslCARevocationPath = null;
230: revocationPath = sslCARevocationPath;
231: if (revocationPath == null)
232: connector.setAttribute("SSLCARevocationPath", null);
233: else
234: connector.setAttribute("SSLCARevocationPath", serverInfo
235: .resolveServerPath(revocationPath));
236:
237: }
238:
239: public void setSslVerifyClient(String sslVerifyClient) {
240: connector.setAttribute("SSLVerifyClient", sslVerifyClient);
241: }
242:
243: public void setSslVerifyDepth(int sslVerifyDepth) {
244: connector.setAttribute("SSLVerifyDepth", sslVerifyDepth);
245: }
246:
247: public void setUseSendfile(boolean useSendfile) {
248: connector.setAttribute("useSendfile", useSendfile);
249: }
250:
251: public static final GBeanInfo GBEAN_INFO;
252:
253: static {
254: GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
255: "Tomcat Connector HTTP APR",
256: Http11APRConnectorGBean.class,
257: BaseHttp11ConnectorGBean.GBEAN_INFO);
258: infoFactory.addInterface(Http11APRProtocol.class, new String[] {
259: //APR Attributes
260: "pollTime",
261: "pollerSize",
262: "useSendfile",
263: "sendfileSize",
264: //SSL Attributes
265: "sslProtocol", "sslCipherSuite", "sslCertificateFile",
266: "sslCertificateKeyFile", "sslPassword",
267: "sslVerifyClient", "sslVerifyDepth",
268: "sslCACertificateFile", "sslCACertificatePath",
269: "sslCertificateChainFile", "sslCARevocationFile",
270: "sslCARevocationPath" }, new String[] {
271: //APR Attributes
272: "pollTime",
273: "pollerSize",
274: "useSendfile",
275: "sendfileSize",
276: //SSL Attributes
277: "sslProtocol", "sslCipherSuite", "sslCertificateFile",
278: "sslCertificateKeyFile", "sslPassword",
279: "sslVerifyClient", "sslVerifyDepth",
280: "sslCACertificateFile", "sslCACertificatePath",
281: "sslCertificateChainFile", "sslCARevocationFile",
282: "sslCARevocationPath" });
283: infoFactory.setConstructor(new String[] { "name", "initParams",
284: "host", "port", "TomcatContainer", "ServerInfo" });
285: GBEAN_INFO = infoFactory.getBeanInfo();
286: }
287:
288: public static GBeanInfo getGBeanInfo() {
289: return GBEAN_INFO;
290: }
291:
292: }
|