Migrated lib to smartgears 4

This commit is contained in:
Luca Frosini 2023-02-22 15:07:38 +01:00
parent d80c0f93e4
commit afc07f92a3
4 changed files with 20 additions and 12 deletions

View File

@ -2,6 +2,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for Common Utility
## [v2.0.0-SNAPSHOT]
- Ported library to smartgears 4
## [v1.0.0-SNAPSHOT]
- First Version

View File

@ -8,7 +8,7 @@
</parent>
<groupId>org.gcube.common</groupId>
<artifactId>common-utility</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<name>Common Utility</name>
<description>This library provides utility functions for broken APIs between smartgears 3 and 4, so only one component must be released twice.</description>
@ -27,7 +27,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -36,8 +36,8 @@
<dependencies>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope</artifactId>
<groupId>org.gcube.common</groupId>
<artifactId>common-security</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>

View File

@ -1,15 +1,14 @@
package org.gcube.common.context;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.security.providers.SecretManagerProvider;
/**
* @author Luca Frosini (ISTI - CNR)
*/
@SuppressWarnings("deprecation")
public class ContextUtility {
public static String getCurrentContextFullName() {
String context = ScopeProvider.instance.get();
String context = SecretManagerProvider.instance.get().getContext();
return context;
}

View File

@ -1,6 +1,10 @@
package org.gcube.common.http;
import java.util.Map;
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.common.security.secrets.Secret;
/**
* @author Luca Frosini (ISTI - CNR)
@ -9,11 +13,11 @@ public class GXHTTPUtility {
public static GXHTTPStringRequest getGXHTTPStringRequest(String address) {
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
// Secret secret = SecretManagerProvider.instance.get();
// Map<String, String> authorizationHeaders = secret.getHTTPAuthorizationHeaders();
// for(String key : authorizationHeaders.keySet()) {
// gxHTTPStringRequest.header(key, authorizationHeaders.get(key));
// }
Secret secret = SecretManagerProvider.instance.get();
Map<String, String> authorizationHeaders = secret.getHTTPAuthorizationHeaders();
for(String key : authorizationHeaders.keySet()) {
gxHTTPStringRequest.header(key, authorizationHeaders.get(key));
}
return gxHTTPStringRequest;
}