summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsu622b <su622b@att.com>2019-07-25 14:57:54 -0400
committersu622b <su622b@att.com>2019-07-25 15:03:57 -0400
commitbceb38a3a8ff0b4d80210724e339905bc714891d (patch)
treed6997d70a13a8a445feaf721f0e141bc2fd05e10
parent3d53d9c961c0fc04e004b3d3158bf9cacdab52b8 (diff)
configurable AAF permissions parts
Issue-ID: DMAAP-1248 Change-Id: I998de1e52b961082f8af3997ab89e4a335e128f3 Signed-off-by: su622b <su622b@att.com>
-rw-r--r--src/main/java/org/onap/dmaap/dmf/mr/security/DMaaPAAFAuthenticatorImpl.java26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/main/java/org/onap/dmaap/dmf/mr/security/DMaaPAAFAuthenticatorImpl.java b/src/main/java/org/onap/dmaap/dmf/mr/security/DMaaPAAFAuthenticatorImpl.java
index 0e6b0f6..642a2ec 100644
--- a/src/main/java/org/onap/dmaap/dmf/mr/security/DMaaPAAFAuthenticatorImpl.java
+++ b/src/main/java/org/onap/dmaap/dmf/mr/security/DMaaPAAFAuthenticatorImpl.java
@@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletRequest;
import org.onap.dmaap.dmf.mr.CambriaApiException;
import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
-
/**
*
* @author sneha.d.desai
@@ -36,8 +35,11 @@ import org.onap.dmaap.dmf.mr.constants.CambriaConstants;
public class DMaaPAAFAuthenticatorImpl implements DMaaPAAFAuthenticator {
private static final String NAMESPACE_PROPERTY = "defaultNSforUEB";
- private static final String DEFAULT_NAMESPACE = "org.onap.dmaap.mr";
- private static final String NAMESPACE_PREFIX = "org.onap";
+ private static final String DEFAULT_NAMESPACE = "org.onap.dmaap.mr";
+ private static final String NAMESPACE_PREFIX = "org.onap";
+ private static final String NAMESPACE_PREFIX_VAR = "namespacePrefix";
+ private static final String DEFAULT_NAMESPACE_VAR = "defaultNamespace";
+ private static final String INSTANCE_PART_VAR = "pubSubInstPart";
/**
* @param req
@@ -51,21 +53,25 @@ public class DMaaPAAFAuthenticatorImpl implements DMaaPAAFAuthenticator {
@Override
public String aafPermissionString(String topicName, String action) throws CambriaApiException {
- String nameSpace = topicName.startsWith(NAMESPACE_PREFIX) ? parseNamespace(topicName) :
- readNamespaceFromProperties();
+ String nameSpace = topicName.startsWith(
+ System.getenv(NAMESPACE_PREFIX_VAR) != null ? System.getenv(NAMESPACE_PREFIX_VAR) : NAMESPACE_PREFIX)
+ ? parseNamespace(topicName) : readNamespaceFromProperties();
- nameSpace = !nameSpace.isEmpty()? nameSpace : DEFAULT_NAMESPACE;
+ nameSpace = !nameSpace.isEmpty() ? nameSpace
+ : (System.getenv(DEFAULT_NAMESPACE_VAR) != null ? System.getenv(DEFAULT_NAMESPACE_VAR)
+ : DEFAULT_NAMESPACE);
- return new StringBuilder(nameSpace).append(".topic|:topic.").append(topicName)
- .append("|").append(action).toString();
+ return new StringBuilder(nameSpace).append(
+ (System.getenv(INSTANCE_PART_VAR) != null ? System.getenv(INSTANCE_PART_VAR) : ".topic") + "|:topic.")
+ .append(topicName).append("|").append(action).toString();
}
String readNamespaceFromProperties() {
- return AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,NAMESPACE_PROPERTY);
+ return AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop, NAMESPACE_PROPERTY);
}
private String parseNamespace(String topicName) {
- return topicName.substring(0,topicName.lastIndexOf('.'));
+ return topicName.substring(0, topicName.lastIndexOf('.'));
}
}