diff --git a/src/main/java/org/gcube/data/access/connector/GeoServerConnectorRequestHandler.java b/src/main/java/org/gcube/data/access/connector/GeoServerConnectorRequestHandler.java index 07a5800..64f4b03 100644 --- a/src/main/java/org/gcube/data/access/connector/GeoServerConnectorRequestHandler.java +++ b/src/main/java/org/gcube/data/access/connector/GeoServerConnectorRequestHandler.java @@ -3,6 +3,8 @@ package org.gcube.data.access.connector; import javax.servlet.http.HttpServletRequest; import javax.xml.bind.annotation.XmlRootElement; +import org.gcube.data.access.connector.rest.GCubeRestClient; +import org.gcube.data.access.connector.rest.entity.AccessibleCredentialsEntity; import org.gcube.smartgears.handlers.application.RequestEvent; import org.gcube.smartgears.handlers.application.RequestHandler; import org.slf4j.Logger; @@ -31,9 +33,27 @@ public class GeoServerConnectorRequestHandler extends RequestHandler { System.out.println("Handling request"); HttpServletRequest httpServletRequest = e.request(); - //TODO get credentials from IS + //TODO get these info from IS + System.out.println("Call to REST client"); + this.logger.info("Call to REST client"); + String endpoint = "https://sdi-d-d4s.d4science.org/sdi-service/gcube/service/GeoServer/credentials/"; + String host = "geoserver1-d-d4s.d4science.org"; +// String host = "http://geoserver1-d-d4s.d4science.org"; +// String host = httpServletRequest.getServerName(); + String token = "feda0617-cd9d-4841-b6f0-e047da5d32ed-98187548"; + //https://geoserver1-d-d4s.d4science.org/geoserver + //https://sdi-d-d4s.d4science.org/sdi-service/gcube/service/GeoServer/credentials/geoserver1-d-d4s.d4science.org?gcube-token=feda0617-cd9d-4841-b6f0-e047da5d32ed-98187548 + System.out.println( "Remote Host: " + httpServletRequest.getRemoteHost()); + System.out.println("Server Name: " +httpServletRequest.getServerName()); + System.out.println("Local Name: " +httpServletRequest.getLocalName()); + + GCubeRestClient client = new GCubeRestClient(); + AccessibleCredentialsEntity accessibleCredentials = client.getAccessibleCredentials(endpoint, host, token); + System.out.println("accessibleCredentials: " + accessibleCredentials.getUsername() + " " + accessibleCredentials.getPassword()); httpServletRequest.setAttribute(AuthenticationUtils.USERNAME, "admin"); httpServletRequest.setAttribute(AuthenticationUtils.PASSWORD, "geoserver"); +// httpServletRequest.setAttribute(AuthenticationUtils.USERNAME, accessibleCredentials.getUsername()); +// httpServletRequest.setAttribute(AuthenticationUtils.PASSWORD, accessibleCredentials.getPassword()); } @Override