Java REST service using authentication token

前端 未结 3 1912
春和景丽
春和景丽 2021-02-05 11:57

On my web app using Java EE 6. I want to expose some of my functionality as a Json Rest Service. I want to use authentication tokens for login, User will send their username, pa

3条回答
  •  Happy的楠姐
    2021-02-05 12:18

    Saving the token in a bean or hash table would not be persistent. A DB would persist between executions.

    If you are going to be using REST then you can either pass the authentication in the parameters to the method, or in the request header itself. Encryption is a different matter. I guess it depends on the scale of the system, and how open it is. If security is a top importance, then yes, you should find some form of encryption.

    I have done similar things using the Spring Framework, and Spring Security. These things are relatively simple using this. To write custom code is to reinvent the wheel. There are many frameworks out there which will help you. However, you would then have the learning curve of the framework.

提交回复
热议问题