src/java.base/share/classes/sun/security/util/ManifestEntryVerifier.java
author redestad
Wed, 22 May 2019 13:19:04 +0200
changeset 54980 e2c952c7ff20
parent 47216 71c04702a3d5
permissions -rw-r--r--
8224589: Improve startup behavior of SecurityProperties Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
45975
d61490c560bf 8169392: Additional jar validation steps
weijun
parents: 31538
diff changeset
     2
 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2436
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2436
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2436
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2436
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2436
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.security.util;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.CodeSigner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.jar.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
16020
b57c48f16179 8006182: cleanup to use java.util.Base64 in java security component, providers, and regression tests
msheppar
parents: 9365
diff changeset
    34
import java.util.Base64;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.security.jca.Providers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * This class is used to verify each entry in a jar file with its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * manifest value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
public class ManifestEntryVerifier {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private static final Debug debug = Debug.getInstance("jar");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
7539
d9cc884e12aa 6998860: Signed jar file verification is currently creating many extra new Sun providers.
mullan
parents: 7524
diff changeset
    47
    /**
d9cc884e12aa 6998860: Signed jar file verification is currently creating many extra new Sun providers.
mullan
parents: 7524
diff changeset
    48
     * Holder class to lazily load Sun provider. NOTE: if
d9cc884e12aa 6998860: Signed jar file verification is currently creating many extra new Sun providers.
mullan
parents: 7524
diff changeset
    49
     * Providers.getSunProvider returned a cached provider, we could avoid the
d9cc884e12aa 6998860: Signed jar file verification is currently creating many extra new Sun providers.
mullan
parents: 7524
diff changeset
    50
     * need for caching the provider with this holder class; we should try to
d9cc884e12aa 6998860: Signed jar file verification is currently creating many extra new Sun providers.
mullan
parents: 7524
diff changeset
    51
     * revisit this in JDK 8.
d9cc884e12aa 6998860: Signed jar file verification is currently creating many extra new Sun providers.
mullan
parents: 7524
diff changeset
    52
     */
d9cc884e12aa 6998860: Signed jar file verification is currently creating many extra new Sun providers.
mullan
parents: 7524
diff changeset
    53
    private static class SunProviderHolder {
d9cc884e12aa 6998860: Signed jar file verification is currently creating many extra new Sun providers.
mullan
parents: 7524
diff changeset
    54
        private static final Provider instance = Providers.getSunProvider();
d9cc884e12aa 6998860: Signed jar file verification is currently creating many extra new Sun providers.
mullan
parents: 7524
diff changeset
    55
    }
d9cc884e12aa 6998860: Signed jar file verification is currently creating many extra new Sun providers.
mullan
parents: 7524
diff changeset
    56
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /** the created digest objects */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    HashMap<String, MessageDigest> createdDigests;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    /** the digests in use for a given entry*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    ArrayList<MessageDigest> digests;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    /** the manifest hashes for the digests in use */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    ArrayList<byte[]> manifestHashes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private String name = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private Manifest man;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private boolean skip = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private JarEntry entry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private CodeSigner[] signers = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Create a new ManifestEntryVerifier object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public ManifestEntryVerifier(Manifest man)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    {
30033
b9c86c17164a 8078468: Update security libraries to use diamond with anonymous classes
darcy
parents: 25859
diff changeset
    80
        createdDigests = new HashMap<>(11);
b9c86c17164a 8078468: Update security libraries to use diamond with anonymous classes
darcy
parents: 25859
diff changeset
    81
        digests = new ArrayList<>();
b9c86c17164a 8078468: Update security libraries to use diamond with anonymous classes
darcy
parents: 25859
diff changeset
    82
        manifestHashes = new ArrayList<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        this.man = man;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Find the hashes in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * manifest for this entry, save them, and set the MessageDigest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * objects to calculate the hashes on the fly. If name is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * null it signifies that update/verify should ignore this entry.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public void setEntry(String name, JarEntry entry)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        digests.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        manifestHashes.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        this.entry = entry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        skip = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        signers = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        if (man == null || name == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        /* get the headers from the manifest for this entry */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        /* if there aren't any, we can't verify any digests for this entry */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
45975
d61490c560bf 8169392: Additional jar validation steps
weijun
parents: 31538
diff changeset
   110
        skip = false;
d61490c560bf 8169392: Additional jar validation steps
weijun
parents: 31538
diff changeset
   111
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        Attributes attr = man.getAttributes(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        if (attr == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            // ugh. we should be able to remove this at some point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            // there are broken jars floating around with ./name and /name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            // in the manifest, and "name" in the zip/jar file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            attr = man.getAttributes("./"+name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            if (attr == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                attr = man.getAttributes("/"+name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                if (attr == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        for (Map.Entry<Object,Object> se : attr.entrySet()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            String key = se.getKey().toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            if (key.toUpperCase(Locale.ENGLISH).endsWith("-DIGEST")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                // 7 is length of "-Digest"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                String algorithm = key.substring(0, key.length()-7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                MessageDigest digest = createdDigests.get(algorithm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                if (digest == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                        digest = MessageDigest.getInstance
7539
d9cc884e12aa 6998860: Signed jar file verification is currently creating many extra new Sun providers.
mullan
parents: 7524
diff changeset
   138
                                        (algorithm, SunProviderHolder.instance);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                        createdDigests.put(algorithm, digest);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                    } catch (NoSuchAlgorithmException nsae) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                        // ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                if (digest != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                    digest.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                    digests.add(digest);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                    manifestHashes.add(
16020
b57c48f16179 8006182: cleanup to use java.util.Base64 in java security component, providers, and regression tests
msheppar
parents: 9365
diff changeset
   149
                                Base64.getMimeDecoder().decode((String)se.getValue()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * update the digests for the digests we are interested in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    public void update(byte buffer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        if (skip) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        for (int i=0; i < digests.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            digests.get(i).update(buffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * update the digests for the digests we are interested in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     */
31538
0981099a3e54 8130022: Use Java-style array declarations consistently
igerasim
parents: 30033
diff changeset
   169
    public void update(byte[] buffer, int off, int len) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        if (skip) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        for (int i=0; i < digests.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            digests.get(i).update(buffer, off, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * get the JarEntry for this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    public JarEntry getEntry()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        return entry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * go through all the digests, calculating the final digest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * and comparing it to the one in the manifest. If this is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * the first time we have verified this object, remove its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * code signers from sigFileSigners and place in verifiedSigners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
9365
469cd39a25de 7040803: regression: bugster fail to start
igor
parents: 9248
diff changeset
   193
    public CodeSigner[] verify(Hashtable<String, CodeSigner[]> verifiedSigners,
469cd39a25de 7040803: regression: bugster fail to start
igor
parents: 9248
diff changeset
   194
                Hashtable<String, CodeSigner[]> sigFileSigners)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        throws JarException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    {
9001
4eb5b77d7425 7023056: NPE from sun.security.util.ManifestEntryVerifier.verify during Maven build
weijun
parents: 7539
diff changeset
   197
        if (skip) {
7524
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents: 5506
diff changeset
   198
            return null;
ec12e1e6fa20 7004035: signed jar with only META-INF/* inside is not verifiable
weijun
parents: 5506
diff changeset
   199
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
45975
d61490c560bf 8169392: Additional jar validation steps
weijun
parents: 31538
diff changeset
   201
        if (digests.isEmpty()) {
d61490c560bf 8169392: Additional jar validation steps
weijun
parents: 31538
diff changeset
   202
            throw new SecurityException("digest missing for " + name);
d61490c560bf 8169392: Additional jar validation steps
weijun
parents: 31538
diff changeset
   203
        }
d61490c560bf 8169392: Additional jar validation steps
weijun
parents: 31538
diff changeset
   204
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        if (signers != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            return signers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        for (int i=0; i < digests.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            MessageDigest digest  = digests.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            byte [] manHash = manifestHashes.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            byte [] theHash = digest.digest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            if (debug != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                debug.println("Manifest Entry: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                                   name + " digest=" + digest.getAlgorithm());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                debug.println("  manifest " + toHex(manHash));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                debug.println("  computed " + toHex(theHash));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                debug.println();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            if (!MessageDigest.isEqual(theHash, manHash))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                throw new SecurityException(digest.getAlgorithm()+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                                            " digest error for "+name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        // take it out of sigFileSigners and put it in verifiedSigners...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        signers = sigFileSigners.remove(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        if (signers != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            verifiedSigners.put(name, signers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        return signers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    // for the toHex function
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    private static final char[] hexc =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * convert a byte array to a hex string for debugging purposes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @param data the binary data to be converted to a hex string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @return an ASCII hex string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    static String toHex(byte[] data) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 23010
diff changeset
   246
        StringBuilder sb = new StringBuilder(data.length*2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        for (int i=0; i<data.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            sb.append(hexc[(data[i] >>4) & 0x0f]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            sb.append(hexc[data[i] & 0x0f]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        return sb.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
}