fixed sonar findings
This commit is contained in:
@ -19,7 +19,7 @@ public class IpInformation {
|
||||
|
||||
/* *** getter / setter *** */
|
||||
public List<PortInformation> getPortInformation() {
|
||||
return portInformation;
|
||||
return new ArrayList<>(portInformation);
|
||||
}
|
||||
|
||||
public List<PortInformation> getOpenPorts() {
|
||||
@ -34,7 +34,7 @@ public class IpInformation {
|
||||
}
|
||||
|
||||
public void setPortInformation(List<PortInformation> portInformation) {
|
||||
this.portInformation = portInformation;
|
||||
this.portInformation = new ArrayList<>(portInformation);
|
||||
}
|
||||
|
||||
public String getIpAddress() {
|
||||
|
||||
@ -16,7 +16,7 @@ public class NetworkScanner {
|
||||
private final static Logger LOGGER = LogManager.getLogger(NetworkScanner.class);
|
||||
|
||||
private String networkString;
|
||||
private NetworkInformation networkInformation = null; // TODO add scan for information
|
||||
// private NetworkInformation networkInformation = null; // TODO add scan for information
|
||||
private List<IpInformation> ipinformationList = new ArrayList<>();
|
||||
|
||||
public NetworkScanner(String network) {
|
||||
@ -43,7 +43,7 @@ public class NetworkScanner {
|
||||
}
|
||||
|
||||
public List<IpInformation> getIpsInNetwork() {
|
||||
return ipinformationList;
|
||||
return new ArrayList<>(ipinformationList);
|
||||
}
|
||||
|
||||
private boolean atLeastOnePortOpen(List<PortInformation> portInformation) {
|
||||
|
||||
@ -1,7 +1,3 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package de.muehlencord.shared.network.ftp;
|
||||
|
||||
/**
|
||||
@ -10,17 +6,8 @@ package de.muehlencord.shared.network.ftp;
|
||||
*/
|
||||
public class FTPConnectionException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4393979078434188521L;
|
||||
private static final long serialVersionUID = 1001347648193052240L;
|
||||
|
||||
/**
|
||||
* Creates a new instance of
|
||||
* <code>FTPConnectionException</code> without detail message.
|
||||
*/
|
||||
public FTPConnectionException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of
|
||||
|
||||
@ -6,17 +6,9 @@ package de.muehlencord.shared.network.http;
|
||||
*/
|
||||
public class MessageNotSendException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8959773341187046577L;
|
||||
private static final long serialVersionUID = -7720277941333614648L;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new instance of
|
||||
* <code>MessageNotSendException</code> without detail message.
|
||||
*/
|
||||
public MessageNotSendException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
*/
|
||||
package de.muehlencord.shared.network.mail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -213,7 +214,7 @@ public class MailMessage {
|
||||
* @return the receiver
|
||||
*/
|
||||
public List<String> getReceiver() {
|
||||
return receiver;
|
||||
return new ArrayList<>(receiver);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -249,7 +250,7 @@ public class MailMessage {
|
||||
* @return the ccReceiver
|
||||
*/
|
||||
public List<String> getCcReceiver() {
|
||||
return ccReceiver;
|
||||
return new ArrayList<>(ccReceiver);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -276,7 +277,7 @@ public class MailMessage {
|
||||
* @return the bccReceiver
|
||||
*/
|
||||
public List<String> getBccReceiver() {
|
||||
return bccReceiver;
|
||||
return new ArrayList<>(bccReceiver);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -6,17 +6,7 @@ package de.muehlencord.shared.network.mail;
|
||||
*/
|
||||
public class MailMessageException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6699249884047524285L;
|
||||
|
||||
/**
|
||||
* Creates a new instance of
|
||||
* <code>MailMessageException</code> without detail message.
|
||||
*/
|
||||
public MailMessageException() {
|
||||
}
|
||||
private static final long serialVersionUID = -8147768630871997864L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of
|
||||
|
||||
@ -27,32 +27,55 @@ import org.apache.logging.log4j.Logger;
|
||||
*/
|
||||
public abstract class MailMessageUtils {
|
||||
|
||||
/** the logging object */
|
||||
/**
|
||||
* the logging object
|
||||
*/
|
||||
private static final Logger LOGGER = LogManager.getLogger(MailMessageUtils.class.getName());
|
||||
|
||||
/** content type of mutipart messages - e.g. multipart_alternative or _mixed */
|
||||
/**
|
||||
* content type of mutipart messages - e.g. multipart_alternative or _mixed
|
||||
*/
|
||||
private static final String CONTENTTYPE_MULTIPART = "multipart/";
|
||||
/** content type of text messages - like text/plain or text/html */
|
||||
/**
|
||||
* content type of text messages - like text/plain or text/html
|
||||
*/
|
||||
private static final String CONTENTTYPE_TEXT = "text/";
|
||||
/** content type of text/plain messages */
|
||||
/**
|
||||
* content type of text/plain messages
|
||||
*/
|
||||
private static final String CONTENTTYPE_TEXT_PLAIN = "text/plain";
|
||||
/** content type of text/html messages */
|
||||
/**
|
||||
* content type of text/html messages
|
||||
*/
|
||||
private static final String CONTENTTYPE_TEXT_HTML = "text/html";
|
||||
/** content type of application based messages - e.g. application/pdf */
|
||||
/**
|
||||
* content type of application based messages - e.g. application/pdf
|
||||
*/
|
||||
private static final String CONTENTTYPE_APPLICATION = "application/";
|
||||
/** content type of application pgp-signature */
|
||||
/**
|
||||
* content type of application pgp-signature
|
||||
*/
|
||||
private static final String CONTENTTYPE_APPLICATION_PGPSIGNATURE = "application/pgp-signature";
|
||||
/** content type of embedded message */
|
||||
/**
|
||||
* content type of embedded message
|
||||
*/
|
||||
private static final String CONTENTTYPE_MESSAGE = "message/";
|
||||
/** content type of attached images */
|
||||
/**
|
||||
* content type of attached images
|
||||
*/
|
||||
private static final String CONTENTTYPE_IMAGE = "image/";
|
||||
/** content type of attached videos */
|
||||
/**
|
||||
* content type of attached videos
|
||||
*/
|
||||
private static final String CONTENTTYPE_VIDEO = "video/";
|
||||
/** content type of attached audios */
|
||||
/**
|
||||
* content type of attached audios
|
||||
*/
|
||||
private static final String CONTENTTYPE_AUDIO = "audio/";
|
||||
|
||||
/**
|
||||
* creates a new instance of MailMessage based on the given javax.mail.Message object
|
||||
* creates a new instance of MailMessage based on the given
|
||||
* javax.mail.Message object
|
||||
*
|
||||
* @param message the message object to create the message from
|
||||
* @return the MailMessage object created from the given javax.mail.Message
|
||||
@ -172,13 +195,10 @@ public abstract class MailMessageUtils {
|
||||
} catch (MailMessageException | IOException | MessagingException ex) {
|
||||
throw new MailMessageException("Error while converting nested message. Reason: " + ex.getMessage(), ex);
|
||||
}
|
||||
} else if (contentType.contains(CONTENTTYPE_APPLICATION)) {
|
||||
} else if ((contentType.contains(CONTENTTYPE_APPLICATION)) || (contentType.contains(CONTENTTYPE_TEXT))) {
|
||||
// message with only attachment
|
||||
returnMessage = new MailMessage(subject, "", messageId);
|
||||
LOGGER.debug("Found attachment - not yet supported, skipping"); // TODO add attachment
|
||||
} else if (contentType.contains(CONTENTTYPE_TEXT)) {
|
||||
returnMessage = new MailMessage(subject, "", messageId);
|
||||
LOGGER.debug("Found attachment - not yet supported, skipping"); // TODO add attachment
|
||||
LOGGER.debug("Found attachment - not yet supported, skipping"); // TODO add attachment
|
||||
} else {
|
||||
String hint = "Unkonwn message format Converting MimeMessage of contentType " + contentType + " not yet implemented.";
|
||||
|
||||
@ -187,7 +207,7 @@ public abstract class MailMessageUtils {
|
||||
LOGGER.debug(mm.getContent());
|
||||
LOGGER.error(hint);
|
||||
} catch (IOException | MessagingException ex) {
|
||||
LOGGER.debug (ex.toString(), ex);
|
||||
LOGGER.debug(ex.toString(), ex);
|
||||
LOGGER.error(hint);
|
||||
}
|
||||
throw new MailMessageException(hint);
|
||||
@ -220,8 +240,9 @@ public abstract class MailMessageUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the content type based on the content-type header. The messad asures the contentype is selected correctly from the string, including trim and
|
||||
* tolower case
|
||||
* returns the content type based on the content-type header. The messad
|
||||
* asures the contentype is selected correctly from the string, including
|
||||
* trim and tolower case
|
||||
*
|
||||
* @param contentType the contenttype string read from email header
|
||||
* @return the content type of the email (small letters)
|
||||
@ -238,8 +259,10 @@ public abstract class MailMessageUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the content of the given bodypart which needs to be a text based bodypart The method tries to read the messages as it is. In case of an
|
||||
* unsupported encoding it reads the message with the default encoding (accepting "ugly" characters)
|
||||
* returns the content of the given bodypart which needs to be a text based
|
||||
* bodypart The method tries to read the messages as it is. In case of an
|
||||
* unsupported encoding it reads the message with the default encoding
|
||||
* (accepting "ugly" characters)
|
||||
*
|
||||
* @param bp the body part to read the content from
|
||||
* @return the content of the body part
|
||||
@ -253,7 +276,7 @@ public abstract class MailMessageUtils {
|
||||
try {
|
||||
returnValue = bp.getContent().toString();
|
||||
} catch (java.io.UnsupportedEncodingException ex) {
|
||||
throw new MessagingException("Cannot read content from bodypart. "+ex.getMessage(), ex);
|
||||
throw new MessagingException("Cannot read content from bodypart. " + ex.getMessage(), ex);
|
||||
} catch (java.io.IOException ioex) {
|
||||
throw new IOException("Cannot read content from bodypart.", ioex);
|
||||
} catch (MessagingException mex) {
|
||||
@ -269,8 +292,9 @@ public abstract class MailMessageUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the content of the given body part by reading the stream directly. This ommits getting unsupported encoding exceptions, as the content is read
|
||||
* with the given encoding
|
||||
* returns the content of the given body part by reading the stream
|
||||
* directly. This ommits getting unsupported encoding exceptions, as the
|
||||
* content is read with the given encoding
|
||||
*
|
||||
* @param bp the bodypart to read the content from
|
||||
* @param encoding the encoding to force
|
||||
@ -332,26 +356,20 @@ public abstract class MailMessageUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true, if the contentType string is one of the known attachment types.
|
||||
* returns true, if the contentType string is one of the known attachment
|
||||
* types.
|
||||
*
|
||||
* @param contentType the contentType to check
|
||||
* @return true, if the contentType string is one of the known attachment types. False otherwise.
|
||||
* @return true, if the contentType string is one of the known attachment
|
||||
* types. False otherwise.
|
||||
*/
|
||||
private static boolean isSupportedAttachmentType(String contentType) {
|
||||
if (contentType.contains(CONTENTTYPE_APPLICATION)) {
|
||||
return true;
|
||||
} else if (contentType.contains(CONTENTTYPE_MESSAGE)) {
|
||||
return true;
|
||||
} else if (contentType.contains(CONTENTTYPE_TEXT)) {
|
||||
return true;
|
||||
} else if (contentType.contains(CONTENTTYPE_IMAGE)) {
|
||||
return true;
|
||||
} else if (contentType.contains(CONTENTTYPE_VIDEO)) {
|
||||
return true;
|
||||
} else if (contentType.contains(CONTENTTYPE_AUDIO)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
boolean contentTypeOther = contentType.contains(CONTENTTYPE_APPLICATION)
|
||||
|| (contentType.contains(CONTENTTYPE_MESSAGE))
|
||||
|| (contentType.contains(CONTENTTYPE_TEXT));
|
||||
boolean contentTypeMedia = (contentType.contains(CONTENTTYPE_IMAGE))
|
||||
|| (contentType.contains(CONTENTTYPE_VIDEO))
|
||||
|| (contentType.contains(CONTENTTYPE_AUDIO));
|
||||
return contentTypeOther || contentTypeMedia;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,17 +6,7 @@ package de.muehlencord.shared.network.mail;
|
||||
*/
|
||||
public class MailReaderConfigurationException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3874572911465653501L;
|
||||
|
||||
/**
|
||||
* Creates a new instance of
|
||||
* <code>MailReaderConfigurationException</code> without detail message.
|
||||
*/
|
||||
public MailReaderConfigurationException() {
|
||||
}
|
||||
private static final long serialVersionUID = -2079782382789782710L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of
|
||||
|
||||
@ -14,8 +14,10 @@ import org.apache.logging.log4j.Logger;
|
||||
*/
|
||||
public abstract class MailReaderConfigurationFactory {
|
||||
|
||||
/** the logging object */
|
||||
private final static Logger LOGGER = LogManager.getLogger(MailReaderConfigurationFactory.class);
|
||||
/**
|
||||
* the logging object
|
||||
*/
|
||||
private final static Logger LOGGER = LogManager.getLogger(MailReaderConfigurationFactory.class);
|
||||
|
||||
/**
|
||||
* reads the config file and creates a configured mailreader configuration
|
||||
@ -23,7 +25,8 @@ public abstract class MailReaderConfigurationFactory {
|
||||
* @param configFile the file to read
|
||||
* @return the configured MailReaderConfiguration object
|
||||
*
|
||||
* @throws MailReaderConfigurationException if the file does not exist or the config cannot be created
|
||||
* @throws MailReaderConfigurationException if the file does not exist or
|
||||
* the config cannot be created
|
||||
*/
|
||||
public static MailReaderConfiguration getConfiguration(String configFile) throws MailReaderConfigurationException {
|
||||
File f = new File(configFile);
|
||||
@ -37,10 +40,12 @@ public abstract class MailReaderConfigurationFactory {
|
||||
is = new FileInputStream(f);
|
||||
p.load(is);
|
||||
} catch (Exception ex) {
|
||||
throw new MailReaderConfigurationException("Error while reading config file. Reason: " + ex.getMessage(), ex);
|
||||
throw new MailReaderConfigurationException("Error while reading config file. Reason: " + ex.getMessage(), ex);
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
if (is != null) {
|
||||
is.close();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOGGER.error("Error while reading input file.");
|
||||
LOGGER.debug(StringUtil.getStackTraceString(ex));
|
||||
|
||||
@ -1,7 +1,3 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package de.muehlencord.shared.network.mail;
|
||||
|
||||
/**
|
||||
@ -10,17 +6,9 @@ package de.muehlencord.shared.network.mail;
|
||||
*/
|
||||
public class MailReaderConnectionException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1593741665654202661L;
|
||||
private static final long serialVersionUID = -3671887060456354046L;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new instance of
|
||||
* <code>MailReaderConnectionException</code> without detail message.
|
||||
*/
|
||||
public MailReaderConnectionException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of
|
||||
|
||||
@ -1,7 +1,3 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package de.muehlencord.shared.network.mail;
|
||||
|
||||
/**
|
||||
@ -10,17 +6,7 @@ package de.muehlencord.shared.network.mail;
|
||||
*/
|
||||
public class MailReaderException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4850689622364462635L;
|
||||
|
||||
/**
|
||||
* Creates a new instance of
|
||||
* <code>MailReaderException</code> without detail message.
|
||||
*/
|
||||
public MailReaderException() {
|
||||
}
|
||||
private static final long serialVersionUID = -7351011499789639376L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of
|
||||
|
||||
@ -2,8 +2,6 @@ package de.muehlencord.shared.network.whois;
|
||||
|
||||
import java.util.Locale;
|
||||
import org.apache.commons.net.whois.WhoisClient;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -12,7 +10,7 @@ import org.apache.logging.log4j.Logger;
|
||||
public class Whois {
|
||||
|
||||
/** logger object */
|
||||
private final static Logger LOGGER = LogManager.getLogger(Whois.class);
|
||||
// private static final Logger LOGGER = LogManager.getLogger(Whois.class);
|
||||
/** whoisClient client from commons-net package to execute commands with */
|
||||
WhoisClient whoisClient;
|
||||
/** the complete output */
|
||||
|
||||
@ -1,7 +1,3 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package de.muehlencord.shared.network.whois;
|
||||
|
||||
/**
|
||||
@ -10,12 +6,7 @@ package de.muehlencord.shared.network.whois;
|
||||
*/
|
||||
public class WhoisException extends Exception {
|
||||
|
||||
/**
|
||||
* Creates a new instance of
|
||||
* <code>WhoisException</code> without detail message.
|
||||
*/
|
||||
public WhoisException() {
|
||||
}
|
||||
private static final long serialVersionUID = 8101593509067902021L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package de.muehlencord.shared.network.whois;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@ -27,28 +28,28 @@ public class WhoisInformation {
|
||||
* @return the network
|
||||
*/
|
||||
public List<String> getNetwork() {
|
||||
return network;
|
||||
return new ArrayList<>(network);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param network the network to set
|
||||
*/
|
||||
public void setNetwork(List<String> network) {
|
||||
this.network = network;
|
||||
this.network = new ArrayList<>(network);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rootNetwork
|
||||
*/
|
||||
public List<String> getRootNetwork() {
|
||||
return rootNetwork;
|
||||
return new ArrayList<>(rootNetwork);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rootNetwork the rootNetwork to set
|
||||
*/
|
||||
public void setRootNetwork(List<String> rootNetwork) {
|
||||
this.rootNetwork = rootNetwork;
|
||||
this.rootNetwork = new ArrayList<>(rootNetwork);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -8,7 +8,7 @@ import java.io.InputStream;
|
||||
*
|
||||
* @author joern@muehlencord.de
|
||||
*/
|
||||
public class BaseTest {
|
||||
public abstract class BaseTest {
|
||||
|
||||
public String readContentFromFile(String name) throws IOException {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user