Configure restful interface HTTPS access __restful

Source: Internet
Author: User

Recently, there is a need in the project, the previous restful interface in the form of HTTPS access, from the Internet to check the data, after a close test to achieve the demand.

After the information on the Internet is collated as follows, please read.

1, according to the previous article tomcat6.0 configure HTTPS one-way (server) encryption method to configure the server HTTPS access.

2, two ways to configure the rest interface HTTPS mode:

First: Increase in Web.xml

<security-constraint>
<web-resource-collection>
<web-resource-name>securedapp</web-resource-name>
<url-pattern>/rest/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>

The second type:

1) Increase in Web.xml

<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/rest/*</url-pattern>
</filter-mapping>

2) Increase Spring-security.xml

<beans:beans xmlns:beans= "Http://www.springframework.org/schema/beans"
Xmlns= "Http://www.springframework.org/schema/security"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
Xsi:schemalocation= "Http://www.springframework.org/schema/beans
Http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
Http://www.springframework.org/schema/security
Http://www.springframework.org/schema/security/spring-security-3.1.xsd ">

<intercept-url pattern= "/rest/**" requires-channel= "https"/>
<port-mappings>
<port-mapping http= "9090" https= "9443"/>
</port-mappings>

<authentication-manager>
</authentication-manager>

</beans:beans>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.