Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Register
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSDU
OSDU Data Platform
System
Register
Commits
55682e2e
Commit
55682e2e
authored
7 months ago
by
Derek Hudson
Browse files
Options
Downloads
Patches
Plain Diff
Fixing the AWS integration tests.
parent
39a2dd24
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!494
Fixing the AWS integration tests.
Pipeline
#279908
failed
7 months ago
Stage: review
Stage: build
Stage: coverage
Stage: containerize
Stage: scan
Stage: deploy
Stage: integration
Stage: publish
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
provider/register-aws/src/main/java/org/opengroup/osdu/register/provider/aws/push_api/AwsSubscriberTestListenerApi.java
+12
-27
12 additions, 27 deletions
...r/provider/aws/push_api/AwsSubscriberTestListenerApi.java
with
12 additions
and
27 deletions
provider/register-aws/src/main/java/org/opengroup/osdu/register/provider/aws/push_api/AwsSubscriberTestListenerApi.java
+
12
−
27
View file @
55682e2e
...
...
@@ -13,17 +13,12 @@
// limitations under the License.
package
org.opengroup.osdu.register.provider.aws.push_api
;
import
com.amazonaws.services.sns.AmazonSNS
;
import
com.amazonaws.services.sns.model.ConfirmSubscriptionRequest
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.google.common.hash.Hashing
;
import
io.swagger.v3.oas.annotations.Hidden
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.checkerframework.checker.units.qual.C
;
import
org.opengroup.osdu.core.aws.sns.AmazonSNSConfig
;
import
org.opengroup.osdu.core.common.cryptographic.ISignatureService
;
import
org.opengroup.osdu.core.common.cryptographic.SignatureServiceException
;
import
org.opengroup.osdu.core.common.logging.JaxRsDpsLog
;
...
...
@@ -39,9 +34,8 @@ import org.springframework.web.context.annotation.RequestScope;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletResponse
;
import
jakarta.validation.constraints.NotBlank
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Base64
;
import
java.util.Scanner
;
...
...
@@ -96,41 +90,32 @@ public class AwsSubscriberTestListenerApi {
try
{
signatureService
.
verifyHmacSignature
(
hmac
,
this
.
serviceConfig
.
getSubscriberSecret
());
}
catch
(
SignatureServiceException
e
)
{
EntityBodyWrapper
wrapper
=
new
EntityBodyWrapper
(
n
ew
ChallengeResponse
()
,
AUTHORIZATION_SIGNATURE_VALIDATION_FAILED
);
EntityBodyWrapper
wrapper
=
new
EntityBodyWrapper
(
n
ull
,
AUTHORIZATION_SIGNATURE_VALIDATION_FAILED
);
return
new
ResponseEntity
<>(
wrapper
,
HttpStatus
.
BAD_REQUEST
);
}
logger
.
info
(
"Signature verified and sending response"
);
// Use the secret you send to the subscriber registration create request
ResponseEntity
<
ChallengeR
esponse
>
cr
=
getResponse
(
crc
,
this
.
serviceConfig
.
getSubscriberSecret
());
EntityBodyWrapper
wrapper
=
new
EntityBodyWrapper
(
cr
.
getBody
(),
""
);
return
new
ResponseEntity
<>(
wrapper
,
cr
.
getStatusCode
()
);
String
r
esponse
Hash
=
getResponse
Hash
(
crc
,
this
.
serviceConfig
.
getSubscriberSecret
());
EntityBodyWrapper
wrapper
=
new
EntityBodyWrapper
(
responseHash
,
null
);
return
new
ResponseEntity
<>(
wrapper
,
HttpStatus
.
OK
);
}
private
ResponseEntity
<
ChallengeResponse
>
getResponse
(
String
crc
,
String
secretString
)
{
private
String
getResponse
Hash
(
String
crc
,
String
secretString
)
{
String
response
=
secretString
+
crc
;
response
=
Hashing
.
sha256
()
.
hashString
(
response
,
StandardCharsets
.
UTF_8
)
.
toString
();
response
=
Base64
.
getEncoder
().
encodeToString
(
response
.
getBytes
());
ChallengeResponse
cr
=
new
ChallengeResponse
();
cr
.
setResponseHash
(
response
);
return
new
ResponseEntity
<>(
cr
,
HttpStatus
.
OK
);
return
Base64
.
getEncoder
().
encodeToString
(
response
.
getBytes
());
}
@Data
@NoArgsConstructor
@AllArgsConstructor
private
static
class
ChallengeResponse
{
private
String
responseHash
=
""
;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
private
static
class
EntityBodyWrapper
{
private
ChallengeResponse
challengeResponse
;
private
String
message
;
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
private
String
responseHash
=
null
;
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
private
String
message
=
null
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment