1 17 18 package org.apache.geronimo.jetty.connector; 19 20 import javax.net.ssl.KeyManagerFactory; 21 22 import org.mortbay.http.SslListener; 23 24 import org.apache.geronimo.gbean.GBeanInfo; 25 import org.apache.geronimo.gbean.GBeanInfoBuilder; 26 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 27 import org.apache.geronimo.jetty.JettyContainer; 28 import org.apache.geronimo.system.serverinfo.ServerInfo; 29 30 35 public class HTTPSConnector extends JettyConnector { 36 private final SslListener https; 37 private final ServerInfo serverInfo; 38 private String keystore; 39 private String algorithm; 40 41 public HTTPSConnector(JettyContainer container, ServerInfo serverInfo) { 42 super(container, new SslListener()); 43 this.serverInfo = serverInfo; 44 https = (SslListener) listener; 45 } 46 47 public String getKeystore() { 48 return keystore; 50 } 51 52 public void setKeystore(String keystore) { 53 this.keystore = keystore; 55 } 56 57 public String getAlgorithm() { 58 return algorithm; 59 } 60 61 68 public void setAlgorithm(String algorithm) { 69 this.algorithm = algorithm; 71 if (algorithm == null) { 72 algorithm = KeyManagerFactory.getDefaultAlgorithm(); 73 } 74 https.setAlgorithm(algorithm); 75 } 76 77 public void setPassword(String password) { 78 https.setPassword(password); 79 } 80 81 public void setKeyPassword(String password) { 82 https.setKeyPassword(password); 83 } 84 85 public String getProtocol() { 86 return https.getProtocol(); 87 } 88 89 public void setProtocol(String protocol) { 90 https.setProtocol(protocol); 91 } 92 93 public String getKeystoreType() { 94 return https.getKeystoreType(); 95 } 96 97 public void setKeystoreType(String keystoreType) { 98 https.setKeystoreType(keystoreType); 99 } 100 101 public void setNeedClientAuth(boolean needClientAuth) { 102 https.setNeedClientAuth(needClientAuth); 103 } 104 105 public boolean getNeedClientAuth() { 106 return https.getNeedClientAuth(); 107 } 108 109 public void doStart() throws Exception { 110 https.setKeystore(serverInfo.resolvePath(keystore)); 111 super.doStart(); 112 } 113 114 public static final GBeanInfo GBEAN_INFO; 115 116 static { 117 GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("Jetty HTTPS Connector", HTTPSConnector.class, JettyConnector.GBEAN_INFO); 118 infoFactory.addAttribute("keystore", String .class, true); 119 infoFactory.addAttribute("algorithm", String .class, true); 120 infoFactory.addAttribute("keyPassword", String .class, true); 121 infoFactory.addAttribute("keystoreType", String .class, true); 122 infoFactory.addAttribute("needClientAuth", boolean.class, true); 123 infoFactory.addAttribute("password", String .class, true); 124 infoFactory.addAttribute("protocol", String .class, true); 125 infoFactory.addReference("ServerInfo", ServerInfo.class, NameFactory.GERONIMO_SERVICE); 126 infoFactory.setConstructor(new String []{"JettyContainer", "ServerInfo"}); 127 GBEAN_INFO = infoFactory.getBeanInfo(); 128 } 129 130 public static GBeanInfo getGBeanInfo() { 131 return GBEAN_INFO; 132 } 133 } 134 | Popular Tags |