Skip to content

Commit 96d2d53

Browse files
author
updating-bot
committed
mirroring bot - 2025/11/01
1 parent f3cd52c commit 96d2d53

37 files changed

+1074
-888
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/**
2+
*
3+
* ====================================================================================================================================================
4+
* "AppWork Utilities" License
5+
* The "AppWork Utilities" will be called [The Product] from now on.
6+
* ====================================================================================================================================================
7+
* Copyright (c) 2009-2025, AppWork GmbH <e-mail@appwork.org>
8+
* Spalter Strasse 58
9+
* 91183 Abenberg
10+
* e-mail@appwork.org
11+
* Germany
12+
* === Preamble ===
13+
* This license establishes the terms under which the [The Product] Source Code & Binary files may be used, copied, modified, distributed, and/or redistributed.
14+
* The intent is that the AppWork GmbH is able to provide their utilities library for free to non-commercial projects whereas commercial usage is only permitted after obtaining a commercial license.
15+
* These terms apply to all files that have the [The Product] License header (IN the file), a <filename>.license or <filename>.info (like mylib.jar.info) file that contains a reference to this license.
16+
*
17+
* === 3rd Party Licences ===
18+
* Some parts of the [The Product] use or reference 3rd party libraries and classes. These parts may have different licensing conditions. Please check the *.license and *.info files of included libraries
19+
* to ensure that they are compatible to your use-case. Further more, some *.java have their own license. In this case, they have their license terms in the java file header.
20+
*
21+
* === Definition: Commercial Usage ===
22+
* If anybody or any organization is generating income (directly or indirectly) by using [The Product] or if there's any commercial interest or aspect in what you are doing, we consider this as a commercial usage.
23+
* If your use-case is neither strictly private nor strictly educational, it is commercial. If you are unsure whether your use-case is commercial or not, consider it as commercial or contact as.
24+
* === Dual Licensing ===
25+
* === Commercial Usage ===
26+
* If you want to use [The Product] in a commercial way (see definition above), you have to obtain a paid license from AppWork GmbH.
27+
* Contact AppWork for further details: e-mail@appwork.org
28+
* === Non-Commercial Usage ===
29+
* If there is no commercial usage (see definition above), you may use [The Product] under the terms of the
30+
* "GNU Affero General Public License" (http://www.gnu.org/licenses/agpl-3.0.en.html).
31+
*
32+
* If the AGPL does not fit your needs, please contact us. We'll find a solution.
33+
* ====================================================================================================================================================
34+
* ==================================================================================================================================================== */
35+
package org.appwork.exceptions;
36+
37+
import org.appwork.resources.IconRef;
38+
import org.appwork.utils.locale._AWU;
39+
import org.appwork.utils.swing.dialog.DialogIcon;
40+
41+
/**
42+
* @author thomas
43+
* @date 31.10.2025
44+
*
45+
*/
46+
public abstract class ErrorReporter {
47+
48+
private static ErrorReporter INSTANCE;
49+
50+
/**
51+
* @return the iNSTANCE
52+
*/
53+
public static ErrorReporter getInstance() {
54+
return INSTANCE;
55+
}
56+
57+
/**
58+
* @param iNSTANCE
59+
* the iNSTANCE to set
60+
*/
61+
public static void setInstance(ErrorReporter iNSTANCE) {
62+
INSTANCE = iNSTANCE;
63+
}
64+
65+
/**
66+
* @param exceptionDialog
67+
*/
68+
public abstract void report(Object context);
69+
70+
/**
71+
* @return
72+
*/
73+
public String getActionName() {
74+
return _AWU.T.errorreport_action_name();
75+
}
76+
77+
/**
78+
* @return
79+
*/
80+
public IconRef getActionIcon() {
81+
return DialogIcon.DIALOG_WARNING;
82+
}
83+
84+
}

svn_utils/src/org/appwork/io/streams/signature/HandleStreamSignatureInputStream.java

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.appwork.io.streams.signature;
22

3-
import java.io.DataInputStream;
43
import java.io.DataOutputStream;
54
import java.io.EOFException;
65
import java.io.IOException;
@@ -15,28 +14,23 @@
1514
import org.appwork.utils.IO;
1615

