fixed sonar bugs

This commit is contained in:
jomu
2015-02-21 15:43:55 +00:00
parent 0da3928f8a
commit b20d4ffd7a
2 changed files with 12 additions and 25 deletions

View File

@ -1,7 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package de.muehlencord.shared.jeeutil;
import java.io.BufferedReader;
@ -20,7 +16,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import static org.apache.log4j.Logger.getLogger;
/**
*
@ -28,7 +23,7 @@ import static org.apache.log4j.Logger.getLogger;
*/
public class AuthenticationFilter implements Filter {
private final static Logger logger = getLogger(AuthenticationFilter.class.getName());
private final static Logger LOGGER = Logger.getLogger(AuthenticationFilter.class);
private final static String USER = AuthenticationFilter.class.getName() + "_user";
private String loginPage;
private String errorPage;
@ -56,17 +51,18 @@ public class AuthenticationFilter implements Filter {
if (session != null) {
if (session.getAttribute(USER) != null) {
currentUser = (User) session.getAttribute(USER);
LOGGER.debug ("found "+currentUser);
} else {
logger.debug("No active session found - going to force login");
LOGGER.debug("No active session found - going to force login");
filterConfig.getServletContext().getRequestDispatcher(loginPage).forward(request, response);
}
} else {
if (currentUser == null) {
logger.debug("No logged in user found - going to force login");
LOGGER.debug("No logged in user found - going to force login");
filterConfig.getServletContext().getRequestDispatcher(loginPage).forward(request, response);
} else {
logger.debug("User is authenticated, continue filter chain");
LOGGER.debug("User is authenticated, continue filter chain");
// user is authenticated, continue with filter chain
chain.doFilter(request, response);
}
@ -97,7 +93,7 @@ public class AuthenticationFilter implements Filter {
pw.print("</html>");
} catch (Exception ex) {
logger.log(Level.ERROR, errorMsg, ex);
LOGGER.log(Level.ERROR, errorMsg, ex);
}
}

View File

@ -1,7 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package de.muehlencord.shared.security;
import static com.lambdaworks.crypto.SCryptUtil.check;
@ -11,8 +7,6 @@ import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Arrays;
import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
import static org.apache.log4j.Logger.getLogger;
/**
*
* @author joern@muehlencord.de
@ -20,8 +14,7 @@ import static org.apache.log4j.Logger.getLogger;
public abstract class PasswordUtil {
/** logging object */
private final static Logger logger = getLogger(PasswordUtil.class);
// private final static Logger LOGGER = Logger.getLogger(PasswordUtil.class);
/** SCrypt CPU cost parameter */
private final static int scryptCpuCostParameter = 16384;
@ -105,13 +98,11 @@ public abstract class PasswordUtil {
*
* @throws SecurityException if the random string could not be computed
*/
public static String getRandomString(String prefix, int length) throws SecurityException {
if (prefix == null) {
prefix = "";
}
int idLength = length - prefix.length();
return prefix + createSaltString(idLength);
public static String getRandomString(final String prefix, int length) throws SecurityException {
String usedPrefix = (prefix == null ? "" : prefix);
int idLength = length - usedPrefix.length();
return prefix + createSaltString(idLength);
}