There are several frameworks for securing Java RESTful web services. I would recommend "Apache Shiro" ( http://shiro.apache.org/ ), it is a very nice and easy to use security infrastructure that will allow you to implement the specified API token security scheme. Take a look at this answer: REST API key generation strategy (where I talked in detail about creating such a solution).
There are other security frameworks that you can use, namely Java EE has security support, and Spring also provides security support. Take a look at this very nice presentation by Matt Riddy where he presents and demonstrates these three frameworks: http://www.slideshare.net/mraible/java-web-application-security-denver-jug-2013
Avoid implementing your “own security scheme" (unless you are an expert on this topic ...), there are many problems that can be missed and lead to problems ... usually these structures are very helpful in preventing that.
NTN.
source share