mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-14 00:30:31 +00:00
AbstractHafasClientInterfaceProvider: Allow configuration of the endpoint.
This commit is contained in:
parent
389cd53bbf
commit
db7b4c8a0d
1 changed files with 14 additions and 8 deletions
|
@ -82,17 +82,18 @@ import okhttp3.HttpUrl;
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafasProvider {
|
public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafasProvider {
|
||||||
public HttpUrl mgateEndpoint;
|
private final HttpUrl apiBase;
|
||||||
|
private String apiEndpoint = "mgate.exe";
|
||||||
@Nullable
|
@Nullable
|
||||||
public String apiVersion;
|
private String apiVersion;
|
||||||
@Nullable
|
@Nullable
|
||||||
public String apiAuthorization;
|
private String apiAuthorization;
|
||||||
@Nullable
|
@Nullable
|
||||||
public String apiClient;
|
private String apiClient;
|
||||||
@Nullable
|
@Nullable
|
||||||
public byte[] requestChecksumSalt;
|
private byte[] requestChecksumSalt;
|
||||||
@Nullable
|
@Nullable
|
||||||
public byte[] requestMicMacSalt;
|
private byte[] requestMicMacSalt;
|
||||||
|
|
||||||
private static final String SERVER_PRODUCT = "hci";
|
private static final String SERVER_PRODUCT = "hci";
|
||||||
private static final HashFunction MD5 = Hashing.md5();
|
private static final HashFunction MD5 = Hashing.md5();
|
||||||
|
@ -101,7 +102,12 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
|
||||||
public AbstractHafasClientInterfaceProvider(final NetworkId network, final HttpUrl apiBase,
|
public AbstractHafasClientInterfaceProvider(final NetworkId network, final HttpUrl apiBase,
|
||||||
final Product[] productsMap) {
|
final Product[] productsMap) {
|
||||||
super(network, productsMap);
|
super(network, productsMap);
|
||||||
this.mgateEndpoint = apiBase.newBuilder().addPathSegment("mgate.exe").build();
|
this.apiBase = checkNotNull(apiBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AbstractHafasClientInterfaceProvider setApiEndpoint(final String apiEndpoint) {
|
||||||
|
this.apiEndpoint = checkNotNull(apiEndpoint);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractHafasClientInterfaceProvider setApiVersion(final String apiVersion) {
|
protected AbstractHafasClientInterfaceProvider setApiVersion(final String apiVersion) {
|
||||||
|
@ -658,7 +664,7 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpUrl requestUrl(final String body) {
|
private HttpUrl requestUrl(final String body) {
|
||||||
final HttpUrl.Builder url = checkNotNull(mgateEndpoint).newBuilder();
|
final HttpUrl.Builder url = apiBase.newBuilder().addPathSegment(apiEndpoint);
|
||||||
if (requestChecksumSalt != null) {
|
if (requestChecksumSalt != null) {
|
||||||
final HashCode checksum = MD5.newHasher().putString(body, Charsets.UTF_8).putBytes(requestChecksumSalt)
|
final HashCode checksum = MD5.newHasher().putString(body, Charsets.UTF_8).putBytes(requestChecksumSalt)
|
||||||
.hash();
|
.hash();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue