Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
Indexer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Indexer
Commits
05f19287
Commit
05f19287
authored
5 years ago
by
MIchael Nguyen
Browse files
Options
Downloads
Patches
Plain Diff
readded headerinfo impl.
parent
c82f7cf4
No related branches found
No related tags found
1 merge request
!6
Trusted ibm
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/util/HeadersInfoAwsImpl.java
+123
-0
123 additions, 0 deletions
...g/opengroup/osdu/indexer/aws/util/HeadersInfoAwsImpl.java
with
123 additions
and
0 deletions
provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/util/HeadersInfoAwsImpl.java
0 → 100644
+
123
−
0
View file @
05f19287
// Copyright © Microsoft Corporation
//
// 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.
package
org.opengroup.osdu.indexer.aws.util
;
import
lombok.extern.java.Log
;
import
org.apache.http.HttpStatus
;
import
org.opengroup.osdu.core.api.DpsHeaders
;
import
org.opengroup.osdu.is.core.model.SlbHeaders
;
import
org.opengroup.osdu.is.core.provider.interfaces.util.IHeadersInfo
;
import
org.opengroup.osdu.is.core.util.AppException
;
import
org.opengroup.osdu.is.core.util.Preconditions
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.annotation.RequestScope
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
javax.inject.Inject
;
@Primary
@Log
@Component
public
class
HeadersInfoAwsImpl
implements
IHeadersInfo
{
@Inject
private
DpsHeaders
headersMap
;
private
static
final
HashSet
<
String
>
FORBIDDEN_FROM_LOGGING
=
new
HashSet
<>();
static
{
FORBIDDEN_FROM_LOGGING
.
add
(
DpsHeaders
.
AUTHORIZATION
);
FORBIDDEN_FROM_LOGGING
.
add
(
DpsHeaders
.
ON_BEHALF_OF
);
}
/**
* Get list of current headers
* @return DpsHeaders headers
*/
@Override
public
DpsHeaders
getHeaders
()
{
if
(
headersMap
==
null
)
{
log
.
warning
(
"Headers Map DpsHeaders is null"
);
// throw to prevent null reference exception below
throw
new
AppException
(
HttpStatus
.
SC_INTERNAL_SERVER_ERROR
,
"Invalid Headers"
,
"Headers Map DpsHeaders is null"
);
}
DpsHeaders
headers
=
this
.
getCoreServiceHeaders
(
headersMap
.
getHeaders
());
return
headers
;
}
/**
* get current logged in user
* @return userEmail
*/
@Override
public
String
getUser
()
{
return
getHeaders
().
getUserEmail
();
}
/**
* get partition id and fallback to account id
* @return Partition ID
*/
@Override
public
String
getPartitionId
()
{
return
getHeaders
().
getPartitionIdWithFallbackToAccountId
();
}
/**
* get the primary partition id
* @return primaryPartitionID
*/
@Override
public
String
getPrimaryPartitionId
()
{
return
getHeadersMap
().
get
(
SlbHeaders
.
PRIMARY_PARTITION_ID
);
}
/**
* get map of the current headers
* @return Map<String, String> headers
*/
@Override
public
Map
<
String
,
String
>
getHeadersMap
()
{
return
getHeaders
().
getHeaders
();
}
/**
* supplement the DPSHeaders with any specific core service headers
* @param input Map<String, String> of core headers
* @return DpsHeaders dpsHeaders
*/
@Override
public
DpsHeaders
getCoreServiceHeaders
(
Map
<
String
,
String
>
input
)
{
Preconditions
.
checkNotNull
(
input
,
"input headers cannot be null"
);
DpsHeaders
output
=
DpsHeaders
.
createFromMap
(
input
);
return
output
;
}
/**
* create string representing a comma delimited list of the current headers
* @return
*/
@Override
public
String
toString
()
{
return
this
.
getHeadersMap
().
entrySet
().
stream
().
filter
(
map
->
!
FORBIDDEN_FROM_LOGGING
.
contains
(
map
.
getKey
().
toLowerCase
())).
map
(
Map
.
Entry
::
toString
).
collect
(
Collectors
.
joining
(
" | "
));
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Gokul Nagare
@gokul_nagare
mentioned in commit
d5255c23
·
4 years ago
mentioned in commit
d5255c23
mentioned in commit d5255c238ba67a6989a5a7dbc26c03b56b0b4f9e
Toggle commit list
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