diff options
Diffstat (limited to 'src/main/java/org/onap/music/main')
-rwxr-xr-x | src/main/java/org/onap/music/main/CachingUtil.java | 15 | ||||
-rwxr-xr-x | src/main/java/org/onap/music/main/MusicUtil.java | 4 | ||||
-rwxr-xr-x | src/main/java/org/onap/music/main/PropertiesListener.java | 9 |
3 files changed, 18 insertions, 10 deletions
diff --git a/src/main/java/org/onap/music/main/CachingUtil.java b/src/main/java/org/onap/music/main/CachingUtil.java index a81887a0..18cf90d9 100755 --- a/src/main/java/org/onap/music/main/CachingUtil.java +++ b/src/main/java/org/onap/music/main/CachingUtil.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (c) 2017 AT&T Intellectual Property * =================================================================== + * Modifications Copyright (c) 2018 IBM + * =================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -65,6 +67,9 @@ public class CachingUtil implements Runnable { private static CacheAccess<String, List<String>> callbackNotifyList = JCS.getInstance("callbackNotifyList"); private static Map<String, Number> userAttempts = new HashMap<>(); private static Map<String, Calendar> lastFailedTime = new HashMap<>(); + + private static final String USERNAME="username"; + private static final String PASSWORD="password"; public boolean isCacheRefreshNeeded() { if (aafCache.get("initBlankMap") == null) @@ -112,8 +117,8 @@ public class CachingUtil implements Runnable { while (it.hasNext()) { Row row = it.next(); String nameSpace = row.getString("keyspace_name"); - String userId = row.getString("username"); - String password = row.getString("password"); + String userId = row.getString(USERNAME); + String password = row.getString(PASSWORD); String keySpace = row.getString("application_name"); try { userAttempts.put(nameSpace, 0); @@ -361,7 +366,7 @@ public class CachingUtil implements Runnable { logger.error(EELFLoggerDelegate.errorLogger,"Application is not onboarded. Please contact admin."); resultMap.put("Exception", "Application is not onboarded. Please contact admin."); } else { - if(!(rs.getString("username").equals(userId)) || !(BCrypt.checkpw(password, rs.getString("password")))) { + if(!(rs.getString(USERNAME).equals(userId)) || !(BCrypt.checkpw(password, rs.getString(PASSWORD)))) { logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.AUTHENTICATIONERROR, ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR); logger.error(EELFLoggerDelegate.errorLogger,"Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId); resultMap.put("Exception", "Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId); @@ -407,8 +412,8 @@ public class CachingUtil implements Runnable { return resultMap; } else { - String user = rs.getString("username"); - pwd = rs.getString("password"); + String user = rs.getString(USERNAME); + pwd = rs.getString(PASSWORD); String ns = rs.getString("application_name"); if(!ns.equals(nameSpace)) { resultMap.put("Exception", "Namespace and keyspace doesn't match"); diff --git a/src/main/java/org/onap/music/main/MusicUtil.java b/src/main/java/org/onap/music/main/MusicUtil.java index cfad845d..d2e8591c 100755 --- a/src/main/java/org/onap/music/main/MusicUtil.java +++ b/src/main/java/org/onap/music/main/MusicUtil.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (c) 2017 AT&T Intellectual Property * =================================================================== + * Modifications Copyright (c) 2018 IBM. + * =================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -578,7 +580,7 @@ public class MusicUtil { authorization = authorization.replaceFirst("Basic", ""); String decoded = Base64.base64Decode(authorization); StringTokenizer token = new StringTokenizer(decoded, ":"); - authValues.put(MusicUtil.USERID, token.nextToken().toString()); + authValues.put(MusicUtil.USERID, token.nextToken()); authValues.put(MusicUtil.PASSWORD,token.nextToken()); return authValues; diff --git a/src/main/java/org/onap/music/main/PropertiesListener.java b/src/main/java/org/onap/music/main/PropertiesListener.java index 0ed18be2..026790ee 100755 --- a/src/main/java/org/onap/music/main/PropertiesListener.java +++ b/src/main/java/org/onap/music/main/PropertiesListener.java @@ -3,6 +3,7 @@ * org.onap.music * =================================================================== * Copyright (c) 2017 AT&T Intellectual Property + * Modifications Copyright (C) 2018 IBM. * =================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +38,7 @@ import org.onap.music.eelf.logging.format.ErrorTypes; public class PropertiesListener implements ServletContextListener { private Properties prop; - + private static final String MUSIC_PROPERTIES="music.properties"; private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PropertiesListener.class); @Override @@ -51,8 +52,8 @@ public class PropertiesListener implements ServletContextListener { try { InputStream musicProps = null; projectProp.load(new FileInputStream(musicPropertiesFilePath)); - if (projectProp.containsKey("music.properties")) { - musicProps = new FileInputStream(projectProp.getProperty("music.properties")); + if (projectProp.containsKey(MUSIC_PROPERTIES)) { + musicProps = new FileInputStream(projectProp.getProperty(MUSIC_PROPERTIES)); } else { musicProps = new FileInputStream(MusicUtil.getMusicPropertiesFilePath()); } @@ -84,7 +85,7 @@ public class PropertiesListener implements ServletContextListener { case "music.rest.ip": MusicUtil.setMusicRestIp(prop.getProperty(key)); break; - case "music.properties": + case MUSIC_PROPERTIES: MusicUtil.setMusicPropertiesFilePath(prop.getProperty(key)); break; case "lock.lease.period": |