简体   繁体   中英

Validate Tomcat Authentication in rest client

I am using rest full web service and tomcat security. I want to write a restclient which will provide the username and password and will do authentication in server.

Please suggest some ways how can I do this?

The easiest way to do this is through basic HTTP authentication. You'll need to modify two files:

1. web.xml of your application. Add:

<login-config>
  <auth-method>BASIC</auth-method>
  <realm-name>Basic authentication</realm-name>
</login-config>
<security-role>
  <description>Some role description</description>
  <role-name>role1</role-name>
</security-role>

2. tomcat-users.xml in conf directory:

<tomcat-users>
  <user name="user1" password="pass" roles="role1" />
</tomcat-users>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM