zackhalil
zackhalil

Reputation: 533

How to set auth role programically for tomcat 8.5

I have the following config web.xml

   <security-constraint>
      <display-name>Login Security Constraint</display-name>
      <web-resource-collection>
         <web-resource-name>Login Protection</web-resource-name>
         <url-pattern>/servlet/*</url-pattern>
         <http-method>DELETE</http-method>
         <http-method>GET</http-method>
         <http-method>POST</http-method>
         <http-method>PUT</http-method>
      </web-resource-collection>
      <auth-constraint>
         <role-name>Login Access</role-name>
      </auth-constraint>
   </security-constraint>

I have my own Login servlet which I have authenticated the user and created a session using

HttpSession session = request.getSession(true);

But how do I add the role name "Login Access" to the session?

Upvotes: 0

Views: 98

Answers (1)

zackhalil
zackhalil

Reputation: 533

I found I had to implement a JDBCRelam and use call in servlet to authenticate the session

request.login(username, password);

Upvotes: 0

Related Questions