I think also that Kosmo request to WMS Styles and Legends starts probably together with a WMS layer request. Since I didn't want to modify any original WMS OJ classes, OJ WMS legend plugin calls after a WMS is loaded. Infact there is a small delay on OJ whenever a user ask for a legend, comparing to the same process on Kosmo
2015-06-05 9:54 GMT+02:00 Giuseppe Aruta <giuseppe.ar...@gmail.com>: > Hi Jukka, > thanks for the quick answer. > Regarding user/password of WMS, I can see that the code comes from > SelectUrlWithAuthPanel.class but I don't see where these datas are stored > on WMS classes ( or maybe not, they are only asked at the beginning of the > WMS request process). > > > This plugin is relatively simple. If you have time you can see the code on > class org.openjump.core.ui.plugin.wms.WMSLegendPlugIn. > > The core of legend request is Line 71, the String > getLegendUrl(PlugInContext context, String names). > The String is divided into 3 parts: > a) PlugInContext refers to WMS layer where to extract the URL calling > layer.getService().getServerUrl(). > b) while String "names" is the name of the WMS layer. > c) the rest of the code calls GetLegendGraphic, Version, etc, including > some graphical components for the legend. > > I don't have experience with WMS. I understood from your code ( > https://username:pas...@site.fi/cgi-bin/service1?) that that > user/password should before the the server URL string (part a of String > getLegendUrl) . > If so, and if OJ memorize somewhere those datas, it should be easy to > modify this String to get Legends from WMS withcredentials. > Otherwhise I should build "ad hoc" another panel where users have to enter > those info again. > > Regarding ChangeWMSStyleDialogPlugIn, I gave a look to it thinking to port > to OpenJUMP. While GetLegend is relatively easy as it is shown a new image > on a separate panel, for the Style it should redraw the workbench. Which I > still don't know how to do. > > I really appreciate any comment or help on the code from you. > > Best Regards > > Peppe > > > 2015-06-04 17:56 GMT+02:00 Rahkonen Jukka (MML) < > jukka.rahko...@maanmittauslaitos.fi>: > >> Hi Peppe, >> >> >> >> Seems to work with Geoserver and it generates also a correct URL for >> Mapserver so it should work. However, there is some little issue with sites >> using basic authentication. I think that the plugin is sending the request >> without credentials or something like that. Note that the error log shows >> URL as >> >> URL: https://username:pas...@site.fi/cgi-bin/service1? and if I copy the >> whole URL into browser I get the legend graphics. However, OpenJUMP gets an >> http 401 “not authorized” response. >> >> >> >> >> >> javax.imageio.IIOException: Can't get input stream from URL! >> >> at javax.imageio.ImageIO.read(Unknown Source) >> >> at >> org.openjump.core.ui.plugin.wms.WMSLegendPlugIn.getLegendPanel(WMSLegendPlugIn.java:150) >> >> at >> org.openjump.core.ui.plugin.wms.WMSLegendPlugIn.execute(WMSLegendPlugIn.java:48) >> >> at >> com.vividsolutions.jump.workbench.plugin.AbstractPlugIn$1.actionPerformed(AbstractPlugIn.java:342) >> >> at >> javax.swing.AbstractButton.fireActionPerformed(Unknown Source) >> >> at >> javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) >> >> at >> javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) >> >> at >> javax.swing.DefaultButtonModel.setPressed(Unknown Source) >> >> at >> javax.swing.AbstractButton.doClick(Unknown Source) >> >> at >> javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source) >> >> at >> javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source) >> >> at >> java.awt.Component.processMouseEvent(Unknown Source) >> >> at >> javax.swing.JComponent.processMouseEvent(Unknown Source) >> >> at java.awt.Component.processEvent(Unknown >> Source) >> >> at java.awt.Container.processEvent(Unknown >> Source) >> >> at >> java.awt.Component.dispatchEventImpl(Unknown Source) >> >> at >> java.awt.Container.dispatchEventImpl(Unknown Source) >> >> at java.awt.Component.dispatchEvent(Unknown >> Source) >> >> at >> java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) >> >> at >> java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) >> >> at >> java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) >> >> at >> java.awt.Container.dispatchEventImpl(Unknown Source) >> >> at java.awt.Window.dispatchEventImpl(Unknown >> Source) >> >> at java.awt.Component.dispatchEvent(Unknown >> Source) >> >> at >> java.awt.EventQueue.dispatchEventImpl(Unknown Source) >> >> at java.awt.EventQueue.access$200(Unknown >> Source) >> >> at java.awt.EventQueue$3.run(Unknown Source) >> >> at java.awt.EventQueue$3.run(Unknown Source) >> >> at >> java.security.AccessController.doPrivileged(Native Method) >> >> at >> java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) >> >> at >> java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) >> >> at java.awt.EventQueue$4.run(Unknown Source) >> >> at java.awt.EventQueue$4.run(Unknown Source) >> >> at >> java.security.AccessController.doPrivileged(Native Method) >> >> at >> java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) >> >> at java.awt.EventQueue.dispatchEvent(Unknown >> Source) >> >> at >> java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) >> >> at >> java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) >> >> at >> java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) >> >> at >> java.awt.EventDispatchThread.pumpEvents(Unknown Source) >> >> at >> java.awt.EventDispatchThread.pumpEvents(Unknown Source) >> >> at java.awt.EventDispatchThread.run(Unknown >> Source) >> >> Caused by: java.io.IOException: Server returned HTTP response code: 401 >> for URL: >> https://username:pas...@site.fi/cgi-bin/service1?&SERVICE=WMS&REQUEST=GetLegendGraphic&VERSION=1.1.1&FORMAT=image/png&WIDTH=16&HEIGHT=16&legend_options=bgColor:0xFFFFEE;dpi:100;fontAntiAliasing:true;forceLabels:on&LAYER=tukialueet >> >> at >> sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) >> >> at >> sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown >> Source) >> >> at java.net.URL.openStream(Unknown Source) >> >> ... 42 more >> >> >> >> -Jukka Rahkonen- >> >> >> >> >> >> Giuseppe Aruta wrote: >> >> >> >> The plugin will be available on OJ 4474 Night Snapshot >> >> >> >> 2015-06-04 15:24 GMT+02:00 Giuseppe Aruta <giuseppe.ar...@gmail.com>: >> >> Dear Jumpers, >> >> I added on OpenJUMP a new plugin that displays WMS layer(s) legend (if >> available) on a Dialog. >> >> This plugin is located on WMS Layer tree context menu, as "Show WMS Layer >> Legend". >> >> The code originally came from Kosmo SAIG and it was completely rewritten >> in order to adapt WMS GetLegendGraphic and GetStyle operators without >> modifing OJ WMS classes. >> >> Best Regards >> >> Peppe >> >> >> >> >> >> >> ------------------------------------------------------------------------------ >> >> _______________________________________________ >> Jump-pilot-devel mailing list >> Jump-pilot-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel >> >> >
------------------------------------------------------------------------------
_______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel