-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfd2524
commit f9ba0ce
Showing
9 changed files
with
234 additions
and
55 deletions.
There are no files selected for viewing
92 changes: 46 additions & 46 deletions
92
src/main/java/com/centerm/fud_demo/config/HttpsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
package com.centerm.fud_demo.config; | ||
|
||
import org.apache.catalina.Context; | ||
import org.apache.catalina.connector.Connector; | ||
import org.apache.tomcat.util.descriptor.web.SecurityCollection; | ||
import org.apache.tomcat.util.descriptor.web.SecurityConstraint; | ||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* @author Sheva | ||
* @version 1.0 | ||
* @date 2020/1/23 下午2:45 | ||
*/ | ||
@Configuration | ||
public class HttpsConfig { | ||
@Bean | ||
public TomcatServletWebServerFactory servletContainer(){ | ||
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(){ | ||
@Override | ||
protected void postProcessContext(Context context) { | ||
SecurityConstraint constraint = new SecurityConstraint(); | ||
constraint.setUserConstraint("CONFIDENTIAL"); | ||
SecurityCollection collection = new SecurityCollection(); | ||
collection.addPattern("/*"); | ||
constraint.addCollection(collection); | ||
context.addConstraint(constraint); | ||
} | ||
}; | ||
tomcat.addAdditionalTomcatConnectors(httpConnector()); | ||
return tomcat; | ||
} | ||
|
||
@Bean | ||
public Connector httpConnector(){ | ||
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); | ||
connector.setScheme("http"); | ||
//Connector监听到的http的端口号 | ||
connector.setPort(8080); | ||
connector.setSecure(false); | ||
//监听到http的端口号后转向到的https的端口号 | ||
connector.setRedirectPort(443); | ||
return connector; | ||
} | ||
} | ||
//package com.centerm.fud_demo.config; | ||
// | ||
//import org.apache.catalina.Context; | ||
//import org.apache.catalina.connector.Connector; | ||
//import org.apache.tomcat.util.descriptor.web.SecurityCollection; | ||
//import org.apache.tomcat.util.descriptor.web.SecurityConstraint; | ||
//import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; | ||
//import org.springframework.context.annotation.Bean; | ||
//import org.springframework.context.annotation.Configuration; | ||
// | ||
///** | ||
// * @author Sheva | ||
// * @version 1.0 | ||
// * @date 2020/1/23 下午2:45 | ||
// */ | ||
//@Configuration | ||
//public class HttpsConfig { | ||
// @Bean | ||
// public TomcatServletWebServerFactory servletContainer(){ | ||
// TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(){ | ||
// @Override | ||
// protected void postProcessContext(Context context) { | ||
// SecurityConstraint constraint = new SecurityConstraint(); | ||
// constraint.setUserConstraint("CONFIDENTIAL"); | ||
// SecurityCollection collection = new SecurityCollection(); | ||
// collection.addPattern("/*"); | ||
// constraint.addCollection(collection); | ||
// context.addConstraint(constraint); | ||
// } | ||
// }; | ||
// tomcat.addAdditionalTomcatConnectors(httpConnector()); | ||
// return tomcat; | ||
// } | ||
// | ||
// @Bean | ||
// public Connector httpConnector(){ | ||
// Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); | ||
// connector.setScheme("http"); | ||
// //Connector监听到的http的端口号 | ||
// connector.setPort(8080); | ||
// connector.setSecure(false); | ||
// //监听到http的端口号后转向到的https的端口号 | ||
// connector.setRedirectPort(443); | ||
// return connector; | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters