Reputation: 49097
I have made a web application using Java EE 6 (using reference implementations) and I want to expose it as a REST web service.
The background is that I want to be able to retrieve data from the web application to a iOS app I made. The question is how would I secure the application? I only want my application to use the web service. Is that possible and how would I do this? I only need to know what I should search for and read and not the actual code.
Upvotes: 16
Views: 16254
Reputation: 63
We have used RestEasy as a part to securing our exposed RESTful webservices. There should be lot of example out there but here is the one which might get you started.
http://howtodoinjava.com/2013/06/26/jax-rs-resteasy-basic-authentication-and-authorization-tutorial/
You can also use OAUTH:
http://oltu.apache.org/index.html
Upvotes: 0
Reputation: 31038
Unfortunately, your webservice will never be completely secure but here are few of the basic things you can do:
POST
requests. This will prevent casual snooping to find out how your webservice works (in order to reverse engineer the protocol).Now I'm going to point out why this won't be completely secure:
What can you do?
Of course this all goes out the window when someone comes along, reverse engineers your app, builds another one to mimic it, and you wouldn't (generally) know any better. These are all just points to keep in mind.
Edit: Also, if it wasn't already obvious, use POST
(or GET
) requests for all app queries (to your server). This, combined with the SSL should thwart your casual snoopers.
Edit2: Seems as if I'm wrong re: POST
being more secure than GET
. This answer was quite useful in pointing that out. So I suppose you can use GET
or POST
interchangeably here.
Upvotes: 8
Reputation: 34597
Depends on how secure you want to make it.
Upvotes: 4
Reputation: 2980
my suggestions are:
due to the nature of http protocol, the path part is encrypted in the https request. therefore it's very safe. there are ways to decrypt the request through man-in-the-middle attack but it requires full control over the client device including install an ilegal ssl certificate. but, i'd spend more time on my app to make it successful.
Upvotes: 1
Reputation: 6633
Create a rule on the machine which hosts your Web Service to only allow your application to access it through some port. In Amazon EC2, this is done creating a rule in the instance Security Group.
Upvotes: 0