Skip to content

Commit f5219da

Browse files
committed
update to java 11, update dependencies, remove jdom,xalan,commons-logging
- switch all file related parameters to File instead of String - remove unneeded "public" from interface methods
1 parent df9f58b commit f5219da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+417
-572
lines changed

pom.xml

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,12 @@
1616
<dependency>
1717
<groupId>commons-codec</groupId>
1818
<artifactId>commons-codec</artifactId>
19-
<version>1.14</version>
19+
<version>1.15</version>
2020
</dependency>
2121
<dependency>
2222
<groupId>org.apache.httpcomponents</groupId>
2323
<artifactId>httpclient</artifactId>
24-
<version>4.5.13</version>
25-
</dependency>
26-
<dependency>
27-
<groupId>commons-logging</groupId>
28-
<artifactId>commons-logging</artifactId>
29-
<version>1.2</version>
30-
</dependency>
31-
<dependency>
32-
<groupId>org.jdom</groupId>
33-
<artifactId>jdom</artifactId>
34-
<version>2.0.2</version>
24+
<version>4.5.14</version>
3525
</dependency>
3626
<dependency>
3727
<groupId>org.bouncycastle</groupId>
@@ -41,38 +31,33 @@
4131
<dependency>
4232
<groupId>org.apache.logging.log4j</groupId>
4333
<artifactId>log4j-core</artifactId>
44-
<version>2.17.1</version>
34+
<version>2.25.2</version>
4535
</dependency>
4636
<dependency>
4737
<groupId>org.gnu</groupId>
4838
<artifactId>gnu-crypto</artifactId>
4939
<version>2.0.1</version>
5040
</dependency>
5141
<dependency>
52-
<groupId>xalan</groupId>
53-
<artifactId>xalan</artifactId>
54-
<version>2.7.2</version>
55-
</dependency>
56-
<dependency>
57-
<groupId>xml-security</groupId>
42+
<groupId>org.apache.santuario</groupId>
5843
<artifactId>xmlsec</artifactId>
59-
<version>1.3.0</version>
44+
<version>4.0.4</version>
6045
</dependency>
6146
<dependency>
6247
<groupId>commons-cli</groupId>
6348
<artifactId>commons-cli</artifactId>
64-
<version>1.4</version>
49+
<version>1.10.0</version>
6550
</dependency>
6651
<dependency>
6752
<groupId>org.junit.jupiter</groupId>
6853
<artifactId>junit-jupiter-api</artifactId>
69-
<version>5.6.0</version>
54+
<version>6.0.0</version>
7055
<scope>test</scope>
7156
</dependency>
7257
<dependency>
7358
<groupId>org.junit.jupiter</groupId>
7459
<artifactId>junit-jupiter-engine</artifactId>
75-
<version>5.6.0</version>
60+
<version>6.0.0</version>
7661
<scope>test</scope>
7762
</dependency>
7863
<dependency>
@@ -99,23 +84,23 @@
9984
<configuration>
10085
<schemaDirectory>src/main/xsd</schemaDirectory>
10186
<defaultXmlConfigDir>src/main/xsd/config</defaultXmlConfigDir>
102-
<javaSource>1.8</javaSource>
87+
<javaSource>11</javaSource>
10388
</configuration>
10489
</plugin>
10590

10691
<plugin>
10792
<groupId>org.apache.maven.plugins</groupId>
10893
<artifactId>maven-compiler-plugin</artifactId>
109-
<version>3.1</version>
94+
<version>3.14.1</version>
11095
<configuration>
111-
<source>1.7</source>
112-
<target>1.7</target>
96+
<source>11</source>
97+
<target>11</target>
11398
</configuration>
11499
</plugin>
115100
<plugin>
116101
<groupId>org.apache.maven.plugins</groupId>
117102
<artifactId>maven-source-plugin</artifactId>
118-
<version>3.0.0</version>
103+
<version>3.3.1</version>
119104
<executions>
120105
<execution>
121106
<id>attach-sources</id>
@@ -125,19 +110,10 @@
125110
</execution>
126111
</executions>
127112
</plugin>
128-
<plugin>
129-
<groupId>org.apache.maven.plugins</groupId>
130-
<artifactId>maven-eclipse-plugin</artifactId>
131-
<version>2.10</version>
132-
<configuration>
133-
<downloadSources>true</downloadSources>
134-
<downloadJavadocs>true</downloadJavadocs>
135-
</configuration>
136-
</plugin>
137113
<plugin>
138114
<groupId>org.apache.maven.plugins</groupId>
139115
<artifactId>maven-surefire-plugin</artifactId>
140-
<version>2.22.1</version>
116+
<version>3.5.4</version>
141117
</plugin>
142118
</plugins>
143119
</build>

