Permalink
Browse files

Tile source: added authorization parameter (#1081)

  • Loading branch information...
roemmer authored and devemux86 committed Aug 20, 2018
1 parent 59d06f3 commit bf7b035af4c565de55dd667e215782a72872ec38
@@ -2,6 +2,7 @@
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2014 Ludwig M Brinckmann
* Copyright 2016 devemux86
* Copyright 2018 iPSAlex
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -22,6 +23,11 @@
import java.net.URL;
class InvalidTileSource implements TileSource {
@Override
public String getAuthorization() {
throw new AssertionError();
}
@Override
public long getDefaultTimeToLive() {
throw new AssertionError();
@@ -2,6 +2,7 @@
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2014 Ludwig M Brinckmann
* Copyright 2016 devemux86
* Copyright 2018 iPSAlex
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -61,6 +62,9 @@ TileBitmap downloadImage() throws IOException {
if (this.downloadJob.tileSource.getReferer() != null) {
urlConnection.setRequestProperty("Referer", this.downloadJob.tileSource.getReferer());
}
if (this.downloadJob.tileSource.getAuthorization() != null) {
urlConnection.setRequestProperty("Authorization", this.downloadJob.tileSource.getAuthorization());
}
if (urlConnection instanceof HttpURLConnection) {
((HttpURLConnection) urlConnection).setInstanceFollowRedirects(this.downloadJob.tileSource.isFollowRedirects());
}
@@ -2,6 +2,7 @@
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2014 Ludwig M Brinckmann
* Copyright 2014-2018 devemux86
* Copyright 2018 iPSAlex
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -34,6 +35,7 @@
private static final int TIMEOUT_READ = 10000;
protected String apiKey;
protected String authorization;
/**
* The default time-to-live (TTL) for cached tiles (one day, or 86,400,000 milliseconds).
*/
@@ -85,6 +87,11 @@ public String getApiKey() {
return apiKey;
}
@Override
public String getAuthorization() {
return authorization;
}
/**
* Returns the default time-to-live (TTL) for cached tiles.
*/
@@ -139,6 +146,10 @@ public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public void setAuthorization(String authorization) {
this.authorization = authorization;
}
public void setFollowRedirects(boolean followRedirects) {
this.followRedirects = followRedirects;
}
@@ -2,6 +2,7 @@
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2014 Ludwig M Brinckmann
* Copyright 2016 devemux86
* Copyright 2018 iPSAlex
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -22,6 +23,11 @@
import java.net.URL;
public interface TileSource {
/**
* @return the Authorization (may be null).
*/
String getAuthorization();
/**
* Returns the default time-to-live (TTL) for cached tiles.
*/

0 comments on commit bf7b035

Please sign in to comment.