April 2018
Intermediate to advanced
382 pages
10h 11m
English
Let's split up the code shown earlier, so that we can better understand what's happening.
In the web.xml file, we are creating a security constraint:
<security-constraint> ... </security-constraint>
We're defining a resource inside it:
<web-resource-collection> <web-resource-name>CH05-Authentication</web-resource-name> <url-pattern>/authServlet</url-pattern> </web-resource-collection>
And we're defining an authorization policy. In this case, it's a role:
<auth-constraint> <role-name>role1</role-name> </auth-constraint>
Now we have UserAuthenticationServlet. We should pay attention to this annotation:
@DeclareRoles({"role1", "role2", "role3"})
It defines which roles are part of the context of this particular servlet.
Another ...
Read now
Unlock full access