本文整理汇总了Java中org.apache.catalina.connector.Connector.setSecure方法的典型用法代码示例。如果您正苦于以下问题:Java Connector.setSecure方法的具体用法?Java Connector.setSecure怎么用?Java Connector.setSecure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.connector.Connector
的用法示例。
在下文中一共展示了Connector.setSecure方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: httpConnector
import org.apache.catalina.connector.Connector; //导入方法依赖的package包/类
public Connector httpConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
// Connector监听的http的端口号
connector.setPort(80);
connector.setSecure(false);
// 监听到http的端口号后转向到的https的端口号
connector.setRedirectPort(8443);
return connector;
}
示例2: createConnector
import org.apache.catalina.connector.Connector; //导入方法依赖的package包/类
/**
* Create a new Connector
*
* @param parent MBean Name of the associated parent component
* @param address The IP address on which to bind
* @param port TCP port number to listen on
* @param isAjp Create a AJP/1.3 Connector
* @param isSSL Create a secure Connector
*
* @exception Exception if an MBean cannot be created or registered
*/
private String createConnector(String parent, String address, int port, boolean isAjp, boolean isSSL)
throws Exception {
Connector retobj = new Connector();
if ((address!=null) && (address.length()>0)) {
retobj.setProperty("address", address);
}
// Set port number
retobj.setPort(port);
// Set the protocol
retobj.setProtocol(isAjp ? "AJP/1.3" : "HTTP/1.1");
// Set SSL
retobj.setSecure(isSSL);
retobj.setScheme(isSSL ? "https" : "http");
// Add the new instance to its parent component
// FIX ME - addConnector will fail
ObjectName pname = new ObjectName(parent);
Service service = getService(pname);
service.addConnector(retobj);
// Return the corresponding MBean name
ObjectName coname = retobj.getObjectName();
return (coname.toString());
}
示例3: createSSLConnector
import org.apache.catalina.connector.Connector; //导入方法依赖的package包/类
private Connector createSSLConnector(String absoluteKeyStore, String keystorePass) {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
try {
connector.setPort(8443);
connector.setSecure(true);
connector.setScheme("https");
protocol.setSSLEnabled(true);
protocol.setKeystoreFile(absoluteKeyStore);
protocol.setKeystorePass(keystorePass);
protocol.setKeystoreType("JKS");
protocol.setKeyAlias("tomcat");
return connector;
} catch(Exception ex) {
throw new IllegalStateException("Can't access to keystore: [" + absoluteKeyStore + "]", ex);
}
}
示例4: initiateHttpConnector
import org.apache.catalina.connector.Connector; //导入方法依赖的package包/类
private Connector initiateHttpConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
connector.setPort(8080);
connector.setSecure(false);
connector.setRedirectPort(8443);
return connector;
}
示例5: servletContainer
import org.apache.catalina.connector.Connector; //导入方法依赖的package包/类
@Bean
public EmbeddedServletContainerFactory servletContainer() {
final TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
if (isEnabled()) {
final Connector ajpConnector = new Connector(getProtocol());
ajpConnector.setPort(getPort());
ajpConnector.setSecure(isSecure());
ajpConnector.setAllowTrace(isAllowTrace());
ajpConnector.setScheme(getScheme());
tomcat.addAdditionalTomcatConnectors(ajpConnector);
}
return tomcat;
}
示例6: createConnector
import org.apache.catalina.connector.Connector; //导入方法依赖的package包/类
/**
* Create a new Connector
*
* @param parent
* MBean Name of the associated parent component
* @param address
* The IP address on which to bind
* @param port
* TCP port number to listen on
* @param isAjp
* Create a AJP/1.3 Connector
* @param isSSL
* Create a secure Connector
*
* @exception Exception
* if an MBean cannot be created or registered
*/
private String createConnector(String parent, String address, int port, boolean isAjp, boolean isSSL)
throws Exception {
Connector retobj = new Connector();
if ((address != null) && (address.length() > 0)) {
retobj.setProperty("address", address);
}
// Set port number
retobj.setPort(port);
// Set the protocol
retobj.setProtocol(isAjp ? "AJP/1.3" : "HTTP/1.1");
// Set SSL
retobj.setSecure(isSSL);
retobj.setScheme(isSSL ? "https" : "http");
// Add the new instance to its parent component
// FIX ME - addConnector will fail
ObjectName pname = new ObjectName(parent);
Service service = getService(pname);
service.addConnector(retobj);
// Return the corresponding MBean name
ObjectName coname = retobj.getObjectName();
return (coname.toString());
}
示例7: configureAjp
import org.apache.catalina.connector.Connector; //导入方法依赖的package包/类
private void configureAjp(final TomcatEmbeddedServletContainerFactory tomcat) {
final CasServerProperties.Ajp ajp = casProperties.getServer().getAjp();
if (ajp.isEnabled() && ajp.getPort() > 0) {
LOGGER.debug("Creating AJP configuration for the embedded tomcat container...");
final Connector ajpConnector = new Connector(ajp.getProtocol());
ajpConnector.setProtocol(ajp.getProtocol());
ajpConnector.setPort(ajp.getPort());
ajpConnector.setSecure(ajp.isSecure());
ajpConnector.setAllowTrace(ajp.isAllowTrace());
ajpConnector.setScheme(ajp.getScheme());
if (ajp.getAsyncTimeout() > 0) {
ajpConnector.setAsyncTimeout(ajp.getAsyncTimeout());
}
ajpConnector.setEnableLookups(ajp.isEnableLookups());
if (ajp.getMaxPostSize() > 0) {
ajpConnector.setMaxPostSize(ajp.getMaxPostSize());
}
ajpConnector.addUpgradeProtocol(new Http2Protocol());
if (ajp.getProxyPort() > 0) {
LOGGER.debug("Set AJP proxy port to [{}]", ajp.getProxyPort());
ajpConnector.setProxyPort(ajp.getProxyPort());
}
if (ajp.getRedirectPort() > 0) {
LOGGER.debug("Set AJP redirect port to [{}]", ajp.getRedirectPort());
ajpConnector.setRedirectPort(ajp.getRedirectPort());
}
ajp.getAttributes().forEach(ajpConnector::setAttribute);
tomcat.addAdditionalTomcatConnectors(ajpConnector);
}
}
示例8: testCustomSslImplementation
import org.apache.catalina.connector.Connector; //导入方法依赖的package包/类
@Test
public void testCustomSslImplementation() throws Exception {
TesterSupport.configureClientSsl();
Tomcat tomcat = getTomcatInstance();
Connector connector = tomcat.getConnector();
Assume.assumeFalse("This test is only for JSSE based SSL connectors",
connector.getProtocolHandlerClassName().contains("Apr"));
connector.setProperty("sslImplementationName",
"org.apache.tomcat.util.net.jsse.TesterBug50640SslImpl");
connector.setProperty(TesterBug50640SslImpl.PROPERTY_NAME,
TesterBug50640SslImpl.PROPERTY_VALUE);
connector.setProperty("sslProtocol", "tls");
File keystoreFile =
new File("test/org/apache/tomcat/util/net/localhost.jks");
connector.setAttribute(
"keystoreFile", keystoreFile.getAbsolutePath());
connector.setSecure(true);
connector.setProperty("SSLEnabled", "true");
File appDir = new File(getBuildDirectory(), "webapps/examples");
tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
tomcat.start();
ByteChunk res = getUrl("https://localhost:" + getPort() +
"/examples/servlets/servlet/HelloWorldExample");
assertTrue(res.toString().indexOf("<a href=\"../helloworld.html\">") > 0);
}
示例9: servletContainer
import org.apache.catalina.connector.Connector; //导入方法依赖的package包/类
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
if (tomcatAjpEnabled) {
Connector ajpConnector = new Connector("AJP/1.3");
ajpConnector.setPort(ajpPort);
ajpConnector.setSecure(false);
ajpConnector.setAllowTrace(false);
ajpConnector.setScheme("http");
tomcat.addAdditionalTomcatConnectors(ajpConnector);
}
return tomcat;
}
示例10: makeConnector
import org.apache.catalina.connector.Connector; //导入方法依赖的package包/类
private Connector makeConnector() {
Connector connector = new Connector(Http11Nio2Protocol.class.getName());
if (keystoreFile == null) {
// HTTP connector
connector.setPort(port);
connector.setSecure(false);
connector.setScheme("http");
} else {
// HTTPS connector
connector.setPort(securePort);
connector.setSecure(true);
connector.setScheme("https");
connector.setAttribute("SSLEnabled", "true");
SSLHostConfig sslHostConfig = new SSLHostConfig();
SSLHostConfigCertificate cert =
new SSLHostConfigCertificate(sslHostConfig, SSLHostConfigCertificate.Type.RSA);
cert.setCertificateKeystoreFile(keystoreFile.toAbsolutePath().toString());
cert.setCertificateKeystorePassword(keystorePassword);
cert.setCertificateKeyAlias(keyAlias);
sslHostConfig.addCertificate(cert);
connector.addSslHostConfig(sslHostConfig);
}
connector.addUpgradeProtocol(new Http2Protocol());
// Keep quiet about the server type
connector.setXpoweredBy(false);
// Basic tuning params:
connector.setAttribute("maxThreads", 400);
connector.setAttribute("acceptCount", 50);
//connector.setAttribute("connectionTimeout", 2000);
connector.setAttribute("maxKeepAliveRequests", 100);
// Avoid running out of ephemeral ports under heavy load?
connector.setAttribute("socket.soReuseAddress", true);
connector.setMaxPostSize(0);
connector.setAttribute("disableUploadTimeout", false);
// Allow long URLs
connector.setAttribute("maxHttpHeaderSize", 65536);
// Enable response compression
connector.setAttribute("compression", "on");
// Defaults are text/html,text/xml,text/plain,text/css
connector.setAttribute("compressableMimeType", "text/html,text/xml,text/plain,text/css,text/csv,application/json");
return connector;
}
示例11: start
import org.apache.catalina.connector.Connector; //导入方法依赖的package包/类
/**
* Starts the Tomcat server.
*/
public void start() {
try {
System.out.println("(EmbeddedTomcat) Creating the embedded Tomcat servlet container");
System.out.println("(EmbeddedTomcat) Catalina home: " + tomcatHome);
System.setProperty("catalina.home", tomcatHome);
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
// Create an embedded server
System.out.println("(EmbeddedTomcat) Creating a new instance of EmbeddedTomcat");
embedded = new Tomcat();
embedded.enableNaming();
// Assemble and install a default HTTP connector
int httpConnectorPort = 8080;
// We must load the engine properties first
EnginePropertiesManager.loadProperties();
String convertigoServer = com.twinsoft.convertigo.engine.EnginePropertiesManager.getProperty(
com.twinsoft.convertigo.engine.EnginePropertiesManager.PropertyName.APPLICATION_SERVER_CONVERTIGO_URL);
System.out.println("(EmbeddedTomcat) Convertigo server property: " + convertigoServer);
int i = convertigoServer.indexOf(':', 6);
if (i != -1) {
int j = convertigoServer.indexOf("/convertigo");
httpConnectorPort = Integer.parseInt(convertigoServer.substring(i+1, j));
}
embedded.setPort(httpPort = httpConnectorPort);
int httpsConnectorPort = httpConnectorPort + 1;
System.out.println("(EmbeddedTomcat) Installing the embedded HTTPS connector listening on port " + httpsConnectorPort);
Connector connector = new Connector();
connector.setPort(httpsConnectorPort);
connector.setSecure(true);
connector.setScheme("https");
connector.setAttribute("keystorePass", "password");
connector.setAttribute("keystoreFile", tomcatHome + "/conf/.keystore");
connector.setAttribute("clientAuth", false);
connector.setAttribute("sslProtocol", "TLS");
connector.setAttribute("SSLEnabled", true);
embedded.getService().addConnector(connector);
Context context = embedded.addWebapp("", tomcatHome + "webapps/ROOT");
context.setParentClassLoader(this.getClass().getClassLoader());
context = embedded.addWebapp("/convertigo", com.twinsoft.convertigo.engine.Engine.WEBAPP_PATH);
context.setParentClassLoader(this.getClass().getClassLoader());
File configFile = new File(com.twinsoft.convertigo.engine.Engine.USER_WORKSPACE_PATH + "/studio/context.xml");
if (configFile.exists()) {
System.out.println("(EmbeddedTomcat) Set convertigo webapp config file to " + configFile.getAbsolutePath());
context.setConfigFile(configFile.toURI().toURL());
}
// Start the embedded server
System.out.println("(EmbeddedTomcat) Starting the server");
embedded.start();
System.out.println("(EmbeddedTomcat) Server successfully started!");
}
catch(Throwable e) {
String stackTrace = Log.getStackTrace(e);
System.out.println("(EmbeddedTomcat) Unexpected exception while launching Tomcat:\n" + stackTrace);
Engine.isStartFailed = true;
}
}