Ignore:
Timestamp:
2017-08-23T00:34:13+02:00 (7 years ago)
Author:
donvip
Message:

fix #josm15178 - use new HTTPS links from French cadastre - requires JOSM 12623+ to load Certigna certificate from platform keystore (not included in JRE keystore)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java

    r32556 r33514  
    77import java.io.BufferedReader;
    88import java.io.IOException;
     9import java.io.InputStream;
    910import java.io.InputStreamReader;
    1011import java.io.OutputStream;
     
    2930import org.openstreetmap.josm.data.validation.util.Entities;
    3031import org.openstreetmap.josm.gui.layer.Layer;
     32import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     33import org.openstreetmap.josm.gui.util.GuiHelper;
     34import org.openstreetmap.josm.io.OsmTransferException;
     35import org.openstreetmap.josm.io.ProgressInputStream;
    3136import org.openstreetmap.josm.tools.GBC;
    3237
    3338public class CadastreInterface {
    3439    public boolean downloadCanceled;
    35     public HttpURLConnection urlConn;
     40    private HttpURLConnection urlConn;
    3641
    3742    private String cookie;
     
    5358    private long cookieTimestamp;
    5459
    55     static final String BASE_URL = "http://www.cadastre.gouv.fr";
     60    static final String BASE_URL = "https://www.cadastre.gouv.fr";
    5661    static final String C_IMAGE_FORMAT = "Cette commune est au format ";
    5762    static final String C_COMMUNE_LIST_START = "<select name=\"codeCommune\"";
     
    98103        } catch (IOException e) {
    99104            Main.error(e);
    100             JOptionPane.showMessageDialog(Main.parent,
     105            GuiHelper.runInEDT(() ->
     106                JOptionPane.showMessageDialog(Main.parent,
    101107                    tr("Town/city {0} not found or not available\n" +
    102                             "or action canceled", wmsLayer.getLocation()));
     108                            "or action canceled", wmsLayer.getLocation())));
    103109            return false;
    104110        }
     
    191197    }
    192198
    193     public void setCookie() {
     199    private void setCookie() {
    194200        this.urlConn.setRequestProperty("Cookie", this.cookie);
    195201    }
     
    591597        lastWMSLayerName = null;
    592598    }
     599
     600    public InputStream getContent(URL url) throws IOException, OsmTransferException {
     601        urlConn = (HttpURLConnection) url.openConnection();
     602        urlConn.setRequestProperty("Connection", "close");
     603        urlConn.setRequestMethod("GET");
     604        setCookie();
     605        return new ProgressInputStream(urlConn, NullProgressMonitor.INSTANCE);
     606    }
    593607}
Note: See TracChangeset for help on using the changeset viewer.