1 28 29 package com.caucho.server.dispatch; 30 31 import com.caucho.log.Log; 32 import com.caucho.server.connection.CauchoRequest; 33 34 import javax.servlet.FilterChain ; 35 import javax.servlet.ServletException ; 36 import javax.servlet.ServletRequest ; 37 import javax.servlet.ServletRequestWrapper ; 38 import javax.servlet.ServletResponse ; 39 import java.io.IOException ; 40 import java.util.HashMap ; 41 import java.util.logging.Logger ; 42 43 47 public class SecurityRoleMapFilterChain implements FilterChain { 48 private static final Logger log = Log.open(SecurityRoleMapFilterChain.class); 49 50 private FilterChain _next; 52 53 private HashMap <String ,String > _roleMap; 55 56 62 public SecurityRoleMapFilterChain(FilterChain next, 63 HashMap <String ,String > roleMap) 64 { 65 _next = next; 66 if (_next == null) 67 throw new NullPointerException (); 68 69 _roleMap = roleMap; 70 } 71 72 80 public void doFilter(ServletRequest request, 81 ServletResponse response) 82 throws ServletException , IOException 83 { 84 ServletRequest ptr = request; 86 CauchoRequest req = null; 87 88 while (ptr instanceof ServletRequestWrapper ) { 89 ServletRequestWrapper wrapper; 90 wrapper = (ServletRequestWrapper ) ptr; 91 92 if (ptr instanceof CauchoRequest) { 93 break; 94 } 95 else if (wrapper.getRequest() != null) 96 ptr = wrapper.getRequest(); 97 else 98 break; 99 } 100 101 if (ptr instanceof CauchoRequest) { 102 req = (CauchoRequest) ptr; 103 104 } 106 107 try { 108 _next.doFilter(request, response); 109 } finally { 110 114 } 115 } 116 } 117 | Popular Tags |