diff --git a/configuration/src/main/java/de/muehlencord/shared/configuration/ConfigurationException.java b/configuration/src/main/java/de/muehlencord/shared/configuration/ConfigurationException.java
index 799ec68..0ed7081 100644
--- a/configuration/src/main/java/de/muehlencord/shared/configuration/ConfigurationException.java
+++ b/configuration/src/main/java/de/muehlencord/shared/configuration/ConfigurationException.java
@@ -6,12 +6,7 @@ package de.muehlencord.shared.configuration;
*/
public class ConfigurationException extends Exception {
- /**
- * Creates a new instance of
- * ParameterException without detail message.
- */
- public ConfigurationException() {
- }
+ private static final long serialVersionUID = 2714239259852576278L;
/**
* Constructs an instance of
diff --git a/configuration/src/main/java/de/muehlencord/shared/configuration/ConverterException.java b/configuration/src/main/java/de/muehlencord/shared/configuration/ConverterException.java
index 9c25f99..96c91d0 100644
--- a/configuration/src/main/java/de/muehlencord/shared/configuration/ConverterException.java
+++ b/configuration/src/main/java/de/muehlencord/shared/configuration/ConverterException.java
@@ -6,12 +6,8 @@ package de.muehlencord.shared.configuration;
*/
public class ConverterException extends Exception {
- /**
- * Creates a new instance of
- * ConverterException without detail message.
- */
- public ConverterException() {
- }
+ private static final long serialVersionUID = 3587621400600640847L;
+
/**
* Constructs an instance of
diff --git a/configuration/src/main/java/de/muehlencord/shared/configuration/Parameter.java b/configuration/src/main/java/de/muehlencord/shared/configuration/Parameter.java
index 35444f1..b5f2979 100644
--- a/configuration/src/main/java/de/muehlencord/shared/configuration/Parameter.java
+++ b/configuration/src/main/java/de/muehlencord/shared/configuration/Parameter.java
@@ -1,5 +1,6 @@
package de.muehlencord.shared.configuration;
+import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.apache.logging.log4j.LogManager;
@@ -121,7 +122,7 @@ public abstract class Parameter {
* @return the list of parameters the given parameter requires
*/
public List> getRequiredParameter() {
- return requiredParameters;
+ return new ArrayList<>(requiredParameters);
}
/**
@@ -149,10 +150,9 @@ public abstract class Parameter {
if (o == null) {
return false;
}
- if (o instanceof Parameter) {
+ if (o.getClass() == this.getClass()) {
Parameter param = (Parameter) o;
return param.getName().equals(getName());
-
} else {
return false;
}
diff --git a/configuration/src/main/java/de/muehlencord/shared/configuration/ValidationException.java b/configuration/src/main/java/de/muehlencord/shared/configuration/ValidationException.java
index ccafdd7..4523819 100644
--- a/configuration/src/main/java/de/muehlencord/shared/configuration/ValidationException.java
+++ b/configuration/src/main/java/de/muehlencord/shared/configuration/ValidationException.java
@@ -6,13 +6,9 @@ package de.muehlencord.shared.configuration;
*/
public class ValidationException extends Exception {
- /**
- * Creates a new instance of
- * ValidationException without detail message.
- */
- public ValidationException() {
- }
+ private static final long serialVersionUID = -5137890709720975939L;
+
/**
* Constructs an instance of
* ValidationException with the specified detail message.
diff --git a/configuration/src/test/java/de/muehlencord/shared/configuration/AppTest.java b/configuration/src/test/java/de/muehlencord/shared/configuration/AppTest.java
deleted file mode 100644
index 774ca4f..0000000
--- a/configuration/src/test/java/de/muehlencord/shared/configuration/AppTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package de.muehlencord.shared.configuration;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Unit test for simple App.
- */
-public class AppTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
-
- /**
- * Rigourous Test :-)
- */
- public void testApp()
- {
- assertTrue( true );
- }
-}
diff --git a/network/src/main/java/de/muehlencord/shared/network/IpInformation.java b/network/src/main/java/de/muehlencord/shared/network/IpInformation.java
index bc9853e..5569a3a 100644
--- a/network/src/main/java/de/muehlencord/shared/network/IpInformation.java
+++ b/network/src/main/java/de/muehlencord/shared/network/IpInformation.java
@@ -19,7 +19,7 @@ public class IpInformation {
/* *** getter / setter *** */
public List getPortInformation() {
- return portInformation;
+ return new ArrayList<>(portInformation);
}
public List getOpenPorts() {
@@ -34,7 +34,7 @@ public class IpInformation {
}
public void setPortInformation(List portInformation) {
- this.portInformation = portInformation;
+ this.portInformation = new ArrayList<>(portInformation);
}
public String getIpAddress() {
diff --git a/network/src/main/java/de/muehlencord/shared/network/NetworkScanner.java b/network/src/main/java/de/muehlencord/shared/network/NetworkScanner.java
index 11350e5..8b0d35f 100644
--- a/network/src/main/java/de/muehlencord/shared/network/NetworkScanner.java
+++ b/network/src/main/java/de/muehlencord/shared/network/NetworkScanner.java
@@ -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 ipinformationList = new ArrayList<>();
public NetworkScanner(String network) {
@@ -43,7 +43,7 @@ public class NetworkScanner {
}
public List getIpsInNetwork() {
- return ipinformationList;
+ return new ArrayList<>(ipinformationList);
}
private boolean atLeastOnePortOpen(List portInformation) {
diff --git a/network/src/main/java/de/muehlencord/shared/network/ftp/FTPConnectionException.java b/network/src/main/java/de/muehlencord/shared/network/ftp/FTPConnectionException.java
index 8b6bacd..ab75b3f 100644
--- a/network/src/main/java/de/muehlencord/shared/network/ftp/FTPConnectionException.java
+++ b/network/src/main/java/de/muehlencord/shared/network/ftp/FTPConnectionException.java
@@ -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
- * FTPConnectionException without detail message.
- */
- public FTPConnectionException() {
- }
/**
* Constructs an instance of
diff --git a/network/src/main/java/de/muehlencord/shared/network/http/MessageNotSendException.java b/network/src/main/java/de/muehlencord/shared/network/http/MessageNotSendException.java
index 6b859c7..9cc6a8d 100644
--- a/network/src/main/java/de/muehlencord/shared/network/http/MessageNotSendException.java
+++ b/network/src/main/java/de/muehlencord/shared/network/http/MessageNotSendException.java
@@ -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
- * MessageNotSendException without detail message.
- */
- public MessageNotSendException() {
- }
/**
* Constructs an instance of
diff --git a/network/src/main/java/de/muehlencord/shared/network/mail/MailMessage.java b/network/src/main/java/de/muehlencord/shared/network/mail/MailMessage.java
index 4ac2a43..fb810cc 100644
--- a/network/src/main/java/de/muehlencord/shared/network/mail/MailMessage.java
+++ b/network/src/main/java/de/muehlencord/shared/network/mail/MailMessage.java
@@ -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 getReceiver() {
- return receiver;
+ return new ArrayList<>(receiver);
}
/**
@@ -249,7 +250,7 @@ public class MailMessage {
* @return the ccReceiver
*/
public List getCcReceiver() {
- return ccReceiver;
+ return new ArrayList<>(ccReceiver);
}
/**
@@ -276,7 +277,7 @@ public class MailMessage {
* @return the bccReceiver
*/
public List getBccReceiver() {
- return bccReceiver;
+ return new ArrayList<>(bccReceiver);
}
/**
diff --git a/network/src/main/java/de/muehlencord/shared/network/mail/MailMessageException.java b/network/src/main/java/de/muehlencord/shared/network/mail/MailMessageException.java
index a729ff5..f9327c0 100644
--- a/network/src/main/java/de/muehlencord/shared/network/mail/MailMessageException.java
+++ b/network/src/main/java/de/muehlencord/shared/network/mail/MailMessageException.java
@@ -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
- * MailMessageException without detail message.
- */
- public MailMessageException() {
- }
+ private static final long serialVersionUID = -8147768630871997864L;
/**
* Constructs an instance of
diff --git a/network/src/main/java/de/muehlencord/shared/network/mail/MailMessageUtils.java b/network/src/main/java/de/muehlencord/shared/network/mail/MailMessageUtils.java
index 0525646..0dd6dd6 100644
--- a/network/src/main/java/de/muehlencord/shared/network/mail/MailMessageUtils.java
+++ b/network/src/main/java/de/muehlencord/shared/network/mail/MailMessageUtils.java
@@ -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;
}
}
diff --git a/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderConfigurationException.java b/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderConfigurationException.java
index eed1f53..508c1c8 100644
--- a/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderConfigurationException.java
+++ b/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderConfigurationException.java
@@ -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
- * MailReaderConfigurationException without detail message.
- */
- public MailReaderConfigurationException() {
- }
+ private static final long serialVersionUID = -2079782382789782710L;
/**
* Constructs an instance of
diff --git a/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderConfigurationFactory.java b/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderConfigurationFactory.java
index 876430d..a804916 100644
--- a/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderConfigurationFactory.java
+++ b/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderConfigurationFactory.java
@@ -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));
diff --git a/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderConnectionException.java b/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderConnectionException.java
index 4057545..ee9c09c 100644
--- a/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderConnectionException.java
+++ b/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderConnectionException.java
@@ -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
- * MailReaderConnectionException without detail message.
- */
- public MailReaderConnectionException() {
- }
/**
* Constructs an instance of
diff --git a/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderException.java b/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderException.java
index 01ad215..df28bb4 100644
--- a/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderException.java
+++ b/network/src/main/java/de/muehlencord/shared/network/mail/MailReaderException.java
@@ -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
- * MailReaderException without detail message.
- */
- public MailReaderException() {
- }
+ private static final long serialVersionUID = -7351011499789639376L;
/**
* Constructs an instance of
diff --git a/network/src/main/java/de/muehlencord/shared/network/whois/Whois.java b/network/src/main/java/de/muehlencord/shared/network/whois/Whois.java
index aaaf83e..43bd46c 100644
--- a/network/src/main/java/de/muehlencord/shared/network/whois/Whois.java
+++ b/network/src/main/java/de/muehlencord/shared/network/whois/Whois.java
@@ -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 */
diff --git a/network/src/main/java/de/muehlencord/shared/network/whois/WhoisException.java b/network/src/main/java/de/muehlencord/shared/network/whois/WhoisException.java
index 8029a66..45635bc 100644
--- a/network/src/main/java/de/muehlencord/shared/network/whois/WhoisException.java
+++ b/network/src/main/java/de/muehlencord/shared/network/whois/WhoisException.java
@@ -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
- * WhoisException without detail message.
- */
- public WhoisException() {
- }
+ private static final long serialVersionUID = 8101593509067902021L;
/**
* Constructs an instance of
diff --git a/network/src/main/java/de/muehlencord/shared/network/whois/WhoisInformation.java b/network/src/main/java/de/muehlencord/shared/network/whois/WhoisInformation.java
index 1436868..006a230 100644
--- a/network/src/main/java/de/muehlencord/shared/network/whois/WhoisInformation.java
+++ b/network/src/main/java/de/muehlencord/shared/network/whois/WhoisInformation.java
@@ -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 getNetwork() {
- return network;
+ return new ArrayList<>(network);
}
/**
* @param network the network to set
*/
public void setNetwork(List network) {
- this.network = network;
+ this.network = new ArrayList<>(network);
}
/**
* @return the rootNetwork
*/
public List getRootNetwork() {
- return rootNetwork;
+ return new ArrayList<>(rootNetwork);
}
/**
* @param rootNetwork the rootNetwork to set
*/
public void setRootNetwork(List rootNetwork) {
- this.rootNetwork = rootNetwork;
+ this.rootNetwork = new ArrayList<>(rootNetwork);
}
/**
diff --git a/network/src/test/java/de/muehlencord/shared/network/BaseTest.java b/network/src/test/java/de/muehlencord/shared/network/BaseTest.java
index 98c65f6..03bc2db 100644
--- a/network/src/test/java/de/muehlencord/shared/network/BaseTest.java
+++ b/network/src/test/java/de/muehlencord/shared/network/BaseTest.java
@@ -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 {
diff --git a/security/src/main/java/de/muehlencord/shared/security/OldPasswordUtil.java b/security/src/main/java/de/muehlencord/shared/security/OldPasswordUtil.java
index 4743bfb..7625817 100644
--- a/security/src/main/java/de/muehlencord/shared/security/OldPasswordUtil.java
+++ b/security/src/main/java/de/muehlencord/shared/security/OldPasswordUtil.java
@@ -10,7 +10,9 @@ import org.apache.commons.codec.binary.Base64;
/**
*
* @author joern@muehlencord.de
+ * @Deprecated uses old algorithms, do not use this class anylonger
*/
+@Deprecated
public abstract class OldPasswordUtil {
/** logging object */
diff --git a/security/src/main/java/de/muehlencord/shared/security/PasswordUtil.java b/security/src/main/java/de/muehlencord/shared/security/PasswordUtil.java
index 18b4c13..50769e8 100644
--- a/security/src/main/java/de/muehlencord/shared/security/PasswordUtil.java
+++ b/security/src/main/java/de/muehlencord/shared/security/PasswordUtil.java
@@ -18,11 +18,11 @@ public class PasswordUtil {
private final static int PARALLELIZATION = 1;
private final static int KEY_LENGTH = 32;
- private final String SYSTEMSALT;
+ private final String systemsalt;
public PasswordUtil(String systemSaltBase64Coded) {
// TODO make some tests like lengths etc
- this.SYSTEMSALT = systemSaltBase64Coded;
+ this.systemsalt = systemSaltBase64Coded;
}
public String getHash(String clearPassword) {
@@ -33,7 +33,7 @@ public class PasswordUtil {
String userSalt = new String(Base64.encode(userSaltBytes));
// create passwordhash with salt
- String passwordHash = getPasswordHash(SYSTEMSALT, userSalt, clearPassword);
+ String passwordHash = getPasswordHash(systemsalt, userSalt, clearPassword);
StringBuilder sb = new StringBuilder();
sb.append(userSalt);
@@ -52,7 +52,7 @@ public class PasswordUtil {
String userSalt = passwordHashWithSalt.substring(0, passwordHashWithSalt.indexOf(":"));
String passwordHash = passwordHashWithSalt.substring(passwordHashWithSalt.indexOf(":")+1);
- String validationHash = getPasswordHash(SYSTEMSALT, userSalt, clearPassword);
+ String validationHash = getPasswordHash(systemsalt, userSalt, clearPassword);
return validationHash.equals(passwordHash);
}
diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPContext.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPContext.java
index 44f4be2..0981927 100644
--- a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPContext.java
+++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPContext.java
@@ -4,6 +4,7 @@ import java.net.Authenticator;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
@@ -50,13 +51,13 @@ public class SPContext {
}
@Override
- public void checkClientTrusted(
- java.security.cert.X509Certificate[] certs, String authType) {
+ public void checkClientTrusted(X509Certificate[] certs, String authType) {
+ // trust all SSLs, do not check
}
@Override
- public void checkServerTrusted(
- java.security.cert.X509Certificate[] certs, String authType) {
+ public void checkServerTrusted(X509Certificate[] certs, String authType) {
+ // trust all SSLs, do not check
}
}};
// Install the all-trusting trust manager
diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPHelper.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPHelper.java
index ce2b550..91bb5a2 100644
--- a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPHelper.java
+++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPHelper.java
@@ -9,36 +9,14 @@ import java.util.Date;
*/
public class SPHelper {
- private static final SimpleDateFormat dateOnlyFormat = new SimpleDateFormat("yyyy-MM-dd");
- // private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
-
/* -- Format for Date Only Field -- */
- public static String toSPDate(Date d) {
+ public static synchronized String toSPDate(Date d) {
+ SimpleDateFormat dateOnlyFormat = new SimpleDateFormat("yyyy-MM-dd");
if (d == null) {
return "";
}
-
- String result;
- synchronized (dateOnlyFormat) {
- result = dateOnlyFormat.format(d);
- }
- return result;
-
- }
-
- /* -- Format for DateTime Field -- */
- /*
- private static String toSPDateAndTime(Date d) {
- if (d == null) {
- return "";
- }
- String result;
- synchronized (dateTimeFormat) {
- result = dateTimeFormat.format(d);
- }
- return result;
+ return dateOnlyFormat.format(d);
}
- */
}
diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPJaxbObject.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPJaxbObject.java
index b5f35ac..3480ee5 100644
--- a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPJaxbObject.java
+++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPJaxbObject.java
@@ -38,7 +38,7 @@ public abstract class SPJaxbObject extends AbstractSpJaxbObject {
+ ":de.muehlencord.shared.sharepoint.api.usergroup"; //
/** the JAX-B context to use */
- private static JAXBContext jaxbContext = null;
+ private static volatile JAXBContext jaxbContext = null;
/** the value object */
protected T value;
diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPValidationEventHandler.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPValidationEventHandler.java
index a1886ed..7e9a4ad 100644
--- a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPValidationEventHandler.java
+++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPValidationEventHandler.java
@@ -35,10 +35,8 @@ public class SPValidationEventHandler implements ValidationEventHandler {
switch (event.getSeverity()) {
case ValidationEvent.WARNING:
return true; // continue after warinings
- case ValidationEvent.ERROR:
- return false; // terminate after errors
- case ValidationEvent.FATAL_ERROR:
- return false; // terminate after fatal errors
+ case ValidationEvent.ERROR: // terminate after errors
+ case ValidationEvent.FATAL_ERROR: // terminate after fatal errors
default:
return false;
}
diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/usergroup/SPUser.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/usergroup/SPUser.java
index a0ad7fc..a7dcdfe 100644
--- a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/usergroup/SPUser.java
+++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/usergroup/SPUser.java
@@ -38,10 +38,8 @@ public class SPUser extends SPJaxbObject {
returnValue = getValue().login;
}
- if (returnValue == null) {
- return null;
- } else if (returnValue.equals("")) {
- return null;
+ if ((returnValue == null) || (returnValue.equals (""))) {
+ return null;
} else {
return returnValue.substring(7); // drop [i:0#.w|
}
diff --git a/sharepoint/api/src/test/java/de/muehlencord/shared/sharepoint/api/BaseTest.java b/sharepoint/api/src/test/java/de/muehlencord/shared/sharepoint/api/BaseTest.java
index 35e21ec..a5bfe1d 100644
--- a/sharepoint/api/src/test/java/de/muehlencord/shared/sharepoint/api/BaseTest.java
+++ b/sharepoint/api/src/test/java/de/muehlencord/shared/sharepoint/api/BaseTest.java
@@ -17,7 +17,7 @@ import org.junit.Before;
*
* @author jomu
*/
-public class BaseTest {
+public abstract class BaseTest {
protected SPContext context = null;
diff --git a/util/src/main/java/de/muehlencord/shared/util/file/BOM.java b/util/src/main/java/de/muehlencord/shared/util/file/BOM.java
index 00dcebc..9c6b961 100644
--- a/util/src/main/java/de/muehlencord/shared/util/file/BOM.java
+++ b/util/src/main/java/de/muehlencord/shared/util/file/BOM.java
@@ -16,67 +16,67 @@ public class BOM {
/**
* UTF32(Big Endian)
*/
- public static final int[] BOM_UTF32_BE = {0x00, 0x00, 0xFE, 0xFF}; //
+ protected static final int[] BOM_UTF32_BE = {0x00, 0x00, 0xFE, 0xFF}; //
/**
* UTF32(Little Endian)
*/
- public static final int[] BOM_UTF32_LE = {0xFF, 0xFE, 0x00, 0x00}; //
+ protected static final int[] BOM_UTF32_LE = {0xFF, 0xFE, 0x00, 0x00}; //
/**
* UTF-1
*/
- public static final int[] BOM_UTF1 = {0xF7, 0x64, 0x4C}; // UTF-1
+ protected static final int[] BOM_UTF1 = {0xF7, 0x64, 0x4C}; // UTF-1
/**
* UTF7 - version 1
*/
- public static final int[] BOM_UTF7_1 = {0x2B, 0x2F, 0x76, 0x38}; // UTF-7
+ protected static final int[] BOM_UTF7_1 = {0x2B, 0x2F, 0x76, 0x38}; // UTF-7
/**
* UTF7 - version 2
*/
- public static final int[] BOM_UTF7_2 = {0x2B, 0x2F, 0x76, 0x39}; // UTF-7
+ protected static final int[] BOM_UTF7_2 = {0x2B, 0x2F, 0x76, 0x39}; // UTF-7
/**
* UTF7 - version 3
*/
- public static final int[] BOM_UTF7_3 = {0x2B, 0x2F, 0x76, 0x2B}; // UTF-7
+ protected static final int[] BOM_UTF7_3 = {0x2B, 0x2F, 0x76, 0x2B}; // UTF-7
/**
* UTF7 - version 4
*/
- public static final int[] BOM_UTF7_4 = {0x2B, 0x2F, 0x76, 0x2F}; // UTF-7
+ protected static final int[] BOM_UTF7_4 = {0x2B, 0x2F, 0x76, 0x2F}; // UTF-7
/**
* UTF-EBCDIC
*/
- public static final int[] BOM_UTF_EBCDIC = {0xDD, 0x73, 0x66, 0x73}; // UTF - EBCDIC
+ protected static final int[] BOM_UTF_EBCDIC = {0xDD, 0x73, 0x66, 0x73}; // UTF - EBCDIC
/**
* UTF-8
*/
- public static final int[] BOM_UTF8 = {0xEF, 0xBB, 0xBF}; // UTF-8
+ protected static final int[] BOM_UTF8 = {0xEF, 0xBB, 0xBF}; // UTF-8
/**
* SCSU
*/
- public static final int[] BOM_SCSU = {0x0E, 0xFE, 0xFF}; // SCSU
+ protected static final int[] BOM_SCSU = {0x0E, 0xFE, 0xFF}; // SCSU
/**
* BOCU-1 - version 1
*/
- public static final int[] BOM_BOCU1_1 = {0xFB, 0xEE, 0x28}; // BOCU-1
+ protected static final int[] BOM_BOCU1_1 = {0xFB, 0xEE, 0x28}; // BOCU-1
/**
* BOCU-2 - version 2
*/
- public static final int[] BOM_BOCU1_2 = {0xFB, 0xEE, 0x28, 0xFF}; // BOCU-1
+ protected static final int[] BOM_BOCU1_2 = {0xFB, 0xEE, 0x28, 0xFF}; // BOCU-1
/**
* UTF-16 - big endian
*/
- public static final int[] BOM_UTF16_BE = {0xFE, 0xFF}; // UTF-16 (Big Endian)
+ protected static final int[] BOM_UTF16_BE = {0xFE, 0xFF}; // UTF-16 (Big Endian)
/**
* UTF-16 - little endian
*/
- public static final int[] BOM_UTF16_LE = {0xFF, 0xFE}; // UTF-16 (Little Endian)
+ protected static final int[] BOM_UTF16_LE = {0xFF, 0xFE}; // UTF-16 (Little Endian)
/**
* GB-18030
*/
- public static final int[] BOM_GB_18030 = {0x84, 0x31, 0x95, 0x33}; // GB-18030
+ protected static final int[] BOM_GB_18030 = {0x84, 0x31, 0x95, 0x33}; // GB-18030
/**
* mapping from bom bytes to encoding name
*/
- private static Map bomMap = null;
+ private static volatile Map bomMap = null;
/**
* key1 of the BOM
*/
@@ -94,28 +94,6 @@ public class BOM {
*/
private int key4 = 0;
- /**
- * setups the bom bytes to encoding name map
- */
- private static void initBomMap() {
- bomMap = new HashMap<>();
- bomMap.put(new BOM(BOM_UTF1), "UTF-1");
- bomMap.put(new BOM(BOM_UTF7_1), "UTF-7");
- bomMap.put(new BOM(BOM_UTF7_2), "UTF-7");
- bomMap.put(new BOM(BOM_UTF7_3), "UTF-7");
- bomMap.put(new BOM(BOM_UTF7_4), "UTF-7");
- bomMap.put(new BOM(BOM_UTF8), "UTF-8");
- bomMap.put(new BOM(BOM_UTF16_BE), "UTF-16_BE");
- bomMap.put(new BOM(BOM_UTF16_LE), "UTF-16_LE");
- bomMap.put(new BOM(BOM_UTF32_BE), "UTF-32_BE");
- bomMap.put(new BOM(BOM_UTF32_LE), "UTF-32_LE");
- bomMap.put(new BOM(BOM_UTF_EBCDIC), "UTF_EBCDIC");
- bomMap.put(new BOM(BOM_SCSU), "UTF-8");
- bomMap.put(new BOM(BOM_BOCU1_1), "BOCU-1");
- bomMap.put(new BOM(BOM_BOCU1_2), "BOCU-1");
- bomMap.put(new BOM(BOM_GB_18030), "GB-18030");
- }
-
/**
* creates a new instance of a BOM
*
@@ -182,13 +160,14 @@ public class BOM {
}
/**
- * returns true, if the given object is a BOM and represents the same encoding as this object
+ * returns true, if the given object is a BOM and represents the same
+ * encoding as this object
*
* @param o the object to compare to
*/
@Override
public boolean equals(Object o) {
- if (o instanceof BOM) {
+ if (o.getClass() == this.getClass()) {
BOM b = (BOM) o;
boolean equalsKey1 = this.key1 == b.key1;
boolean equalsKey2 = this.key2 == b.key2;
@@ -220,11 +199,28 @@ public class BOM {
*
* @param bomBytes the bytes representing the bom
* @return the name of the encoding for the given bom bytes
- * @throws UnsupportedEncodingException if no valid encoding name can be found
+ * @throws UnsupportedEncodingException if no valid encoding name can be
+ * found
*/
public static String getEncoding(final int[] bomBytes) throws UnsupportedEncodingException {
if (bomMap == null) {
- initBomMap();
+
+ bomMap = new HashMap<>();
+ bomMap.put(new BOM(BOM_UTF1), "UTF-1");
+ bomMap.put(new BOM(BOM_UTF7_1), "UTF-7");
+ bomMap.put(new BOM(BOM_UTF7_2), "UTF-7");
+ bomMap.put(new BOM(BOM_UTF7_3), "UTF-7");
+ bomMap.put(new BOM(BOM_UTF7_4), "UTF-7");
+ bomMap.put(new BOM(BOM_UTF8), "UTF-8");
+ bomMap.put(new BOM(BOM_UTF16_BE), "UTF-16_BE");
+ bomMap.put(new BOM(BOM_UTF16_LE), "UTF-16_LE");
+ bomMap.put(new BOM(BOM_UTF32_BE), "UTF-32_BE");
+ bomMap.put(new BOM(BOM_UTF32_LE), "UTF-32_LE");
+ bomMap.put(new BOM(BOM_UTF_EBCDIC), "UTF_EBCDIC");
+ bomMap.put(new BOM(BOM_SCSU), "UTF-8");
+ bomMap.put(new BOM(BOM_BOCU1_1), "BOCU-1");
+ bomMap.put(new BOM(BOM_BOCU1_2), "BOCU-1");
+ bomMap.put(new BOM(BOM_GB_18030), "GB-18030");
}
BOM currentBOM = new BOM(bomBytes);
@@ -234,4 +230,4 @@ public class BOM {
throw new UnsupportedEncodingException("Not supported encoding found");
}
}
-}
\ No newline at end of file
+}
diff --git a/util/src/main/java/de/muehlencord/shared/util/file/BOMStripperInputStream.java b/util/src/main/java/de/muehlencord/shared/util/file/BOMStripperInputStream.java
index 2017d93..6d9f446 100644
--- a/util/src/main/java/de/muehlencord/shared/util/file/BOMStripperInputStream.java
+++ b/util/src/main/java/de/muehlencord/shared/util/file/BOMStripperInputStream.java
@@ -16,7 +16,7 @@ public class BOMStripperInputStream extends PushbackInputStream {
*
* @see http://en.wikipedia.org/wiki/Byte-order_mark for details
*/
- public static final int[][] BOMS = {
+ protected static final int[][] BOMS = {
BOM.BOM_UTF32_BE,
BOM.BOM_UTF32_LE,
BOM.BOM_UTF1,
diff --git a/util/src/main/java/de/muehlencord/shared/util/file/FileUtil.java b/util/src/main/java/de/muehlencord/shared/util/file/FileUtil.java
index 94d13c5..43ca895 100644
--- a/util/src/main/java/de/muehlencord/shared/util/file/FileUtil.java
+++ b/util/src/main/java/de/muehlencord/shared/util/file/FileUtil.java
@@ -19,6 +19,7 @@ import java.text.Format;
import static java.util.Arrays.asList;
import java.util.LinkedList;
import java.util.List;
+import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -66,12 +67,15 @@ public abstract class FileUtil {
} // method getFilesFromDirecotry
/**
- * returns a file handle to a file in the given folder using the given formater and the given number.
+ * returns a file handle to a file in the given folder using the given
+ * formater and the given number.
*
* @param outputFolder the folder to link the file to as strnig
* @param ft a format object to use to format the filename of the given file
- * @param number a number used to call the given formater to name the file number
- * @return a file handle build from formater and number linked to given directory
+ * @param number a number used to call the given formater to name the file
+ * number
+ * @return a file handle build from formater and number linked to given
+ * directory
*/
public static File getFileName(final String outputFolder, final Format ft, final int number) {
String folderName = outputFolder;
@@ -198,7 +202,10 @@ public abstract class FileUtil {
}
message = s.toString();
} catch (FileNotFoundException fnex) {
- throw new FileNotFoundException("Error occured while reading file. Reason:" + fnex.getMessage());
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.log(Level.DEBUG, "Error occured while readoing file. Reason:" + fnex, fnex);
+ }
+ throw new FileNotFoundException("Error occured while reading file. Reason:" + fnex);
}
return message;
diff --git a/util/src/test/java/de/muehlencord/shared/util/DefaultTest.java b/util/src/test/java/de/muehlencord/shared/util/DefaultTest.java
index ca19d84..227d971 100644
--- a/util/src/test/java/de/muehlencord/shared/util/DefaultTest.java
+++ b/util/src/test/java/de/muehlencord/shared/util/DefaultTest.java
@@ -8,7 +8,7 @@ import java.io.InputStream;
*
* @author joern@muehlencord.de
*/
-public class DefaultTest {
+public abstract class DefaultTest {
public String readContentFromFile(String name) throws IOException {