Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: merge conflict #8

Merged
merged 7 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Please refer to the official [site](https://github.com/ionos-cloud/edc-ionos-s3)

## Based on the following

- [https://github.com/eclipse-dataspaceconnector/DataSpaceConnector](https://github.com/eclipse-dataspaceconnector/DataSpaceConnector) - v0.4.1;
- [https://github.com/eclipse-dataspaceconnector/DataSpaceConnector](https://github.com/eclipse-dataspaceconnector/DataSpaceConnector) - v0.7.2;
- [International Data Spaces](https://www.internationaldataspaces.org);
- [GAIA-X](https://gaia-x.eu) project;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ public S3Regions retrieveRegions(String token) {
}
}

public boolean verifyToken(String token) {
if(token == null || token.isEmpty())
return false;

String url = "https://api.ionos.com/cloudapi/v6/locations";

Request request = new Request.Builder().url(url)
.addHeader("Authorization", "Bearer " + token)
.get()
.build();
try (Response response = client.newCall(request).execute()) {
if (!response.isSuccessful()) {
return false;

} else return response.body() != null;
} catch (IOException e) {
throw new EdcException("Error access Ionos Cloud", e);

}
}

public S3AccessKey createAccessKey(String token) {

Request request = new Request.Builder().url(ACCESS_KEYS_ENDPOINT_URL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ public S3ConnectorImpl(String regionId, @NotNull String accessKey, @NotNull Stri
this.maxFiles = maxFiles;

this.regionId = Objects.requireNonNullElse(regionId, REGION_ID_DEFAULT);
var endpoint = getEndpoint( this.regionId , token);

this.minioClient = MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build();
if(S3ApiClient.verifyToken(token)) {
var endpoint = getEndpoint(this.regionId, token);
this.minioClient = MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build();
} else {
this.minioClient = null;
}
}

@Override
Expand Down Expand Up @@ -86,7 +89,7 @@ public void uploadObject(String bucketName, String objectName, ByteArrayInputStr
if (!bucketExists(bucketName.toLowerCase())) {
createBucket(bucketName.toLowerCase());
}

try {
minioClient.putObject(PutObjectArgs.builder()
.bucket(bucketName.toLowerCase())
Expand Down Expand Up @@ -161,10 +164,10 @@ public List<S3Object> listObjects(String bucketName, String objectName) {
.map(item -> new S3Object(item.objectName(), item.size()))
.collect(Collectors.toList());
}

@Override
public S3AccessKey createAccessKey() {
try{
try{
return S3ApiClient.createAccessKey(token);
} catch (Exception e) {
throw new EdcException("Error creating access key", e);
Expand All @@ -179,15 +182,15 @@ public S3AccessKey retrieveAccessKey(String keyID) {
throw new EdcException("Error retrieving access key", e);
}
}
@Override
public void deleteAccessKey(String keyID) {

@Override
public void deleteAccessKey(String keyID) {
try{
S3ApiClient.deleteAccessKey(token, keyID);
} catch (Exception e) {
throw new EdcException("Error deleting access key", e);
}
}
}

private String getEndpoint(String regionId, String token) {
var regions = S3ApiClient.retrieveRegions(token);
Expand All @@ -204,4 +207,4 @@ private String getEndpoint(String regionId, String token) {
public S3Connector clone(String region, String accessKey, String secretKey) {
return new S3ConnectorImpl(region, accessKey, secretKey, this.token, this.maxFiles);
}
}
}
11 changes: 8 additions & 3 deletions launchers/dev/connector-consumer/resources/config.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
edc.participant.id=consumer
edc.dsp.callback.address=http://localhost:9292/protocol
web.http.port=9191
web.http.path=/api
web.http.management.port=9192
Expand All @@ -10,13 +9,19 @@ web.http.control.port=9293
web.http.control.path=/control
web.http.public.port=9393
web.http.public.path=/public
edc.dsp.callback.address=http://localhost:9292/protocol
edc.dataplane.token.validation.endpoint=http://localhost:9293/control/token
edc.dataplane.api.public.baseurl=http://localhost:9393/public

edc.api.auth.key=password
edc.transfer.proxy.token.signer.privatekey.alias=edc.connector.private.key
edc.transfer.proxy.token.verifier.publickey.alias=edc.connector.public.key

edc.vault.hashicorp.url=http://localhost:8200
edc.vault.hashicorp.token=test-token
edc.vault.hashicorp.timeout.seconds=30

edc.ionos.access.key=<YOUR S3 KEY>
edc.ionos.secret.key=<YOUR S3 KEY SECRET>
edc.ionos.endpoint=https://s3-eu-central-1.ionoscloud.com
edc.ionos.token=<IONOS-TOKEN>
edc.ionos.endpoint.region=<IONOS ENDPOINT REGION>
edc.ionos.token=<IONOS API TOKEN>