1716
public class HandleStreamSignatureInputStream extends InputStream {
18-
1917
private DigestInterface digester;
2018
private long remainingPayloadSize = 0;
2119
private long payloadBytesRead = 0;
22-
2320
private byte[] nonceBytes;
24-
2521
/**
2622
* Holds the calculated signature after reading a chunk
2723
*/
2824
private byte[] calculatedSignature;
2925
private long lastValidPayloadPosition;
3026
private final byte[] single;
3127
private HoldBackInputStream in;
32-
3328
private final int signatureLength;
3429
/**
3530
* is used to read the expected signature from the stream
3631
*/
3732
private final byte[] expectedSignature;
3833
private long streamVersion = -1;
39-
private DataInputStream dataIn;
4034
private boolean closed;
4135
private DataOutputStream digesterStream;
4236

@@ -57,23 +51,18 @@ public HandleStreamSignatureInputStream(final InputStream is, Mac mac, final byt
5751
* - works only if the MAc or MessageDigest supports cloneing
5852
*/
5953
public HandleStreamSignatureInputStream(final InputStream is, DigestInterface digester, final byte[] nonceBytes) {
60-
6154
single = new byte[1];
6255
signatureLength = digester.getLength();
63-
6456
// +1 to detect EOF if we read exactly the payload length
6557
in = new HoldBackInputStream(is, signatureLength, 1);
66-
dataIn = new DataInputStream(in);
6758
expectedSignature = new byte[signatureLength];
6859
this.digester = digester;
6960
digesterStream = new DataOutputStream(new DigesterOutputStream(digester));
7061
this.nonceBytes = nonceBytes;
71-
7262
}
7363

7464
protected void initChunkDigester(long chunkSize) throws IOException {
7565
StreamSignatureCreatingOutputStream.initChunkDigesterStatic(digesterStream, streamVersion, chunkSize, nonceBytes, calculatedSignature);
76-
7766
}
7867

7968
@Override
@@ -104,17 +93,15 @@ public long readVersionNumber() throws IOException {
10493
}
10594

10695
public synchronized void mark(int readlimit) {
107-
10896
}
10997

11098
/*
11199
* (non-Javadoc)
112-
*
100+
*
113101
* @see java.io.InputStream#markSupported()
114102
*/
115103
@Override
116104
public boolean markSupported() {
117-
118105
return false;
119106
}
120107

@@ -133,18 +120,14 @@ private final int internalRead(final byte[] b, final int off, final int len) thr
133120
if (streamVersion == 1) {
134121
// ok 08.10.2021
135122
} else {
136-
137123
throw new IOException("Unknown Streamversion");
138124
}
139125
}
140-
141126
if (remainingPayloadSize == 0) {
142127
// init next chunk
143128
remainingPayloadSize = readNextPayloadBlockSize();
144-
145129
initChunkDigester(remainingPayloadSize);
146130
}
147-
148131
final int toRead = (int) Math.min(remainingPayloadSize, len);
149132
int actuallyRead = in.read(b, off, toRead);
150133
if (actuallyRead >= 0) {
@@ -153,14 +136,11 @@ private final int internalRead(final byte[] b, final int off, final int len) thr
153136
digesterStream.write(b, off, actuallyRead);
154137
}
155138
if (in.getTail() != null) {
156-
157139
byte[] tail = in.getTail();
158140
if (len == 0) {
159-
160141
// the first time tail is set, len must be >0, else we would not have read anything
161142
throw new WTFException("not possible here");
162143
}
163-
164144
validateSignature(tail, true);
165145
// no return. it is possible to receive the tail, but return read bytes
166146
} else if (remainingPayloadSize == 0) {
@@ -172,7 +152,6 @@ private final int internalRead(final byte[] b, final int off, final int len) thr
172152
if (count < 0) {
173153
if (n == 0) {
174154
// end of stream. the current buffer is the tail
175-
176155
if (in.getTail() == null || in.getTail().length != expectedSignature.length) {
177156
throw new WTFException("Invalid Tail");
178157
}
@@ -187,11 +166,9 @@ private final int internalRead(final byte[] b, final int off, final int len) thr
187166
}
188167
}
189168
validateSignature(expectedSignature, tail);
190-
191169
if (!tail) {
192170
if (in.getTail() != null) {
193171
// we reached the EOF while reading the signature.
194-
195172
throw new EOFException("Unexpected End Of Stream");
196173
}
197174
}
@@ -207,10 +184,8 @@ public boolean isClosed() {
207184
}
208185

209186
protected void validateSignature(byte[] tail, boolean eof) throws SignatureMismatchException, StreamEndedUnexpectedException {
210-
211187
if (eof) {
212188
DigestInterface cloneBeforeEndSalt = null;
213-
214189
if (remainingPayloadSize == 0) {
215190
// we need the "incomplete stream" check only if remaining ==0. only if the stream got cut exactly after a block, we need to
216191
// check if the final signature failed, or is just not an end signature.
@@ -224,38 +199,31 @@ protected void validateSignature(byte[] tail, boolean eof) throws SignatureMisma
224199
// not supported
225200
// e.printStackTrace();
226201
}
227-
228202
}
229203
digester.update(StreamSignatureCreatingOutputStream.END_SIGNATURE_SALT);
230204
calculatedSignature = digester.doFinal();
231-
232205
if (!Arrays.equals(tail, calculatedSignature)) {
233206
if (cloneBeforeEndSalt != null && Arrays.equals(tail, cloneBeforeEndSalt.doFinal())) {
234207
// stream is broken end ended before the final block
235208
// all bytes so far are correct, but the stream ended before the final block was read
236209
this.lastValidPayloadPosition = payloadBytesRead;
237-
238210
throw new StreamEndedUnexpectedException();
239211
}
240212
throw new SignatureMismatchException();
241213
} else {
242214
this.lastValidPayloadPosition = payloadBytesRead;
243-
244215
}
245-
246216
} else {
247217
calculatedSignature = digester.doFinal();
248218
if (!Arrays.equals(tail, calculatedSignature)) {
249219
throw new SignatureMismatchException();
250220
} else {
251221
this.lastValidPayloadPosition = payloadBytesRead;
252-
253222
}
254223
}
255224
}
256225

257226
protected long readHeader() throws IOException {
258-
259227
return IO.readLongOptimized(in);
260228
}
261229

@@ -277,19 +245,18 @@ public long getPayloadBytesLoaded() {
277245

278246
/*
279247
* (non-Javadoc)
280-
*
248+
*
281249
* @see java.io.InputStream#close()
282250
*/
283251
@Override
284252
public void close() throws IOException {
285253
this.closed = true;
286254
in.close();
287-
288255
}
289256

290257
/*
291258
* (non-Javadoc)
292-
*
259+
*
293260
* @see java.io.InputStream#skip(long)
294261
*/
295262
@Override
@@ -307,7 +274,6 @@ public long skip(long n) throws IOException {
307274
}
308275
remaining -= ret;
309276
}
310-
311277
return n - remaining;
312278
}
313279

0 commit comments

Comments
 (0)