Remove org.apache.commons.codec.binary.Base64 depends; I'm using java.util.Base64
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-access/gcube-geoserver-connector@150782 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a61f0ac59d
commit
4d2d46cd7d
|
@ -5,7 +5,7 @@ import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import java.util.Base64;
|
||||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||||
|
@ -139,7 +139,7 @@ public class GeoServerConnectorRequestHandler extends RequestHandler {
|
||||||
logger.warn("Get token from basic authorization header");
|
logger.warn("Get token from basic authorization header");
|
||||||
// header = Authorization: Basic base64credentials
|
// header = Authorization: Basic base64credentials
|
||||||
String base64Credentials = StringUtils.delete(authorization, AuthenticationUtils.BASIC);
|
String base64Credentials = StringUtils.delete(authorization, AuthenticationUtils.BASIC);
|
||||||
String credentials = new String(Base64.decodeBase64(StringUtils.trimWhitespace(base64Credentials)));
|
String credentials = new String(Base64.getDecoder().decode(StringUtils.trimWhitespace(base64Credentials)));
|
||||||
|
|
||||||
// credentials = username:token
|
// credentials = username:token
|
||||||
final String[] values = credentials.split(":", 2);
|
final String[] values = credentials.split(":", 2);
|
||||||
|
@ -186,9 +186,11 @@ public class GeoServerConnectorRequestHandler extends RequestHandler {
|
||||||
DiscoveryClient<GCoreEndpoint> client = ICFactory.clientFor(GCoreEndpoint.class);
|
DiscoveryClient<GCoreEndpoint> client = ICFactory.clientFor(GCoreEndpoint.class);
|
||||||
|
|
||||||
List<GCoreEndpoint> gCoreEndpoints = client.submit(query);
|
List<GCoreEndpoint> gCoreEndpoints = client.submit(query);
|
||||||
|
int size = gCoreEndpoints.size();
|
||||||
|
logger.warn("gCoreEndpoints size = " + size);
|
||||||
|
|
||||||
if (gCoreEndpoints.size() > 0) {
|
if (size > 0) {
|
||||||
GCoreEndpoint gCoreEndpoint = gCoreEndpoints.get(0);
|
GCoreEndpoint gCoreEndpoint = gCoreEndpoints.get(size-1);
|
||||||
return gCoreEndpoint.profile().endpointMap().get("org.gcube.spatial.data.sdi.SDIService").uri()
|
return gCoreEndpoint.profile().endpointMap().get("org.gcube.spatial.data.sdi.SDIService").uri()
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import java.util.Base64;
|
||||||
import org.gcube.data.access.connector.utils.AuthenticationUtils;
|
import org.gcube.data.access.connector.utils.AuthenticationUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -41,7 +41,7 @@ public class GeoServerFilter implements Filter {
|
||||||
// set authorization header
|
// set authorization header
|
||||||
String token = username + ":" + password;
|
String token = username + ":" + password;
|
||||||
String basic_authentication = AuthenticationUtils.BASIC + AuthenticationUtils.WHITESPACE
|
String basic_authentication = AuthenticationUtils.BASIC + AuthenticationUtils.WHITESPACE
|
||||||
+ Base64.encodeBase64String(token.getBytes());
|
+ Base64.getEncoder().encodeToString(token.getBytes());
|
||||||
|
|
||||||
request.addHeader(AuthenticationUtils.AUTHORIZATION, basic_authentication);
|
request.addHeader(AuthenticationUtils.AUTHORIZATION, basic_authentication);
|
||||||
logger.warn("Added authorization header : " + request.getHeader(AuthenticationUtils.AUTHORIZATION));
|
logger.warn("Added authorization header : " + request.getHeader(AuthenticationUtils.AUTHORIZATION));
|
||||||
|
|
Loading…
Reference in New Issue