Force to use https instead of http with spring-ws - spring

How will you force http connection to use https when clients try to connect to the server using spring-ws? I have seen some examples that uses WebSecurityConfigurerAdapter, but what is the best way of doing it for annotation based (No XML configuration file exists) spring-ws?

That really depends on the container you're running Spring-WS in. For instance, in Tomcat, you have to put a security constraint in your web.xml.

Actually I ended up using Spring EndpointInterceptors to accomplish this. Here is one example I referred to:http://spring-webservice-2-step-by-step.blogspot.com/2011/12/spring-web-services-20-step-by-step.html

Related

Listing all deployed rest endpoints (spring-boot, tomcat)

I know there is a similar kind of question exist but if works only for glassfish server.
Listing all deployed rest endpoints (spring-boot, jersey)
Is it possible to list all my configured rest-endpoints with spring boot? The actuator lists all existing paths on startup, I want something similar for my custom services, so I can check on startup if all paths are configured correctly and use this info for client calls.
How do I do this? I use #Path/#GET annotations on my service beans and register them via ResourceConfig#registerClasses.
Is there a way to query the Config for all Paths?
Update2: I want to have something like
GET /rest/mycontroller/info
POST /res/mycontroller/update
...
In my opinion, you are already using the right tool (actuator) to answer to your request.
Actuator gives you all the rest method running and you can configure it on your own, by disabling/enabling specific endpoints
If you have a look on the documentationprobably it can help you.
In any case, the default configuration of actuator display the endpoints (built-in in Intellij for your development).

RestTemplate with client-certificates

I would like to use client-certificates to communicate between spring-boot applications. My problem is, that don't know how to configure RestTemplate to use a client-certificate to authenticate against the other application.
If possible i would prefer to solve this problem with the Spring Boot properties instead of writing code - but any solution is better then none.
You are looking to implement a two way SSL authentication. It will have to be supported by whatever ClientHttpRequestFactory is configured in your RestTemplate.
If you use Spring Boot defaults, that is standard javax.net stack, take a look at Spring Boot Client authentication demo. Apache HttpClient and other libraries might require a different setup.

Spring Boot Server using HTTPS, Management Server only HTTP?

Based on an answer from #andy-wilkinson to a past Spring Boot question, it appears that with the exception of a couple parameters (port for example), the management server leverages the same configuration as the regular servlet container.
I would like to configure the main Spring Boot server to use HTTPS (for the application/service it is serving) and to use just HTTP for the actuator endpoints. Has anyone done this? Is this even possible?
-Joshua
It's not possible at the moment. Please open an issue if it's an enhancement that you'd like to see.

Getting Remote Host in jersey 2.4 grizzly http container

I'm using jersey 2.4 grizzly2-http container in my application and was wondering is there a way to get the Remote Host address inside a Request Filter. I would like to reject all requests that are not coming from a list of allowed remote IPs.
Thanks
Josip
I would recommend using a servlet filter external to Jersey. This will be much more customizable. Tomcat has one natively, but you could always role your own. This way you can externalize this from your code and make changes in your web.xml without having to rebuild your app.
http://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#Remote_Address_Filter
Here is a more generic one you could use with grizzly
java- using a filter to check remote address

Spring integration. Want to use HTTPS

I'm using Spring Integration - HTTP Adaptor.
Now, I want to make it HTTPS. Please let me know how to implement it.
If you mean on the client (outbound) side, simply use an https://... url.
If you mean on the server (inbound) side, then configure your servlet container to use SSL.

Resources