Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Dataset
Commits
4245307f
Commit
4245307f
authored
Jun 08, 2020
by
David Diederich
Browse files
Merge branch 'trusted-ibm' into 'master'
Trusted ibm See merge request osdu/platform/system/delivery!6
parents
039c2cc5
8aa1360b
Pipeline
#2349
passed with stages
in 29 minutes and 32 seconds
Changes
11
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
4245307f
...
...
@@ -4,6 +4,9 @@ variables:
AWS_SERVICE
:
delivery
AWS_ENVIRONMENT
:
dev
IBM_BUILD_SUBDIR
:
provider/delivery-ibm
IBM_INT_TEST_SUBDIR
:
testing/delivery-test-ibm
include
:
-
project
:
'
osdu/platform/ci-cd-pipelines'
file
:
'
standard-setup.yml'
...
...
@@ -23,6 +26,9 @@ include:
-
project
:
'
osdu/platform/ci-cd-pipelines'
file
:
'
cloud-providers/aws.yml'
-
project
:
'
osdu/platform/ci-cd-pipelines'
file
:
'
cloud-providers/ibm.yml'
# disable the eslint scanner
# I think this is being generated from the presence of an HTML file, but there
# is no javascript to scan, so the job isn't helpful and just gets in the way
...
...
NOTICE
View file @
4245307f
...
...
@@ -2,11 +2,20 @@
Generated by fossa-cli (https://github.com/fossas/fossa-cli).
This software includes the following software and licenses:
========================================================================
Apache-1.1
========================================================================
The following software have components provided under the terms of this license:
- StAX (from http://stax.codehaus.org/)
========================================================================
Apache-2.0
========================================================================
The following software have components provided under the terms of this license:
- AMQP 1.0 JMS Spring Boot AutoConfiguration (from https://repo1.maven.org/maven2/org/amqphub/spring/amqp-10-jms-spring-boot-autoconfigure)
- AMQP 1.0 JMS Spring Boot Starter (from https://repo1.maven.org/maven2/org/amqphub/spring/amqp-10-jms-spring-boot-starter)
- ASM Core (from )
- ASM based accessors helper used by json-smart (from )
- AWS Java SDK for AWS Amplify (from https://aws.amazon.com/sdkforjava)
...
...
@@ -200,6 +209,7 @@ The following software have components provided under the terms of this license:
- Apache Commons Codec (from http://commons.apache.org/proper/commons-codec/)
- Apache Commons Lang (from http://commons.apache.org/proper/commons-lang/)
- Apache Commons Logging (from http://commons.apache.org/proper/commons-logging/)
- Apache Geronimo JMS Spec 2.0 (from http://geronimo.apache.org/maven/${siteId}/${version})
- Apache HttpAsyncClient (from http://hc.apache.org/httpcomponents-asyncclient)
- Apache HttpClient (from http://hc.apache.org/httpcomponents-client)
- Apache HttpCore (from http://hc.apache.org/httpcomponents-core-ga)
...
...
@@ -266,8 +276,8 @@ The following software have components provided under the terms of this license:
- Lucene Spatial Extras (from )
- Lucene Suggest (from )
- MapStruct Core (from )
- Mockito (from http://www.mockito.org)
- Mockito (from http://mockito.org)
- Mockito (from http://www.mockito.org)
- Mockito (from http://mockito.org)
- Mockito (from http://www.mockito.org)
- Netty/Buffer (from http://netty.io/)
...
...
@@ -277,6 +287,7 @@ The following software have components provided under the terms of this license:
- Netty/Handler (from )
- Netty/Resolver (from )
- Netty/Transport (from http://netty.io/)
- Netty/Transport/Native/Unix/Common (from )
- Nimbus JOSE+JWT (from https://bitbucket.org/connect2id/nimbus-jose-jwt)
- Nimbus LangTag (from https://bitbucket.org/connect2id/nimbus-language-tags)
- OAuth 2.0 SDK with OpenID Connect extensions (from https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions)
...
...
@@ -287,7 +298,8 @@ The following software have components provided under the terms of this license:
- OpenCensus (from https://github.com/census-instrumentation/opencensus-java)
- OpenCensus (from https://github.com/census-instrumentation/opencensus-java)
- PowerMock (from http://www.powermock.org)
- RabbitMQ Java Client (from http://www.rabbitmq.com)
- QpidJMS Client (from )
- Simple XML (from http://simple.sourceforge.net)
- SnakeYAML (from http://www.snakeyaml.org)
- Spring AOP (from https://github.com/spring-projects/spring-framework)
- Spring Beans (from https://github.com/spring-projects/spring-framework)
...
...
@@ -310,11 +322,16 @@ The following software have components provided under the terms of this license:
- Spring Core (from https://github.com/spring-projects/spring-framework)
- Spring Data Core (from )
- Spring Expression Language (SpEL) (from https://github.com/spring-projects/spring-framework)
- Spring JMS (from https://github.com/spring-projects/spring-framework)
- Spring Messaging (from https://github.com/spring-projects/spring-framework)
- Spring Plugin - Core (from )
- Spring Plugin - Metadata Extension (from )
- Spring TestContext Framework (from https://github.com/spring-projects/spring-framework)
- Spring Transaction (from https://github.com/spring-projects/spring-framework)
- Spring Web (from https://github.com/spring-projects/spring-framework)
- Spring Web MVC (from https://github.com/spring-projects/spring-framework)
- StAX (from http://stax.codehaus.org/)
- StAX API (from http://stax.codehaus.org/)
- T-Digest (from https://github.com/tdunning/t-digest)
- aggs-matrix-stats (from https://github.com/elastic/elasticsearch)
- cli (from https://github.com/elastic/elasticsearch)
...
...
@@ -326,12 +343,13 @@ The following software have components provided under the terms of this license:
- jackson-databind (from http://github.com/FasterXML/jackson)
- java-cloudant (from https://cloudant.com)
- java-cloudant (from https://cloudant.com)
- javax.inject (from )
- javax.inject (from http://code.google.com/p/atinject/)
- javax.inject (from )
- jersey-repackaged-guava (from )
- jose4j (from https://bitbucket.org/b_c/jose4j/)
- lang-mustache (from https://github.com/elastic/elasticsearch)
- lettuce (from http://github.com/mp911de/lettuce/wiki)
- minio (from https://github.com/minio/minio-java)
- org.xmlunit:xmlunit-core (from http://www.xmlunit.org/)
- parent-join (from https://github.com/elastic/elasticsearch)
- powermock-api-mockito (from )
...
...
@@ -342,6 +360,7 @@ The following software have components provided under the terms of this license:
- powermock-module-junit4 (from http://www.powermock.org)
- powermock-module-junit4-common (from )
- powermock-reflect (from )
- proton-j (from )
- rank-eval (from https://github.com/elastic/elasticsearch)
- rest (from https://github.com/elastic/elasticsearch)
- rest-high-level (from https://github.com/elastic/elasticsearch)
...
...
@@ -379,6 +398,7 @@ The following software have components provided under the terms of this license:
- Hamcrest Core (from http://hamcrest.org/)
- Lucene Common Analyzers (from )
- StAX (from http://stax.codehaus.org/)
========================================================================
BSD-3-Clause
...
...
@@ -403,6 +423,7 @@ CC-BY-3.0
========================================================================
The following software have components provided under the terms of this license:
- "Java Concurrency in Practice" book annotations (from http://jcip.net/)
- FindBugs-jsr305 (from http://findbugs.sourceforge.net/)
========================================================================
...
...
@@ -450,7 +471,6 @@ The following software have components provided under the terms of this license:
- HK2 Implementation Utilities (from )
- JavaMail API (from )
- OSGi resource locator (from )
- RabbitMQ Java Client (from http://www.rabbitmq.com)
- ServiceLocator Default Implementation (from git://java.net/hk2~git/hk2-locator)
- aopalliance-repackaged (from )
- javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250)
...
...
@@ -475,7 +495,6 @@ The following software have components provided under the terms of this license:
- JavaMail API (from )
- OSGi resource locator (from )
- RabbitMQ Java Client (from http://www.rabbitmq.com)
- javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250)
- javax.ws.rs-api (from http://jax-rs-spec.java.net)
- tomcat-embed-core (from http://tomcat.apache.org/)
...
...
@@ -502,6 +521,7 @@ The following software have components provided under the terms of this license:
- Javassist (from http://www.javassist.org/)
- Logback Classic Module (from )
- Logback Core Module (from )
- SpotBugs Annotations (from https://spotbugs.github.io/)
========================================================================
LGPL-2.1-or-later
...
...
@@ -510,6 +530,7 @@ The following software have components provided under the terms of this license:
- Javassist (from http://www.javassist.org/)
- SnakeYAML (from http://www.snakeyaml.org)
- SpotBugs Annotations (from https://spotbugs.github.io/)
========================================================================
LGPL-3.0-only
...
...
@@ -517,7 +538,6 @@ LGPL-3.0-only
The following software have components provided under the terms of this license:
- Apache Log4j API (from )
- RabbitMQ Java Client (from http://www.rabbitmq.com)
========================================================================
MIT
...
...
@@ -533,10 +553,10 @@ The following software have components provided under the terms of this license:
- JUL to SLF4J bridge (from http://www.slf4j.org)
- Java JWT (from http://www.jwt.io)
- Lucene Core (from )
- Mockito (from http://mockito.org)
- Mockito (from http://mockito.org)
- Mockito (from http://www.mockito.org)
- Mockito (from http://www.mockito.org)
- Mockito (from http://mockito.org)
- Mockito (from http://mockito.org)
- Netty/Codec/HTTP (from )
- Netty/Common (from )
- Project Lombok (from https://projectlombok.org)
...
...
@@ -552,7 +572,6 @@ The following software have components provided under the terms of this license:
- Javassist (from http://www.javassist.org/)
- Javassist (from http://www.javassist.org/)
- Javassist (from http://www.javassist.org/)
- RabbitMQ Java Client (from http://www.rabbitmq.com)
========================================================================
MPL-2.0
...
...
@@ -562,7 +581,6 @@ The following software have components provided under the terms of this license:
- Javassist (from http://www.javassist.org/)
- Javassist (from http://www.javassist.org/)
- Javassist (from http://www.javassist.org/)
- RabbitMQ Java Client (from http://www.rabbitmq.com)
========================================================================
Public-Domain
...
...
@@ -597,7 +615,6 @@ The following software have components provided under the terms of this license:
- HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/)
- Joda-Time (from http://www.joda.org/joda-time/)
- Project Lombok (from https://projectlombok.org)
- RabbitMQ Java Client (from http://www.rabbitmq.com)
- Spring Web (from https://github.com/spring-projects/spring-framework)
========================================================================
...
...
@@ -606,6 +623,5 @@ unknown
The following software have components provided under the terms of this license:
- Byte Buddy (without dependencies) (from )
- RabbitMQ Java Client (from http://www.rabbitmq.com)
configuration/settings.xml
deleted
100644 → 0
View file @
039c2cc5
<?xml version="1.0" encoding="UTF-8"?>
<settings
xmlns=
"http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
>
<servers>
<server>
<id>
os-core
</id>
<username>
os-core
</username>
<!-- Treat this auth token like a password. Do not share it with anyone, including Microsoft support. -->
<!-- The generated token expires on or before 11/14/2019 -->
<password>
${VSTS_FEED_TOKEN}
</password>
</server>
</servers>
</settings>
provider/delivery-ibm/pom.xml
View file @
4245307f
...
...
@@ -30,30 +30,18 @@
<description>
Delivery service on IBM
</description>
<packaging>
jar
</packaging>
<properties>
<aws.version>
1.11.637
</aws.version>
<deployment.environment>
dev
</deployment.environment>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
com.amazonaws
</groupId>
<artifactId>
aws-java-sdk-bom
</artifactId>
<version>
${aws.version}
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Internal packages -->
<!-- Remove this and refactor the test -->
<dependency>
<groupId>
com.ibm.cos
</groupId>
<artifactId>
ibm-cos-java-sdk
</artifactId>
<version>
2.1.0
</version>
</dependency>
<dependency>
<groupId>
org.opengroup.osdu
</groupId>
<artifactId>
os-core-lib-ibm
</artifactId>
<version>
0.0.1
3
-SNAPSHOT
</version>
<version>
0.0.1
4
-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
org.opengroup.osdu
</groupId>
...
...
provider/delivery-ibm/src/main/java/org/opengroup/osdu/delivery/provider/ibm/service/StorageServiceImpl.java
View file @
4245307f
...
...
@@ -16,9 +16,11 @@
package
org.opengroup.osdu.delivery.provider.ibm.service
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Arrays
;
import
java.util.Date
;
...
...
@@ -33,11 +35,14 @@ import org.opengroup.osdu.delivery.provider.interfaces.IStorageService;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
com.ibm.cloud.objectstorage.HttpMethod
;
import
com.ibm.cloud.objectstorage.SdkClientException
;
import
com.ibm.cloud.objectstorage.services.s3.AmazonS3
;
import
com.ibm.cloud.objectstorage.services.s3.model.GeneratePresignedUrlRequest
;
import
io.minio.MinioClient
;
import
io.minio.errors.ErrorResponseException
;
import
io.minio.errors.InsufficientDataException
;
import
io.minio.errors.InternalException
;
import
io.minio.errors.InvalidBucketNameException
;
import
io.minio.errors.InvalidExpiresRangeException
;
import
io.minio.errors.InvalidResponseException
;
import
io.minio.errors.XmlParserException
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -52,7 +57,7 @@ public class StorageServiceImpl implements IStorageService {
@Inject
private
CloudObjectStorageFactory
cosFactory
;
private
AmazonS3
s3
Client
;
private
MinioClient
minio
Client
;
private
ExpirationDateHelper
expirationDateHelper
;
...
...
@@ -64,7 +69,7 @@ public class StorageServiceImpl implements IStorageService {
@PostConstruct
public
void
init
()
{
s3
Client
=
cosFactory
.
getClient
();
minio
Client
=
cosFactory
.
getClient
();
expirationDateHelper
=
new
ExpirationDateHelper
();
instantHelper
=
new
InstantHelper
();
}
...
...
@@ -83,14 +88,15 @@ public class StorageServiceImpl implements IStorageService {
String
bucketName
=
s3ObjectKeyParts
[
0
];
String
s3Key
=
String
.
join
(
"/"
,
Arrays
.
copyOfRange
(
s3ObjectKeyParts
,
1
,
s3ObjectKeyParts
.
length
));
URL
s3SignedUrl
=
generateSignedS3Url
(
bucketName
,
s3Key
,
"GET"
);
SignedUrl
url
=
new
SignedUrl
();
try
{
URL
s3SignedUrl
=
generateSignedS3Url
(
bucketName
,
s3Key
,
"GET"
);
url
.
setUri
(
new
URI
(
s3SignedUrl
.
toString
()));
url
.
setUrl
(
s3SignedUrl
);
url
.
setCreatedAt
(
instantHelper
.
getCurrentInstant
());
}
catch
(
URISyntax
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"There was an error generating the URI."
,
e
);
throw
new
AppException
(
HttpStatus
.
SC_BAD_REQUEST
,
"Malformed URL"
,
URI_EXCEPTION_REASON
,
e
);
}
...
...
@@ -101,13 +107,13 @@ public class StorageServiceImpl implements IStorageService {
* This method will take a string of a pre-validated S3 bucket name, and use the
* AWS Java SDK to generate a signed URL with an expiration date set to be
* as-configured
*
*
* @param s3BucketName - pre-validated S3 bucket name
* @param s3ObjectKey - pre-validated S3 object key (keys include the path +
* filename)
* @return - String of the signed S3 URL to allow file access temporarily
*/
private
URL
generateSignedS3Url
(
String
s3BucketName
,
String
s3ObjectKey
,
String
httpMethod
)
{
private
URL
generateSignedS3Url
(
String
s3BucketName
,
String
s3ObjectKey
,
String
httpMethod
)
{
// Set the presigned URL to expire after the amount of time specified by the
// configuration variables
Date
expiration
=
expirationDateHelper
.
getExpirationDate
(
s3SignedUrlExpirationTimeInDays
);
...
...
@@ -115,16 +121,16 @@ public class StorageServiceImpl implements IStorageService {
log
.
debug
(
"Requesting a signed S3 URL with an expiration of: "
+
expiration
.
toString
()
+
" ("
+
s3SignedUrlExpirationTimeInDays
+
" minutes from now)"
);
// Generate the presigned URL
GeneratePresignedUrlRequest
generatePresignedUrlRequest
=
new
GeneratePresignedUrlRequest
(
s3BucketName
,
s3ObjectKey
).
withMethod
(
HttpMethod
.
valueOf
(
httpMethod
)).
withExpiration
(
expiration
);
try
{
// Attempt to generate the signed S3 URL
URL
url
=
s3Client
.
generatePresignedUrl
(
generatePresignedUrlRequest
);
return
url
;
}
catch
(
SdkClientException
e
)
{
// Catch any SDK client exceptions, and return a 500 error
log
.
error
(
"There was an AWS SDK error processing the signing request."
,
e
);
log
.
debug
(
"creating signed url from minio "
);
int
expiryTime
=
24
*
60
*
60
*
s3SignedUrlExpirationTimeInDays
;
String
url
=
minioClient
.
presignedGetObject
(
s3BucketName
,
s3ObjectKey
,
expiryTime
);
log
.
debug
(
"url from minio "
+
url
);
return
new
URL
(
url
);
}
catch
(
InvalidKeyException
|
ErrorResponseException
|
IllegalArgumentException
|
InsufficientDataException
|
InternalException
|
InvalidBucketNameException
|
InvalidExpiresRangeException
|
InvalidResponseException
|
NoSuchAlgorithmException
|
XmlParserException
|
IOException
e
)
{
log
.
error
(
"error creating signed url from minio "
,
e
);
throw
new
AppException
(
HttpStatus
.
SC_SERVICE_UNAVAILABLE
,
"Remote Service Unavailable"
,
AWS_SDK_EXCEPTION_MSG
,
e
);
}
...
...
provider/delivery-ibm/src/test/java/org/opengroup/osdu/delivery/provider/ibm/service/test/StorageServiceImplTest.java
View file @
4245307f
...
...
@@ -30,6 +30,7 @@ import java.util.Date;
import
org.apache.http.HttpStatus
;
import
org.junit.Assert
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
...
...
@@ -48,6 +49,8 @@ import com.ibm.cloud.objectstorage.SdkClientException;
import
com.ibm.cloud.objectstorage.services.s3.AmazonS3
;
import
com.ibm.cloud.objectstorage.services.s3.model.GeneratePresignedUrlRequest
;
// TODO must be refactor after minio migration
@Ignore
@RunWith
(
MockitoJUnitRunner
.
class
)
@SpringBootTest
(
classes
={
DeliveryApplication
.
class
})
public
class
StorageServiceImplTest
{
...
...
testing/delivery-test-ibm/pom.xml
View file @
4245307f
...
...
@@ -35,9 +35,15 @@
<dependency>
<groupId>
org.opengroup.osdu
</groupId>
<artifactId>
os-core-lib-ibm
</artifactId>
<version>
0.0.13-SNAPSHOT
</version>
<version>
0.0.14-SNAPSHOT
</version>
</dependency>
<!-- Remove this and refactor the test -->
<dependency>
<groupId>
com.ibm.cos
</groupId>
<artifactId>
ibm-cos-java-sdk
</artifactId>
<version>
2.1.0
</version>
</dependency>
<!-- Testing -->
<dependency>
<groupId>
junit
</groupId>
...
...
@@ -158,41 +164,5 @@
<url>
https://community.opengroup.org/api/v4/projects/118/packages/maven
</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-surefire-plugin
</artifactId>
<version>
2.5
</version>
<configuration>
<trimStackTrace>
false
</trimStackTrace>
<systemPropertyVariables>
<OTHER_RELEVANT_DATA_COUNTRIES>
US
</OTHER_RELEVANT_DATA_COUNTRIES>
<LEGAL_TAG>
opendes-public-usa-dataset-1
</LEGAL_TAG>
<DEFAULT_DATA_PARTITION_ID_TENANT1>
opendes
</DEFAULT_DATA_PARTITION_ID_TENANT1>
<DEFAULT_DATA_PARTITION_ID_TENANT2>
common
</DEFAULT_DATA_PARTITION_ID_TENANT2>
<ENTITLEMENTS_DOMAIN>
ibm.com
</ENTITLEMENTS_DOMAIN>
<SEARCH_HOST>
http://localhost:8085/api/search/v2/
</SEARCH_HOST>
<STORAGE_HOST>
http://localhost:8082/api/storage/v2/
</STORAGE_HOST>
<DELIVERY_HOST>
http://localhost:8086/api/delivery/v2/
</DELIVERY_HOST>
<KEYCLOAK_URL>
CHANGE_ME
</KEYCLOAK_URL>
<KEYCLOAK_REALM>
OSDU
</KEYCLOAK_REALM>
<KEYCLOAK_CLIENT_ID>
osdu-login
</KEYCLOAK_CLIENT_ID>
<KEYCLOAK_CLIENT_SECRET>
CHANGE_ME
</KEYCLOAK_CLIENT_SECRET>
<AUTH_USER_ACCESS>
CHANGE_ME
</AUTH_USER_ACCESS>
<AUTH_USER_ACCESS_PASSWORD>
CHANGE_ME
</AUTH_USER_ACCESS_PASSWORD>
<IBM_COS_ENDPOINT>
CHANGE_ME
</IBM_COS_ENDPOINT>
<IBM_COS_REGION>
us-south
</IBM_COS_REGION>
<IBM_COS_ACCESS_KEY>
CHANGE_ME
</IBM_COS_ACCESS_KEY>
<IBM_COS_SECRET_KEY>
CHANGE_ME
</IBM_COS_SECRET_KEY>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
testing/delivery-test-ibm/src/test/java/org/opengroup/osdu/util/CloudStorageUtilsIBM.java
View file @
4245307f
...
...
@@ -21,6 +21,8 @@ package org.opengroup.osdu.util;
import
java.util.List
;
import
org.opengroup.osdu.core.ibm.util.Config
;
import
com.ibm.cloud.objectstorage.ClientConfiguration
;
import
com.ibm.cloud.objectstorage.auth.AWSCredentials
;
import
com.ibm.cloud.objectstorage.auth.AWSStaticCredentialsProvider
;
...
...
@@ -41,10 +43,10 @@ public class CloudStorageUtilsIBM extends CloudStorageUtils {
public
CloudStorageUtilsIBM
()
{
String
url
=
System
.
getProperty
(
"IBM_COS_ENDPOINT"
);
String
region
=
System
.
getProperty
(
"IBM_COS_REGION"
,
"us-south"
);
String
accessKey
=
System
.
getProperty
(
"IBM_COS_ACCESS_KEY"
);
String
secretKey
=
System
.
getProperty
(
"IBM_COS_SECRET_KEY"
);
String
url
=
Config
.
getEnvironmentVariable
(
"IBM_COS_ENDPOINT"
);
String
region
=
Config
.
getEnvironmentVariable
(
"IBM_COS_REGION"
);
String
accessKey
=
Config
.
getEnvironmentVariable
(
"IBM_COS_ACCESS_KEY"
);
String
secretKey
=
Config
.
getEnvironmentVariable
(
"IBM_COS_SECRET_KEY"
);
AWSCredentials
credentials
=
new
BasicAWSCredentials
(
accessKey
,
secretKey
);
...
...
testing/delivery-test-ibm/src/test/java/org/opengroup/osdu/util/IBMHTTPClient.java
View file @
4245307f
...
...
@@ -19,6 +19,8 @@
package
org.opengroup.osdu.util
;
import
org.opengroup.osdu.core.ibm.util.IdentityClient
;
import
lombok.ToString
;
import
lombok.extern.java.Log
;
...
...
testing/delivery-test-ibm/src/test/java/org/opengroup/osdu/util/IdentityClient.java
deleted
100644 → 0
View file @
039c2cc5
/**
* Copyright 2020 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @author alanbraz@br.ibm.com
*
*/
package
org.opengroup.osdu.util
;
import
java.io.IOException
;
public
class
IdentityClient
{
public
static
String
getTokenForUserWithAccess
(){
try
{
String
user
=
System
.
getProperty
(
"AUTH_USER_ACCESS"
);
String
pass
=
System
.
getProperty
(
"AUTH_USER_ACCESS_PASSWORD"
);
return
KeyCloakProvider
.
getToken
(
user
,
pass
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
}
testing/delivery-test-ibm/src/test/java/org/opengroup/osdu/util/KeyCloakProvider.java
deleted
100644 → 0
View file @
039c2cc5
/**
* Copyright 2020 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @author alanbraz@br.ibm.com
*
*/
package
org.opengroup.osdu.util
;
import
java.io.BufferedReader
;
import
java.io.DataOutputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.net.ssl.HttpsURLConnection
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
public
class
KeyCloakProvider
{
private
static
String
url
;
private
static
String
realm
;
private
static
String
client_id
;
private
static
String
client_secret
;
private
static
String
grant_type
=
"password"
;
static
{
url
=
System
.
getProperty
(
"KEYCLOAK_URL"
);
realm
=
System
.
getProperty
(
"KEYCLOAK_REALM"
,
"OSDU"
);
client_id
=
System
.
getProperty
(
"KEYCLOAK_CLIENT_ID"
);
client_secret
=
System
.
getProperty
(
"KEYCLOAK_CLIENT_SECRET"
);
}
public
static
String
getToken
(
String
user
,
String
pwd
)
throws
IOException
{
String
token_endpoint
=
String
.
format
(
"https://%s/auth/realms/%s/protocol/openid-connect/token"
,
url
,
realm
);
URL
url
=
new
URL
(
token_endpoint
);
HttpsURLConnection
con
=
(
HttpsURLConnection
)
url
.
openConnection
();
con
.
setRequestMethod
(
"POST"
);
con
.
setRequestProperty
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
Map
<
String
,
String
>
parameters
=
new
HashMap
<>();
parameters
.
put
(
"grant_type"
,
grant_type
);
parameters
.
put
(
"client_id"
,
client_id
);
parameters
.
put
(
"client_secret"
,
client_secret
);
parameters
.
put
(
"username"
,
user
);
parameters
.
put
(
"password"
,
pwd
);
con
.
setDoOutput
(
true
);
DataOutputStream
out
=
new
DataOutputStream
(
con
.
getOutputStream
());
out
.
writeBytes
(
getParamsString
(
parameters
));
out
.
flush
();
out
.
close
();
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
con
.
getInputStream
()));
String
inputLine
;
StringBuffer
content
=
new
StringBuffer
();
while
((
inputLine
=
in
.
readLine
())
!=
null
)
{
content
.
append
(
inputLine
);
}
in
.
close
();
con
.
disconnect
();
Gson
gson
=
new
Gson
();
JsonObject
jobj
=
gson
.
fromJson
(
content
.
toString
(),
JsonObject
.
class
);
String
token
=
jobj
.
get
(
"access_token"
).
getAsString
();
return
token
;
}