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
Search
Commits
78eaa3cc
Commit
78eaa3cc
authored
Apr 16, 2021
by
Alok Joshi
Browse files
review comment changes
parent
6c6d8c66
Pipeline
#36307
failed with stages
in 35 minutes and 21 seconds
Changes
9
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
docs/tutorial/PolicyService-Integration.md
View file @
78eaa3cc
...
...
@@ -23,7 +23,8 @@ Here are steps to enable Policy service for a provider:
-
Add and provide values for following runtime configuration in
`application.properties`
```
service.policy.enabled=true
POLICY_API=${policy_service_endpoint}
service.policy.endpoint=${policy_service_endpoint}
policy.cache.timeout=<timeout_in_minutes>
PARTITION_API=${partition_service_endpoint}
```
...
...
provider/search-aws/src/main/resources/application.properties
View file @
78eaa3cc
...
...
@@ -68,7 +68,7 @@ server.ssl.key-store-password=${SSL_KEY_STORE_PASSWORD:}
# Policy service properties
service.policy.enabled
=
false
POLICY_API
=
${ENTITLEMENTS_BASE_URL}/api/policy/v1
POLICY_ID
=
search
service.policy.endpoint
=
${ENTITLEMENTS_BASE_URL}/api/policy/v1
service.policy.id
=
search
PARTITION_API
=
${ENTITLEMENTS_BASE_URL}/api/partition/v1
aws.environment
=
${ENVIRONMENT}
\ No newline at end of file
provider/search-azure/src/main/resources/application.properties
View file @
78eaa3cc
...
...
@@ -78,4 +78,6 @@ management.health.azure-key-vault.enabled=false
# Policy service properties
service.policy.enabled
=
${policy_enabled}
POLICY_API
=
${policy_service_endpoint}
\ No newline at end of file
service.policy.endpoint
=
${policy_service_endpoint}
policy.cache.timeout
=
5
service.policy.id
=
search
\ No newline at end of file
search-core/src/main/java/org/opengroup/osdu/search/policy/di/PartitionClientFactory.java
View file @
78eaa3cc
...
...
@@ -14,22 +14,28 @@
package
org.opengroup.osdu.search.policy.di
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.opengroup.osdu.core.common.partition.IPartitionFactory
;
import
org.opengroup.osdu.core.common.partition.PartitionAPIConfig
;
import
org.opengroup.osdu.core.common.partition.PartitionFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.config.AbstractFactoryBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Component
;
@Component
@Primary
@Configuration
@ConfigurationProperties
@Getter
@Setter
@ConditionalOnProperty
(
value
=
"service.policy.enabled"
,
havingValue
=
"true"
,
matchIfMissing
=
false
)
public
class
PartitionClientFactory
extends
AbstractFactoryBean
<
IPartitionFactory
>
{
@Value
(
"${PARTITION_API}"
)
private
String
partitionAPIEndpoint
;
private
String
PARTITION_API
;
@Override
public
Class
<?>
getObjectType
()
{
...
...
@@ -39,7 +45,7 @@ public class PartitionClientFactory extends AbstractFactoryBean<IPartitionFactor
@Override
protected
IPartitionFactory
createInstance
()
throws
Exception
{
PartitionAPIConfig
apiConfig
=
PartitionAPIConfig
.
builder
()
.
rootUrl
(
partitionAPIEndpoint
)
.
rootUrl
(
PARTITION_API
)
.
build
();
return
new
PartitionFactory
(
apiConfig
);
}
...
...
search-core/src/main/java/org/opengroup/osdu/search/policy/di/PolicyCacheConfiguration.java
View file @
78eaa3cc
...
...
@@ -15,7 +15,8 @@
package
org.opengroup.osdu.search.policy.di
;
import
lombok.Getter
;
import
org.springframework.beans.factory.annotation.Value
;
import
lombok.Setter
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Lazy
;
...
...
@@ -23,16 +24,17 @@ import org.springframework.context.annotation.Lazy;
import
javax.inject.Named
;
@Configuration
@ConfigurationProperties
(
prefix
=
"policy.cache"
)
@Getter
@Setter
@Lazy
public
class
PolicyCacheConfiguration
{
@Value
(
"${policy.cache.timeout:5}"
)
private
int
cacheTimeOut
;
private
int
timeout
;
@Bean
@Named
(
"POLICY_CACHE_TIMEOUT"
)
public
int
getPolicyCacheTimeout
()
{
return
cacheT
ime
O
ut
;
return
t
ime
o
ut
;
}
}
search-core/src/main/java/org/opengroup/osdu/search/policy/di/PolicyClientFactory.java
View file @
78eaa3cc
...
...
@@ -41,7 +41,7 @@ public class PolicyClientFactory extends AbstractFactoryBean<IPolicyFactory> {
@Override
protected
IPolicyFactory
createInstance
()
throws
Exception
{
PolicyAPIConfig
apiConfig
=
PolicyAPIConfig
.
builder
()
.
rootUrl
(
serviceConfiguration
.
get
PolicyApi
Endpoint
())
.
rootUrl
(
serviceConfiguration
.
getEndpoint
())
.
build
();
return
new
PolicyFactory
(
apiConfig
,
httpResponseBodyMapper
);
}
...
...
search-core/src/main/java/org/opengroup/osdu/search/policy/di/PolicyServiceConfiguration.java
View file @
78eaa3cc
...
...
@@ -15,18 +15,18 @@
package
org.opengroup.osdu.search.policy.di
;
import
lombok.Getter
;
import
org.springframework.beans.factory.annotation.Value
;
import
lombok.Setter
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
@ConfigurationProperties
(
prefix
=
"service.policy"
)
@Getter
@Setter
@ConditionalOnProperty
(
value
=
"service.policy.enabled"
,
havingValue
=
"true"
,
matchIfMissing
=
false
)
public
class
PolicyServiceConfiguration
{
@Value
(
"${POLICY_ID:search}"
)
private
String
policyId
;
@Value
(
"${POLICY_API}"
)
private
String
policyApiEndpoint
;
private
String
id
;
private
String
endpoint
;
}
search-core/src/main/java/org/opengroup/osdu/search/policy/service/PolicyServiceImpl.java
View file @
78eaa3cc
...
...
@@ -89,7 +89,7 @@ public class PolicyServiceImpl implements IPolicyService{
searchPolicy
.
setRecords
(
records
);
PolicyRequest
policy
=
new
PolicyRequest
();
policy
.
setPolicyId
(
this
.
policyServiceConfiguration
.
get
Policy
Id
());
policy
.
setPolicyId
(
this
.
policyServiceConfiguration
.
getId
());
policy
.
setInput
(
new
JsonParser
().
parse
(
new
Gson
().
toJson
(
searchPolicy
)).
getAsJsonObject
());
return
policy
;
}
...
...
search-core/src/test/java/org/opengroup/osdu/search/service/policy/service/PolicyServiceImplTest.java
View file @
78eaa3cc
...
...
@@ -82,7 +82,7 @@ public class PolicyServiceImplTest {
Mockito
.
when
(
serviceClient
.
evaluateBatchPolicy
(
any
())).
thenReturn
(
batchPolicyResponse
);
Groups
groups
=
new
Groups
();
Mockito
.
when
(
entitlementsService
.
getGroups
(
any
())).
thenReturn
(
groups
);
Mockito
.
when
(
policyServiceConfiguration
.
get
Policy
Id
()).
thenReturn
(
"search"
);
Mockito
.
when
(
policyServiceConfiguration
.
getId
()).
thenReturn
(
"search"
);
List
<
String
>
result
=
sut
.
evaluateSearchDataAuthorizationPolicy
(
recordMetadataList
,
OperationType
.
view
);
Assert
.
assertEquals
(
1
,
result
.
size
());
Assert
.
assertEquals
(
"id:123"
,
result
.
get
(
0
));
...
...
Write
Preview
Markdown
is supported
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