From cd2e3b0642e595baa0eaa828ff94db2d6f19af5c Mon Sep 17 00:00:00 2001 From: Joern Muehlencord Date: Sun, 21 Feb 2021 16:30:23 +0100 Subject: [PATCH] updated libraries --- jeeutil/pom.xml | 18 +-- .../shared/jeeutil/jwt/JWTDecoder.java | 105 ++++++++---------- .../shared/jeeutil/jwt/JWTEncoder.java | 6 +- .../de/muehlencord/shared/poi/PoiUtil.java | 22 +++- pom.xml | 57 +++++----- 5 files changed, 103 insertions(+), 105 deletions(-) diff --git a/jeeutil/pom.xml b/jeeutil/pom.xml index dab8b2b..6210e37 100644 --- a/jeeutil/pom.xml +++ b/jeeutil/pom.xml @@ -31,22 +31,8 @@ limitations under the License. - com.inversoft - prime-jwt - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.core - jackson-annotations - - + io.fusionauth + fusionauth-jwt javax diff --git a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTDecoder.java b/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTDecoder.java index 12bca70..52d8c72 100644 --- a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTDecoder.java +++ b/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTDecoder.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2019 Joern Muehlencord (joern@muehlencord.de). * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,80 +15,73 @@ */ package de.muehlencord.shared.jeeutil.jwt; +import io.fusionauth.jwt.Verifier; +import io.fusionauth.jwt.domain.JWT; +import io.fusionauth.jwt.hmac.HMACVerifier; import java.time.ZonedDateTime; -import org.primeframework.jwt.Verifier; -import org.primeframework.jwt.domain.JWT; -import org.primeframework.jwt.domain.JWTException; -import org.primeframework.jwt.hmac.HMACVerifier; /** - * * @author Joern Muehlencord (joern@muehlencord.de) */ public class JWTDecoder { - private boolean parsedSuccessfully = false; - private JWT jwt = null; + private boolean parsedSuccessfully; + private JWT jwt = null; - public JWTDecoder(String password, String issuer, String jwtString) throws JWTException { - if ((password == null) || (issuer == null) || (jwtString == null)) { - throw new JWTException("password, issuer and jwt must not be null"); - } - Verifier verifier = HMACVerifier.newVerifier(password); -// Verifier verifier = RSAVerifier.newVerifier(new String(Files.readAllBytes(Paths.get("public_key.pem")))); - try { - jwt = JWT.getDecoder().decode(jwtString, verifier); - parsedSuccessfully = jwt.issuer.equals(issuer); - } catch (JWTException ex) { - jwt = null; - } + public JWTDecoder(String password, String issuer, String jwtString) throws JWTException { + if ((password == null) || (issuer == null) || (jwtString == null)) { + throw new JWTException("password, issuer and jwt must not be null"); } + Verifier verifier = HMACVerifier.newVerifier(password); + jwt = JWT.getDecoder().decode(jwtString, verifier); + parsedSuccessfully = jwt != null && jwt.issuer.equals(issuer); + } - public String getIssuer() { - if (jwt == null) { - return null; - } else { - return jwt.issuer; - } + public String getIssuer() { + if (jwt == null) { + return null; + } else { + return jwt.issuer; } + } - public ZonedDateTime getIssuedAt() { - if (jwt == null) { - return null; - } else { - return jwt.issuedAt; - } + public ZonedDateTime getIssuedAt() { + if (jwt == null) { + return null; + } else { + return jwt.issuedAt; } + } - public String getSubject() { - if (jwt == null) { - return null; - } else { - return jwt.subject; - } + public String getSubject() { + if (jwt == null) { + return null; + } else { + return jwt.subject; } + } - public String getUniqueId() { - if (jwt == null) { - return null; - } else { - return jwt.uniqueId; - } + public String getUniqueId() { + if (jwt == null) { + return null; + } else { + return jwt.uniqueId; } + } - public ZonedDateTime getExpiration() { - if (jwt == null) { - return null; - } else { - return jwt.expiration; - } + public ZonedDateTime getExpiration() { + if (jwt == null) { + return null; + } else { + return jwt.expiration; } + } - public boolean isValid() { - if ((jwt == null) || (jwt.isExpired())) { - return false; - } else { - return this.parsedSuccessfully; - } + public boolean isValid() { + if ((jwt == null) || (jwt.isExpired())) { + return false; + } else { + return this.parsedSuccessfully; } + } } diff --git a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTEncoder.java b/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTEncoder.java index 2ab6c65..7cdaef7 100644 --- a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTEncoder.java +++ b/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/jwt/JWTEncoder.java @@ -15,10 +15,10 @@ */ package de.muehlencord.shared.jeeutil.jwt; +import io.fusionauth.jwt.Signer; +import io.fusionauth.jwt.domain.JWT; +import io.fusionauth.jwt.hmac.HMACSigner; import java.time.ZonedDateTime; -import org.primeframework.jwt.Signer; -import org.primeframework.jwt.domain.JWT; -import org.primeframework.jwt.hmac.HMACSigner; /** * diff --git a/poi-util/src/main/java/de/muehlencord/shared/poi/PoiUtil.java b/poi-util/src/main/java/de/muehlencord/shared/poi/PoiUtil.java index 0c3468e..fcdaa6b 100644 --- a/poi-util/src/main/java/de/muehlencord/shared/poi/PoiUtil.java +++ b/poi-util/src/main/java/de/muehlencord/shared/poi/PoiUtil.java @@ -255,8 +255,28 @@ public abstract class PoiUtil { } } + public static int getIntegerValue(Row currentRow, int cellNumber) throws PoiException { + return getIntegerValue(currentRow, cellNumber, false, 0); + } + + public static Integer getIntegerValue(Row currentRow, int cellNumber, boolean returnDefaultValue, Integer defaultValue) throws PoiException { + if (currentRow == null) { + throw new PoiException("Current row must not be null"); + } + Cell cell = currentRow.getCell(cellNumber); + if ((PoiUtil.cellEmpty(cell)) && !returnDefaultValue) { + throw new PoiException("Cannot read cell " + cellNumber + " from row " + currentRow.getRowNum()); + } else { + if (PoiUtil.cellEmpty(cell)) { + return defaultValue; + } else { + return Double.valueOf(cell.getNumericCellValue()).intValue(); + } + } + } + /** - * remove charecters which often cause troubles in other applications - e.g. em dash (long dash) is created by Excel automatically + * remove characters which often cause troubles in other applications - e.g. em dash (long dash) is created by Excel automatically * * @param sourceValue the input string to execute the replacement * @return sourceValue with replaced characters diff --git a/pom.xml b/pom.xml index 7dea8e8..ed20ee7 100644 --- a/pom.xml +++ b/pom.xml @@ -104,7 +104,7 @@ limitations under the License. commons-codec commons-codec - 1.13 + 1.15 commons-net @@ -114,33 +114,33 @@ limitations under the License. org.apache.commons commons-lang3 - 3.9 + 3.11 commons-io commons-io - 2.6 + 2.8.0 org.slf4j slf4j-api - 1.7.28 + 1.7.30 org.slf4j slf4j-log4j12 - 1.7.28 + 1.7.30 org.slf4j jcl-over-slf4j - 1.7.28 + 1.7.30 com.sun.mail javax.mail - 1.6.2 + 1.6.2 com.microsoft.ews-java-api @@ -150,88 +150,87 @@ limitations under the License. com.google.code.gson gson - 2.8.5 + 2.8.6 com.fasterxml.jackson.core jackson-annotations - 2.11.2 + 2.11.3 jar com.fasterxml.jackson.core jackson-databind - 2.11.2 + 2.11.3 jar com.fasterxml.jackson.datatype jackson-datatype-jsr310 - 2.11.2 + 2.11.3 org.apache.shiro shiro-core - 1.4.1 + 1.7.1 org.apache.shiro shiro-web - 1.4.1 + 1.7.1 javax javaee-api - 7.0 + 8.0.1 javax javaee-web-api - 7.0 + 8.0.1 provided com.lambdaworks scrypt - 1.4.0 + 1.4.0 org.bouncycastle bcprov-jdk15on - 1.62 + 1.68 org.hibernate hibernate-core - 5.3.10.Final + 5.4.23.Final jar org.primefaces primefaces - 7.0 + 8.0 com.github.adminfaces admin-template - 1.0.2 + 1.2.0 org.omnifaces omnifaces - 3.3 + 3.4.1 org.apache.poi poi-ooxml - 4.0.1 - + 5.0.0 - com.inversoft - prime-jwt - 2.0.0 + io.fusionauth + fusionauth-jwt + 4.1.0 @@ -239,14 +238,14 @@ limitations under the License. org.projectlombok lombok provided - 1.18.12 + 1.18.16 org.junit.jupiter junit-jupiter-engine - 5.5.1 + 5.7.0 test @@ -405,4 +404,4 @@ limitations under the License. - \ No newline at end of file +