test/jdk/sun/security/tools/jarsigner/DigestDontIgnoreCase.java
author weijun
Thu, 18 Jul 2019 08:53:06 +0800
changeset 57488 94691d8e746f
permissions -rw-r--r--
8217375: jarsigner breaks old signature with long lines in manifest Reviewed-by: jjiang, weijun Contributed-by: Philipp Kunz <philipp.kunz@paratix.ch>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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.IOException;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    25
import java.io.OutputStream;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    26
import java.nio.file.Files;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    27
import java.nio.file.Path;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    28
import java.util.Arrays;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    29
import java.util.Map;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    30
import java.util.jar.JarFile;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    31
import java.util.jar.JarOutputStream;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    32
import java.util.jar.JarEntry;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    33
import jdk.test.lib.SecurityTools;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    34
import org.testng.annotations.Test;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    35
import org.testng.annotations.BeforeClass;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    36
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    37
import static java.nio.charset.StandardCharsets.UTF_8;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    38
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
 * @test
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    41
 * @bug 8217375
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    42
 * @library /test/lib
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    43
 * @run testng DigestDontIgnoreCase
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    44
 * @summary Check that existing manifest digest entries are taken for valid
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    45
 * only if they match the actual digest value also taking upper and lower
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    46
 * case of the base64 encoded form of the digests into account.
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    47
 */
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    48
/*
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    49
 * <pre>mfDigest.equalsIgnoreCase(base64Digests[i])</pre>
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    50
 * previously in JarSigner.java on on line 985
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    51
 * @see jdk.security.jarsigner.JarSigner#updateDigests
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    52
 */
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    53
public class DigestDontIgnoreCase {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    54
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    55
    static final String KEYSTORE_FILENAME = "test.jks";
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    56
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    57
    static final String DUMMY_FILE1 = "dummy1.txt";
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    58
    static final byte[] DUMMY_CONTENTS1 = DUMMY_FILE1.getBytes(UTF_8);
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    59
    static final String DUMMY_FILE2 = "dummy2.txt";
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    60
    static final byte[] DUMMY_CONTENTS2 = DUMMY_FILE2.getBytes(UTF_8);
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    61
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    62
    byte[] goodSignedManifest;
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
    @BeforeClass
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    65
    public void prepareCertificate() throws Exception {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    66
        SecurityTools.keytool("-genkeypair -keyalg DSA -keystore "
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    67
                + KEYSTORE_FILENAME + " -storepass changeit -keypass changeit"
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    68
                + " -alias a -dname CN=X").shouldHaveExitValue(0);
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    69
    }
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    70
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    71
    void prepareJarFile(String filename, Map<String, byte[]> contents)
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    72
            throws IOException {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    73
        try (OutputStream out = Files.newOutputStream(Path.of(filename));
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    74
                JarOutputStream jos = new JarOutputStream(out)) {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    75
            for (Map.Entry<String, byte[]> entry : contents.entrySet()) {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    76
                JarEntry je = new JarEntry(entry.getKey());
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    77
                jos.putNextEntry(je);
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    78
                jos.write(entry.getValue());
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    79
                jos.closeEntry();
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
        }
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    82
    }
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    83
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    84
    @BeforeClass(dependsOnMethods = "prepareCertificate")
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    85
    public void prepareGoodSignedManifest() throws Exception {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    86
        String filename = "prepare.jar";
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    87
        prepareJarFile(filename, Map.of(DUMMY_FILE1, DUMMY_CONTENTS1));
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    88
        SecurityTools.jarsigner("-keystore " + KEYSTORE_FILENAME +
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    89
                " -storepass changeit -verbose -debug " + filename + " a")
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    90
                .shouldHaveExitValue(0);
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    91
        goodSignedManifest = Utils.readJarManifestBytes(filename);
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    92
        Utils.echoManifest(goodSignedManifest,
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    93
                "reference manifest with one file signed");
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    94
    }
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    95
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    96
    void testWithManifest(String filename, byte[] manifestBytes)
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    97
            throws Exception {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    98
        Utils.echoManifest(manifestBytes,
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
    99
                "going to test " + filename + " with manifest");
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   100
        prepareJarFile(filename, Map.of(
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   101
                JarFile.MANIFEST_NAME, manifestBytes,
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   102
                DUMMY_FILE1, DUMMY_CONTENTS1, // with digest already in manifest
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   103
                DUMMY_FILE2, DUMMY_CONTENTS2)); // causes manifest update
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   104
        Utils.echoManifest(Utils.readJarManifestBytes(filename),
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   105
                filename + " created with manifest");
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   106
        SecurityTools.jarsigner("-keystore " + KEYSTORE_FILENAME +
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   107
                " -storepass changeit -debug -verbose " + filename + " a")
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   108
                .shouldHaveExitValue(0);
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   109
        Utils.echoManifest(Utils.readJarManifestBytes(filename),
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   110
                filename + " signed resulting in manifest");
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   111
        SecurityTools.jarsigner("-verify -strict -keystore " +
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   112
                KEYSTORE_FILENAME + " -storepass changeit -debug -verbose " +
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   113
                filename + " a").shouldHaveExitValue(0);
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
    @Test
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   117
    public void verifyDigestGoodCase() throws Exception {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   118
        testWithManifest("good.jar", goodSignedManifest);
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
    @Test
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   122
    public void testDigestHeaderNameCase() throws Exception {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   123
        byte[] mfBadHeader = new String(goodSignedManifest, UTF_8).
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   124
                replace("SHA-256-Digest", "sha-256-dIGEST").getBytes(UTF_8);
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   125
        testWithManifest("switch-header-name-case.jar", mfBadHeader);
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   126
    }
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   127
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   128
    @Test
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   129
    public void testDigestWrongCase() throws Exception {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   130
        byte[] mfBadDigest = switchCase(goodSignedManifest, "Digest");
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   131
        testWithManifest("switch-digest-case.jar", mfBadDigest);
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   132
    }
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
    byte[] switchCase(byte[] manifest, String attrName) {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   135
        byte[] wrongCase = Arrays.copyOf(manifest, manifest.length);
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   136
        byte[] name = (attrName + ":").getBytes(UTF_8);
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   137
        int matched = 0; // number of bytes before position i matching attrName
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   138
        for (int i = 0; i < wrongCase.length; i++) {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   139
            if (wrongCase[i] == '\r' &&
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   140
                    (i == wrongCase.length - 1 || wrongCase[i + 1] == '\n')) {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   141
                continue;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   142
            } else if ((wrongCase[i] == '\r' || wrongCase[i] == '\n')
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   143
                    && (i == wrongCase.length - 1 || wrongCase[i + 1] != ' ')) {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   144
                matched = 0;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   145
            } else if (matched == name.length) {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   146
                wrongCase[i] = switchCase(wrongCase[i]);
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   147
            } else if (name[matched] == wrongCase[i]) {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   148
                matched++;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   149
            } else {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   150
                matched = 0;
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   151
            }
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   152
        }
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   153
        return wrongCase;
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
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   156
    byte switchCase(byte c) {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   157
        if (c >= 'A' && c <= 'Z') {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   158
            return (byte) ('a' + (c - 'A'));
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   159
        } else if (c >= 'a' && c <= 'z') {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   160
            return (byte) ('A' + (c - 'a'));
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   161
        } else {
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   162
            return c;
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
94691d8e746f 8217375: jarsigner breaks old signature with long lines in manifest
weijun
parents:
diff changeset
   166
}