1 /* 2 Spring-Annotation, an easy way to configre Spring-Framework without all that XML. 3 Copyright (C) 2007 Spring-Annotation Development Team (http://www.urubatan.com.br) 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 19 <a href="http://www.gnu.org/licenses/lgpl.html">http://www.gnu.org/licenses/lgpl.html</a> 20 */ 21 package net.sourceforge.sannotations.web; 22 23 import java.security.Principal; 24 import java.util.Set; 25 import javax.servlet.http.HttpServletRequest; 26 import javax.servlet.http.HttpServletRequestWrapper; 27 28 /*** 29 * RequestWrapper to enable the roles in the "currentUserRoles" set to be user as JAAS "isUserInRole" call in servlets environment 30 * 31 * @author Urubatan 32 */ 33 public class RequestSeurityWrapper extends HttpServletRequestWrapper implements HttpServletRequest { 34 private final Set<String> userRoles; 35 //TODO document 36 @Override 37 public Principal getUserPrincipal() { 38 return super.getUserPrincipal(); 39 } 40 //TODO document 41 @Override 42 public boolean isUserInRole(final String role) { 43 return this.userRoles.contains(role); 44 } 45 //TODO document 46 public RequestSeurityWrapper(final HttpServletRequest request, final Set<String> userRoles) { 47 super(request); 48 this.userRoles = userRoles; 49 } 50 }