# HG changeset patch # User Felix Wolfsteller # Date 1352292572 -3600 # Node ID 9fca4d60fb7c318d08a353022bc30761e8761dcc # Parent 471baa410470aea9297fee7321c1a6add20da305 Reintroduce wrongly outbacked changes (rev 4418-4425). diff -r 471baa410470 -r 9fca4d60fb7c flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Wed Nov 07 13:40:00 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Wed Nov 07 13:49:32 2012 +0100 @@ -730,6 +730,8 @@ String addWMS(); + String printMapSettings(); + String addWMSTooltip(); String adjustElevation(); diff -r 471baa410470 -r 9fca4d60fb7c flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Wed Nov 07 13:40:00 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Wed Nov 07 13:49:32 2012 +0100 @@ -372,6 +372,7 @@ getFeatureInfoTooltip = Information Tool getFeatureInfoWindowTitle = Informations for Map Layers. addWMS = images/add_map.png +printMapSettings = images/print_map_settings.png addWMSTooltip = Load layers from external WMS service. adjustElevation = images/adjustElevation.png measureLine = images/measure_line.png diff -r 471baa410470 -r 9fca4d60fb7c flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Wed Nov 07 13:40:00 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Wed Nov 07 13:49:32 2012 +0100 @@ -373,6 +373,7 @@ getFeatureInfoTooltip = Informationswerkzeug getFeatureInfoWindowTitle = Informationen zu Kartenebenen addWMS = images/add_map.png +printMapSettings = images/print_map_settings.png addWMSTooltip = Laden von Kartenebenen eines externen WMS Dienstes. adjustElevation = images/adjustElevation.png measureLine = images/measure_line.png diff -r 471baa410470 -r 9fca4d60fb7c flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Wed Nov 07 13:40:00 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Wed Nov 07 13:49:32 2012 +0100 @@ -373,6 +373,7 @@ getFeatureInfoTooltip = Information Tool getFeatureInfoWindowTitle = Informations for Map Layers. addWMS = images/add_map.png +printMapSettings = images/print_map_settings.png addWMSTooltip = Load layers from external WMS service. adjustElevation = images/adjustElevation.png measureLine = images/measure_line.png diff -r 471baa410470 -r 9fca4d60fb7c flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java Wed Nov 07 13:40:00 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java Wed Nov 07 13:49:32 2012 +0100 @@ -1,16 +1,5 @@ package de.intevation.flys.client.client.ui.map; -import org.gwtopenmaps.openlayers.client.Bounds; -import org.gwtopenmaps.openlayers.client.Map; -import org.gwtopenmaps.openlayers.client.control.DragPan; -import org.gwtopenmaps.openlayers.client.control.SelectFeature; -import org.gwtopenmaps.openlayers.client.control.SelectFeatureOptions; -import org.gwtopenmaps.openlayers.client.control.ZoomBox; -import org.gwtopenmaps.openlayers.client.event.MapZoomListener; -import org.gwtopenmaps.openlayers.client.feature.VectorFeature; -import org.gwtopenmaps.openlayers.client.layer.Vector; -import org.gwtopenmaps.openlayers.client.util.Attributes; - import com.google.gwt.core.client.GWT; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.SelectionType; @@ -30,8 +19,20 @@ import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.ThemeList; +import org.gwtopenmaps.openlayers.client.Bounds; +import org.gwtopenmaps.openlayers.client.Map; +import org.gwtopenmaps.openlayers.client.control.DragPan; +import org.gwtopenmaps.openlayers.client.control.SelectFeature; +import org.gwtopenmaps.openlayers.client.control.SelectFeatureOptions; +import org.gwtopenmaps.openlayers.client.control.ZoomBox; +import org.gwtopenmaps.openlayers.client.event.MapZoomListener; +import org.gwtopenmaps.openlayers.client.feature.VectorFeature; +import org.gwtopenmaps.openlayers.client.layer.Vector; +import org.gwtopenmaps.openlayers.client.util.Attributes; + /** + * Toolbar for the Map views. * @author Ingo Weinzierl */ public class MapToolbar @@ -60,6 +61,7 @@ protected ImgButton removeButton; protected ImgButton elevationButton; protected ImgLink printMapLink; + protected ImgButton printMapSettings; protected Label epsgLabel; @@ -123,6 +125,9 @@ printMapLink = createPrintMapLink(); addMember(printMapLink); + + printMapSettings = createMapPrintSettingsControl(); + addMember(printMapSettings); } addMember(zoomToMaxButton); @@ -641,6 +646,17 @@ } + protected ImgButton createMapPrintSettingsControl() { + ImgButton btn = createButton(MSG.printMapSettings(), new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + + } + }); + return btn; + } + + protected ImgButton createWMSControl() { final String srs = floodMap.getRiverProjection(); diff -r 471baa410470 -r 9fca4d60fb7c flys-client/src/main/java/de/intevation/flys/client/server/GGInAFilter.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/GGInAFilter.java Wed Nov 07 13:40:00 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,180 +0,0 @@ -package de.intevation.flys.client.server; - -import java.io.IOException; -import java.util.Enumeration; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.apache.log4j.Logger; - -import de.intevation.flys.client.server.auth.Authentication; -import de.intevation.flys.client.server.auth.AuthenticationException; -import de.intevation.flys.client.server.auth.AuthenticationFactory; -import de.intevation.flys.client.server.auth.User; -import de.intevation.flys.client.server.features.Features; - - -/** ServletFilter used for GGInA authentification and certain authorisation. */ -public class GGInAFilter implements Filter { - - /** Private logger. */ - private static Logger logger = Logger.getLogger(GGInAFilter.class); - - private boolean deactivate = false; - private String authmethod; - private String redirecturl; - private ServletContext sc; - - public static final String LOGIN_JSP = "/login.jsp"; - public static final String LOGIN_SERVLET = "/flys/login"; - public static final String FLYS_CSS = "/FLYS.css"; - - - /** - * Initialize. - * - * Read FilterConfig parameter deactivate - */ - @Override - public void init(FilterConfig config) - throws ServletException - { - String deactivate = config.getInitParameter("deactivate"); - this.sc = config.getServletContext(); - logger.debug("GGInAFilter context " + this.sc.getContextPath()); - this.authmethod = sc.getInitParameter("authentication"); - this.redirecturl = sc.getInitParameter("redirect-url"); - if (deactivate != null && deactivate.equalsIgnoreCase("true")) { - this.deactivate = true; - } - - } - - - /** - * Called when filter in chain invoked. - * @param req request to servlet - * @param resp response of servlet - * @param chain the filter chain - */ - @Override - public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) - throws IOException, ServletException - { - if (this.deactivate) { - logger.debug("GGinAFilter is deactivated"); - chain.doFilter(req, resp); - return; - } - - HttpServletRequest sreq = (HttpServletRequest) req; - - String requesturi = sreq.getRequestURI(); - for (Enumeration e = req.getAttributeNames() ; e.hasMoreElements() ;) { - logger.debug(e.nextElement()); - } - - logger.debug("Request for: " + requesturi); - - // Allow access to login pages - // TODO Maybe replace with Filter - String path = this.sc.getContextPath(); - if (requesturi.equals(path + "/login.jsp") || - requesturi.equals(path + "/flys/login") - || requesturi.equals(path + "/FLYS.css")) { - logger.debug("Request for login " + requesturi); - chain.doFilter(req, resp); - return; - } - - boolean redirect = false; - - HttpSession session = sreq.getSession(); - - String uri = path + "/" + this.redirecturl; - - /* Redirect if uri is root or redirecturl */ - if (requesturi.equals(uri) || requesturi.equals(path + "/")) { - redirect = true; - } - - if (sreq.getQueryString() != null) { - uri = uri + "?" + sreq.getQueryString(); - } - session.setAttribute("requesturi", uri); - - User user = (User)session.getAttribute("user"); - if (user == null) { - logger.debug("No user in session: " + requesturi); - this.handleResponse(resp, redirect); - return; - } - if (user.hasExpired()) { - // try to re-authenticate the user - logger.debug("User ticket has expired: " + requesturi); - String encoding = sreq.getCharacterEncoding(); - try { - Authentication auth = this.auth(user, encoding); - if (auth == null || !auth.isSuccess()) { - logger.debug("Re-athentication not successful"); - this.handleResponse(resp, redirect); - } - } - catch(AuthenticationException e) { - logger.error("Failure during re-authentication", e); - this.handleResponse(resp, redirect); - return; - } - } - - logger.debug("GGInAFilter.doFilter"); - chain.doFilter(req, resp); - return; - } - - private void redirect(ServletResponse resp) throws IOException { - logger.debug("Redirect to login"); - ((HttpServletResponse) resp).sendRedirect(this.sc.getContextPath() + - "/login.jsp"); - } - - private void sendNotAuthenticated(ServletResponse resp) throws IOException { - logger.debug("Send not authenticated"); - ((HttpServletResponse)resp).sendError(HttpServletResponse.SC_FORBIDDEN, "User not authenticated"); - } - - private void handleResponse(ServletResponse resp, boolean redirect) throws IOException { - if (redirect) { - this.redirect(resp); - } - else { - this.sendNotAuthenticated(resp); - } - } - - - /** - * Do nothing at destruction. - */ - @Override - public void destroy() { - } - - private Authentication auth(User user, String encoding) - throws AuthenticationException, IOException { - Features features = (Features)sc.getAttribute(Features.CONTEXT_ATTRIBUTE); - return AuthenticationFactory.getInstance(this.authmethod).auth( - user.getName(), user.getPassword(), encoding, features); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 471baa410470 -r 9fca4d60fb7c flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java Wed Nov 07 13:40:00 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java Wed Nov 07 13:49:32 2012 +0100 @@ -1,22 +1,39 @@ package de.intevation.flys.client.server; import de.intevation.artifacts.common.ArtifactNamespaceContext; - import de.intevation.artifacts.common.utils.ClientProtocolUtils; import de.intevation.artifacts.common.utils.JSON; import de.intevation.artifacts.common.utils.StringUtils; import de.intevation.artifacts.common.utils.XMLUtils; - import de.intevation.artifacts.httpclient.exceptions.ConnectionException; - import de.intevation.artifacts.httpclient.http.HttpClient; import de.intevation.artifacts.httpclient.http.HttpClientImpl; - import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; +import de.intevation.flys.client.shared.MapUtils; +import de.intevation.flys.client.shared.model.MapConfig; -import de.intevation.flys.client.shared.model.MapConfig; -import de.intevation.flys.client.shared.MapUtils; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; +import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.log4j.Logger; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; /* import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -24,31 +41,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; */ -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; - -import java.net.URLEncoder; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.ServletException; - -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; - -import org.apache.commons.httpclient.methods.GetMethod; - -import org.apache.log4j.Logger; - /* Used by direct API call. -> Enforce GPLv3 import org.mapfish.print.MapPrinter; import org.mapfish.print.output.OutputFactory; @@ -57,10 +49,6 @@ import org.mapfish.print.utils.PJsonObject; */ -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - public class MapPrintServiceImpl extends HttpServlet { @@ -371,6 +359,9 @@ new org.apache.commons.httpclient.HttpClient( new MultiThreadedHttpConnectionManager()); + // FIXME: The request is not authenticated. + // Currently this is not a problem because /flys/map-print + // is whitelisted in GGInAFilter. GetMethod get = new GetMethod(url); int result = client.executeMethod(get); InputStream in = get.getResponseBodyAsStream(); diff -r 471baa410470 -r 9fca4d60fb7c flys-client/src/main/java/de/intevation/flys/client/server/RiverInfoServiceImpl.java --- a/flys-client/src/main/java/de/intevation/flys/client/server/RiverInfoServiceImpl.java Wed Nov 07 13:40:00 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/RiverInfoServiceImpl.java Wed Nov 07 13:49:32 2012 +0100 @@ -31,6 +31,8 @@ /** + * GWT Service to serve the gauge and measurement station info + * * @author Björn Ricks */ public class RiverInfoServiceImpl diff -r 471baa410470 -r 9fca4d60fb7c flys-client/src/main/java/de/intevation/flys/client/server/filter/GGInAFilter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/filter/GGInAFilter.java Wed Nov 07 13:49:32 2012 +0100 @@ -0,0 +1,182 @@ +package de.intevation.flys.client.server.filter; + +import de.intevation.flys.client.server.auth.Authentication; +import de.intevation.flys.client.server.auth.AuthenticationException; +import de.intevation.flys.client.server.auth.AuthenticationFactory; +import de.intevation.flys.client.server.auth.User; +import de.intevation.flys.client.server.features.Features; + +import java.io.IOException; +import java.util.Enumeration; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; + + +/** ServletFilter used for GGInA authentification and certain authorisation. */ +public class GGInAFilter implements Filter { + + /** Private logger. */ + private static Logger logger = Logger.getLogger(GGInAFilter.class); + + private boolean deactivate = false; + private String authmethod; + private String redirecturl; + private ServletContext sc; + + public static final String LOGIN_JSP = "/login.jsp"; + public static final String LOGIN_SERVLET = "/flys/login"; + public static final String FLYS_CSS = "/FLYS.css"; + public static final String MAP_PRINT = "/flys/map-print"; + public static final String MAPFISH_PRINT = "/flys/mapfish-print/print.pdf"; + + + /** + * Initialize. + * + * Read FilterConfig parameter deactivate + */ + @Override + public void init(FilterConfig config) + throws ServletException + { + String deactivate = config.getInitParameter("deactivate"); + this.sc = config.getServletContext(); + logger.debug("GGInAFilter context " + this.sc.getContextPath()); + this.authmethod = sc.getInitParameter("authentication"); + this.redirecturl = sc.getInitParameter("redirect-url"); + if (deactivate != null && deactivate.equalsIgnoreCase("true")) { + this.deactivate = true; + } + + } + + + /** + * Called when filter in chain invoked. + * @param req request to servlet + * @param resp response of servlet + * @param chain the filter chain + */ + @Override + public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) + throws IOException, ServletException + { + if (this.deactivate) { + logger.debug("GGinAFilter is deactivated"); + chain.doFilter(req, resp); + return; + } + + HttpServletRequest sreq = (HttpServletRequest) req; + + String requesturi = sreq.getRequestURI(); + for (Enumeration e = req.getAttributeNames() ; e.hasMoreElements() ;) { + logger.debug(e.nextElement()); + } + + logger.debug("Request for: " + requesturi); + + // Allow access to login pages + // TODO Maybe replace with Filter + String path = this.sc.getContextPath(); + if (requesturi.equals(path + LOGIN_JSP) + || requesturi.equals(path + LOGIN_SERVLET) + || requesturi.equals(path + FLYS_CSS) + || requesturi.equals(path + MAP_PRINT) + || requesturi.equals(path + MAPFISH_PRINT)) { + logger.debug("Request for login " + requesturi); + chain.doFilter(req, resp); + return; + } + + boolean redirect = false; + + HttpSession session = sreq.getSession(); + + String uri = path + "/" + this.redirecturl; + + /* Redirect if uri is root or redirecturl */ + if (requesturi.equals(uri) || requesturi.equals(path + "/")) { + redirect = true; + } + + if (sreq.getQueryString() != null) { + uri = uri + "?" + sreq.getQueryString(); + } + session.setAttribute("requesturi", uri); + + User user = (User)session.getAttribute("user"); + if (user == null) { + logger.debug("No user in session: " + requesturi); + this.handleResponse(resp, redirect); + return; + } + if (user.hasExpired()) { + // try to re-authenticate the user + logger.debug("User ticket has expired: " + requesturi); + String encoding = sreq.getCharacterEncoding(); + try { + Authentication auth = this.auth(user, encoding); + if (auth == null || !auth.isSuccess()) { + logger.debug("Re-athentication not successful"); + this.handleResponse(resp, redirect); + } + } + catch(AuthenticationException e) { + logger.error("Failure during re-authentication", e); + this.handleResponse(resp, redirect); + return; + } + } + + chain.doFilter(req, resp); + return; + } + + private void redirect(ServletResponse resp) throws IOException { + logger.debug("Redirect to login"); + ((HttpServletResponse) resp).sendRedirect(this.sc.getContextPath() + + "/login.jsp"); + } + + private void sendNotAuthenticated(ServletResponse resp) throws IOException { + logger.debug("Send not authenticated"); + ((HttpServletResponse)resp).sendError(HttpServletResponse.SC_FORBIDDEN, "User not authenticated"); + } + + private void handleResponse(ServletResponse resp, boolean redirect) throws IOException { + if (redirect) { + this.redirect(resp); + } + else { + this.sendNotAuthenticated(resp); + } + } + + + /** + * Do nothing at destruction. + */ + @Override + public void destroy() { + } + + private Authentication auth(User user, String encoding) + throws AuthenticationException, IOException { + Features features = (Features)sc.getAttribute(Features.CONTEXT_ATTRIBUTE); + return AuthenticationFactory.getInstance(this.authmethod).auth( + user.getName(), user.getPassword(), encoding, features); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 471baa410470 -r 9fca4d60fb7c flys-client/src/main/java/de/intevation/flys/client/server/filter/NoCacheFilter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/filter/NoCacheFilter.java Wed Nov 07 13:49:32 2012 +0100 @@ -0,0 +1,74 @@ +package de.intevation.flys.client.server.filter; + +import java.io.IOException; +import java.util.Enumeration; +import java.util.Date; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; + +/** ServletFilter to avoid caching for GWTs *.nocache.* files. */ +public class NoCacheFilter implements Filter { + + private static final long DAY = 86400000L; + + private static final String NO_CACHE = ".nocache."; + + private static Logger log = Logger.getLogger(NoCacheFilter.class); + + /** + * Initialize. + */ + @Override + public void init(FilterConfig config) + throws ServletException + { + } + + + /** + * Called when filter in chain invoked. + * @param req request to servlet + * @param resp response of servlet + * @param chain the filter chain + */ + @Override + public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) + throws IOException, ServletException + { + HttpServletRequest httpreq = (HttpServletRequest)req; + String uri = httpreq.getRequestURI(); + + if (uri.contains(NO_CACHE)) { + log.debug("Set no-cache for " + uri); + + Date now = new Date(); + HttpServletResponse httpresp = (HttpServletResponse)resp; + httpresp.setDateHeader("Date", now.getTime()); + httpresp.setDateHeader("Expires", now.getTime() - DAY); + httpresp.setHeader("Pragma", "no-cache"); + httpresp.setHeader("Cache-control", + "no-cache, no-store, must-revalidate"); + } + + chain.doFilter(req, resp); + } + + + /** + * Do nothing at destruction. + */ + @Override + public void destroy() { + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 471baa410470 -r 9fca4d60fb7c flys-client/src/main/webapp/WEB-INF/web.xml --- a/flys-client/src/main/webapp/WEB-INF/web.xml Wed Nov 07 13:40:00 2012 +0100 +++ b/flys-client/src/main/webapp/WEB-INF/web.xml Wed Nov 07 13:49:32 2012 +0100 @@ -564,7 +564,7 @@ GGInAFilter - de.intevation.flys.client.server.GGInAFilter + de.intevation.flys.client.server.filter.GGInAFilter deactivate false @@ -576,6 +576,17 @@ /* + + NoCacheFilter + de.intevation.flys.client.server.filter.NoCacheFilter + + + + NoCacheFilter + /* + + + FLYS.html