src/main/java/org/kopi/ebics/certificate/CertificateManager.java

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.kopi.ebics.certificate;
2121

22+
import java.io.File;
2223
import java.io.FileOutputStream;
2324
import java.io.IOException;
2425
import java.io.OutputStream;
@@ -131,15 +132,11 @@ public void createE002Certificate(Date end) throws GeneralSecurityException, IOE
131132

132133
/**
133134
* Saves the certificates in PKCS12 format
134-
* @param path the certificates path
135-
* @param pwdCallBack the password call back
136-
* @throws GeneralSecurityException
137-
* @throws IOException
138135
*/
139-
public void save(String path, PasswordCallback pwdCallBack)
136+
public void save(File directory, PasswordCallback pwdCallBack)
140137
throws GeneralSecurityException, IOException
141138
{
142-
writePKCS12Certificate(path + "/" + user.getUserId(), pwdCallBack.getPassword());
139+
writePKCS12Certificate(new File(directory, user.getUserId()), pwdCallBack.getPassword());
143140
}
144141

145142
/**
@@ -149,7 +146,7 @@ public void save(String path, PasswordCallback pwdCallBack)
149146
* @throws GeneralSecurityException
150147
* @throws IOException
151148
*/
152-
public void load(String path, PasswordCallback pwdCallBack)
149+
public void load(File path, PasswordCallback pwdCallBack)
153150
throws GeneralSecurityException, IOException
154151
{
155152
KeyStoreManager loader;
@@ -169,24 +166,20 @@ public void load(String path, PasswordCallback pwdCallBack)
169166

170167
/**
171168
* Writes a the generated certificates into a PKCS12 key store.
172-
* @param filename the key store file name
169+
* @param file the key store file
173170
* @param password the key password
174171
* @throws IOException
175172
*/
176-
public void writePKCS12Certificate(String filename, char[] password)
173+
public void writePKCS12Certificate(File file, char[] password)
177174
throws GeneralSecurityException, IOException
178175
{
179-
if (filename == null || "".equals(filename)) {
180-
throw new IOException("The file name cannot be empty");
181-
}
182-
183-
if (!filename.toLowerCase().endsWith(".p12")) {
184-
filename += ".p12";
185-
}
186-
187-
FileOutputStream fos = new FileOutputStream(filename);
188-
writePKCS12Certificate(password, fos);
189-
fos.close();
176+
var outFile = file;
177+
if (!file.getName().toLowerCase().endsWith(".p12")) {
178+
outFile = new File(file.getParentFile(), file.getName() + ".p12");
179+
}
180+
try (FileOutputStream fos = new FileOutputStream(outFile)) {
181+
writePKCS12Certificate(password, fos);
182+
}
190183
}
191184

192185
/**
@@ -222,8 +215,8 @@ public void writePKCS12Certificate(char[] password, OutputStream fos)
222215
// DATA MEMBERS
223216
// --------------------------------------------------------------------
224217

225-
private X509Generator generator;
226-
private EbicsUser user;
218+
private final X509Generator generator;
219+
private final EbicsUser user;
227220

228221
private X509Certificate a005Certificate;
229222
private X509Certificate e002Certificate;

src/main/java/org/kopi/ebics/certificate/KeyStoreManager.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.kopi.ebics.certificate;
2121

22+
import java.io.File;
2223
import java.io.FileInputStream;
2324
import java.io.IOException;
2425
import java.io.InputStream;
@@ -98,7 +99,7 @@ public final PrivateKey getPrivateKey(String alias) throws GeneralSecurityExcept
9899
* @throws GeneralSecurityException
99100
* @throws IOException
100101
*/
101-
public void load(String path, char[] password)
102+
public void load(File path, char[] password)
102103
throws GeneralSecurityException, IOException
103104
{
104105
keyStore = KeyStore.getInstance("PKCS12", "BC");
@@ -112,8 +113,8 @@ public void load(String path, char[] password)
112113
* @throws GeneralSecurityException
113114
* @throws IOException
114115
*/
115-
private void load(String path) throws GeneralSecurityException, IOException {
116-
if (path.equals("")) {
116+
private void load(File path) throws GeneralSecurityException, IOException {
117+
if (path == null) {
117118
this.keyStore.load(null, null);
118119
} else {
119120
this.keyStore.load(new FileInputStream(path), password);

src/main/java/org/kopi/ebics/certificate/KeyUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.kopi.ebics.certificate;
2121

2222
import java.io.UnsupportedEncodingException;
23+
import java.nio.charset.StandardCharsets;
2324
import java.security.GeneralSecurityException;
2425
import java.security.KeyPair;
2526
import java.security.KeyPairGenerator;
@@ -92,14 +93,13 @@ public static byte[] getKeyDigest(RSAPublicKey publicKey) throws EbicsException
9293
}
9394

9495
try {
95-
digest = MessageDigest.getInstance("SHA-256", "BC").digest(hash.getBytes("US-ASCII"));
96+
digest = MessageDigest.getInstance("SHA-256", "BC").digest(hash.getBytes(
97+
StandardCharsets.US_ASCII));
9698
} catch (GeneralSecurityException e) {
9799
throw new EbicsException(e.getMessage());
98-
} catch (UnsupportedEncodingException e) {
99-
throw new EbicsException(e.getMessage());
100100
}
101101

102-
return new String(Hex.encodeHex(digest, false)).getBytes();
102+
return new String(Hex.encodeHex(digest, false)).getBytes();
103103
}
104104

105105
/**

src/main/java/org/kopi/ebics/certificate/X509Generator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ private long generateSerial() {
264264
// DATA MEMBERS
265265
// --------------------------------------------------------------------
266266

267-
private static SimpleDateFormat sdfSerial;
267+
private static final SimpleDateFormat sdfSerial;
268268

269269
static {
270270
sdfSerial = new SimpleDateFormat("yyyyMMddHHmmssSSS");

src/main/java/org/kopi/ebics/client/Bank.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ public String getSaveName() {
167167
* The bank URL
168168
* @serial
169169
*/
170-
private URL url;
170+
private final URL url;
171171

172172
/**
173173
* The bank host id
174174
* @serial
175175
*/
176-
private String hostId;
176+
private final String hostId;
177177

178178
/**
179179
* Does the bank use certificates for signing/crypting ?
@@ -185,7 +185,7 @@ public String getSaveName() {
185185
* The bank name
186186
* @serial
187187
*/
188-
private String name;
188+
private final String name;
189189

190190
/**
191191
* The bank encryption digest

src/main/java/org/kopi/ebics/client/EbicsClient.java

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@
6969
*/
7070
public class EbicsClient {
7171
private static File getRootDir() {
72-
return new File(
73-
System.getProperty("user.home") + File.separator + "ebics" + File.separator + "client");
72+
return new File(System.getProperty("user.home"), "ebics" + File.separator + "client");
7473
}
7574

7675
static {
@@ -233,7 +232,7 @@ private void createLetters(EbicsUser user, boolean useCertificates)
233232
List<InitLetter> letters = Arrays.asList(letterManager.createA005Letter(user),
234233
letterManager.createE002Letter(user), letterManager.createX002Letter(user));
235234

236-
File directory = new File(configuration.getLettersDirectory(user));
235+
File directory = configuration.getLettersDirectory(user);
237236
for (InitLetter letter : letters) {
238237
try (FileOutputStream out = new FileOutputStream(new File(directory, letter.getName()))) {
239238
letter.writeTo(out);
@@ -243,8 +242,6 @@ private void createLetters(EbicsUser user, boolean useCertificates)
243242

244243
/**
245244
* Loads a user knowing its ID
246-
*
247-
* @throws Exception
248245
*/
249246
public User loadUser(String hostId, String partnerId, String userId,
250247
PasswordCallback passwordCallback) throws Exception {
@@ -282,15 +279,14 @@ public User loadUser(String hostId, String partnerId, String userId,
282279
*
283280
* @param user the user
284281
* @param product the application product
285-
* @throws Exception
286282
*/
287283
public void sendINIRequest(User user, Product product) throws Exception {
288284
String userId = user.getUserId();
289285
logger.info(messages.getString("ini.request.send", userId));
290-
if (user.isInitialized()) {
291-
logger.info(messages.getString("user.already.initialized", userId));
292-
return;
293-
}
286+
// if (user.isInitialized()) {
287+
// logger.info(messages.getString("user.already.initialized", userId));
288+
// return;
289+
// }
294290
EbicsSession session = createSession(user, product);
295291
KeyManagement keyManager = new KeyManagement(session);
296292
configuration.getTraceManager().setTraceDirectory(
@@ -312,16 +308,15 @@ public void sendINIRequest(User user, Product product) throws Exception {
312308
* the user ID.
313309
* @param product
314310
* the application product.
315-
* @throws Exception
316311
*/
317312
public void sendHIARequest(User user, Product product) throws Exception {
318313
String userId = user.getUserId();
319314
logger.info(messages.getString("hia.request.send", userId));
320-
if (user.isInitializedHIA()) {
321-
logger
322-
.info(messages.getString("user.already.hia.initialized", userId));
323-
return;
324-
}
315+
// if (user.isInitializedHIA()) {
316+
// logger
317+
// .info(messages.getString("user.already.hia.initialized", userId));
318+
// return;
319+
// }
325320
EbicsSession session = createSession(user, product);
326321
KeyManagement keyManager = new KeyManagement(session);
327322
configuration.getTraceManager().setTraceDirectory(
@@ -433,7 +428,7 @@ public void fetchFile(File file, User user, Product product, EbicsOrderType orde
433428
// don't log this exception as an error, caller can decide how to handle
434429
throw e;
435430
} catch (Exception e) {
436-
logger.error(messages.getString("download.file.error"), e);
431+
logger.error("{} {}", messages.getString("download.file.error"), e.getMessage(), e);
437432
throw e;
438433
}
439434
}
@@ -538,7 +533,7 @@ public static EbicsClient createEbicsClient(File rootDir, File configFile) throw
538533

539534
final Locale locale = new Locale(language, country);
540535

541-
DefaultConfiguration configuration = new DefaultConfiguration(rootDir.getAbsolutePath(),
536+
DefaultConfiguration configuration = new DefaultConfiguration(rootDir,
542537
properties.properties) {
543538

544539
@Override
@@ -653,7 +648,7 @@ public static void main(String[] args) throws Exception {
653648
String outputFileValue = cmd.getOptionValue("o");
654649
String inputFileValue = cmd.getOptionValue("i");
655650

656-
List<? extends EbicsOrderType> fetchFileOrders = Arrays.asList(OrderType.STA, OrderType.VMK,
651+
var fetchFileOrders = List.of(OrderType.STA, OrderType.VMK,
657652
OrderType.C52, OrderType.C53, OrderType.C54,
658653
OrderType.ZDF, OrderType.ZB6, OrderType.PTK, OrderType.HAC, OrderType.Z01);
659654

@@ -665,7 +660,7 @@ public static void main(String[] args) throws Exception {
665660
}
666661
}
667662

668-
List<? extends EbicsOrderType> sendFileOrders = Arrays.asList(OrderType.XKD, OrderType.FUL, OrderType.XCT,
663+
var sendFileOrders = List.of(OrderType.XKD, OrderType.FUL, OrderType.XCT,
669664
OrderType.XE2, OrderType.CCT);
670665
for (EbicsOrderType type : sendFileOrders) {
671666
if (hasOption(cmd, type)) {

0 commit comments

Comments
 (0)