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
Partition
Commits
d899de0f
Commit
d899de0f
authored
Feb 20, 2021
by
Riabokon Stanislav(EPAM)[GCP]
Browse files
Merge branch 'integration-master' into 'master'
# Conflicts: # provider/partition-gcp/pom.xml
parents
adf10f2c
de8138b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
partition-core/src/main/java/org/opengroup/osdu/partition/logging/AuditLogger.java
View file @
d899de0f
/*
Copyright 2002-2021 Google LLC
Copyright 2002-2021 EPAM Systems, Inc
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.partition.logging
;
import
com.google.common.base.Strings
;
import
java.util.List
;
import
lombok.RequiredArgsConstructor
;
import
org.opengroup.osdu.core.common.entitlements.IEntitlementsFactory
;
import
org.opengroup.osdu.core.common.entitlements.IEntitlementsService
;
import
org.opengroup.osdu.core.common.logging.JaxRsDpsLog
;
import
org.opengroup.osdu.core.common.logging.audit.AuditPayload
;
import
org.opengroup.osdu.core.common.logging.audit.AuditStatus
;
import
org.opengroup.osdu.core.common.model.entitlements.EntitlementsException
;
import
org.opengroup.osdu.core.common.model.entitlements.Groups
;
import
org.opengroup.osdu.core.common.model.http.AppException
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.annotation.RequestScope
;
...
...
@@ -31,11 +22,27 @@ import org.springframework.web.context.annotation.RequestScope;
public
class
AuditLogger
{
private
final
JaxRsDpsLog
logger
;
private
final
IEntitlementsFactory
factory
;
private
final
DpsHeaders
headers
;
private
AuditEvents
events
=
null
;
private
AuditEvents
getAuditEvents
()
{
if
(
this
.
events
==
null
)
{
this
.
events
=
new
AuditEvents
(
"partitionAccountUser"
);
if
(
Strings
.
isNullOrEmpty
(
this
.
headers
.
getUserEmail
()))
{
IEntitlementsService
service
=
this
.
factory
.
create
(
headers
);
try
{
Groups
groups
=
service
.
getGroups
();
this
.
events
=
new
AuditEvents
(
groups
.
getMemberEmail
());
}
catch
(
EntitlementsException
e
)
{
throw
new
AppException
(
HttpStatus
.
UNAUTHORIZED
.
value
(),
"Authentication Failure"
,
e
.
getMessage
(),
e
);
}
}
else
{
this
.
events
=
new
AuditEvents
(
this
.
headers
.
getUserEmail
());
}
}
return
this
.
events
;
}
...
...
partition-core/src/test/java/org/opengroup/osdu/partition/logging/AuditLoggerTest.java
View file @
d899de0f
...
...
@@ -20,6 +20,7 @@ package org.opengroup.osdu.partition.logging;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -29,7 +30,9 @@ import org.junit.runner.RunWith;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
org.opengroup.osdu.core.common.entitlements.IEntitlementsFactory
;
import
org.opengroup.osdu.core.common.logging.JaxRsDpsLog
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
AuditLoggerTest
{
...
...
@@ -37,6 +40,12 @@ public class AuditLoggerTest {
@Mock
private
JaxRsDpsLog
log
;
@Mock
private
IEntitlementsFactory
factory
;
@Mock
private
DpsHeaders
headers
;
@InjectMocks
private
AuditLogger
sut
;
...
...
@@ -44,6 +53,7 @@ public class AuditLoggerTest {
@Before
public
void
setup
()
{
when
(
this
.
headers
.
getUserEmail
()).
thenReturn
(
"test_user@email.com"
);
resources
=
Collections
.
singletonList
(
"resources"
);
}
...
...
provider/partition-gcp/src/main/java/org/opengroup/osdu/partition/provider/gcp/security/AuthorizationService.java
View file @
d899de0f
...
...
@@ -45,9 +45,6 @@ public class AuthorizationService implements IAuthorizationService {
try
{
AuthorizationResponse
authorizationResponse
=
authorizationServiceImpl
.
authorizeAny
(
headers
,
PARTITION_ADMIN_ROLE
);
if
(
Objects
.
nonNull
(
authorizationResponse
))
{
headers
.
put
(
"user"
,
authorizationResponse
.
getUser
());
}
}
catch
(
AppException
e
)
{
throw
e
;
}
catch
(
Exception
e
)
{
...
...
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