diff --git a/CHANGELOG.md b/CHANGELOG.md index fc5c125..406d062 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm # Changelog for gxREST +## [v2.0.0-SNAPSHOT] + +- removed all the old providers +- removed set of gcube headers ## [v1.2.0] diff --git a/gxHTTP/CHANGELOG.md b/gxHTTP/CHANGELOG.md index 01bb1fd..55cbced 100644 --- a/gxHTTP/CHANGELOG.md +++ b/gxHTTP/CHANGELOG.md @@ -2,6 +2,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm # Changelog for gxHTTP +## [v2.0.0-SNAPSHOT] + +- removed all the old providers +- removed set of gcube headers + ## [v1.2.0] diff --git a/gxHTTP/pom.xml b/gxHTTP/pom.xml index 1c3e5aa..5881016 100644 --- a/gxHTTP/pom.xml +++ b/gxHTTP/pom.xml @@ -7,7 +7,7 @@ org.gcube.common gxREST - 1.2.0 + 2.0.0-SNAPSHOT gxHTTP @@ -28,11 +28,6 @@ - - org.gcube.common - authorization-client - - org.slf4j slf4j-api diff --git a/gxHTTP/src/main/java/org/gcube/common/gxhttp/reference/GXConnection.java b/gxHTTP/src/main/java/org/gcube/common/gxhttp/reference/GXConnection.java index 1fb775a..44383db 100644 --- a/gxHTTP/src/main/java/org/gcube/common/gxhttp/reference/GXConnection.java +++ b/gxHTTP/src/main/java/org/gcube/common/gxhttp/reference/GXConnection.java @@ -14,8 +14,6 @@ import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; -import org.gcube.common.authorization.library.provider.AccessTokenProvider; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.gxhttp.request.GXHTTPStringRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -119,28 +117,11 @@ public class GXConnection { public HttpURLConnection send(HTTPMETHOD method) throws Exception { return send(this.buildURL(), method); } - - private HttpURLConnection addGCubeAuthorizationToken(HttpURLConnection uConn) throws Exception { - if (!this.extCall) { - String oldGcubeAuthToken = SecurityTokenProvider.instance.get(); - if (Objects.isNull(oldGcubeAuthToken) || oldGcubeAuthToken.isEmpty()) { - String umaToken = AccessTokenProvider.instance.get(); - if(Objects.isNull(umaToken) || umaToken.isEmpty()) { - throw new IllegalStateException("The security token in the current environment is null."); - }else { - uConn.setRequestProperty("Authorization", "Bearer " + umaToken); - } - } else { - uConn.setRequestProperty(org.gcube.common.authorization.client.Constants.TOKEN_HEADER_ENTRY, oldGcubeAuthToken); - } - } - return uConn; - } - + private HttpURLConnection send(URL url, HTTPMETHOD method) throws Exception { HttpURLConnection uConn = (HttpURLConnection) url.openConnection(); - uConn = addGCubeAuthorizationToken(uConn); + //uConn = addGCubeAuthorizationToken(uConn); uConn.setDoOutput(true); // uConn.setRequestProperty("Content-type", APPLICATION_JSON_CHARSET_UTF_8); diff --git a/gxHTTP/src/main/java/org/gcube/common/gxhttp/reference/GXHTTP.java b/gxHTTP/src/main/java/org/gcube/common/gxhttp/reference/GXHTTP.java index 19faf1a..7ab2d69 100644 --- a/gxHTTP/src/main/java/org/gcube/common/gxhttp/reference/GXHTTP.java +++ b/gxHTTP/src/main/java/org/gcube/common/gxhttp/reference/GXHTTP.java @@ -85,17 +85,6 @@ public interface GXHTTP { * @throws Exception */ RESPONSE connect() throws Exception; - - /** - * Overrides the default security token. - * @param token the new token - */ - void setSecurityToken(String token); - - /** - * States if the service being called in an external service (not gCube). - * @param ext true if external, false otherwise - */ - void isExternalCall(boolean ext); + } diff --git a/gxHTTP/src/main/java/org/gcube/common/gxhttp/reference/GXHTTPRequestBuilder.java b/gxHTTP/src/main/java/org/gcube/common/gxhttp/reference/GXHTTPRequestBuilder.java index 089f0a0..dce3961 100644 --- a/gxHTTP/src/main/java/org/gcube/common/gxhttp/reference/GXHTTPRequestBuilder.java +++ b/gxHTTP/src/main/java/org/gcube/common/gxhttp/reference/GXHTTPRequestBuilder.java @@ -78,24 +78,7 @@ public class GXHTTPRequestBuilder { public static final String UUID_REGEX = "^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}-[a-fA-F0-9]{8,9}){1}$"; - - /** - * Overrides the default security token. - * - * @param token - */ - public void setSecurityToken(String token) { - if (!this.connection.isExtCall()) { - if(Pattern.matches(UUID_REGEX, token)) { - this.connection.setProperty(org.gcube.common.authorization.client.Constants.TOKEN_HEADER_ENTRY, token); - }else { - this.connection.setProperty("Authorization", "Bearer " + token); - } - }else { - throw new UnsupportedOperationException("Cannot set the security token on an external call"); - } - } - + /** * Add headers to the request. * diff --git a/gxHTTP/src/main/java/org/gcube/common/gxhttp/request/GXHTTPCommonRequest.java b/gxHTTP/src/main/java/org/gcube/common/gxhttp/request/GXHTTPCommonRequest.java index e2bec16..37a8294 100644 --- a/gxHTTP/src/main/java/org/gcube/common/gxhttp/request/GXHTTPCommonRequest.java +++ b/gxHTTP/src/main/java/org/gcube/common/gxhttp/request/GXHTTPCommonRequest.java @@ -84,12 +84,6 @@ class GXHTTPCommonRequest { return builder.connect(); } - /* (non-Javadoc) - * @see org.gcube.common.gxhttp.reference.GXHTTP#setSecurityToken(java.lang.String) - */ - public void setSecurityToken(String token) { - builder.setSecurityToken(token); - } /* (non-Javadoc) * @see org.gcube.common.gxhttp.reference.GXHTTP#isExternalCall(boolean) diff --git a/gxHTTP/src/test/java/org/gcube/common/gxhttp/GXHTTPStringRequestTest.java b/gxHTTP/src/test/java/org/gcube/common/gxhttp/GXHTTPStringRequestTest.java index e281c87..7200c68 100644 --- a/gxHTTP/src/test/java/org/gcube/common/gxhttp/GXHTTPStringRequestTest.java +++ b/gxHTTP/src/test/java/org/gcube/common/gxhttp/GXHTTPStringRequestTest.java @@ -10,15 +10,9 @@ import java.util.Map; import java.util.Properties; import java.util.WeakHashMap; -import org.gcube.common.authorization.client.Constants; -import org.gcube.common.authorization.client.exceptions.ObjectNotFound; -import org.gcube.common.authorization.library.AuthorizationEntry; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.gxhttp.request.GXHTTPStringRequest; import org.gcube.common.gxhttp.util.ContentUtils; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; @@ -56,30 +50,6 @@ public class GXHTTPStringRequestTest { } } - @BeforeClass - public static void beforeClass() throws Exception { - setContext(DEFAULT_TEST_SCOPE); - } - - public static void setContext(String token) throws ObjectNotFound, Exception { - if (DEFAULT_TEST_SCOPE.isEmpty()) { - skipTest = true; - return; - } - SecurityTokenProvider.instance.set(token); - } - - public static String getCurrentScope(String token) throws ObjectNotFound, Exception { - AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token); - String context = authorizationEntry.getContext(); - return context; - } - - @AfterClass - public static void afterClass() throws Exception { - SecurityTokenProvider.instance.reset(); - } - /** * Test method for {@link org.gcube.common.gxhttp.request.GXHTTPStringRequest#newRequest(java.lang.String)}. */ diff --git a/gxJRS/CHANGELOG.md b/gxJRS/CHANGELOG.md index 6f3ca69..747c938 100644 --- a/gxJRS/CHANGELOG.md +++ b/gxJRS/CHANGELOG.md @@ -2,6 +2,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm # Changelog for gxJRS +## [v2.0.0-SNAPSHOT] + +- removed all the old providers +- removed set of gcube headers ## [v1.2.0] diff --git a/gxJRS/pom.xml b/gxJRS/pom.xml index c3311e0..12caa01 100644 --- a/gxJRS/pom.xml +++ b/gxJRS/pom.xml @@ -5,7 +5,7 @@ org.gcube.common gxREST - 1.2.0 + 2.0.0-SNAPSHOT gxJRS @@ -37,7 +37,7 @@ org.gcube.distribution gcube-bom - 2.0.1 + 3.0.0-SNAPSHOT pom import diff --git a/gxJRS/src/main/java/org/gcube/common/gxrest/request/GXHTTPStreamRequest.java b/gxJRS/src/main/java/org/gcube/common/gxrest/request/GXHTTPStreamRequest.java index 73c9943..626dab8 100644 --- a/gxJRS/src/main/java/org/gcube/common/gxrest/request/GXHTTPStreamRequest.java +++ b/gxJRS/src/main/java/org/gcube/common/gxrest/request/GXHTTPStreamRequest.java @@ -137,22 +137,6 @@ public class GXHTTPStreamRequest implements GXHTTP { return new GXInboundResponse(builder.connect()); } - /* (non-Javadoc) - * @see org.gcube.common.gxrest.request.GXHTTP#setSecurityToken(java.lang.String) - */ - @Override - public void setSecurityToken(String token) { - builder.setSecurityToken(token); - } - - /* (non-Javadoc) - * @see org.gcube.common.gxrest.request.GXHTTP#isExternalCall(boolean) - */ - @Override - public void isExternalCall(boolean ext) { - builder.isExternalCall(ext); - - } /** * @param string diff --git a/gxJRS/src/main/java/org/gcube/common/gxrest/request/GXWebTargetAdapterRequest.java b/gxJRS/src/main/java/org/gcube/common/gxrest/request/GXWebTargetAdapterRequest.java index 98a4c13..a7f2222 100644 --- a/gxJRS/src/main/java/org/gcube/common/gxrest/request/GXWebTargetAdapterRequest.java +++ b/gxJRS/src/main/java/org/gcube/common/gxrest/request/GXWebTargetAdapterRequest.java @@ -7,8 +7,8 @@ import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Map; -import java.util.Objects; import java.util.Map.Entry; +import java.util.Objects; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; @@ -25,7 +25,6 @@ import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.gxhttp.reference.GXConnection; import org.gcube.common.gxhttp.reference.GXHTTP; import org.gcube.common.gxrest.response.inbound.GXInboundResponse; @@ -45,7 +44,6 @@ public class GXWebTargetAdapterRequest implements GXHTTP,GXInboundResp private static final Logger logger = LoggerFactory.getLogger(GXWebTargetAdapterRequest.class); private MediaType[] mediaType; MultivaluedMap headers = new MultivaluedHashMap(); - private boolean extCall = false; /** * Creates a new request. @@ -121,26 +119,9 @@ public class GXWebTargetAdapterRequest implements GXHTTP,GXInboundResp } } this.adaptee = client.target(address); - this.headers.add(org.gcube.common.authorization.client.Constants.TOKEN_HEADER_ENTRY, - SecurityTokenProvider.instance.get()); this.headers.add("User-Agent", this.getClass().getSimpleName()); } - /** - * Overrides the default security token. - * - * @param token - * the new token - */ - @Override - public void setSecurityToken(String token) { - if (!this.extCall) - this.headers.add(org.gcube.common.authorization.client.Constants.TOKEN_HEADER_ENTRY, token); - - else - throw new UnsupportedOperationException("Cannot set the security token on an external call"); - } - /** * Sets the identity user agent associated to the request. * @@ -405,13 +386,4 @@ public class GXWebTargetAdapterRequest implements GXHTTP,GXInboundResp throw new UnsupportedOperationException("WebTarget does not support CONNECT"); } - /* - * (non-Javadoc) - * - * @see org.gcube.common.gxrest.request.GXHTTP#isExternalCall(boolean) - */ - @Override - public void isExternalCall(boolean ext) { - this.extCall = ext; - } } diff --git a/gxJRS/src/test/java/org/gcube/common/gxrest/request/GXHTTPStringRequestTest.java b/gxJRS/src/test/java/org/gcube/common/gxrest/request/GXHTTPStringRequestTest.java index dc5e160..cdef15a 100644 --- a/gxJRS/src/test/java/org/gcube/common/gxrest/request/GXHTTPStringRequestTest.java +++ b/gxJRS/src/test/java/org/gcube/common/gxrest/request/GXHTTPStringRequestTest.java @@ -13,7 +13,6 @@ import org.gcube.com.fasterxml.jackson.databind.JsonMappingException; import org.gcube.common.authorization.client.Constants; import org.gcube.common.authorization.client.exceptions.ObjectNotFound; import org.gcube.common.authorization.library.AuthorizationEntry; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.gxrest.response.inbound.GXInboundResponse; import org.junit.AfterClass; import org.junit.Before; @@ -67,7 +66,7 @@ public class GXHTTPStringRequestTest { skipTest = true; return; } - SecurityTokenProvider.instance.set(token); + //SecurityTokenProvider.instance.set(token); } public static String getCurrentScope(String token) throws ObjectNotFound, Exception { @@ -78,7 +77,7 @@ public class GXHTTPStringRequestTest { @AfterClass public static void afterClass() throws Exception { - SecurityTokenProvider.instance.reset(); + //SecurityTokenProvider.instance.reset(); } /** diff --git a/gxJRS/src/test/java/org/gcube/common/gxrest/request/GXWebTargetAdapterHTTPSRequestTest.java b/gxJRS/src/test/java/org/gcube/common/gxrest/request/GXWebTargetAdapterHTTPSRequestTest.java index e9b87e5..573986a 100644 --- a/gxJRS/src/test/java/org/gcube/common/gxrest/request/GXWebTargetAdapterHTTPSRequestTest.java +++ b/gxJRS/src/test/java/org/gcube/common/gxrest/request/GXWebTargetAdapterHTTPSRequestTest.java @@ -1,9 +1,20 @@ package org.gcube.common.gxrest.request; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; +import java.util.Properties; +import java.util.WeakHashMap; + +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.MediaType; + import org.gcube.common.authorization.client.Constants; import org.gcube.common.authorization.client.exceptions.ObjectNotFound; import org.gcube.common.authorization.library.AuthorizationEntry; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.gxrest.response.inbound.GXInboundResponse; import org.junit.AfterClass; import org.junit.Before; @@ -12,17 +23,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.BlockJUnit4ClassRunner; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.MediaType; -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; -import java.util.Properties; -import java.util.WeakHashMap; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - /** * Test cases for {@link GXWebTargetAdapterRequest#newHTTPSRequest(String)} * @@ -70,7 +70,7 @@ public class GXWebTargetAdapterHTTPSRequestTest { skipTest = true; return; } else { - SecurityTokenProvider.instance.set(token); + //SecurityTokenProvider.instance.set(token); } } @@ -82,7 +82,7 @@ public class GXWebTargetAdapterHTTPSRequestTest { @AfterClass public static void afterClass() throws Exception { - SecurityTokenProvider.instance.reset(); + //SecurityTokenProvider.instance.reset(); } /** diff --git a/gxJRS/src/test/java/org/gcube/common/gxrest/request/GXWebTargetAdapterRequestTest.java b/gxJRS/src/test/java/org/gcube/common/gxrest/request/GXWebTargetAdapterRequestTest.java index 2b97336..bdc8d18 100644 --- a/gxJRS/src/test/java/org/gcube/common/gxrest/request/GXWebTargetAdapterRequestTest.java +++ b/gxJRS/src/test/java/org/gcube/common/gxrest/request/GXWebTargetAdapterRequestTest.java @@ -1,6 +1,7 @@ package org.gcube.common.gxrest.request; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.IOException; import java.io.InputStream; @@ -11,10 +12,7 @@ import java.util.WeakHashMap; import javax.ws.rs.client.Entity; import javax.ws.rs.core.MediaType; -import org.gcube.common.authorization.client.Constants; import org.gcube.common.authorization.client.exceptions.ObjectNotFound; -import org.gcube.common.authorization.library.AuthorizationEntry; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.gxrest.response.inbound.GXInboundResponse; import org.junit.AfterClass; import org.junit.Before; @@ -67,19 +65,14 @@ public class GXWebTargetAdapterRequestTest { skipTest = true; return; } else { - SecurityTokenProvider.instance.set(token); + //SecurityTokenProvider.instance.set(token); } } - public static String getCurrentScope(String token) throws ObjectNotFound, Exception { - AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token); - String context = authorizationEntry.getContext(); - return context; - } - + @AfterClass public static void afterClass() throws Exception { - SecurityTokenProvider.instance.reset(); + //SecurityTokenProvider.instance.reset(); } /** diff --git a/pom.xml b/pom.xml index 024ac97..0f4228b 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.gcube.common gxREST - 1.2.0 + 2.0.0-SNAPSHOT pom gCube eXtensions to REST gCube eXtensions to REST