Switch to TLS

This commit is contained in:
Zahnstocher 2014-06-19 16:07:15 +02:00
parent e3dbd574d0
commit c5d0d27b5f
6 changed files with 83 additions and 19 deletions

View file

@ -27,7 +27,6 @@ public class NameFinderPoiFilter extends PoiFilter {
List<Amenity> searchedAmenities = new ArrayList<Amenity>(); List<Amenity> searchedAmenities = new ArrayList<Amenity>();
private String query = ""; //$NON-NLS-1$ private String query = ""; //$NON-NLS-1$
private String lastError = ""; //$NON-NLS-1$ private String lastError = ""; //$NON-NLS-1$
@ -55,12 +54,24 @@ public class NameFinderPoiFilter extends PoiFilter {
@Override @Override
protected List<Amenity> searchAmenities(double lat, double lon, double topLatitude, protected List<Amenity> searchAmenities(double lat, double lon, double topLatitude,
double bottomLatitude, double leftLongitude, double rightLongitude, ResultMatcher<Amenity> matcher) { double bottomLatitude, double leftLongitude, double rightLongitude, ResultMatcher<Amenity> matcher) {
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
String NOMINATIM_API;
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
NOMINATIM_API = "https://nominatim.openstreetmap.org/search/";
}
else {
NOMINATIM_API = "http://nominatim.openstreetmap.org/search/";
}
searchedAmenities.clear(); searchedAmenities.clear();
String viewbox = "viewboxlbrt="+((float) leftLongitude)+","+((float) bottomLatitude)+","+((float) rightLongitude)+","+((float) topLatitude); String viewbox = "viewboxlbrt="+((float) leftLongitude)+","+((float) bottomLatitude)+","+((float) rightLongitude)+","+((float) topLatitude);
try { try {
lastError = ""; lastError = "";
String urlq = "http://nominatim.openstreetmap.org/search/"+URLEncoder.encode(query)+ "?format=xml&addressdetails=1&limit="+LIMIT+"&bounded=1&"+viewbox; String urlq = NOMINATIM_API + URLEncoder.encode(query)+ "?format=xml&addressdetails=1&limit="+LIMIT+"&bounded=1&"+viewbox;
log.info(urlq); log.info(urlq);
URL url = new URL(urlq); //$NON-NLS-1$ URL url = new URL(urlq); //$NON-NLS-1$
InputStream stream = url.openStream(); InputStream stream = url.openStream();

View file

@ -142,6 +142,7 @@ public class SearchAddressOnlineFragment extends SherlockFragment implements Sea
} }
protected void searchPlaces(final String search) { protected void searchPlaces(final String search) {
if(Algorithms.isEmpty(search)){ if(Algorithms.isEmpty(search)){
return; return;
} }
@ -154,9 +155,21 @@ public class SearchAddressOnlineFragment extends SherlockFragment implements Sea
@Override @Override
protected Void doInBackground(Void... params) { protected Void doInBackground(Void... params) {
try { try {
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
String NOMINATIM_API;
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
NOMINATIM_API = "https://nominatim.openstreetmap.org/search";
}
else {
NOMINATIM_API = "http://nominatim.openstreetmap.org/search";
}
final List<Place> places = new ArrayList<Place>(); final List<Place> places = new ArrayList<Place>();
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append("http://nominatim.openstreetmap.org/search"); //$NON-NLS-1$ b.append(NOMINATIM_API); //$NON-NLS-1$
b.append("?format=xml&addressdetails=0&accept-language=").append(Locale.getDefault().getLanguage()); //$NON-NLS-1$ b.append("?format=xml&addressdetails=0&accept-language=").append(Locale.getDefault().getLanguage()); //$NON-NLS-1$
b.append("&q=").append(URLEncoder.encode(search, "UTF-8")); //$NON-NLS-1$ b.append("&q=").append(URLEncoder.encode(search, "UTF-8")); //$NON-NLS-1$

View file

@ -331,7 +331,7 @@ public class EditingPOIActivity implements DialogProvider {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
ctx.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://wiki.openstreetmap.org/wiki/Map_Features"))); ctx.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://wiki.openstreetmap.org/wiki/Map_Features")));
} }
}); });
linkToOsmDoc.setMovementMethod(LinkMovementMethod.getInstance()); linkToOsmDoc.setMovementMethod(LinkMovementMethod.getInstance());

View file

@ -45,9 +45,6 @@ import android.widget.Toast;
public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
// private final static String SITE_API = "http://api06.dev.openstreetmap.org/";
private final static String SITE_API = "http://api.openstreetmap.org/"; //$NON-NLS-1$
private static final long NO_CHANGESET_ID = -1; private static final long NO_CHANGESET_ID = -1;
private final OsmandApplication ctx; private final OsmandApplication ctx;
@ -73,7 +70,25 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
return entityInfo; return entityInfo;
} }
private final static String URL_TO_UPLOAD_GPX = " http://api.openstreetmap.org/api/0.6/gpx/create"; private static String getSiteApi()
{
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
String RETURN_API;
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
RETURN_API = "https://api.openstreetmap.org/";
}
else {
RETURN_API = "http://api.openstreetmap.org/";
}
// RETURN_API = "http://api06.dev.openstreetmap.org/";
return RETURN_API;
}
private final static String URL_TO_UPLOAD_GPX = getSiteApi() + "api/0.6/gpx/create";
public String uploadGPXFile(String tagstring, String description, String visibility, File f) { public String uploadGPXFile(String tagstring, String description, String visibility, File f) {
String url = URL_TO_UPLOAD_GPX; String url = URL_TO_UPLOAD_GPX;
@ -178,7 +193,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
} catch (IOException e) { } catch (IOException e) {
log.error("Unhandled exception", e); //$NON-NLS-1$ log.error("Unhandled exception", e); //$NON-NLS-1$
} }
String response = sendRequest(SITE_API + "api/0.6/changeset/create/", "PUT", writer.getBuffer().toString(), ctx.getString(R.string.opening_changeset), true); //$NON-NLS-1$ //$NON-NLS-2$ String response = sendRequest(getSiteApi() + "api/0.6/changeset/create/", "PUT", writer.getBuffer().toString(), ctx.getString(R.string.opening_changeset), true); //$NON-NLS-1$ //$NON-NLS-2$
if (response != null && response.length() > 0) { if (response != null && response.length() > 0) {
id = Long.parseLong(response); id = Long.parseLong(response);
} }
@ -256,7 +271,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
} catch (IOException e) { } catch (IOException e) {
log.error("Unhandled exception", e); //$NON-NLS-1$ log.error("Unhandled exception", e); //$NON-NLS-1$
} }
String res = sendRequest(SITE_API+"api/0.6/changeset/"+changeSetId + "/upload", "POST", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ String res = sendRequest(getSiteApi() + "api/0.6/changeset/"+changeSetId + "/upload", "POST", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
writer.getBuffer().toString(), ctx.getString(R.string.commiting_node), true); writer.getBuffer().toString(), ctx.getString(R.string.commiting_node), true);
log.debug(res+""); //$NON-NLS-1$ log.debug(res+""); //$NON-NLS-1$
if (res != null) { if (res != null) {
@ -286,7 +301,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
@Override @Override
public void closeChangeSet() { public void closeChangeSet() {
if (changeSetId != NO_CHANGESET_ID) { if (changeSetId != NO_CHANGESET_ID) {
String response = sendRequest(SITE_API+"api/0.6/changeset/"+changeSetId+"/close", "PUT", "", ctx.getString(R.string.closing_changeset), true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ String response = sendRequest(getSiteApi() + "api/0.6/changeset/"+changeSetId+"/close", "PUT", "", ctx.getString(R.string.closing_changeset), true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
log.info("Response : " + response); //$NON-NLS-1$ log.info("Response : " + response); //$NON-NLS-1$
changeSetId = NO_CHANGESET_ID; changeSetId = NO_CHANGESET_ID;
} }
@ -296,7 +311,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
public EntityInfo loadNode(Node n) { public EntityInfo loadNode(Node n) {
long nodeId = n.getId(); // >> 1; long nodeId = n.getId(); // >> 1;
try { try {
String res = sendRequest(SITE_API + "api/0.6/node/"+nodeId, "GET", null, ctx.getString(R.string.loading_poi_obj) + nodeId, false); //$NON-NLS-1$ //$NON-NLS-2$ String res = sendRequest(getSiteApi() + "api/0.6/node/"+nodeId, "GET", null, ctx.getString(R.string.loading_poi_obj) + nodeId, false); //$NON-NLS-1$ //$NON-NLS-2$
if(res != null){ if(res != null){
OsmBaseStorage st = new OsmBaseStorage(); OsmBaseStorage st = new OsmBaseStorage();
st.parseOSM(new ByteArrayInputStream(res.getBytes("UTF-8")), null, null, true); //$NON-NLS-1$ st.parseOSM(new ByteArrayInputStream(res.getBytes("UTF-8")), null, null, true); //$NON-NLS-1$
@ -330,7 +345,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
} }
long nodeId = n.getId() >> 1; long nodeId = n.getId() >> 1;
try { try {
String res = sendRequest(SITE_API+"api/0.6/node/"+nodeId, "GET", null, ctx.getString(R.string.loading_poi_obj) + nodeId, false); //$NON-NLS-1$ //$NON-NLS-2$ String res = sendRequest(getSiteApi() + "api/0.6/node/"+nodeId, "GET", null, ctx.getString(R.string.loading_poi_obj) + nodeId, false); //$NON-NLS-1$ //$NON-NLS-2$
if(res != null){ if(res != null){
OsmBaseStorage st = new OsmBaseStorage(); OsmBaseStorage st = new OsmBaseStorage();
st.parseOSM(new ByteArrayInputStream(res.getBytes("UTF-8")), null, null, true); //$NON-NLS-1$ st.parseOSM(new ByteArrayInputStream(res.getBytes("UTF-8")), null, null, true); //$NON-NLS-1$

View file

@ -235,9 +235,20 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
protected List<OpenStreetNote> loadingBugs(double topLatitude, double leftLongitude, double bottomLatitude,double rightLongitude){ protected List<OpenStreetNote> loadingBugs(double topLatitude, double leftLongitude, double bottomLatitude,double rightLongitude){
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
String SITE_API;
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
SITE_API = "https://api.openstreetmap.org/";
}
else {
SITE_API = "http://api.openstreetmap.org/";
}
List<OpenStreetNote> bugs = new ArrayList<OpenStreetNote>(); List<OpenStreetNote> bugs = new ArrayList<OpenStreetNote>();
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append("http://api.openstreetmap.org/api/0.6/notes?bbox="); //$NON-NLS-1$ b.append(SITE_API + "api/0.6/notes?bbox="); //$NON-NLS-1$
b.append(leftLongitude); //$NON-NLS-1$ b.append(leftLongitude); //$NON-NLS-1$
b.append(",").append(bottomLatitude); //$NON-NLS-1$ b.append(",").append(bottomLatitude); //$NON-NLS-1$
b.append(",").append(rightLongitude); //$NON-NLS-1$ b.append(",").append(rightLongitude); //$NON-NLS-1$

View file

@ -22,7 +22,21 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
private static final Log log = PlatformUtil.getLog(OsmBugsRemoteUtil.class); private static final Log log = PlatformUtil.getLog(OsmBugsRemoteUtil.class);
private final static String SITE_API = "http://api.openstreetmap.org/api/0.6/notes"; //$NON-NLS-1$ static String getNotesApi()
{
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
String RETURN_API;
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
RETURN_API = "https://api.openstreetmap.org/api/0.6/notes";
}
else {
RETURN_API = "http://api.openstreetmap.org/api/0.6/notes";
}
return RETURN_API;
}
private OsmandApplication app; private OsmandApplication app;
private OsmandSettings settings; private OsmandSettings settings;
@ -35,7 +49,7 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
@Override @Override
public String createNewBug(double latitude, double longitude, String text){ public String createNewBug(double latitude, double longitude, String text){
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append(SITE_API).append("?"); //$NON-NLS-1$ b.append(getNotesApi()).append("?"); //$NON-NLS-1$
b.append("lat=").append(latitude); //$NON-NLS-1$ b.append("lat=").append(latitude); //$NON-NLS-1$
b.append("&lon=").append(longitude); //$NON-NLS-1$ b.append("&lon=").append(longitude); //$NON-NLS-1$
b.append("&text=").append(URLEncoder.encode(text)); //$NON-NLS-1$ b.append("&text=").append(URLEncoder.encode(text)); //$NON-NLS-1$
@ -45,7 +59,7 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
@Override @Override
public String addingComment(long id, String text){ public String addingComment(long id, String text){
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append(SITE_API).append("/"); b.append(getNotesApi()).append("/");
b.append(id); //$NON-NLS-1$ b.append(id); //$NON-NLS-1$
b.append("/comment?text=").append(URLEncoder.encode(text)); //$NON-NLS-1$ b.append("/comment?text=").append(URLEncoder.encode(text)); //$NON-NLS-1$
return editingPOI(b.toString(), "POST", "adding comment"); //$NON-NLS-1$ return editingPOI(b.toString(), "POST", "adding comment"); //$NON-NLS-1$
@ -54,7 +68,7 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
@Override @Override
public String closingBug(long id, String text){ public String closingBug(long id, String text){
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append(SITE_API).append("/"); b.append(getNotesApi()).append("/");
b.append(id); //$NON-NLS-1$ b.append(id); //$NON-NLS-1$
b.append("/close?text=").append(URLEncoder.encode(text)); //$NON-NLS-1$ b.append("/close?text=").append(URLEncoder.encode(text)); //$NON-NLS-1$
return editingPOI(b.toString(), "POST", "close bug") ; //$NON-NLS-1$ return editingPOI(b.toString(), "POST", "close bug") ; //$NON-NLS-1$