1 /**
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one or more
4 * contributor license agreements. See the NOTICE file distributed with
5 * this work for additional information regarding copyright ownership.
6 * The ASF licenses this file to You under the Apache License, Version 2.0
7 * (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package org.apache.geronimo.jetty.connector;
20
21 import javax.net.ssl.KeyManagerFactory;
22
23 import org.apache.geronimo.gbean.GBeanInfo;
24 import org.apache.geronimo.gbean.GBeanInfoBuilder;
25 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
26 import org.apache.geronimo.jetty.JettyContainer;
27 import org.apache.geronimo.jetty.JettySecureConnector;
28 import org.apache.geronimo.management.geronimo.KeystoreManager;
29 import org.apache.geronimo.management.geronimo.WebManager;
30
31 /**
32 * Implementation of a HTTPS connector based on Jetty's SslConnector (which uses pure JSSE).
33 *
34 * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $
35 */
36 public class HTTPSConnector extends JettyConnector implements JettySecureConnector {
37 private final GeronimoSSLListener https;
38 private String algorithm;
39
40 public HTTPSConnector(JettyContainer container, KeystoreManager keystoreManager) {
41 super(container, new GeronimoSSLListener(keystoreManager));
42 https = (GeronimoSSLListener) listener;
43 }
44
45 public int getDefaultPort() {
46 return 443;
47 }
48
49 public String getProtocol() {
50 return WebManager.PROTOCOL_HTTPS;
51 }
52
53 public String getAlgorithm() {
54 return algorithm;
55 }
56
57 /**
58 * Algorithm to use.
59 * As different JVMs have different implementations available, the default algorithm can be used by supplying the value "Default".
60 *
61 * @param algorithm the algorithm to use, or "Default" to use the default from {@link javax.net.ssl.KeyManagerFactory#getDefaultAlgorithm()}
62 */
63 public void setAlgorithm(String algorithm) {
64
65 this.algorithm = algorithm;
66 if ("default".equalsIgnoreCase(algorithm)) {
67 algorithm = KeyManagerFactory.getDefaultAlgorithm();
68 }
69 https.setAlgorithm(algorithm);
70 }
71
72 public String getSecureProtocol() {
73 return https.getProtocol();
74 }
75
76 public void setSecureProtocol(String protocol) {
77 https.setProtocol(protocol);
78 }
79
80 public void setClientAuthRequired(boolean needClientAuth) {
81 https.setNeedClientAuth(needClientAuth);
82 }
83
84 public boolean isClientAuthRequired() {
85 return https.getNeedClientAuth();
86 }
87
88 public void setClientAuthRequested(boolean wantClientAuth) {
89 https.setWantClientAuth(wantClientAuth);
90 }
91
92 public boolean isClientAuthRequested() {
93 return https.getWantClientAuth();
94 }
95
96 public void setKeyStore(String keyStore) {
97 https.setKeyStore(keyStore);
98 }
99
100 public String getKeyStore() {
101 return https.getKeyStore();
102 }
103
104 public void setTrustStore(String trustStore) {
105 https.setTrustStore(trustStore);
106 }
107
108 public String getTrustStore() {
109 return https.getTrustStore();
110 }
111
112 public void setKeyAlias(String keyAlias) {
113 https.setKeyAlias(keyAlias);
114 }
115
116 public String getKeyAlias() {
117 return https.getKeyAlias();
118 }
119
120 public static final GBeanInfo GBEAN_INFO;
121
122 static {
123 GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("Jetty Connector HTTPS", HTTPSConnector.class, JettyConnector.GBEAN_INFO);
124 infoFactory.addAttribute("algorithm", String.class, true, true);
125 infoFactory.addAttribute("secureProtocol", String.class, true, true);
126 infoFactory.addAttribute("keyStore", String.class, true, true);
127 infoFactory.addAttribute("keyAlias", String.class, true, true);
128 infoFactory.addAttribute("trustStore", String.class, true, true);
129 infoFactory.addAttribute("clientAuthRequired", boolean.class, true, true);
130 infoFactory.addAttribute("clientAuthRequested", boolean.class, true, true);
131 infoFactory.addReference("KeystoreManager", KeystoreManager.class, NameFactory.GERONIMO_SERVICE);
132 infoFactory.addInterface(JettySecureConnector.class);
133 infoFactory.setConstructor(new String[]{"JettyContainer", "KeystoreManager"});
134 GBEAN_INFO = infoFactory.getBeanInfo();
135 }
136
137 public static GBeanInfo getGBeanInfo() {
138 return GBEAN_INFO;
139 }
140
141
142
143
144 public String getKeystoreFileName() {
145 return null;
146 }
147
148 public void setKeystoreFileName(String name) {
149 }
150
151 public void setKeystorePassword(String password) {
152 }
153
154 public String getKeystoreType() {
155 return null;
156 }
157
158 public void setKeystoreType(String type) {
159 }
160 }