Securing a REST API in Java

10,607

Solution 1

There are several frameworks to do secure Java RESTful web services. I would recommend "Apache Shiro" (http://shiro.apache.org/), it is a very nice and easy to use security framework that will allow you to implement the API token security scheme you mention. Take a look at this response: REST API key generation strategy (where I gave some insights on creating such a solution).

There are other security frameworks you can use, namely Java EE has support for security and also Spring provides support for security. Take a look at this very nice presentation by Matt Raible where he presents and demos these three frameworks: http://www.slideshare.net/mraible/java-web-application-security-denver-jug-2013

Avoid to implement "your own security scheme" (if you are not an expert in the topic...), there are many issues that may be overlooked and lead to problems... normally these frameworks help a lot on avoiding that.

HTH.

Solution 2

You can take a look at OAuth. Its widely adopted and there are libraries that help you implement the protocol

Share:
10,607
jcm
Author by

jcm

Updated on June 09, 2022

Comments

  • jcm
    jcm almost 2 years

    I am building a REST API in Java - using Jersey. I want to secure sensitive API calls with an API token security scheme, but I don't have any idea where to start.

    Is there a framework that will do this for me out of the box? Or do I have to implement my own security scheme?