Skip to content

Commit

Permalink
IM-280 Read RIDB api key from credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
inigo-cobian committed Feb 7, 2024
1 parent 41a012f commit 2cdddce
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.List;
import java.util.Map;

import org.integratedmodelling.klab.Authentication;
import org.integratedmodelling.klab.Urn;
import org.integratedmodelling.klab.Version;
import org.integratedmodelling.klab.api.data.IGeometry;
Expand All @@ -24,6 +25,8 @@
import org.integratedmodelling.klab.components.geospace.extents.Projection;
import org.integratedmodelling.klab.components.geospace.extents.Shape;
import org.integratedmodelling.klab.data.resources.Resource;
import org.integratedmodelling.klab.exceptions.KlabMissingCredentialsException;
import org.integratedmodelling.klab.rest.ExternalAuthenticationCredentials;
import org.integratedmodelling.klab.rest.ResourceReference;
import org.integratedmodelling.klab.scale.Scale;

Expand Down Expand Up @@ -86,8 +89,11 @@ public void encodeData(Urn urn, Builder builder, IGeometry geometry, IContextual
parameters.put(RADIUS, "0.0");
}

// API key must be defined as parameter in the URN
String apiKey = urn.getParameters().containsKey(APIKEY) ? urn.getParameters().get(APIKEY) : null;
ExternalAuthenticationCredentials credentials = Authentication.INSTANCE.getCredentials("https://ridb.recreation.gov/api/v1");
if (credentials == null) {
throw new KlabMissingCredentialsException("API key for RecreationIDB is missing.");
}
String apiKey = credentials.getCredentials().get(0);

IScale scale = geometry instanceof IScale ? (IScale) geometry : Scale.create(geometry);

Expand Down

0 comments on commit 2cdddce

Please sign in to comment.