| | |
| | | /*
|
| | | * To change this license header, choose License Headers in Project Properties.
|
| | | * To change this template file, choose Tools | Templates
|
| | | * and open the template in the editor.
|
| | | * Nutzerverwaltung - User and role management in your browser
|
| | | * Copyright (C) 2011-2016 Ulrich Hilger, http://uhilger.de
|
| | | *
|
| | | * This program is free software: you can redistribute it and/or modify
|
| | | * it under the terms of the GNU General Public License as published by
|
| | | * the Free Software Foundation, either version 3 of the License, or
|
| | | * (at your option) any later version.
|
| | | *
|
| | | * This program is distributed in the hope that it will be useful,
|
| | | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| | | * GNU General Public License for more details.
|
| | | *
|
| | | * You should have received a copy of the GNU General Public License
|
| | | * along with this program. If not, see http://www.gnu.org/licenses/
|
| | | */
|
| | |
|
| | | package de.uhilger.um.web;
|
| | |
|
| | | import java.io.IOException;
|
| | |
| | | * @author hilgeru
|
| | | */
|
| | | public class NiceFilter implements Filter {
|
| | | |
| | | private static final String ZIEL = "../api?c=de.uhilger.um.api.UserMgr&m=";
|
| | |
|
| | | @Override
|
| | | public void init(FilterConfig filterConfig) throws ServletException {
|
| | | // ...
|
| | | }
|
| | |
|
| | | /*
|
| | | hier wird ein URL wie z.B. |
| | | http]://example.com/um/svc/testmethode
|
| | | umgesetzt auf
|
| | | http]://example.com/um/api?c=de.uhilger.um.api.UserMgr&m=testmethode
|
| | | |
| | | der Teil 'svc' ist im Filter Mapping des Deployment Descriptor |
| | | deklariert. Der Teil 'api' zeigt mit Hilfe eines Servlet |
| | | Mappings im Deployment Descriptor auf das Transit-Servlet.
|
| | | |
| | | der statische Teil des Ziel-URL ist hier hart kodiert, das kann man |
| | | freilich je nach Bedarf noch dynamisch gestalten
|
| | | */
|
| | | |
| | | @Override
|
| | | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
| | | if(request instanceof HttpServletRequest) {
|
| | | HttpServletRequest hr = (HttpServletRequest) request;
|
| | | String servletPath = hr.getServletPath();
|
| | | String[] path = servletPath.split("/");
|
| | | request.getRequestDispatcher("../api?c=de.uhilger.um.api.UserMgr&m=" + path[2]).forward(request, response);
|
| | | request.getRequestDispatcher(ZIEL + path[2]).forward(request, response);
|
| | | }
|
| | | }
|
| | |
|