author | weijun |
Thu, 18 Jul 2019 08:53:06 +0800 | |
changeset 57488 | 94691d8e746f |
permissions | -rw-r--r-- |
57488
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
1 |
/* |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
4 |
* |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
8 |
* |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
13 |
* accompanied this code). |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
14 |
* |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
18 |
* |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
21 |
* questions. |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
22 |
*/ |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
23 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
24 |
import java.io.ByteArrayInputStream; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
25 |
import java.io.ByteArrayOutputStream; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
26 |
import java.io.IOException; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
27 |
import java.security.MessageDigest; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
28 |
import java.util.ArrayList; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
29 |
import java.util.List; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
30 |
import java.util.stream.Collectors; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
31 |
import java.util.jar.Manifest; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
32 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
33 |
import sun.security.util.ManifestDigester; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
34 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
35 |
import org.testng.annotations.DataProvider; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
36 |
import org.testng.annotations.Factory; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
37 |
import org.testng.annotations.BeforeMethod; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
38 |
import org.testng.annotations.Test; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
39 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
40 |
import static java.nio.charset.StandardCharsets.UTF_8; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
41 |
import static org.testng.Assert.*; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
42 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
43 |
/** |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
44 |
* @test |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
45 |
* @bug 8217375 |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
46 |
* @modules java.base/sun.security.util |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
47 |
* @compile ../../tools/jarsigner/Utils.java |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
48 |
* @run testng ReproduceRaw |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
49 |
* @summary Verifies that {@link ManifestDigester} can reproduce parts of |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
50 |
* manifests in their binary form so that {@link JarSigner} can rely on |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
51 |
* {@link ManifestDigester.Entry#reproduceRaw} to write in a map view |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
52 |
* unmodified entries back also unmodified in their binary form. |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
53 |
* <p> |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
54 |
* See also<ul> |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
55 |
* <li>{@link PreserveRawManifestEntryAndDigest} with end to end tests |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
56 |
* with {@code jarsigner} tool and</li> |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
57 |
* <li>{@link FindHeaderEndVsManifestDigesterFindFirstSection} about |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
58 |
* identifying the binary portion of only main attributes and more extensive |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
59 |
* main attributes digesting tests while this one test here is more about |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
60 |
* reproducing individual sections and that they result in the same |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
61 |
* digests.</li> |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
62 |
* </ul> |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
63 |
*/ |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
64 |
public class ReproduceRaw { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
65 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
66 |
static final boolean VERBOSE = false; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
67 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
68 |
@DataProvider(name = "parameters") |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
69 |
public static Object[][] parameters() { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
70 |
List<Object[]> tests = new ArrayList<>(); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
71 |
for (String lineBreak : new String[] { "\n", "\r", "\r\n" }) { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
72 |
for (boolean oldStyle : new Boolean[] { false, true }) { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
73 |
for (boolean workaround : new Boolean[] { false, true }) { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
74 |
tests.add(new Object[] { lineBreak, oldStyle, workaround }); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
75 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
76 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
77 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
78 |
return tests.toArray(new Object[tests.size()][]); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
79 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
80 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
81 |
@Factory(dataProvider = "parameters") |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
82 |
public static Object[] createTests(String lineBreak, |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
83 |
boolean oldStyle, boolean digestWorkaround) { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
84 |
return new Object[]{ |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
85 |
new ReproduceRaw(lineBreak, oldStyle, digestWorkaround) |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
86 |
}; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
87 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
88 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
89 |
final String lineBreak; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
90 |
final boolean oldStyle; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
91 |
final boolean digestWorkaround; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
92 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
93 |
public ReproduceRaw(String lineBreak, |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
94 |
boolean oldStyle, boolean digestWorkaround) { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
95 |
this.lineBreak = lineBreak; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
96 |
this.oldStyle = oldStyle; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
97 |
this.digestWorkaround = digestWorkaround; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
98 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
99 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
100 |
@BeforeMethod |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
101 |
public void verbose() { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
102 |
System.out.println("lineBreak = " + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
103 |
Utils.escapeStringWithNumbers(lineBreak)); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
104 |
System.out.println("oldStyle = " + oldStyle); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
105 |
System.out.println("digestWorkaround = " + digestWorkaround); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
106 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
107 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
108 |
class EchoMessageDigest extends MessageDigest { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
109 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
110 |
ByteArrayOutputStream buf; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
111 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
112 |
EchoMessageDigest() { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
113 |
super("echo"); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
114 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
115 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
116 |
@Override |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
117 |
protected void engineReset() { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
118 |
buf = new ByteArrayOutputStream(); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
119 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
120 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
121 |
@Override |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
122 |
protected void engineUpdate(byte input) { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
123 |
buf.write(input); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
124 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
125 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
126 |
@Override |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
127 |
protected void engineUpdate(byte[] i, int o, int l) { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
128 |
buf.write(i, o, l); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
129 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
130 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
131 |
@Override protected byte[] engineDigest() { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
132 |
return buf.toByteArray(); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
133 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
134 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
135 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
136 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
137 |
/** |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
138 |
* similar to corresponding part of {@link JarSigner#sign0} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
139 |
* (stripped down to the code for reproducing the old manifest entry by |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
140 |
* entry which was too difficult to achieve using the real JarSigner code |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
141 |
* in the test here) |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
142 |
*/ |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
143 |
byte[] reproduceRawManifest(byte[] mfRawBytes, |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
144 |
boolean mainAttsProperlyDelimited, |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
145 |
boolean sectionProperlyDelimited) throws IOException { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
146 |
Manifest manifest = new Manifest(new ByteArrayInputStream(mfRawBytes)); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
147 |
ManifestDigester oldMd = new ManifestDigester(mfRawBytes); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
148 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
149 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
150 |
// main attributes |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
151 |
assertEquals(oldMd.getMainAttsEntry().isProperlyDelimited(), |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
152 |
mainAttsProperlyDelimited); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
153 |
oldMd.getMainAttsEntry().reproduceRaw(baos); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
154 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
155 |
// individual sections |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
156 |
for (String key : manifest.getEntries().keySet()) { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
157 |
assertEquals(oldMd.get(key).isProperlyDelimited(), |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
158 |
sectionProperlyDelimited); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
159 |
oldMd.get(key).reproduceRaw(baos); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
160 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
161 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
162 |
return baos.toByteArray(); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
163 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
164 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
165 |
static String regExscape(String expr) { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
166 |
for (int i = 0; i < expr.length(); i++) { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
167 |
if (expr.charAt(i) == '\r' || expr.charAt(i) == '\n') { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
168 |
expr = expr.substring(0, i) + "\\" + expr.substring(i++); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
169 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
170 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
171 |
return expr; |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
172 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
173 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
174 |
byte[] digest(byte[] manifest, String section) { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
175 |
MessageDigest digester = new EchoMessageDigest(); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
176 |
ManifestDigester md = new ManifestDigester(manifest); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
177 |
ManifestDigester.Entry entry = section == null ? |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
178 |
md.getMainAttsEntry(oldStyle) : md.get(section, oldStyle); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
179 |
return digestWorkaround ? |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
180 |
entry.digestWorkaround(digester) : |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
181 |
entry.digest(digester); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
182 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
183 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
184 |
void test(byte[] originalManifest, boolean mainAttsProperlyDelimited, |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
185 |
boolean sectionProperlyDelimited) throws Exception { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
186 |
Utils.echoManifest(originalManifest, "original manifest"); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
187 |
byte[] reproducedManifest = reproduceRawManifest(originalManifest, |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
188 |
mainAttsProperlyDelimited, sectionProperlyDelimited); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
189 |
Utils.echoManifest(reproducedManifest, "reproduced manifest"); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
190 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
191 |
// The reproduced manifest is not necessarily completely identical to |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
192 |
// the original if it contained superfluous blank lines. |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
193 |
// It's sufficient that the digests are equal and as an additional |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
194 |
// check, the reproduced manifest is here compared to the original |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
195 |
// without more than double line breaks. |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
196 |
if (!lineBreak.repeat(2).equals(new String(originalManifest, UTF_8))) { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
197 |
assertEquals( |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
198 |
new String(reproducedManifest, UTF_8), |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
199 |
new String(originalManifest, UTF_8).replaceAll( |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
200 |
regExscape(lineBreak) + "(" + regExscape(lineBreak) + ")+", |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
201 |
lineBreak.repeat(2))); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
202 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
203 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
204 |
// compare digests of reproduced manifest entries with digests of |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
205 |
// original manifest entries |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
206 |
assertEquals(digest(originalManifest, null), |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
207 |
digest(reproducedManifest, null)); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
208 |
for (String key : new Manifest(new ByteArrayInputStream( |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
209 |
originalManifest)).getEntries().keySet()) { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
210 |
assertEquals(digest(originalManifest, key), |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
211 |
digest(reproducedManifest, key)); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
212 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
213 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
214 |
// parse and compare original and reproduced manifests as manifests |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
215 |
assertEquals(new Manifest(new ByteArrayInputStream(originalManifest)), |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
216 |
new Manifest(new ByteArrayInputStream(reproducedManifest))); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
217 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
218 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
219 |
void test(byte[] originalManifest, boolean mainAttsProperlyDelimited) |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
220 |
throws Exception { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
221 |
// assert all individual sections properly delimited particularly useful |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
222 |
// when no individual sections present |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
223 |
test(originalManifest, mainAttsProperlyDelimited, true); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
224 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
225 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
226 |
@Test |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
227 |
public void testManifestStartsWithBlankLine() throws Exception { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
228 |
test(lineBreak.getBytes(UTF_8), true); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
229 |
test(lineBreak.repeat(2).getBytes(UTF_8), true); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
230 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
231 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
232 |
@Test |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
233 |
public void testEOFAndNoLineBreakAfterMainAttributes() throws Exception { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
234 |
assertThrows(RuntimeException.class, () -> |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
235 |
test("Manifest-Version: 1.0".getBytes(UTF_8), false) |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
236 |
); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
237 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
238 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
239 |
@Test |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
240 |
public void testEOFAndNoBlankLineAfterMainAttributes() throws Exception { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
241 |
test(("Manifest-Version: 1.0" + lineBreak).getBytes(UTF_8), false); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
242 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
243 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
244 |
@Test |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
245 |
public void testNormalMainAttributes() throws Exception { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
246 |
test(("Manifest-Version: 1.0" + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
247 |
lineBreak.repeat(2)).getBytes(UTF_8), true); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
248 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
249 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
250 |
@Test |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
251 |
public void testExtraLineBreakAfterMainAttributes() throws Exception { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
252 |
test(("Manifest-Version: 1.0" + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
253 |
lineBreak.repeat(3)).getBytes(UTF_8), true); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
254 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
255 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
256 |
@Test |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
257 |
public void testIndividualSectionNoLineBreak() throws Exception { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
258 |
assertNull(new ManifestDigester(( |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
259 |
"Manifest-Version: 1.0" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
260 |
lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
261 |
"Name: Section-Name" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
262 |
"Key: Value" |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
263 |
).getBytes(UTF_8)).get("Section-Name")); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
264 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
265 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
266 |
@Test |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
267 |
public void testIndividualSectionOneLineBreak() throws Exception { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
268 |
test(( |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
269 |
"Manifest-Version: 1.0" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
270 |
lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
271 |
"Name: Section-Name" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
272 |
"Key: Value" + lineBreak |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
273 |
).getBytes(UTF_8), true, false); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
274 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
275 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
276 |
@Test |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
277 |
public void testNormalIndividualSectionTwoLineBreak() throws Exception { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
278 |
test(( |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
279 |
"Manifest-Version: 1.0" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
280 |
lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
281 |
"Name: Section-Name" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
282 |
"Key: Value" + lineBreak.repeat(2) |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
283 |
).getBytes(UTF_8), true, true); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
284 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
285 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
286 |
@Test |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
287 |
public void testExtraLineBreakAfterIndividualSection() throws Exception { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
288 |
test(( |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
289 |
"Manifest-Version: 1.0" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
290 |
lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
291 |
"Name: Section-Name" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
292 |
"Key: Value" + lineBreak.repeat(3) |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
293 |
).getBytes(UTF_8), true, true); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
294 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
295 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
296 |
@Test |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
297 |
public void testIndividualSections() throws Exception { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
298 |
test(( |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
299 |
"Manifest-Version: 1.0" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
300 |
lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
301 |
"Name: Section-Name" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
302 |
"Key: Value" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
303 |
lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
304 |
"Name: Section-Name" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
305 |
"Key: Value" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
306 |
lineBreak |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
307 |
).getBytes(UTF_8), true, true); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
308 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
309 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
310 |
@Test |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
311 |
public void testExtraLineBreakBetweenIndividualSections() throws Exception { |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
312 |
test(( |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
313 |
"Manifest-Version: 1.0" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
314 |
lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
315 |
"Name: Section-Name" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
316 |
"Key: Value" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
317 |
lineBreak.repeat(2) + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
318 |
"Name: Section-Name" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
319 |
"Key: Value" + lineBreak + |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
320 |
lineBreak |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
321 |
).getBytes(UTF_8), true, true); |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
322 |
} |
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
323 |
|
94691d8e746f
8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff
changeset
|
324 |
} |