2

I have a Restful Web Service written in Java:

Example:

@GET
@PATH("/foo")
public Response getFoo(){
... 
}

and a filter

public void doFilter(ServletRequest req, ServletResponse response, FilterChain chain) {
   ....
}

How can i make sure that incoming requests and sent responses from my REST API are transported by HTTPS?

Gobliins
  • 3,848
  • 16
  • 67
  • 122

1 Answers1

0

If you have access to ServletRequest, you can use ServletRequest.isSecure to determine whether it was HTTPS or not.

Be careful, if your application gets deployed behind some frontend servers that extract HTTPS for you, you have to do something different. Usually check some headers or similar.

Robert Bräutigam
  • 7,514
  • 1
  • 20
  • 38