fixed sonar bugs
This commit is contained in:
@ -1,7 +1,3 @@
|
|||||||
/*
|
|
||||||
* To change this template, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package de.muehlencord.shared.jeeutil;
|
package de.muehlencord.shared.jeeutil;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@ -20,7 +16,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
import org.apache.log4j.Level;
|
import org.apache.log4j.Level;
|
||||||
import org.apache.log4j.Logger;
|
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 {
|
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 final static String USER = AuthenticationFilter.class.getName() + "_user";
|
||||||
private String loginPage;
|
private String loginPage;
|
||||||
private String errorPage;
|
private String errorPage;
|
||||||
@ -56,17 +51,18 @@ public class AuthenticationFilter implements Filter {
|
|||||||
if (session != null) {
|
if (session != null) {
|
||||||
if (session.getAttribute(USER) != null) {
|
if (session.getAttribute(USER) != null) {
|
||||||
currentUser = (User) session.getAttribute(USER);
|
currentUser = (User) session.getAttribute(USER);
|
||||||
|
LOGGER.debug ("found "+currentUser);
|
||||||
} else {
|
} 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);
|
filterConfig.getServletContext().getRequestDispatcher(loginPage).forward(request, response);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (currentUser == null) {
|
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);
|
filterConfig.getServletContext().getRequestDispatcher(loginPage).forward(request, response);
|
||||||
} else {
|
} else {
|
||||||
logger.debug("User is authenticated, continue filter chain");
|
LOGGER.debug("User is authenticated, continue filter chain");
|
||||||
// user is authenticated, continue with filter chain
|
// user is authenticated, continue with filter chain
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
}
|
}
|
||||||
@ -97,7 +93,7 @@ public class AuthenticationFilter implements Filter {
|
|||||||
pw.print("</html>");
|
pw.print("</html>");
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.log(Level.ERROR, errorMsg, ex);
|
LOGGER.log(Level.ERROR, errorMsg, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,3 @@
|
|||||||
/*
|
|
||||||
* To change this template, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package de.muehlencord.shared.security;
|
package de.muehlencord.shared.security;
|
||||||
|
|
||||||
import static com.lambdaworks.crypto.SCryptUtil.check;
|
import static com.lambdaworks.crypto.SCryptUtil.check;
|
||||||
@ -11,8 +7,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import static org.apache.log4j.Logger.getLogger;
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author joern@muehlencord.de
|
* @author joern@muehlencord.de
|
||||||
@ -20,8 +14,7 @@ import static org.apache.log4j.Logger.getLogger;
|
|||||||
public abstract class PasswordUtil {
|
public abstract class PasswordUtil {
|
||||||
|
|
||||||
/** logging object */
|
/** logging object */
|
||||||
private final static Logger logger = getLogger(PasswordUtil.class);
|
// private final static Logger LOGGER = Logger.getLogger(PasswordUtil.class);
|
||||||
|
|
||||||
|
|
||||||
/** SCrypt CPU cost parameter */
|
/** SCrypt CPU cost parameter */
|
||||||
private final static int scryptCpuCostParameter = 16384;
|
private final static int scryptCpuCostParameter = 16384;
|
||||||
@ -105,13 +98,11 @@ public abstract class PasswordUtil {
|
|||||||
*
|
*
|
||||||
* @throws SecurityException if the random string could not be computed
|
* @throws SecurityException if the random string could not be computed
|
||||||
*/
|
*/
|
||||||
public static String getRandomString(String prefix, int length) throws SecurityException {
|
public static String getRandomString(final String prefix, int length) throws SecurityException {
|
||||||
if (prefix == null) {
|
String usedPrefix = (prefix == null ? "" : prefix);
|
||||||
prefix = "";
|
|
||||||
}
|
|
||||||
int idLength = length - prefix.length();
|
|
||||||
return prefix + createSaltString(idLength);
|
|
||||||
|
|
||||||
|
int idLength = length - usedPrefix.length();
|
||||||
|
return prefix + createSaltString(idLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user