custom logging filter
This commit is contained in:
parent
24278442e3
commit
4cf3a730db
|
@ -2,6 +2,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||||
|
|
||||||
# Changelog for org.gcube.spatial.data.ws-thredds
|
# Changelog for org.gcube.spatial.data.ws-thredds
|
||||||
|
|
||||||
|
## [v0.2.6-SNAPSHOT]
|
||||||
|
Fixes #21265
|
||||||
|
|
||||||
## [v0.2.5]
|
## [v0.2.5]
|
||||||
Fixes #21265
|
Fixes #21265
|
||||||
|
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -8,7 +8,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.gcube.spatial.data</groupId>
|
<groupId>org.gcube.spatial.data</groupId>
|
||||||
<artifactId>ws-thredds</artifactId>
|
<artifactId>ws-thredds</artifactId>
|
||||||
<version>0.2.5</version>
|
<version>0.2.6-SNAPSHOT</version>
|
||||||
<name>ws-thredds</name>
|
<name>ws-thredds</name>
|
||||||
<description>prototype of WS integration with data-transfer for Thredds pubblication</description>
|
<description>prototype of WS integration with data-transfer for Thredds pubblication</description>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.gcube.usecases.ws.thredds.engine.impl;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.ClientRequestContext;
|
||||||
|
import javax.ws.rs.client.ClientRequestFilter;
|
||||||
|
|
||||||
|
import org.gcube.common.calls.Call;
|
||||||
|
import org.gcube.common.calls.Interceptors;
|
||||||
|
import org.gcube.common.calls.Request;
|
||||||
|
import org.gcube.data.transfer.library.utils.ScopeUtils;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class CustomAuthorizationFilter implements ClientRequestFilter {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void filter(final ClientRequestContext rc) throws IOException {
|
||||||
|
if (ScopeUtils.getCurrentScope()!=null){
|
||||||
|
Request requestContext = Interceptors.executeRequestChain(new Call());
|
||||||
|
|
||||||
|
for (Entry<String, String> entry: requestContext.getHeaders()){
|
||||||
|
log.debug("Copying HTTP request header {} : {}",entry.getKey(),entry.getValue());
|
||||||
|
rc.getHeaders().put(entry.getKey(), Collections.singletonList((Object)entry.getValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,7 +23,6 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||||
import org.gcube.data.transfer.library.DataTransferClient;
|
import org.gcube.data.transfer.library.DataTransferClient;
|
||||||
import org.gcube.data.transfer.library.TransferResult;
|
import org.gcube.data.transfer.library.TransferResult;
|
||||||
import org.gcube.data.transfer.library.client.AuthorizationFilter;
|
|
||||||
import org.gcube.data.transfer.library.faults.DestinationNotSetException;
|
import org.gcube.data.transfer.library.faults.DestinationNotSetException;
|
||||||
import org.gcube.data.transfer.library.faults.FailedTransferException;
|
import org.gcube.data.transfer.library.faults.FailedTransferException;
|
||||||
import org.gcube.data.transfer.library.faults.InitializationException;
|
import org.gcube.data.transfer.library.faults.InitializationException;
|
||||||
|
@ -338,7 +337,7 @@ public class ThreddsController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Client getWebClient() {
|
private static Client getWebClient() {
|
||||||
return ClientBuilder.newClient(new ClientConfig().register(AuthorizationFilter.class))
|
return ClientBuilder.newClient(new ClientConfig().register(CustomAuthorizationFilter.class))
|
||||||
.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
|
.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue