diff --git a/src/main/java/net/lacnic/portal/auth/client/PortalWSClient.java b/src/main/java/net/lacnic/portal/auth/client/PortalWSClient.java index cf354bf..d5d099a 100644 --- a/src/main/java/net/lacnic/portal/auth/client/PortalWSClient.java +++ b/src/main/java/net/lacnic/portal/auth/client/PortalWSClient.java @@ -143,7 +143,8 @@ public static Properties getPaiProperties() { try (InputStream input = new FileInputStream(CONF_DIR.concat("/pai.properties"))) { prop.load(input); } catch (IOException ex) { - ex.printStackTrace(); + logger.error("An error occurred: {}", ex.getMessage(), ex); + } return prop; } diff --git a/src/main/java/net/lacnic/portal/auth/client/Utils2FA.java b/src/main/java/net/lacnic/portal/auth/client/Utils2FA.java index 46b6e67..9cc2331 100644 --- a/src/main/java/net/lacnic/portal/auth/client/Utils2FA.java +++ b/src/main/java/net/lacnic/portal/auth/client/Utils2FA.java @@ -8,6 +8,8 @@ import org.apache.commons.codec.binary.Base32; import org.apache.commons.codec.binary.Hex; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.zxing.BarcodeFormat; import com.google.zxing.MultiFormatWriter; @@ -18,6 +20,7 @@ import de.taimos.totp.TOTP; public class Utils2FA { + private static final Logger logger = LoggerFactory.getLogger(Utils2FA.class); private static final String UTF_8 = "UTF-8"; @@ -30,7 +33,7 @@ public static String obtenerSecretKey(String user) { Utils2FA.createQRCode(barCodeUrl, calcularRutaImgQR, 300, 300); return secretKey; } catch (IOException | WriterException e) { - e.printStackTrace(); + logger.error("An error occurred: {}", e.getMessage(), e); return null; } diff --git a/src/main/java/net/lacnic/portal/auth/client/UtilsFiles.java b/src/main/java/net/lacnic/portal/auth/client/UtilsFiles.java index f784085..d4ac3de 100755 --- a/src/main/java/net/lacnic/portal/auth/client/UtilsFiles.java +++ b/src/main/java/net/lacnic/portal/auth/client/UtilsFiles.java @@ -8,7 +8,11 @@ import java.io.InputStream; import java.util.UUID; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class UtilsFiles { + private static final Logger logger = LoggerFactory.getLogger(UtilsFiles.class); public static byte[] getBytesFromFile(String fileString) throws IOException { return getBytesFromFile(new File(fileString)); @@ -23,7 +27,7 @@ public static byte[] calcularBytesImgQR(String secretKey) { try { return getBytesFromFile(calcularRutaImgQR(secretKey)); } catch (IOException e) { - e.printStackTrace(); + logger.error("An error occurred: {}", e.getMessage(), e); return null; } } @@ -65,9 +69,9 @@ public static File obtenerFile(byte[] bytes, String extension) { return file; } catch (FileNotFoundException e) { - e.printStackTrace(); + logger.error("An error occurred: {}", e.getMessage(), e); } catch (Exception e) { - e.printStackTrace(); + logger.error("An error occurred: {}", e.getMessage(), e); } return null; } diff --git a/src/main/java/net/lacnic/portal/auth/client/UtilsLogin.java b/src/main/java/net/lacnic/portal/auth/client/UtilsLogin.java index 7e656c4..cda4334 100644 --- a/src/main/java/net/lacnic/portal/auth/client/UtilsLogin.java +++ b/src/main/java/net/lacnic/portal/auth/client/UtilsLogin.java @@ -45,7 +45,8 @@ public static LoginData loginTfa(String username, String password, String totp) LoginData infoLDAP = PortalWSClient.getLoginDataTfa(username, password, totp); return infoLDAP; } catch (Exception e) { - e.printStackTrace(); + logger.error("An error occurred: {}", e.getMessage(), e); + return new LoginData("Error: verifique usuario y/o contraseƱa"); } }