From 0b98f0d21142e02a8839ca626d0a1e7031e661b0 Mon Sep 17 00:00:00 2001 From: buddhini81 Date: Wed, 12 Apr 2017 13:26:08 +0530 Subject: [PATCH] Code changes related to modifications in section 7 of the article (#1641) * Change @ServletSecurity annotation to reflect usage of 2 different roles * Modification related to @ServletSecurity * Add new folder WEB-INF * Delete .gitkeep * Create web.xml inside WEB-INF * Update web.xml * Deleting this as its moved in to WEB-INF --- .../JavaEEAnnotationsSample/README.txt | 13 +++++++++++-- .../baeldung/javaeeannotations/AccountServlet.java | 4 ++-- .../src/main/webapp/{ => WEB-INF}/web.xml | 3 +-- 3 files changed, 14 insertions(+), 6 deletions(-) rename jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/webapp/{ => WEB-INF}/web.xml (97%) diff --git a/jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/README.txt b/jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/README.txt index 063856b2be..0f95e588b8 100644 --- a/jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/README.txt +++ b/jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/README.txt @@ -12,8 +12,17 @@ NOTES: @WebServlet annotation designates the AccountServlet class as a Servlet c An initialization parameter 'type' is being set to denote the type of the bank account. @ServletSecurity annotation imposes security constraints on the AccountServlet based on - the tomcat-users.xml (this code assumes there is a role 'admin' in your tomcat-users.xml) - + the tomcat-users.xml. +   + This code assumes that your tomcat-users.xml looks as follows: + + + + + + + +   N.B : To see @ServletSecurity annotation in action, please uncomment the annotation code for @ServletSecurity. diff --git a/jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/java/com/baeldung/javaeeannotations/AccountServlet.java b/jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/java/com/baeldung/javaeeannotations/AccountServlet.java index aa7e490eed..a487d4c3b1 100644 --- a/jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/java/com/baeldung/javaeeannotations/AccountServlet.java +++ b/jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/java/com/baeldung/javaeeannotations/AccountServlet.java @@ -17,8 +17,8 @@ import javax.servlet.http.HttpServletResponse; initParams = { @WebInitParam(name = "type", value = "savings") } ) /*@ServletSecurity( - value = @HttpConstraint(rolesAllowed = {"admin"}), - httpMethodConstraints = {@HttpMethodConstraint(value = "POST", rolesAllowed = {"admin"})} + value = @HttpConstraint(rolesAllowed = {"Member"}), + httpMethodConstraints = {@HttpMethodConstraint(value = "POST", rolesAllowed = {"Admin"})} )*/ public class AccountServlet extends javax.servlet.http.HttpServlet { diff --git a/jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/webapp/web.xml b/jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/webapp/WEB-INF/web.xml similarity index 97% rename from jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/webapp/web.xml rename to jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/webapp/WEB-INF/web.xml index f01eb341e4..a92885ec11 100644 --- a/jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/webapp/web.xml +++ b/jee7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/src/main/webapp/WEB-INF/web.xml @@ -7,5 +7,4 @@ BASIC default - - \ No newline at end of file +