From 8d5386be38db25a2a41c3bf6c876adee21ca26cc Mon Sep 17 00:00:00 2001
From: Roberto Sánchez <roberto.sanchez@curisit.net>
Date: Fri, 19 Sep 2014 08:26:02 +0000
Subject: [PATCH] #396 fix - Fixed more SonarQube issues

---
 securis/src/main/java/net/curisit/securis/ioc/SecurisModule.java |  238 ++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 120 insertions(+), 118 deletions(-)

diff --git a/securis/src/main/java/net/curisit/securis/ioc/SecurisModule.java b/securis/src/main/java/net/curisit/securis/ioc/SecurisModule.java
index 7e60cac..827218e 100644
--- a/securis/src/main/java/net/curisit/securis/ioc/SecurisModule.java
+++ b/securis/src/main/java/net/curisit/securis/ioc/SecurisModule.java
@@ -22,142 +22,144 @@
 
 public class SecurisModule extends AbstractModule {
 
-	private static final int DEFAULT_PORT = 9997;
-	private static final String PROPERTIES_FILE_NAME = "/server.properties";
+    private static final int DEFAULT_PORT = 9997;
+    private static final String PROPERTIES_FILE_NAME = "/server.properties";
 
-	private static final Logger LOG = LogManager.getLogger(SecurisModule.class);
+    private static final Logger LOG = LogManager.getLogger(SecurisModule.class);
 
-	@Override
-	protected void configure() {
+    @Override
+    protected void configure() {
 
-	}
+    }
 
-	public String getPassword() {
-		return getFilePassword() + " " + "53curi5";
-	}
+    public String getPassword() {
+        return getFilePassword() + " " + "53curi5";
+    }
 
-	public String getFilePassword() {
-		return "cur151T";
-	}
+    public String getFilePassword() {
+        return "cur151T";
+    }
 
-	public String getUrl(File appDir) {
-		return String.format("jdbc:h2:%s/db/securis;CIPHER=AES", appDir.getAbsolutePath());
-	}
+    public String getUrl(File appDir) {
+        return String.format("jdbc:h2:%s/db/securis;CIPHER=AES", appDir.getAbsolutePath());
+    }
 
-	@Named("base-uri")
-	@Provides
-	@Singleton
-	public URI getBaseURI() {
-		// TODO Read from configuration, where?
-		try {
-			// String url = MessageFormat.format("http://{0}/", InetAddress.getLocalHost().getHostAddress());
-			String url = MessageFormat.format("http://{0}/", "0.0.0.0");
-			LOG.debug("Server url{}", url);
-			return UriBuilder.fromUri(url).port(getPort()).build();
-		} catch (IllegalArgumentException | UriBuilderException e) {
-			return UriBuilder.fromUri("http://localhost/").port(getPort()).build();
-		}
-	}
+    @Named("base-uri")
+    @Provides
+    @Singleton
+    public URI getBaseURI() {
+        // TODO Read from configuration, where?
+        try {
+            String url = MessageFormat.format("http://{0}/", "0.0.0.0");
+            LOG.debug("Server url{}", url);
+            return UriBuilder.fromUri(url).port(getPort()).build();
+        } catch (IllegalArgumentException | UriBuilderException e) {
+            return UriBuilder.fromUri("http://localhost/").port(getPort()).build();
+        }
+    }
 
-	private int getPort() {
-		Integer port;
-		Properties prop = new Properties();
-		try {
-			prop.load(getClass().getResourceAsStream(PROPERTIES_FILE_NAME));
-			port = Integer.valueOf(prop.getProperty("port"));
-			if (port == null)
-				return DEFAULT_PORT;
-			else
-				return port;
-		} catch (Exception ex) {
-			return DEFAULT_PORT;
-		}
-	}
+    private int getPort() {
+        Integer port;
+        Properties prop = new Properties();
+        try {
+            prop.load(getClass().getResourceAsStream(PROPERTIES_FILE_NAME));
+            port = Integer.valueOf(prop.getProperty("port"));
+            if (port == null) {
+                return DEFAULT_PORT;
+            } else {
+                return port;
+            }
+        } catch (Exception ex) {
+            return DEFAULT_PORT;
+        }
+    }
 
-	protected List<String> getAppDbFiles() {
+    protected List<String> getAppDbFiles() {
 
-		return Arrays.asList("/db/schema.sql");
-	}
+        return Arrays.asList("/db/schema.sql");
+    }
 
-	@Named("temporary-dir")
-	@Provides
-	@Singleton
-	public File getTemporaryDir() {
-		String tmp = getAppDir().getAbsolutePath();
-		tmp += File.separator + ".TEMP";
-		File ftmp = new File(tmp);
-		if (!ftmp.exists()) {
-			if (!ftmp.mkdirs())
-				return null;
-			LOG.debug("Created temporary directory for app in: {}", ftmp.getAbsolutePath());
-			ftmp.deleteOnExit();
-		}
-		return ftmp;
-	}
+    @Named("temporary-dir")
+    @Provides
+    @Singleton
+    public File getTemporaryDir() {
+        String tmp = getAppDir().getAbsolutePath();
+        tmp += File.separator + ".TEMP";
+        File ftmp = new File(tmp);
+        if (!ftmp.exists()) {
+            if (!ftmp.mkdirs()) {
+                return null;
+            }
+            LOG.debug("Created temporary directory for app in: {}", ftmp.getAbsolutePath());
+            ftmp.deleteOnExit();
+        }
+        return ftmp;
+    }
 
-	@Named("app-dir")
-	@Provides
-	@Singleton
-	public File getAppDir() {
-		String appDir = System.getProperty("user.home", System.getProperty("user.dir"));
-		if (appDir == null) {
-			appDir = ".";
-		}
-		appDir += File.separator + ".SeCuris";
-		File fAppDir = new File(appDir);
-		if (!fAppDir.exists()) {
-			if (!fAppDir.mkdirs())
-				return null;
-			LOG.debug("Created app working directory app in: {}", fAppDir.getAbsolutePath());
-		}
-		return fAppDir;
-	}
+    @Named("app-dir")
+    @Provides
+    @Singleton
+    public File getAppDir() {
+        String appDir = System.getProperty("user.home", System.getProperty("user.dir"));
+        if (appDir == null) {
+            appDir = ".";
+        }
+        appDir += File.separator + ".SeCuris";
+        File fAppDir = new File(appDir);
+        if (!fAppDir.exists()) {
+            if (!fAppDir.mkdirs()) {
+                return null;
+            }
+            LOG.debug("Created app working directory app in: {}", fAppDir.getAbsolutePath());
+        }
+        return fAppDir;
+    }
 
-	@Named("support-email")
-	@Provides
-	@Singleton
-	public String getSupportEmail() {
-		return "integrity@curistec.com";
-	}
+    @Named("support-email")
+    @Provides
+    @Singleton
+    public String getSupportEmail() {
+        return "integrity@curistec.com";
+    }
 
-	@Named("hash-logo")
-	@Provides
-	@Singleton
-	public String getHashLogo() {
-		return "1b42616809d4cd8ccf109e3c30d0ab25067f160b30b7354a08ddd563de0096ba";
-	}
+    @Named("hash-logo")
+    @Provides
+    @Singleton
+    public String getHashLogo() {
+        return "1b42616809d4cd8ccf109e3c30d0ab25067f160b30b7354a08ddd563de0096ba";
+    }
 
-	@Named("license-req-file-name")
-	@Provides
-	@Singleton
-	public String getLicenseReqFileName() {
-		return "license.req";
-	}
+    @Named("license-req-file-name")
+    @Provides
+    @Singleton
+    public String getLicenseReqFileName() {
+        return "license.req";
+    }
 
-	@Named("license-file-name")
-	@Provides
-	@Singleton
-	public String getLicenseFileName() {
-		return "license.lic";
-	}
+    @Named("license-file-name")
+    @Provides
+    @Singleton
+    public String getLicenseFileName() {
+        return "license.lic";
+    }
 
-	@Provides
-	@Singleton
-	public DataSource getDataSource(@Named("app-dir") File appDir) {
+    @Provides
+    @Singleton
+    public DataSource getDataSource(@Named("app-dir") File appDir) {
 
-		JdbcDataSource dataSource = new JdbcDataSource();
-		dataSource.setURL(getUrl(appDir));
-		dataSource.setUser("curis");
-		dataSource.setPassword(getPassword());
-		LOG.debug("JdbcDataSource: {}", dataSource);
-		return dataSource;
-	}
+        JdbcDataSource dataSource = new JdbcDataSource();
+        dataSource.setURL(getUrl(appDir));
+        dataSource.setUser("curis");
+        dataSource.setPassword(getPassword());
+        LOG.debug("JdbcDataSource: {}", dataSource);
+        return dataSource;
+    }
 
-	@Named("db-files")
-	@Provides
-	@Singleton
-	public List<String> getDbFiles() {
-		return getAppDbFiles();
-	}
+    @Named("db-files")
+    @Provides
+    @Singleton
+    public List<String> getDbFiles() {
+        return getAppDbFiles();
+    }
 
 }

--
Gitblit v1.3.2