diff options
Diffstat (limited to 'src/main/java/org')
3 files changed, 10 insertions, 58 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 2ad7117b..9ffa2503 100755 --- a/src/main/java/org/onap/music/main/MusicUtil.java +++ b/src/main/java/org/onap/music/main/MusicUtil.java @@ -642,22 +642,6 @@ public class MusicUtil { return response; } - - public static Map<String,String> extractBasicAuthentication(String authorization){ - Map<String,String> authValues = new HashMap<>(); - if(authorization == null) { - authValues.put("ERROR", "Authorization cannot be null"); - return authValues; - } - authorization = authorization.replaceFirst("Basic", ""); - String decoded = Base64.base64Decode(authorization); - StringTokenizer token = new StringTokenizer(decoded, ":"); - authValues.put(MusicUtil.USERID, token.nextToken()); - authValues.put(MusicUtil.PASSWORD,token.nextToken()); - return authValues; - - } - public static boolean isValidConsistency(String consistency) { for (String string : cosistencyLevel) { if (string.equalsIgnoreCase(consistency)) @@ -669,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) { diff --git a/src/main/java/org/onap/music/service/impl/MusicCassaCore.java b/src/main/java/org/onap/music/service/impl/MusicCassaCore.java index cf6f5ed3..cebdc667 100644 --- a/src/main/java/org/onap/music/service/impl/MusicCassaCore.java +++ b/src/main/java/org/onap/music/service/impl/MusicCassaCore.java @@ -286,7 +286,7 @@ public class MusicCassaCore implements MusicCoreService { try { LockObject lockOwner = getLockingServiceHandle().peekLockQueue(keyspace, table, primaryKeyValue); if (!lockOwner.getIsLockOwner()) { - return "No lock holder!"; + return null; } return "$" + fullyQualifiedKey + "$" + lockOwner.getLockRef(); } catch (MusicLockingException | MusicServiceException | MusicQueryException e) { |