diff options
author | 2018-10-10 18:35:03 -0400 | |
---|---|---|
committer | 2018-10-10 18:37:20 -0400 | |
commit | 3c077fdac44a644167b246ed4e0377603f54804d (patch) | |
tree | 69fc09df0cdb22cdbf4c7b7500caa77da4a303b6 /src/main/java/com/att/dmf/mr/utils | |
parent | 7183a01048c01c4810f2096408406cd0dbf85753 (diff) |
fixes for sonar vulnerabilities
Issue-ID: DMAAP-824
Change-Id: I15a693f443370f5fd03cf3ede2946afa6b7f1a3b
Signed-off-by: sunil unnava <sunil.unnava@att.com>
Diffstat (limited to 'src/main/java/com/att/dmf/mr/utils')
-rw-r--r-- | src/main/java/com/att/dmf/mr/utils/ConfigurationReader.java | 12 | ||||
-rw-r--r-- | src/main/java/com/att/dmf/mr/utils/Emailer.java | 5 | ||||
-rw-r--r-- | src/main/java/com/att/dmf/mr/utils/Utils.java | 20 |
3 files changed, 25 insertions, 12 deletions
diff --git a/src/main/java/com/att/dmf/mr/utils/ConfigurationReader.java b/src/main/java/com/att/dmf/mr/utils/ConfigurationReader.java index 17de391..aebca34 100644 --- a/src/main/java/com/att/dmf/mr/utils/ConfigurationReader.java +++ b/src/main/java/com/att/dmf/mr/utils/ConfigurationReader.java @@ -112,6 +112,7 @@ public class ConfigurationReader { * @throws ServletException * @throws KafkaConsumerCacheException * @throws ConfigDbException + * @throws KeyExistsException */ @Autowired public ConfigurationReader(@Qualifier("propertyReader") rrNvReadable settings, @@ -128,7 +129,7 @@ public class ConfigurationReader { */ @Qualifier("dMaaPAuthenticatorImpl") DMaaPAuthenticator<NsaSimpleApiKey> fSecurityManager ) - throws missingReqdSetting, invalidSettingValue, ServletException, KafkaConsumerCacheException, ConfigDbException { + throws missingReqdSetting, invalidSettingValue, ServletException, KafkaConsumerCacheException, ConfigDbException, KeyExistsException { this.fMetrics = fMetrics; this.zk = zk; @@ -158,7 +159,7 @@ public class ConfigurationReader { } protected void servletSetup() - throws rrNvReadable.missingReqdSetting, rrNvReadable.invalidSettingValue, ServletException, ConfigDbException { + throws rrNvReadable.missingReqdSetting, rrNvReadable.invalidSettingValue, ServletException, ConfigDbException, KeyExistsException { try { fMetrics.toJson(); @@ -169,19 +170,12 @@ public class ConfigurationReader { if ( adminSecret != null && adminSecret.length () > 0 ) { - try - { final NsaApiDb<NsaSimpleApiKey> adminDb = new BaseNsaApiDbImpl<NsaSimpleApiKey> ( new MemConfigDb(), new NsaSimpleApiKeyFactory() ); adminDb.createApiKey ( "admin", adminSecret ); fSecurityManager.addAuthenticator ( new DMaaPOriginalUebAuthenticator<NsaSimpleApiKey> ( adminDb, 10*60*1000 ) ); - } - catch ( KeyExistsException e ) - { - throw new RuntimeException ( "This key can't exist in a fresh in-memory DB!", e ); - } } // setup a backend diff --git a/src/main/java/com/att/dmf/mr/utils/Emailer.java b/src/main/java/com/att/dmf/mr/utils/Emailer.java index a940abf..1b68216 100644 --- a/src/main/java/com/att/dmf/mr/utils/Emailer.java +++ b/src/main/java/com/att/dmf/mr/utils/Emailer.java @@ -89,7 +89,6 @@ public class Emailer private static final EELFLogger log = EELFManager.getInstance().getLogger(Emailer.class); public static final String kSetting_MailAuthUser = "mailLogin"; - public static final String kSetting_MailAuthPwd = "mailPassword"; public static final String kSetting_MailFromEmail = "mailFromEmail"; public static final String kSetting_MailFromName = "mailFromName"; public static final String kSetting_SmtpServer = "mailSmtpServer"; @@ -162,14 +161,14 @@ public class Emailer makeSetting ( prop, "mail.smtp.starttls.enable", kSetting_SmtpServerSsl, true ); final String un = getSetting ( kSetting_MailAuthUser, "" ); - final String pw = getSetting ( kSetting_MailAuthPwd, "" ); + final String value=(AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,"mailPassword")!=null)?AJSCPropertiesMap.getProperty(CambriaConstants.msgRtr_prop,"mailPassword"):""; final Session session = Session.getInstance ( prop, new javax.mail.Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication ( un, pw ); + return new PasswordAuthentication ( un, value ); } } ); diff --git a/src/main/java/com/att/dmf/mr/utils/Utils.java b/src/main/java/com/att/dmf/mr/utils/Utils.java index 70691cf..c2b8b88 100644 --- a/src/main/java/com/att/dmf/mr/utils/Utils.java +++ b/src/main/java/com/att/dmf/mr/utils/Utils.java @@ -21,16 +21,22 @@ *******************************************************************************/ package com.att.dmf.mr.utils; +import java.io.IOException; +import java.io.InputStream; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Enumeration; import java.util.LinkedList; import java.util.List; +import java.util.Properties; import javax.servlet.http.HttpServletRequest; +import com.att.dmf.mr.backends.kafka.KafkaPublisher; import com.att.dmf.mr.beans.DMaaPContext; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** * This is an utility class for various operations for formatting * @author nilanjana.maity @@ -41,6 +47,7 @@ public class Utils { private static final String DATE_FORMAT = "dd-MM-yyyy::hh:mm:ss:SSS"; public static final String CAMBRIA_AUTH_HEADER = "X-CambriaAuth"; private static final String BATCH_ID_FORMAT = "000000"; + private static final EELFLogger log = EELFManager.getInstance().getLogger(Utils.class); private Utils() { super(); @@ -142,4 +149,17 @@ public class Utils { } return list; } + + public static String getKafkaproperty(){ + InputStream input = new Utils().getClass().getResourceAsStream("/kafka.properties"); + Properties props = new Properties(); + try { + props.load(input); + } catch (IOException e) { + log.error("failed to read kafka.properties"); + } + return props.getProperty("key"); + + + } } |