Rakesh Mahapatro
Rakesh Mahapatro

Reputation: 866

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?

Upvotes: 0

Views: 1676

Answers (1)

daniel
daniel

Reputation: 763

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>

Upvotes: 2

Related Questions