1919import javax .servlet .ServletException ;
2020import javax .servlet .http .HttpServletRequest ;
2121import javax .servlet .http .HttpServletResponse ;
22+ import org .slf4j .Logger ;
23+ import org .vast .ows .OWSUtils ;
2224import com .vaadin .server .VaadinServlet ;
2325
2426
2527@ SuppressWarnings ("serial" )
2628public class AdminUIServlet extends VaadinServlet
2729{
30+ final transient Logger log ;
2831 final transient AdminUISecurity securityHandler ;
2932
3033
31- AdminUIServlet (AdminUISecurity securityHandler )
34+ AdminUIServlet (AdminUISecurity securityHandler , Logger log )
3235 {
36+ this .log = log ;
3337 this .securityHandler = securityHandler ;
3438 }
3539
@@ -46,10 +50,29 @@ protected void service(HttpServletRequest request, HttpServletResponse response)
4650 securityHandler .checkPermission (securityHandler .admin_access );
4751 super .service (request , response );
4852 }
53+ catch (SecurityException e )
54+ {
55+ log .info ("Access Forbidden: {}" , e .getMessage ());
56+ sendError (response , HttpServletResponse .SC_FORBIDDEN , e .getMessage ());
57+ }
4958 finally
5059 {
5160 securityHandler .clearCurrentUser ();
5261 }
5362 }
63+
64+
65+ protected void sendError (HttpServletResponse resp , int errorCode , String errorMsg )
66+ {
67+ try
68+ {
69+ resp .sendError (errorCode , errorMsg );
70+ }
71+ catch (IOException e )
72+ {
73+ if (!OWSUtils .isClientDisconnectError (e ) && log .isDebugEnabled ())
74+ log .error ("Cannot send error" , e );
75+ }
76+ }
5477
5578}
0 commit comments