Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit 51330bb

Browse files
authored
Added example for hasAccessToWebResource
1 parent 74993f1 commit 51330bb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/main/doc/securityContext.asciidoc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,24 @@ If the implementation is not done using JACC, which is allowed albeit discourage
214214

215215
The _hasAccessToWebResource(String resource, String... methods)_ method is identical to _hasAccessToWebResource(String resource)_ with the difference that instead of the "GET" string the caller supplied strings from the _methods_ parameter are used.
216216

217+
As an example, consider the following Servlet definition:
218+
219+
[source,java]
220+
----
221+
@WebServlet("/protectedServlet")
222+
@ServletSecurity(@HttpConstraint(rolesAllowed = "foo"))
223+
public class ProtectedServlet extends HttpServlet { ... }
224+
----
225+
226+
And the following call to _hasAccessToWebResource_:
227+
228+
[source,java]
229+
----
230+
securityContext.hasAccessToWebResource("/protectedServlet")
231+
----
232+
233+
The above "hasAccessToWebResource" call would return true if and only if the caller is in role "foo".
234+
217235

218236
=== Triggering the Authentication Process
219237

0 commit comments

Comments
 (0)