This is an automated email from the ASF dual-hosted git repository.
abhay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/master by this push:
new 050000c RANGER-2400: policy name needs to be unique within security
zone and service - part 2
050000c is described below
commit 050000ceccb616ab5dff109283a1f7c4d42bb878
Author: Abhay Kulkarni <[email protected]>
AuthorDate: Thu Apr 18 13:21:48 2019 -0700
RANGER-2400: policy name needs to be unique within security zone and
service - part 2
---
.../model/validation/RangerPolicyValidator.java | 24 ++++++++++++----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git
a/agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java
b/agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java
index 54e541d..8882f43 100644
---
a/agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java
+++
b/agents-common/src/main/java/org/apache/ranger/plugin/model/validation/RangerPolicyValidator.java
@@ -251,7 +251,7 @@ public class RangerPolicyValidator extends RangerValidator {
}
if(existingPolicy != null) {
- if(!
StringUtils.equalsIgnoreCase(existingPolicy.getService(), policy.getService()))
{
+ if
(!StringUtils.equalsIgnoreCase(existingPolicy.getService(),
policy.getService())) {
ValidationErrorCode error =
ValidationErrorCode.POLICY_VALIDATION_ERR_POLICY_UPDATE_MOVE_SERVICE_NOT_ALLOWED;
failures.add(new
ValidationFailureDetailsBuilder()
.field("service name")
@@ -265,7 +265,7 @@ public class RangerPolicyValidator extends RangerValidator {
int existingPolicyType =
existingPolicy.getPolicyType() == null ? RangerPolicy.POLICY_TYPE_ACCESS :
existingPolicy.getPolicyType();
int policyType = policy.getPolicyType()
== null ? RangerPolicy.POLICY_TYPE_ACCESS : policy.getPolicyType();
- if(existingPolicyType != policyType) {
+ if (existingPolicyType != policyType) {
ValidationErrorCode error =
ValidationErrorCode.POLICY_VALIDATION_ERR_POLICY_TYPE_CHANGE_NOT_ALLOWED;
failures.add(new
ValidationFailureDetailsBuilder()
.field("policy type")
@@ -278,15 +278,17 @@ public class RangerPolicyValidator extends
RangerValidator {
String existingZoneName =
existingPolicy.getZoneName();
- if (!StringUtils.equals(existingZoneName,
zoneName)) {
- ValidationErrorCode error =
ValidationErrorCode.POLICY_VALIDATION_ERR_UPDATE_ZONE_NAME_NOT_ALLOWED;
- failures.add(new
ValidationFailureDetailsBuilder()
- .field("zoneName")
-
.isSemanticallyIncorrect()
-
.becauseOf(error.getMessage(id, existingZoneName, zoneName))
-
.errorCode(error.getErrorCode())
- .build());
- valid = false;
+ if (StringUtils.isNotEmpty(zoneName) ||
StringUtils.isNotEmpty(existingZoneName)) {
+ if
(!StringUtils.equals(existingZoneName, zoneName)) {
+ ValidationErrorCode error =
ValidationErrorCode.POLICY_VALIDATION_ERR_UPDATE_ZONE_NAME_NOT_ALLOWED;
+ failures.add(new
ValidationFailureDetailsBuilder()
+
.field("zoneName")
+
.isSemanticallyIncorrect()
+
.becauseOf(error.getMessage(id, existingZoneName, zoneName))
+
.errorCode(error.getErrorCode())
+ .build());
+ valid = false;
+ }
}
}