Commit 69edfa65 authored by Komal Makkar's avatar Komal Makkar
Browse files

minor changes

parent 83e7f9b9
Pipeline #13777 failed with stage
in 2 minutes and 1 second
...@@ -51,26 +51,27 @@ public class CredentialHeadersProvider implements FactoryBean<DpsHeaders> { ...@@ -51,26 +51,27 @@ public class CredentialHeadersProvider implements FactoryBean<DpsHeaders> {
@Override @Override
public DpsHeaders getObject() throws Exception { public DpsHeaders getObject() throws Exception {
if(this.pubsubRequestBodyExtractor.isHandshakeRequest()) {
// The headers are not needed for the handshake requests.
return new DpsHeaders();
}
RequestMethod requestMethod = RequestMethod.valueOf(httpRequest.getMethod()); RequestMethod requestMethod = RequestMethod.valueOf(httpRequest.getMethod());
switch (requestMethod) { switch (requestMethod) {
case POST: case POST:
case PUT: case PUT:
case PATCH: { case PATCH: {
if(this.pubsubRequestBodyExtractor.isHandshakeRequest()) { Map<String, String> attributes = this.pubsubRequestBodyExtractor.extractAttributesFromRequestBody();
// The headers are not needed for the handshake requests. try {
return new DpsHeaders(); //extract headers from pubsub message
} else { String dataPartitionId = attributes.get(DpsHeaders.DATA_PARTITION_ID);
Map<String, String> attributes = this.pubsubRequestBodyExtractor.extractAttributesFromRequestBody(); String authToken = this.serviceAccountJwtClient.getIdToken(dataPartitionId);
try { attributes.put(DpsHeaders.AUTHORIZATION, authToken);
//extract headers from pubsub message return DpsHeaders.createFromMap(attributes);
String dataPartitionId = attributes.get(DpsHeaders.DATA_PARTITION_ID); } catch (AppException e) {
String authToken = this.serviceAccountJwtClient.getIdToken(dataPartitionId); throw new Exception("Failed to generate headers for register service.");
attributes.put(DpsHeaders.AUTHORIZATION, authToken);
return DpsHeaders.createFromMap(attributes);
} catch (AppException e) {
throw new Exception("Failed to generate headers for register service.");
}
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment