updated to log4j2
This commit is contained in:
@ -21,6 +21,17 @@ public class IpInformation {
|
||||
public List<PortInformation> getPortInformation() {
|
||||
return portInformation;
|
||||
}
|
||||
|
||||
public List<PortInformation> getOpenPorts() {
|
||||
List<PortInformation> openPorts = new ArrayList<>();
|
||||
|
||||
for (PortInformation currentPort : getPortInformation()) {
|
||||
if (currentPort.isOpen()) {
|
||||
openPorts.add (currentPort);
|
||||
}
|
||||
}
|
||||
return openPorts;
|
||||
}
|
||||
|
||||
public void setPortInformation(List<PortInformation> portInformation) {
|
||||
this.portInformation = portInformation;
|
||||
@ -29,5 +40,10 @@ public class IpInformation {
|
||||
public String getIpAddress() {
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getIpAddress()+": "+getPortInformation();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,7 +4,8 @@ import de.muehlencord.shared.network.whois.NetworkInformation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.net.util.SubnetUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -12,7 +13,7 @@ import org.apache.log4j.Logger;
|
||||
*/
|
||||
public class NetworkScanner {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(NetworkScanner.class);
|
||||
private final static Logger LOGGER = LogManager.getLogger(NetworkScanner.class);
|
||||
|
||||
private String networkString;
|
||||
private NetworkInformation networkInformation = null; // TODO add scan for information
|
||||
|
||||
@ -5,7 +5,8 @@ import java.net.Socket;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -13,7 +14,7 @@ import org.apache.log4j.Logger;
|
||||
*/
|
||||
public final class PortScan {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(PortScan.class);
|
||||
private final static Logger LOGGER = LogManager.getLogger(PortScan.class);
|
||||
|
||||
private PortScan() {
|
||||
// hide constructor
|
||||
@ -30,7 +31,7 @@ public final class PortScan {
|
||||
socket.close();
|
||||
return new PortInformation(port, true);
|
||||
} catch (Exception ex) {
|
||||
LOGGER.debug(ex.toString(), ex);
|
||||
LOGGER.trace(ex.toString(), ex);
|
||||
return new PortInformation(port, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,8 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -15,7 +16,7 @@ import org.apache.log4j.Logger;
|
||||
*/
|
||||
public class PortScanner {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(PortScanner.class);
|
||||
private final static Logger LOGGER = LogManager.getLogger(PortScanner.class);
|
||||
|
||||
private final int startPort;
|
||||
private final int endPort;
|
||||
@ -46,7 +47,7 @@ public class PortScanner {
|
||||
resultList.add(f.get());
|
||||
}
|
||||
} catch (InterruptedException | ExecutionException ex) {
|
||||
LOGGER.error(ex.toString(), ex);
|
||||
LOGGER.trace(ex.toString(), ex);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
|
||||
@ -10,7 +10,8 @@ import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -21,7 +22,7 @@ public class FTPConnection {
|
||||
/** the default timeout in ms */
|
||||
public static final int DEFAULTTIMEOUT = 30000;
|
||||
/** the logger object */
|
||||
private final static Logger LOGGER = Logger.getLogger(FTPConnection.class);
|
||||
private final static Logger LOGGER = LogManager.getLogger(FTPConnection.class);
|
||||
/** the username to connect with */
|
||||
private String userName;
|
||||
/** the password to connect with */
|
||||
|
||||
@ -16,7 +16,8 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Communication endpoint for posting a messages
|
||||
@ -25,7 +26,7 @@ import org.apache.log4j.Logger;
|
||||
*/
|
||||
public class HttpLayer {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(HttpLayer.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger(HttpLayer.class);
|
||||
/** the url to post to */
|
||||
private final String destinationUrlString;
|
||||
/** the encoding to use */
|
||||
|
||||
@ -15,7 +15,8 @@ import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.search.MessageIDTerm;
|
||||
import javax.mail.search.SearchTerm;
|
||||
import javax.mail.util.SharedByteArrayInputStream;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* MailReader to connect and work with IMAP mailboxes. Also works with exchange servers.
|
||||
@ -25,7 +26,7 @@ import org.apache.log4j.Logger;
|
||||
public abstract class DefaultMailReader implements MailReader {
|
||||
|
||||
/** the logging object */
|
||||
private final static Logger LOGGER = Logger.getLogger(DefaultMailReader.class);
|
||||
private final static Logger LOGGER = LogManager.getLogger(DefaultMailReader.class);
|
||||
/** the store to connect with */
|
||||
private Store store = null;
|
||||
/** the smtp host to work with */
|
||||
|
||||
@ -17,7 +17,8 @@ import javax.mail.MessagingException;
|
||||
import javax.mail.Multipart;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Util class to convert between javax.mail.Message and MailMessage objects
|
||||
@ -27,7 +28,7 @@ import org.apache.log4j.Logger;
|
||||
public abstract class MailMessageUtils {
|
||||
|
||||
/** the logging object */
|
||||
private static final Logger LOGGER = Logger.getLogger(MailMessageUtils.class.getName());
|
||||
private static final Logger LOGGER = LogManager.getLogger(MailMessageUtils.class.getName());
|
||||
|
||||
/** content type of mutipart messages - e.g. multipart_alternative or _mixed */
|
||||
private static final String CONTENTTYPE_MULTIPART = "multipart/";
|
||||
|
||||
@ -5,7 +5,8 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -14,7 +15,7 @@ import org.apache.log4j.Logger;
|
||||
public abstract class MailReaderConfigurationFactory {
|
||||
|
||||
/** the logging object */
|
||||
private final static Logger LOGGER = Logger.getLogger(MailReaderConfigurationFactory.class);
|
||||
private final static Logger LOGGER = LogManager.getLogger(MailReaderConfigurationFactory.class);
|
||||
|
||||
/**
|
||||
* reads the config file and creates a configured mailreader configuration
|
||||
|
||||
@ -4,7 +4,8 @@ import de.muehlencord.shared.network.mail.DefaultMailReader;
|
||||
import de.muehlencord.shared.network.mail.MailReaderConfiguration;
|
||||
import de.muehlencord.shared.network.mail.MailReaderConnectionException;
|
||||
import javax.mail.Session;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Implementation of MaiLReader to connect to an IMAP server
|
||||
@ -14,7 +15,7 @@ import org.apache.log4j.Logger;
|
||||
public class ImapMailReader extends DefaultMailReader {
|
||||
|
||||
/** the logger object */
|
||||
private final static Logger LOGGER = Logger.getLogger(ImapMailReader.class);
|
||||
private final static Logger LOGGER = LogManager.getLogger(ImapMailReader.class);
|
||||
|
||||
/**
|
||||
* creates a new instance to connect to an IMAP (or MS Exchange) server
|
||||
|
||||
@ -4,7 +4,8 @@ import static de.muehlencord.shared.network.CidrTool.rangeToCidrList;
|
||||
import static de.muehlencord.shared.util.StringUtil.getValueBetweenKeywords;
|
||||
import java.text.ParseException;
|
||||
import java.util.Map;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
||||
/**
|
||||
@ -14,7 +15,7 @@ import org.apache.log4j.Logger;
|
||||
public class ArinWhoisParser extends AbstractWhoisParser implements WhoisParser {
|
||||
|
||||
/** logger object */
|
||||
private final static Logger LOGGER = Logger.getLogger(DefaultWhoisParser.class);
|
||||
private final static Logger LOGGER = LogManager.getLogger(DefaultWhoisParser.class);
|
||||
/** information to be returned */
|
||||
private WhoisInformation whoisInformation;
|
||||
|
||||
|
||||
@ -2,7 +2,8 @@ package de.muehlencord.shared.network.whois;
|
||||
|
||||
import static de.muehlencord.shared.network.CidrTool.rangeToCidrList;
|
||||
import java.util.Map;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -11,7 +12,7 @@ import org.apache.log4j.Logger;
|
||||
public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisParser {
|
||||
|
||||
/** logger object */
|
||||
private final static Logger LOGGER = Logger.getLogger(DefaultWhoisParser.class);
|
||||
private final static Logger LOGGER = LogManager.getLogger(DefaultWhoisParser.class);
|
||||
/** information to be returned */
|
||||
private WhoisInformation whoisInformation;
|
||||
|
||||
|
||||
@ -2,7 +2,8 @@ package de.muehlencord.shared.network.whois;
|
||||
|
||||
import java.util.Locale;
|
||||
import org.apache.commons.net.whois.WhoisClient;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -11,7 +12,7 @@ import org.apache.log4j.Logger;
|
||||
public class Whois {
|
||||
|
||||
/** logger object */
|
||||
private final static Logger LOGGER = Logger.getLogger(Whois.class);
|
||||
private final static Logger LOGGER = LogManager.getLogger(Whois.class);
|
||||
/** whoisClient client from commons-net package to execute commands with */
|
||||
WhoisClient whoisClient;
|
||||
/** the complete output */
|
||||
|
||||
2
network/src/main/resources/buildInfo.properties
Normal file
2
network/src/main/resources/buildInfo.properties
Normal file
@ -0,0 +1,2 @@
|
||||
build.version=${project.version}
|
||||
build.timestamp=${timestamp}
|
||||
14
network/src/main/resources/log4j2.xml
Normal file
14
network/src/main/resources/log4j2.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration>
|
||||
<Appenders>
|
||||
<Console name="STDOUT" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.apache.log4j.xml" level="info"/>
|
||||
<Root level="debug">
|
||||
<AppenderRef ref="STDOUT"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
Reference in New Issue
Block a user