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
Notification
Commits
d561a222
Commit
d561a222
authored
Nov 17, 2020
by
Rucha Deshpande
Browse files
Update os-core-lib-aws version
parent
ab4445a8
Changes
3
Hide whitespace changes
Inline
Side-by-side
provider/notification-aws/pom.xml
View file @
d561a222
...
...
@@ -50,7 +50,7 @@
<dependency>
<groupId>
org.opengroup.osdu.core.aws
</groupId>
<artifactId>
os-core-lib-aws
</artifactId>
<version>
0.3.1
2
</version>
<version>
0.3.1
3-SNAPSHOT
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-secretsmanager -->
...
...
provider/notification-aws/src/main/java/org/opengroup/osdu/notification/provider/aws/impl/ServiceAccountJwtAwsClientImpl.java
View file @
d561a222
...
...
@@ -13,15 +13,25 @@
package
org.opengroup.osdu.notification.provider.aws.impl
;
import
com.amazonaws.auth.AWSCredentialsProvider
;
import
com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement
;
import
com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagementClientBuilder
;
import
com.amazonaws.services.simplesystemsmanagement.model.GetParameterRequest
;
import
com.amazonaws.services.simplesystemsmanagement.model.GetParameterResult
;
import
com.amazonaws.services.simplesystemsmanagement.model.Parameter
;
import
lombok.AccessLevel
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.opengroup.osdu.core.aws.entitlements.ServicePrincipal
;
import
org.opengroup.osdu.core.aws.iam.IAMConfig
;
import
org.opengroup.osdu.core.aws.secrets.SecretsManager
;
import
org.opengroup.osdu.core.common.util.IServiceAccountJwtClient
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
@Component
public
class
ServiceAccountJwtAwsClientImpl
implements
IServiceAccountJwtClient
{
...
...
@@ -46,12 +56,55 @@ public class ServiceAccountJwtAwsClientImpl implements IServiceAccountJwtClient
public
String
environment
;
@Value
(
"${aws.tokenUrl}"
)
@Getter
()
public
String
tokenUrl
;
@Value
(
"${aws.oauth.custom.scope}"
)
@Getter
()
private
String
awsOauthCustomScope
;
String
client_credentials_secret
;
String
client_credentials_clientid
;
ServicePrincipal
sp
;
private
AWSCredentialsProvider
amazonAWSCredentials
;
private
AWSSimpleSystemsManagement
ssmManager
;
@PostConstruct
public
void
init
()
{
if
(
ssmEnabled
)
{
SecretsManager
sm
=
new
SecretsManager
();
sp
=
new
ServicePrincipal
(
amazonRegion
,
environment
,
tokenUrl
,
awsOauthCustomScope
);
String
client_credentials_client_id
=
"/osdu/"
+
environment
+
"/client-credentials-client-id"
;
String
client_secret_key
=
"client_credentials_client_secret"
;
String
client_secret_secretName
=
"/osdu/"
+
environment
+
"/client_credentials_secret"
;
amazonAWSCredentials
=
IAMConfig
.
amazonAWSCredentials
();
ssmManager
=
AWSSimpleSystemsManagementClientBuilder
.
standard
()
.
withCredentials
(
amazonAWSCredentials
)
.
withRegion
(
amazonRegion
)
.
build
();
GetParameterRequest
paramRequest
=
new
GetParameterRequest
()
.
withName
(
client_credentials_client_id
)
.
withWithDecryption
(
true
);
GetParameterResult
paramResult
=
ssmManager
.
getParameter
(
paramRequest
);
Parameter
paramsResult
=
paramResult
.
getParameter
();
client_credentials_clientid
=
paramsResult
.
getValue
();
client_credentials_secret
=
sm
.
getSecret
(
client_secret_secretName
,
amazonRegion
,
client_secret_key
);
}
}
@Override
public
String
getIdToken
(
String
s
)
{
ServicePrincipal
sp
=
new
ServicePrincipal
(
amazonRegion
,
environment
);
String
token
=
sp
.
getServicePrincipalAccessToken
();
String
token
=
sp
.
getServicePrincipalAccessToken
(
client_credentials_clientid
,
client_credentials_secret
);
return
token
;
}
...
...
testing/notification-test-aws/pom.xml
View file @
d561a222
...
...
@@ -44,7 +44,7 @@
<dependency>
<groupId>
org.opengroup.osdu.core.aws
</groupId>
<artifactId>
os-core-lib-aws
</artifactId>
<version>
0.3.1
2
</version>
<version>
0.3.1
3-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.amazonaws
</groupId>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment