aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap
diff options
context:
space:
mode:
authorTschaen, Brendan <ctschaen@att.com>2019-06-02 19:00:24 -0400
committerTschaen, Brendan <ctschaen@att.com>2019-06-02 19:08:47 -0400
commitdb41ae6ccfd603f4955141017b41a5bda30c9add (patch)
tree6ac574f79f5ec6499c575e9c343931064459cf17 /src/main/java/org/onap
parentb7431be81e01554b21a94c2e7c1b1a527c329845 (diff)
AuthUtil tests added
Change-Id: I78a13b43c85cb208c217841ed85eaf0284aad930 Issue-ID: MUSIC-405 Signed-off-by: Tschaen, Brendan <ctschaen@att.com>
Diffstat (limited to 'src/main/java/org/onap')
-rw-r--r--src/main/java/org/onap/music/authentication/AuthUtil.java20
-rwxr-xr-xsrc/main/java/org/onap/music/main/MusicUtil.java30
2 files changed, 9 insertions, 41 deletions
diff --git a/src/main/java/org/onap/music/authentication/AuthUtil.java b/src/main/java/org/onap/music/authentication/AuthUtil.java
index 999acc75..51e3dac0 100644
--- a/src/main/java/org/onap/music/authentication/AuthUtil.java
+++ b/src/main/java/org/onap/music/authentication/AuthUtil.java
@@ -134,7 +134,11 @@ public class AuthUtil {
*/
public static boolean isAccessAllowed(ServletRequest request, String nameSpace) throws Exception {
- if (nameSpace.isEmpty()) {
+ if (request==null) {
+ throw new Exception("Request cannot be null");
+ }
+
+ if (nameSpace==null || nameSpace.isEmpty()) {
throw new Exception("NameSpace not Declared!");
}
@@ -143,9 +147,7 @@ public class AuthUtil {
//logger.info(EELFLoggerDelegate.applicationLogger,
// "AAFPermission of the requested MechId for all the namespaces: " + aafPermsList);
- String requestUri = null;
logger.debug(EELFLoggerDelegate.applicationLogger, "Requested nameSpace: " + nameSpace);
- HttpServletRequest httpRequest = null;
List<AAFPermission> aafPermsFinalList = filterNameSpacesAAFPermissions(nameSpace, aafPermsList);
@@ -154,10 +156,8 @@ public class AuthUtil {
"AuthUtil list of AAFPermission for the specific namespace ::::::::::::::::::::::::::::::::::::::::::::"
+ aafPermsFinalList);
- if (null != request) {
- httpRequest = (HttpServletRequest) request;
- requestUri = httpRequest.getRequestURI().substring(httpRequest.getContextPath().length() + 1);
- }
+ HttpServletRequest httpRequest = (HttpServletRequest) request;
+ String requestUri = httpRequest.getRequestURI().substring(httpRequest.getContextPath().length() + 1);
logger.debug(EELFLoggerDelegate.applicationLogger,
"AuthUtil requestUri ::::::::::::::::::::::::::::::::::::::::::::" + requestUri);
@@ -222,10 +222,8 @@ public class AuthUtil {
String[] subPath = null;
//String type = null;
//type = keyArray[0];
- String instance = null;
- instance = keyArray[1];
- String action = null;
- action = keyArray[2];
+ String instance = keyArray[1];
+ String action = keyArray[2];
//if the instance & action both are * , then allow
if ("*".equalsIgnoreCase(instance) && "*".equalsIgnoreCase(action)) {
diff --git a/src/main/java/org/onap/music/main/MusicUtil.java b/src/main/java/org/onap/music/main/MusicUtil.java
index 17e3fcf6..9ffa2503 100755
--- a/src/main/java/org/onap/music/main/MusicUtil.java
+++ b/src/main/java/org/onap/music/main/MusicUtil.java
@@ -653,36 +653,6 @@ public class MusicUtil {
public static ConsistencyLevel getConsistencyLevel(String consistency) {
return consistencyName.get(consistency.toUpperCase());
- }
-
- public static void loadProperties() throws Exception {
- Properties prop = new Properties();
- InputStream input = null;
- try {
- // load the properties file
- input = MusicUtil.class.getClassLoader().getResourceAsStream("music.properties");
- prop.load(input);
- } catch (Exception ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "Unable to find properties file.", ex);
- throw new Exception();
- } finally {
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- e.printStackTrace();
- logger.error(EELFLoggerDelegate.errorLogger, e);
- }
- }
- }
- // get the property value and return it
- MusicUtil.setMyCassaHost(prop.getProperty("cassandra.host"));
- MusicUtil.setCassName(prop.getProperty("cassandra.user"));
- MusicUtil.setCassPwd(prop.getProperty("cassandra.password"));
- MusicUtil.setCassandraPort(Integer.parseInt(prop.getProperty("cassandra.port")));
- MusicUtil.setNotifyTimeOut(Integer.parseInt(prop.getProperty("notify.timeout")));
- MusicUtil.setNotifyInterval(Integer.parseInt(prop.getProperty("notify.interval")));
- MusicUtil.setCacheObjectMaxLife(Integer.parseInt(prop.getProperty("cacheobject.maxlife")));
}
public static void setNotifyInterval(int notifyinterval) {