dependency updates
This commit is contained in:
1154
.editorconfig
Normal file
1154
.editorconfig
Normal file
File diff suppressed because it is too large
Load Diff
@ -62,7 +62,7 @@ limitations under the License.
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@ -42,7 +42,7 @@ public abstract class AbstractController<T extends Serializable> extends CommonA
|
||||
|
||||
private final Class<T> entityClass;
|
||||
|
||||
public AbstractController(Class<T> clazz) {
|
||||
protected AbstractController(Class<T> clazz) {
|
||||
this.entityClass = clazz;
|
||||
}
|
||||
|
||||
@ -68,24 +68,21 @@ public abstract class AbstractController<T extends Serializable> extends CommonA
|
||||
*/
|
||||
@Lock(LockType.READ)
|
||||
public T find(Object id, String... subGraphItems) {
|
||||
EntityGraph graph = this.em.createEntityGraph(entityClass);
|
||||
EntityGraph<T> graph = this.em.createEntityGraph(entityClass);
|
||||
for (String subGraphItem : subGraphItems) {
|
||||
graph.addSubgraph(subGraphItem);
|
||||
}
|
||||
|
||||
Map hints = new HashMap<>();
|
||||
Map<String, Object> hints = new HashMap<>();
|
||||
hints.put("javax.persistence.loadgraph", graph);
|
||||
|
||||
T entity = (T) em.find(entityClass, id, hints);
|
||||
return entity;
|
||||
return em.find(entityClass, id, hints);
|
||||
}
|
||||
|
||||
@Lock(LockType.READ)
|
||||
public List<T> find(String queryName, Map<String, Object> parameterMap) throws ControllerException {
|
||||
public List<T> find(String queryName, Map<String, Object> parameterMap) {
|
||||
Query query = em.createNamedQuery(queryName);
|
||||
parameterMap.entrySet().forEach((entry) -> {
|
||||
query.setParameter(entry.getKey(), entry.getValue());
|
||||
});
|
||||
parameterMap.entrySet().forEach(entry -> query.setParameter(entry.getKey(), entry.getValue()));
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
|
||||
@ -15,20 +15,19 @@
|
||||
*/
|
||||
package de.muehlencord.shared.db;
|
||||
|
||||
import de.muehlencord.shared.util.DateUtil;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Date;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Does not work, cannot Spring independent inject current username - implemented in AbstractController manually
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class AuditListener {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AuditListener.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(AuditListener.class);
|
||||
|
||||
// @PrePersist
|
||||
public void prePersist(Auditable auditable) {
|
||||
@ -43,8 +42,8 @@ public class AuditListener {
|
||||
audit.setCreatedOn(now);
|
||||
audit.setLastUpdatedOn(now);
|
||||
// audit.setCreatedBy(LoggedUser.get()); // TODO where to get the user from
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("prePersist executed");
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("prePersist executed");
|
||||
}
|
||||
|
||||
}
|
||||
@ -53,12 +52,11 @@ public class AuditListener {
|
||||
public void preUpdate(Auditable auditable) {
|
||||
Audit audit = auditable.getAudit();
|
||||
|
||||
// TODO where to get the user from
|
||||
LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC);
|
||||
// Date now = DateUtil.getCurrentTimeInUTC();
|
||||
audit.setLastUpdatedOn(now);
|
||||
// audit.setUpdatedBy(LoggedUser.get()); // TODO where to get the user from
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("preUpdate executed");
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("preUpdate executed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
||||
debug="false">
|
||||
|
||||
<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%c] %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<category name="de.muehlencord">
|
||||
<priority value="DEBUG"/>
|
||||
</category>
|
||||
|
||||
<category name="com.sun">
|
||||
<priority value="WARN"/>
|
||||
</category>
|
||||
|
||||
<category name="javax.xml">
|
||||
<priority value="WARN"/>
|
||||
</category>
|
||||
|
||||
<logger name="org.hibernate">
|
||||
<level value="info"/>
|
||||
</logger>
|
||||
|
||||
<root>
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="consoleAppender" />
|
||||
</root>
|
||||
</log4j:configuration>
|
||||
@ -60,14 +60,14 @@ public class APIErrorResponse {
|
||||
this.rootCause = rootCauseMessage;
|
||||
}
|
||||
|
||||
public APIErrorResponse(Exception exception, Locale locale) {
|
||||
public APIErrorResponse(Exception exception) {
|
||||
this.status = Response.Status.INTERNAL_SERVER_ERROR;
|
||||
this.errorCode = "0";
|
||||
this.message = exception.getLocalizedMessage();
|
||||
this.rootCause = null;
|
||||
}
|
||||
|
||||
public APIErrorResponse(Exception exception, Locale locale, Throwable th) {
|
||||
public APIErrorResponse(Exception exception, Throwable th) {
|
||||
this.status = Response.Status.INTERNAL_SERVER_ERROR;
|
||||
this.errorCode = "0";
|
||||
this.message = exception.getLocalizedMessage();
|
||||
|
||||
@ -31,7 +31,7 @@ public class APIException extends RuntimeException {
|
||||
public static final String HTTP_HEADER_X_ROOT_CAUSE = "X-Root-Cause";
|
||||
private static final long serialVersionUID = -4356132354448841938L;
|
||||
|
||||
private final Response httpResponse;
|
||||
private final transient Response httpResponse;
|
||||
|
||||
public APIException(APIError apiError, Locale locale) {
|
||||
httpResponse = createHttpResponse(new APIErrorResponse(apiError, locale));
|
||||
@ -49,8 +49,8 @@ public class APIException extends RuntimeException {
|
||||
httpResponse = createHttpResponse(new APIErrorResponse(apiError, new Locale(locale), rootCause));
|
||||
}
|
||||
|
||||
public APIException(Exception exception, Locale locale) {
|
||||
httpResponse = createHttpResponse(new APIErrorResponse(exception, locale));
|
||||
public APIException(Exception exception) {
|
||||
httpResponse = createHttpResponse(new APIErrorResponse(exception));
|
||||
}
|
||||
|
||||
public Response getHttpResponse() {
|
||||
|
||||
@ -25,12 +25,11 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class APIExceptionInterceptor {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(APIExceptionInterceptor.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(APIExceptionInterceptor.class);
|
||||
|
||||
@Inject
|
||||
Locale locale;
|
||||
@ -43,11 +42,7 @@ public class APIExceptionInterceptor {
|
||||
// if an exception is thrown during processing, this is passed in to the catch block below
|
||||
proceedResponse = context.proceed();
|
||||
} catch (Exception ex) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(ex.getMessage());
|
||||
LOGGER.debug("Detailed stacktrace", new Object[]{ex});
|
||||
}
|
||||
|
||||
logger.debug(ex.getMessage(), ex);
|
||||
Response errorResponse;
|
||||
if (ex instanceof APIException) {
|
||||
errorResponse = ((APIException) ex).getHttpResponse();
|
||||
@ -60,7 +55,7 @@ public class APIExceptionInterceptor {
|
||||
// this exception is handled via the ConstraintViolationMapper
|
||||
throw (ConstraintViolationException) ex.getCause();
|
||||
} else {
|
||||
errorResponse = new APIException(ex, locale).getHttpResponse();
|
||||
errorResponse = new APIException(ex).getHttpResponse();
|
||||
}
|
||||
return errorResponse;
|
||||
}
|
||||
|
||||
112
network/pom.xml
112
network/pom.xml
@ -1,4 +1,3 @@
|
||||
|
||||
<!--
|
||||
Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
|
||||
@ -14,72 +13,73 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<artifactId>shared-network</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>shared-util</artifactId>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>ews-java-api</artifactId>
|
||||
<groupId>com.microsoft.ews-java-api</groupId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<artifactId>commons-net</artifactId>
|
||||
<groupId>commons-net</groupId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<artifactId>jaxws-api</artifactId>
|
||||
<groupId>javax.xml.ws</groupId>
|
||||
<scope>test</scope>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<name>shared-network</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>shared</artifactId>
|
||||
<groupId>de.muehlencord</groupId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<url>http://maven.apache.org</url>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
</build>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<artifactId>shared-util</artifactId>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microsoft.ews-java-api</groupId>
|
||||
<artifactId>ews-java-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-net</groupId>
|
||||
<artifactId>commons-net</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.xml.ws</groupId>
|
||||
<artifactId>jaxws-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</project>
|
||||
|
||||
@ -19,15 +19,28 @@ import static java.lang.Long.valueOf;
|
||||
import static java.lang.Math.floor;
|
||||
import static java.lang.Math.log;
|
||||
import static java.lang.Math.pow;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class CidrTool {
|
||||
|
||||
private static final int[] CIDR2MASK = new int[]{0x00000000, 0x80000000,
|
||||
0xC0000000, 0xE0000000, 0xF0000000, 0xF8000000, 0xFC000000,
|
||||
0xFE000000, 0xFF000000, 0xFF800000, 0xFFC00000, 0xFFE00000,
|
||||
0xFFF00000, 0xFFF80000, 0xFFFC0000, 0xFFFE0000, 0xFFFF0000,
|
||||
0xFFFF8000, 0xFFFFC000, 0xFFFFE000, 0xFFFFF000, 0xFFFFF800,
|
||||
0xFFFFFC00, 0xFFFFFE00, 0xFFFFFF00, 0xFFFFFF80, 0xFFFFFFC0,
|
||||
0xFFFFFFE0, 0xFFFFFFF0, 0xFFFFFFF8, 0xFFFFFFFC, 0xFFFFFFFE,
|
||||
0xFFFFFFFF};
|
||||
|
||||
private CidrTool() {
|
||||
// hide constructor
|
||||
}
|
||||
|
||||
public static List<String> rangeToCidrList(String startIp, String endIp) {
|
||||
long start = ipToLong(startIp);
|
||||
long end = ipToLong(endIp);
|
||||
@ -45,7 +58,7 @@ public class CidrTool {
|
||||
|
||||
maxsize--;
|
||||
}
|
||||
double x = log(end - start + 1) / log(2);
|
||||
double x = log(end - start + 1D) / log(2);
|
||||
byte maxdiff = (byte) (32 - floor(x));
|
||||
if (maxsize < maxdiff) {
|
||||
maxsize = maxdiff;
|
||||
@ -57,16 +70,6 @@ public class CidrTool {
|
||||
return pairs;
|
||||
}
|
||||
|
||||
|
||||
private static final int[] CIDR2MASK = new int[]{0x00000000, 0x80000000,
|
||||
0xC0000000, 0xE0000000, 0xF0000000, 0xF8000000, 0xFC000000,
|
||||
0xFE000000, 0xFF000000, 0xFF800000, 0xFFC00000, 0xFFE00000,
|
||||
0xFFF00000, 0xFFF80000, 0xFFFC0000, 0xFFFE0000, 0xFFFF0000,
|
||||
0xFFFF8000, 0xFFFFC000, 0xFFFFE000, 0xFFFFF000, 0xFFFFF800,
|
||||
0xFFFFFC00, 0xFFFFFE00, 0xFFFFFF00, 0xFFFFFF80, 0xFFFFFFC0,
|
||||
0xFFFFFFE0, 0xFFFFFFF0, 0xFFFFFFF8, 0xFFFFFFFC, 0xFFFFFFFE,
|
||||
0xFFFFFFFF};
|
||||
|
||||
private static long ipToLong(String strIP) {
|
||||
long[] ip = new long[4];
|
||||
String[] ipSec = strIP.split("\\.");
|
||||
|
||||
@ -17,6 +17,7 @@ package de.muehlencord.shared.network.whois;
|
||||
|
||||
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.slf4j.Logger;
|
||||
@ -31,7 +32,12 @@ public class ArinWhoisParser extends AbstractWhoisParser implements WhoisParser
|
||||
/**
|
||||
* logger object
|
||||
*/
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(DefaultWhoisParser.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(ArinWhoisParser.class);
|
||||
|
||||
private static final String START_STRING = "# start";
|
||||
private static final String END_STRING = "# end";
|
||||
private static final String NET_RANGE = "NetRange:";
|
||||
private static final String ORG_NAME = "OrgName:";
|
||||
/**
|
||||
* information to be returned
|
||||
*/
|
||||
@ -41,19 +47,19 @@ public class ArinWhoisParser extends AbstractWhoisParser implements WhoisParser
|
||||
public WhoisInformation parseWhoIsString(String whoisString) throws WhoisException {
|
||||
whoisInformation = new WhoisInformation();
|
||||
whoisInformation.setResponseString(whoisString);
|
||||
if (whoisString.contains("# start")) { // multiple values
|
||||
if (whoisString.contains(START_STRING)) {
|
||||
|
||||
String multipleWhoisString = whoisString;
|
||||
|
||||
while (multipleWhoisString.contains("# start")) {
|
||||
while (multipleWhoisString.contains(START_STRING)) {
|
||||
String whoisPartString;
|
||||
try {
|
||||
whoisPartString = getValueBetweenKeywords(multipleWhoisString, "# start", "# end");
|
||||
whoisPartString = getValueBetweenKeywords(multipleWhoisString, START_STRING, END_STRING);
|
||||
} catch (ParseException ex) {
|
||||
throw new WhoisException("Error while reading whois part elements. Reason: " + ex.getMessage(), ex);
|
||||
}
|
||||
analyse(whoisPartString);
|
||||
multipleWhoisString = multipleWhoisString.substring(multipleWhoisString.indexOf("# end") + 4);
|
||||
multipleWhoisString = multipleWhoisString.substring(multipleWhoisString.indexOf(END_STRING) + 4);
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -78,11 +84,11 @@ public class ArinWhoisParser extends AbstractWhoisParser implements WhoisParser
|
||||
}
|
||||
|
||||
private void analyseBlock(String block) throws WhoisException {
|
||||
LOGGER.debug("Start analysing block");
|
||||
LOGGER.debug("\n---\n" + block + "\n---\n");
|
||||
logger.debug("Start analysing block");
|
||||
logger.debug("\n---\n{}\n---\n", block);
|
||||
|
||||
if ((block == null) || (block.equals("")) || (!block.contains(" "))) {
|
||||
LOGGER.debug("Skippig empty block");
|
||||
if ((block == null) || (!block.contains(" "))) {
|
||||
logger.debug("Skipping empty block");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -98,23 +104,24 @@ public class ArinWhoisParser extends AbstractWhoisParser implements WhoisParser
|
||||
|
||||
switch (startString) {
|
||||
|
||||
case "NetRange:":
|
||||
if (valueMap.containsKey("NetRange:")) {
|
||||
String netRange = valueMap.get("NetRange:");
|
||||
case NET_RANGE:
|
||||
if (valueMap.containsKey(NET_RANGE)) {
|
||||
String netRange = valueMap.get(NET_RANGE);
|
||||
// convert inetnum to CDIR
|
||||
String[] ipAddresses = netRange.split(" "); // TODO - what happens if not 3 parts are found
|
||||
// TODO - what happens if not 3 parts are found
|
||||
String[] ipAddresses = netRange.split(" ");
|
||||
// FIXME add CDIR notation support
|
||||
String startIpAddress = ipAddresses[0];
|
||||
String endIPAddress = ipAddresses[2];
|
||||
whoisInformation.addNetwork(rangeToCidrList(startIpAddress, endIPAddress));
|
||||
LOGGER.info("Network:" + whoisInformation.getNetwork().toString());
|
||||
logger.info("Network: {}", whoisInformation.getNetwork());
|
||||
} else {
|
||||
throw new WhoisException("Cannot identify netrange value");
|
||||
}
|
||||
break;
|
||||
|
||||
case "OrgName:":
|
||||
String orgName = getValue("OrgName:", valueMap);
|
||||
case ORG_NAME:
|
||||
String orgName = getValue(ORG_NAME, valueMap);
|
||||
String orgId = getValue("OrgId:", valueMap);
|
||||
String country = getValue("Country:", valueMap);
|
||||
|
||||
@ -125,23 +132,23 @@ public class ArinWhoisParser extends AbstractWhoisParser implements WhoisParser
|
||||
orgId = orgName;
|
||||
}
|
||||
whoisInformation.setNetworkInformation(new NetworkInformation(orgName, orgId, country));
|
||||
LOGGER.info("Networkinformation:" + whoisInformation.getNetworkInformation().toString());
|
||||
logger.info("Networkinformation: {}", whoisInformation.getNetworkInformation());
|
||||
break;
|
||||
|
||||
case "OrgAbuseHandle:":
|
||||
// TODO add abuse handler
|
||||
LOGGER.info("Skipping OrgAbuseHandle block");
|
||||
logger.info("Skipping OrgAbuseHandle block");
|
||||
break;
|
||||
case "OrgTechHandle:":
|
||||
// admin person of network server belongs to
|
||||
LOGGER.info("Skipping OrgTechHandle block");
|
||||
logger.info("Skipping OrgTechHandle block");
|
||||
break;
|
||||
|
||||
case "#":
|
||||
LOGGER.info("Skipping comment block");
|
||||
logger.info("Skipping comment block");
|
||||
break;
|
||||
default:
|
||||
LOGGER.info("Unknown block found");
|
||||
logger.info("Unknown block found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
package de.muehlencord.shared.network.whois;
|
||||
|
||||
import static de.muehlencord.shared.network.CidrTool.rangeToCidrList;
|
||||
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -29,7 +30,7 @@ public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisPars
|
||||
/**
|
||||
* logger object
|
||||
*/
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(DefaultWhoisParser.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(DefaultWhoisParser.class);
|
||||
/**
|
||||
* information to be returned
|
||||
*/
|
||||
@ -56,11 +57,11 @@ public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisPars
|
||||
}
|
||||
|
||||
private void analyseBlock(String block) throws WhoisException {
|
||||
LOGGER.debug("Start analysing block");
|
||||
LOGGER.debug("\n---\n" + block + "\n---\n");
|
||||
logger.debug("Start analysing block");
|
||||
logger.debug("\n---\n{}\n---\n", block);
|
||||
|
||||
if ((block == null) || (block.equals("")) || (!block.contains(" "))) {
|
||||
LOGGER.debug("Skippig empty block");
|
||||
if ((block == null) || (!block.contains(" "))) {
|
||||
logger.debug("Skipping empty block");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -76,9 +77,8 @@ public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisPars
|
||||
case "inetnum:":
|
||||
String inetnum = getValue("inetnum:", valueMap);
|
||||
String country = getValue("country:", valueMap);
|
||||
String netname = getValue("descr:", valueMap);
|
||||
String descr = getValue("netname:", valueMap);
|
||||
String parent = getValue("parent:", valueMap);
|
||||
String netname = getValue("netname:", valueMap);
|
||||
String descr = getValue("descr:", valueMap);
|
||||
|
||||
if ((inetnum == null) || (country == null)) {
|
||||
throw new WhoisException("Cannot identify inetnum and/or country value");
|
||||
@ -86,7 +86,8 @@ public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisPars
|
||||
|
||||
if (inetnum.contains(" ")) {
|
||||
// convert inetnum to CDIR
|
||||
String[] ipAddresses = inetnum.split(" "); // TODO - what happens if not 3 parts are found
|
||||
// TODO - what happens if not 3 parts are found
|
||||
String[] ipAddresses = inetnum.split(" ");
|
||||
// FIXME add CDIR notation support
|
||||
String startIpAddress = ipAddresses[0];
|
||||
String endIPAddress = ipAddresses[2];
|
||||
@ -95,15 +96,7 @@ public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisPars
|
||||
whoisInformation.addNetwork(inetnum);
|
||||
}
|
||||
|
||||
/*
|
||||
if (parent != null) {
|
||||
whoisInformation.addRootNetwork(parent);
|
||||
LOGGER.info("Root network by parent" + whoisInformation.getRootNetwork().toString());
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
LOGGER.info("Network:" + whoisInformation.getNetwork().toString());
|
||||
logger.info("Network: {}", whoisInformation.getNetwork());
|
||||
whoisInformation.setNetworkInformation(new NetworkInformation(netname, descr, country));
|
||||
|
||||
break;
|
||||
@ -111,26 +104,26 @@ public class DefaultWhoisParser extends AbstractWhoisParser implements WhoisPars
|
||||
// get information on level-2 network
|
||||
String route = getValue("route:", valueMap);
|
||||
whoisInformation.addRootNetwork(route);
|
||||
LOGGER.info("Root network " + whoisInformation.getRootNetwork().toString());
|
||||
logger.info("Root network: {}", whoisInformation.getRootNetwork());
|
||||
break;
|
||||
|
||||
case "role:":
|
||||
// admin company of network server belongs to
|
||||
LOGGER.info("Skipping role block");
|
||||
logger.info("Skipping role block");
|
||||
break;
|
||||
case "person:":
|
||||
// admin person of network server belongs to
|
||||
LOGGER.info("Skipping person block");
|
||||
logger.info("Skipping person block");
|
||||
break;
|
||||
case "% Information":
|
||||
case "% Note:":
|
||||
case "% This":
|
||||
case "%":
|
||||
LOGGER.info("Skipping comment block");
|
||||
logger.info("Skipping comment block");
|
||||
break;
|
||||
default:
|
||||
LOGGER.info("Unknown block found");
|
||||
LOGGER.error(block);
|
||||
logger.info("Unknown block found");
|
||||
logger.error(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package de.muehlencord.shared.network.whois;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import de.muehlencord.shared.network.BaseTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* test the default implementation
|
||||
*
|
||||
* @author Joern Muehlencord, 2021-09-22
|
||||
* @since 1.2.0
|
||||
*/
|
||||
class DefaultWhoisParserTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
void parseWhoIsString() throws Exception {
|
||||
String whoisInformation = this.readContentFromFile("90.63.251.1.txt");
|
||||
DefaultWhoisParser parser = new DefaultWhoisParser();
|
||||
WhoisInformation information = parser.parseWhoIsString(whoisInformation);
|
||||
assertNotNull (information);
|
||||
information.validate();
|
||||
System.out.println ("parseWhoIsString");
|
||||
System.out.println (information.getNetworkInformation().toString());
|
||||
System.out.println (information.getNetwork().toString());
|
||||
System.out.println (information.getRootNetwork().toString());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
% This is the RIPE Database query service.
|
||||
% The objects are in RPSL format.
|
||||
%
|
||||
% The RIPE Database is subject to Terms and Conditions.
|
||||
% See http://www.ripe.net/db/support/db-terms-conditions.pdf
|
||||
|
||||
% Note: this output has been filtered.
|
||||
% To receive output for a database update, use the "-B" flag.
|
||||
|
||||
% Information related to '90.63.251.0 - 90.63.251.255'
|
||||
|
||||
% Abuse contact for '90.63.251.0 - 90.63.251.255' is 'gestionip.ft@orange.com'
|
||||
|
||||
inetnum: 90.63.251.0 - 90.63.251.255
|
||||
netname: IP2000-ADSL-BAS
|
||||
descr: LNAUB658 Aubervilliers Bloc 1
|
||||
country: FR
|
||||
admin-c: WITR1-RIPE
|
||||
tech-c: WITR1-RIPE
|
||||
status: ASSIGNED PA
|
||||
remarks: for hacking, spamming or security problems send mail to
|
||||
remarks: abuse@orange.fr
|
||||
mnt-by: FT-BRX
|
||||
created: 2015-10-09T11:39:49Z
|
||||
last-modified: 2019-10-07T13:05:05Z
|
||||
source: RIPE
|
||||
|
||||
role: Wanadoo France Technical Role
|
||||
address: FRANCE TELECOM/SCR
|
||||
address: 48 rue Camille Desmoulins
|
||||
address: 92791 ISSY LES MOULINEAUX CEDEX 9
|
||||
address: FR
|
||||
phone: +33 1 58 88 50 00
|
||||
abuse-mailbox: abuse@orange.fr
|
||||
admin-c: BRX1-RIPE
|
||||
tech-c: BRX1-RIPE
|
||||
nic-hdl: WITR1-RIPE
|
||||
mnt-by: FT-BRX
|
||||
created: 2001-12-04T17:57:08Z
|
||||
last-modified: 2013-07-16T14:09:50Z
|
||||
source: RIPE # Filtered
|
||||
|
||||
% Information related to '90.63.192.0/18AS3215'
|
||||
|
||||
route: 90.63.192.0/18
|
||||
descr: France Telecom IP2000-ADSL-BAS
|
||||
origin: AS3215
|
||||
mnt-by: FT-BRX
|
||||
created: 2012-12-11T10:12:42Z
|
||||
last-modified: 2012-12-11T10:12:42Z
|
||||
source: RIPE
|
||||
|
||||
% This query was served by the RIPE Database Query Service version 1.101 (ANGUS)
|
||||
@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright 2019 Joern Muehlencord (joern@muehlencord.de).
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
||||
debug="true">
|
||||
|
||||
<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%c] %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<category name="de.muehlencord">
|
||||
<priority value="DEBUG"/>
|
||||
</category>
|
||||
|
||||
<category name="com.sun">
|
||||
<priority value="WARN"/>
|
||||
</category>
|
||||
|
||||
<category name="javax.xml">
|
||||
<priority value="WARN"/>
|
||||
</category>
|
||||
|
||||
<logger name="org.hibernate">
|
||||
<level value="INFO"/>
|
||||
</logger>
|
||||
|
||||
<root>
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="consoleAppender" />
|
||||
</root>
|
||||
</log4j:configuration>
|
||||
@ -15,41 +15,42 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<artifactId>shared-poi-util</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>de.muehlencord</groupId>
|
||||
<artifactId>shared</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<name>shared-poi-util</name>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<artifactId>shared-util</artifactId>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<name>shared-poi-util</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>shared</artifactId>
|
||||
<groupId>de.muehlencord</groupId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</project>
|
||||
682
pom.xml
682
pom.xml
@ -15,357 +15,28 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.muehlencord</groupId>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<artifactId>shared</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>shared</name>
|
||||
|
||||
<modules>
|
||||
<module>configuration</module>
|
||||
<module>network</module>
|
||||
<module>util</module>
|
||||
<module>jeeutil</module>
|
||||
<module>shiro-faces</module>
|
||||
<module>poi-util</module>
|
||||
<module>db</module>
|
||||
</modules>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:https://jomu.timelord.de/git/jomu/shared/</connection>
|
||||
<developerConnection>scm:git:https://jomu.timelord.de/git/jomu/shared/</developerConnection>
|
||||
<url>https://jomu.timelord.de/git/jomu/shared/</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<system>Gitea</system>
|
||||
<url>https://jomu.timelord.de/git/jomu/shared/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Joern Muehlencord</name>
|
||||
<email>joern@muehlencord.de</email>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<properties>
|
||||
<!-- project setup -->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<artifactId>shared-db</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<type>ejb</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<artifactId>shared-shiro-faces</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<artifactId>shared-util</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<artifactId>shared-jeeutil</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-net</groupId>
|
||||
<artifactId>commons-net</artifactId>
|
||||
<version>3.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.30</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.30</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>1.7.30</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microsoft.ews-java-api</groupId>
|
||||
<artifactId>ews-java-api</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.11.3</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.11.3</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>2.11.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
<version>1.7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-web</artifactId>
|
||||
<version>1.7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
<version>8.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-web-api</artifactId>
|
||||
<version>8.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.lambdaworks</groupId>
|
||||
<artifactId>scrypt</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.68</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>5.4.23.Final</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.primefaces</groupId>
|
||||
<artifactId>primefaces</artifactId>
|
||||
<version>8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.adminfaces</groupId>
|
||||
<artifactId>admin-template</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.omnifaces</groupId>
|
||||
<artifactId>omnifaces</artifactId>
|
||||
<version>3.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.fusionauth</groupId>
|
||||
<artifactId>fusionauth-jwt</artifactId>
|
||||
<version>4.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Dev Tools -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
<version>1.18.16</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Testing -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.7.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- deploy artifacts to maven repository -->
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.8</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- ensure sources are build so they are also uploaded -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- ensure java doc is built -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- create license file -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>license-maven-plugin</artifactId>
|
||||
<version>1.14</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>download-licenses</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>download-licenses</goal>
|
||||
<goal>add-third-party</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<licensesOutputDirectory>${licenses.dir}</licensesOutputDirectory>
|
||||
<outputDirectory>${licenses.dir}</outputDirectory>
|
||||
<licenseMerges>
|
||||
<licenseMerge>The Apache Software License, Version 2.0|Apache 2|Apache License, Version 2.0|Apache Public License 2.0</licenseMerge>
|
||||
</licenseMerges>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- sign jar archives -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<keyname>993245E2EC7608BB</keyname>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<!-- build archive -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
|
||||
<!-- build maven ejb artifacts -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-ejb-plugin</artifactId>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
|
||||
@ -377,8 +48,8 @@ limitations under the License.
|
||||
|
||||
<!-- control junit tests from maven build -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
@ -387,21 +58,354 @@ limitations under the License.
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.5.3</version>
|
||||
<configuration>
|
||||
<tagNameFormat>v@{project.version}</tagNameFormat>
|
||||
</configuration>
|
||||
<version>2.5.3</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>shared-db</artifactId>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<type>ejb</type>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>shared-shiro-faces</artifactId>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>shared-util</artifactId>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>shared-jeeutil</artifactId>
|
||||
<groupId>de.muehlencord.shared</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<groupId>commons-codec</groupId>
|
||||
<version>1.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>commons-net</artifactId>
|
||||
<groupId>commons-net</groupId>
|
||||
<version>3.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<groupId>commons-io</groupId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>ews-java-api</artifactId>
|
||||
<groupId>com.microsoft.ews-java-api</groupId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>gson</artifactId>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<version>2.8.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<type>jar</type>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<type>jar</type>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<version>1.7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>shiro-web</artifactId>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<version>1.7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
<groupId>javax</groupId>
|
||||
<version>8.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>javaee-web-api</artifactId>
|
||||
<groupId>javax</groupId>
|
||||
<scope>provided</scope>
|
||||
<version>8.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>scrypt</artifactId>
|
||||
<groupId>com.lambdaworks</groupId>
|
||||
<version>1.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<version>1.68</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<type>jar</type>
|
||||
<version>5.4.23.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>primefaces</artifactId>
|
||||
<groupId>org.primefaces</groupId>
|
||||
<version>10.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>admin-template</artifactId>
|
||||
<groupId>com.github.adminfaces</groupId>
|
||||
<version>1.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>omnifaces</artifactId>
|
||||
<groupId>org.omnifaces</groupId>
|
||||
<version>3.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<version>5.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>fusionauth-jwt</artifactId>
|
||||
<groupId>io.fusionauth</groupId>
|
||||
<version>4.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Dev Tools -->
|
||||
<dependency>
|
||||
<artifactId>lombok</artifactId>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<scope>provided</scope>
|
||||
<version>1.18.22</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Testing -->
|
||||
<dependency>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<scope>test</scope>
|
||||
<version>5.8.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<developers>
|
||||
<developer>
|
||||
<email>joern@muehlencord.de</email>
|
||||
<name>Joern Muehlencord</name>
|
||||
</developer>
|
||||
</developers>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<groupId>de.muehlencord</groupId>
|
||||
|
||||
<issueManagement>
|
||||
<system>Gitea</system>
|
||||
<url>https://jomu.timelord.de/git/jomu/shared/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<distribution>repo</distribution>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<modules>
|
||||
<module>configuration</module>
|
||||
<module>network</module>
|
||||
<module>util</module>
|
||||
<module>jeeutil</module>
|
||||
<module>shiro-faces</module>
|
||||
<module>poi-util</module>
|
||||
<module>db</module>
|
||||
</modules>
|
||||
|
||||
<name>shared</name>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- deploy artifacts to maven repository -->
|
||||
<plugin>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<serverId>ossrh</serverId>
|
||||
</configuration>
|
||||
<extensions>true</extensions>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<version>1.6.8</version>
|
||||
</plugin>
|
||||
|
||||
<!-- ensure sources are build so they are also uploaded -->
|
||||
<plugin>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
<id>attach-sources</id>
|
||||
</execution>
|
||||
</executions>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
|
||||
<!-- ensure java doc is built -->
|
||||
<plugin>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<id>attach-javadocs</id>
|
||||
</execution>
|
||||
</executions>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<version>3.1.1</version>
|
||||
</plugin>
|
||||
|
||||
<!-- create license file -->
|
||||
<plugin>
|
||||
<artifactId>license-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<configuration>
|
||||
<licenseMerges>
|
||||
<licenseMerge>The Apache Software License, Version 2.0|Apache 2|Apache License, Version 2.0|Apache Public License 2.0</licenseMerge>
|
||||
</licenseMerges>
|
||||
<licensesOutputDirectory>${licenses.dir}</licensesOutputDirectory>
|
||||
<outputDirectory>${licenses.dir}</outputDirectory>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>download-licenses</goal>
|
||||
<goal>add-third-party</goal>
|
||||
</goals>
|
||||
<id>download-licenses</id>
|
||||
<phase>generate-resources</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<version>1.14</version>
|
||||
</plugin>
|
||||
|
||||
<!-- sign jar archives -->
|
||||
<plugin>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<configuration>
|
||||
<keyname>993245E2EC7608BB</keyname>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<version>1.6</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<id>release</id>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<properties>
|
||||
<!-- project setup -->
|
||||
<jackson.version>2.13.0</jackson.version>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<slf4j.version>1.7.32</slf4j.version>
|
||||
</properties>
|
||||
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:https://jomu.timelord.de/git/jomu/shared/</connection>
|
||||
<developerConnection>scm:git:https://jomu.timelord.de/git/jomu/shared/</developerConnection>
|
||||
<tag>HEAD</tag>
|
||||
<url>https://jomu.timelord.de/git/jomu/shared/</url>
|
||||
</scm>
|
||||
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
|
||||
</project>
|
||||
|
||||
@ -28,7 +28,7 @@ public abstract class AbstractAccessControlTag extends AbstractTag {
|
||||
|
||||
protected TagAttribute attribute;
|
||||
|
||||
public AbstractAccessControlTag(TagConfig config) {
|
||||
protected AbstractAccessControlTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
|
||||
@ -19,13 +19,16 @@ import java.io.IOException;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.view.facelets.FaceletContext;
|
||||
import javax.faces.view.facelets.TagConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public abstract class AbstractAuthenticationTag extends AbstractTag {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractAuthenticationTag.class);
|
||||
|
||||
protected AbstractAuthenticationTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
@ -34,13 +37,13 @@ public abstract class AbstractAuthenticationTag extends AbstractTag {
|
||||
|
||||
protected boolean applyTagHandler() {
|
||||
if (isAuthenticated()) {
|
||||
if (LOGGER.isTraceEnabled()) {
|
||||
LOGGER.trace("Authentication verified, tag will be evaluated");
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Authentication verified, tag will be evaluated");
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if (LOGGER.isTraceEnabled()) {
|
||||
LOGGER.trace ("Authentifaction verification failed, tag will not be evaluated");
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Authentifaction verification failed, tag will not be evaluated");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -53,8 +56,4 @@ public abstract class AbstractAuthenticationTag extends AbstractTag {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -19,8 +19,6 @@ import javax.faces.view.facelets.TagConfig;
|
||||
import javax.faces.view.facelets.TagHandler;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -28,9 +26,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public abstract class AbstractTag extends TagHandler {
|
||||
|
||||
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractTag.class);
|
||||
|
||||
public AbstractTag(TagConfig config) {
|
||||
protected AbstractTag(TagConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
|
||||
@ -24,20 +24,19 @@ import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class StreamUtils {
|
||||
public interface StreamUtils {
|
||||
|
||||
public static <T> Collector<T, ?, T> singletonCollector() {
|
||||
default <T> Collector<T, ?, T> singletonCollector() {
|
||||
return getCollectorFunction(getListTSingleFunction());
|
||||
}
|
||||
|
||||
private static <T> Collector<T, ?, T> getCollectorFunction(Function<List<T>, T> listTFunction) {
|
||||
default <T> Collector<T, ?, T> getCollectorFunction(Function<List<T>, T> listTFunction) {
|
||||
return Collectors.collectingAndThen(Collectors.toList(), listTFunction);
|
||||
}
|
||||
|
||||
private static <T> Function<List<T>, T> getListTSingleFunction() {
|
||||
default <T> Function<List<T>, T> getListTSingleFunction() {
|
||||
return list -> {
|
||||
if (list == null) {
|
||||
throw new IllegalStateException("List must not be null");
|
||||
|
||||
@ -21,7 +21,7 @@ package de.muehlencord.shared.util;
|
||||
*/
|
||||
public class StringEncodingException extends Exception {
|
||||
|
||||
protected final static String DEFAULT_MSG = "An encoding exception occurred";
|
||||
protected static final String DEFAULT_MSG = "An encoding exception occurred";
|
||||
|
||||
/**
|
||||
* Creates a new instance of
|
||||
|
||||
@ -15,37 +15,37 @@
|
||||
*/
|
||||
package de.muehlencord.shared.util;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord (joern@muehlencord.de)
|
||||
*/
|
||||
public class StringEncodingExceptionTest {
|
||||
class StringEncodingExceptionTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testDefaultConstructor() {
|
||||
void testDefaultConstructor() {
|
||||
StringEncodingException ex = new StringEncodingException();
|
||||
assertTrue (ex.getMessage().equals (StringEncodingException.DEFAULT_MSG));
|
||||
assertEquals(StringEncodingException.DEFAULT_MSG, ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageConstructor() {
|
||||
void testMessageConstructor() {
|
||||
String msg = "Test message";
|
||||
StringEncodingException ex = new StringEncodingException(msg);
|
||||
assertTrue (ex.getMessage().equals (msg));
|
||||
assertEquals(ex.getMessage(), msg);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRootcauseConstructor() {
|
||||
void testRootcauseConstructor() {
|
||||
String msg = "Test message";
|
||||
StringEncodingException rootCause = new StringEncodingException();
|
||||
StringEncodingException ex = new StringEncodingException(msg, rootCause);
|
||||
assertTrue (ex.getMessage().equals (msg));
|
||||
assertTrue (ex.getCause().equals (rootCause));
|
||||
assertEquals(ex.getMessage(), msg);
|
||||
assertEquals(ex.getCause(), rootCause);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user