jdk/src/share/classes/sun/security/pkcs/SignerInfo.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 4152 bc36a9f01ac6
child 9248 44d129a2adfa
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4152
diff changeset
     2
 * Copyright (c) 1996, 2009, 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: 4152
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: 4152
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: 4152
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4152
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4152
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.pkcs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.OutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.math.BigInteger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.security.cert.X509Certificate;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.security.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.security.x509.AlgorithmId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.security.x509.X500Name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.security.x509.KeyUsageExtension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.security.x509.PKIXExtensions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.misc.HexDumpEncoder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * A SignerInfo, as defined in PKCS#7's signedData type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @author Benjamin Renaud
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
public class SignerInfo implements DerEncoder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    BigInteger version;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    X500Name issuerName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    BigInteger certificateSerialNumber;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    AlgorithmId digestAlgorithmId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    AlgorithmId digestEncryptionAlgorithmId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    byte[] encryptedDigest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    PKCS9Attributes authenticatedAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    PKCS9Attributes unauthenticatedAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    public SignerInfo(X500Name  issuerName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                      BigInteger serial,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
                      AlgorithmId digestAlgorithmId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
                      AlgorithmId digestEncryptionAlgorithmId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                      byte[] encryptedDigest) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        this.version = BigInteger.ONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        this.issuerName = issuerName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        this.certificateSerialNumber = serial;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        this.digestAlgorithmId = digestAlgorithmId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        this.digestEncryptionAlgorithmId = digestEncryptionAlgorithmId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        this.encryptedDigest = encryptedDigest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public SignerInfo(X500Name  issuerName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                      BigInteger serial,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                      AlgorithmId digestAlgorithmId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                      PKCS9Attributes authenticatedAttributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                      AlgorithmId digestEncryptionAlgorithmId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                      byte[] encryptedDigest,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                      PKCS9Attributes unauthenticatedAttributes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        this.version = BigInteger.ONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        this.issuerName = issuerName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        this.certificateSerialNumber = serial;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        this.digestAlgorithmId = digestAlgorithmId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        this.authenticatedAttributes = authenticatedAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        this.digestEncryptionAlgorithmId = digestEncryptionAlgorithmId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        this.encryptedDigest = encryptedDigest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        this.unauthenticatedAttributes = unauthenticatedAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * Parses a PKCS#7 signer info.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public SignerInfo(DerInputStream derin)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        throws IOException, ParsingException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        this(derin, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * Parses a PKCS#7 signer info.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * <p>This constructor is used only for backwards compatibility with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * PKCS#7 blocks that were generated using JDK1.1.x.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @param derin the ASN.1 encoding of the signer info.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @param oldStyle flag indicating whether or not the given signer info
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * is encoded according to JDK1.1.x.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    public SignerInfo(DerInputStream derin, boolean oldStyle)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        throws IOException, ParsingException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        // version
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        version = derin.getBigInteger();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        // issuerAndSerialNumber
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        DerValue[] issuerAndSerialNumber = derin.getSequence(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        byte[] issuerBytes = issuerAndSerialNumber[0].toByteArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        issuerName = new X500Name(new DerValue(DerValue.tag_Sequence,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                                               issuerBytes));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        certificateSerialNumber = issuerAndSerialNumber[1].getBigInteger();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        // digestAlgorithmId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        DerValue tmp = derin.getDerValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        digestAlgorithmId = AlgorithmId.parse(tmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        // authenticatedAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        if (oldStyle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            // In JDK1.1.x, the authenticatedAttributes are always present,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            // encoded as an empty Set (Set of length zero)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            derin.getSet(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            // check if set of auth attributes (implicit tag) is provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            // (auth attributes are OPTIONAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            if ((byte)(derin.peekByte()) == (byte)0xA0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                authenticatedAttributes = new PKCS9Attributes(derin);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        // digestEncryptionAlgorithmId - little RSA naming scheme -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        // signature == encryption...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        tmp = derin.getDerValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        digestEncryptionAlgorithmId = AlgorithmId.parse(tmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        // encryptedDigest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        encryptedDigest = derin.getOctetString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        // unauthenticatedAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        if (oldStyle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            // In JDK1.1.x, the unauthenticatedAttributes are always present,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            // encoded as an empty Set (Set of length zero)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            derin.getSet(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            // check if set of unauth attributes (implicit tag) is provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            // (unauth attributes are OPTIONAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            if (derin.available() != 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                && (byte)(derin.peekByte()) == (byte)0xA1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                unauthenticatedAttributes =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                    new PKCS9Attributes(derin, true);// ignore unsupported attrs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        // all done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        if (derin.available() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            throw new ParsingException("extra data at the end");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    public void encode(DerOutputStream out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        derEncode(out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * DER encode this object onto an output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * Implements the <code>DerEncoder</code> interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @param out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * the output stream on which to write the DER encoding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * @exception IOException on encoding error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    public void derEncode(OutputStream out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        DerOutputStream seq = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        seq.putInteger(version);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        DerOutputStream issuerAndSerialNumber = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        issuerName.encode(issuerAndSerialNumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        issuerAndSerialNumber.putInteger(certificateSerialNumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        seq.write(DerValue.tag_Sequence, issuerAndSerialNumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        digestAlgorithmId.encode(seq);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        // encode authenticated attributes if there are any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        if (authenticatedAttributes != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            authenticatedAttributes.encode((byte)0xA0, seq);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        digestEncryptionAlgorithmId.encode(seq);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        seq.putOctetString(encryptedDigest);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        // encode unauthenticated attributes if there are any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        if (unauthenticatedAttributes != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            unauthenticatedAttributes.encode((byte)0xA1, seq);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        DerOutputStream tmp = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        tmp.write(DerValue.tag_Sequence, seq);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        out.write(tmp.toByteArray());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * Returns the (user) certificate pertaining to this SignerInfo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    public X509Certificate getCertificate(PKCS7 block)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        return block.getCertificate(certificateSerialNumber, issuerName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * Returns the certificate chain pertaining to this SignerInfo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    public ArrayList<X509Certificate> getCertificateChain(PKCS7 block)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        X509Certificate userCert;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        userCert = block.getCertificate(certificateSerialNumber, issuerName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        if (userCert == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        ArrayList<X509Certificate> certList = new ArrayList<X509Certificate>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        certList.add(userCert);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        X509Certificate[] pkcsCerts = block.getCertificates();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        if (pkcsCerts == null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            || userCert.getSubjectDN().equals(userCert.getIssuerDN())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            return certList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        Principal issuer = userCert.getIssuerDN();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        int start = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        while (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            boolean match = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            int i = start;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            while (i < pkcsCerts.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                if (issuer.equals(pkcsCerts[i].getSubjectDN())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                    // next cert in chain found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                    certList.add(pkcsCerts[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                    // if selected cert is self-signed, we're done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                    // constructing the chain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                    if (pkcsCerts[i].getSubjectDN().equals(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                                            pkcsCerts[i].getIssuerDN())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                        start = pkcsCerts.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                        issuer = pkcsCerts[i].getIssuerDN();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                        X509Certificate tmpCert = pkcsCerts[start];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                        pkcsCerts[start] = pkcsCerts[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                        pkcsCerts[i] = tmpCert;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                        start++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                    match = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                    i++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            if (!match)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        return certList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    /* Returns null if verify fails, this signerInfo if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
       verify succeeds. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    SignerInfo verify(PKCS7 block, byte[] data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    throws NoSuchAlgorithmException, SignatureException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            ContentInfo content = block.getContentInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            if (data == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                data = content.getContentBytes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            String digestAlgname = getDigestAlgorithmId().getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            byte[] dataSigned;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            // if there are authenticate attributes, get the message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            // digest and compare it with the digest of data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            if (authenticatedAttributes == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                dataSigned = data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                // first, check content type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                ObjectIdentifier contentType = (ObjectIdentifier)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                       authenticatedAttributes.getAttributeValue(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                         PKCS9Attribute.CONTENT_TYPE_OID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                if (contentType == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                    !contentType.equals(content.contentType))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                    return null;  // contentType does not match, bad SignerInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                // now, check message digest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                byte[] messageDigest = (byte[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                    authenticatedAttributes.getAttributeValue(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                         PKCS9Attribute.MESSAGE_DIGEST_OID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                if (messageDigest == null) // fail if there is no message digest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                MessageDigest md = MessageDigest.getInstance(digestAlgname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                byte[] computedMessageDigest = md.digest(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                if (messageDigest.length != computedMessageDigest.length)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                for (int i = 0; i < messageDigest.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                    if (messageDigest[i] != computedMessageDigest[i])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                // message digest attribute matched
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                // digest of original data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                // the data actually signed is the DER encoding of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                // the authenticated attributes (tagged with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                // the "SET OF" tag, not 0xA0).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                dataSigned = authenticatedAttributes.getDerEncoding();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            // put together digest algorithm and encryption algorithm
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            // to form signing algorithm
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            String encryptionAlgname =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                getDigestEncryptionAlgorithmId().getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
4152
bc36a9f01ac6 6870812: enhance security tools to use ECC algorithms
weijun
parents: 2
diff changeset
   338
            // Workaround: sometimes the encryptionAlgname is actually
bc36a9f01ac6 6870812: enhance security tools to use ECC algorithms
weijun
parents: 2
diff changeset
   339
            // a signature name
bc36a9f01ac6 6870812: enhance security tools to use ECC algorithms
weijun
parents: 2
diff changeset
   340
            String tmp = AlgorithmId.getEncAlgFromSigAlg(encryptionAlgname);
bc36a9f01ac6 6870812: enhance security tools to use ECC algorithms
weijun
parents: 2
diff changeset
   341
            if (tmp != null) encryptionAlgname = tmp;
bc36a9f01ac6 6870812: enhance security tools to use ECC algorithms
weijun
parents: 2
diff changeset
   342
            String algname = AlgorithmId.makeSigAlg(
bc36a9f01ac6 6870812: enhance security tools to use ECC algorithms
weijun
parents: 2
diff changeset
   343
                    digestAlgname, encryptionAlgname);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            Signature sig = Signature.getInstance(algname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            X509Certificate cert = getCertificate(block);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            if (cert == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            if (cert.hasUnsupportedCriticalExtension()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                throw new SignatureException("Certificate has unsupported "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                                             + "critical extension(s)");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            // Make sure that if the usage of the key in the certificate is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            // restricted, it can be used for digital signatures.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            // XXX We may want to check for additional extensions in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            // future.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            boolean[] keyUsageBits = cert.getKeyUsage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            if (keyUsageBits != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                KeyUsageExtension keyUsage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                    // We don't care whether or not this extension was marked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                    // critical in the certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                    // We're interested only in its value (i.e., the bits set)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                    // and treat the extension as critical.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                    keyUsage = new KeyUsageExtension(keyUsageBits);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                    throw new SignatureException("Failed to parse keyUsage "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                                                 + "extension");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                boolean digSigAllowed = ((Boolean)keyUsage.get(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                        KeyUsageExtension.DIGITAL_SIGNATURE)).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                boolean nonRepuAllowed = ((Boolean)keyUsage.get(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                        KeyUsageExtension.NON_REPUDIATION)).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                if (!digSigAllowed && !nonRepuAllowed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                    throw new SignatureException("Key usage restricted: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                                                 + "cannot be used for "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                                                 + "digital signatures");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            PublicKey key = cert.getPublicKey();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            sig.initVerify(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            sig.update(dataSigned);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            if (sig.verify(encryptedDigest)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            throw new SignatureException("IO error verifying signature:\n" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                                         e.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        } catch (InvalidKeyException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            throw new SignatureException("InvalidKey: " + e.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    /* Verify the content of the pkcs7 block. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    SignerInfo verify(PKCS7 block)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    throws NoSuchAlgorithmException, SignatureException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        return verify(block, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    public BigInteger getVersion() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            return version;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    public X500Name getIssuerName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        return issuerName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    public BigInteger getCertificateSerialNumber() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        return certificateSerialNumber;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    public AlgorithmId getDigestAlgorithmId() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        return digestAlgorithmId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    public PKCS9Attributes getAuthenticatedAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        return authenticatedAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    public AlgorithmId getDigestEncryptionAlgorithmId() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        return digestEncryptionAlgorithmId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    public byte[] getEncryptedDigest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        return encryptedDigest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    public PKCS9Attributes getUnauthenticatedAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        return unauthenticatedAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        HexDumpEncoder hexDump = new HexDumpEncoder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        String out = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        out += "Signer Info for (issuer): " + issuerName + "\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        out += "\tversion: " + Debug.toHexString(version) + "\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        out += "\tcertificateSerialNumber: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
               Debug.toHexString(certificateSerialNumber) + "\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        out += "\tdigestAlgorithmId: " + digestAlgorithmId + "\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        if (authenticatedAttributes != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            out += "\tauthenticatedAttributes: " + authenticatedAttributes +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                   "\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        out += "\tdigestEncryptionAlgorithmId: " + digestEncryptionAlgorithmId +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            "\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        out += "\tencryptedDigest: " + "\n" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            hexDump.encodeBuffer(encryptedDigest) + "\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        if (unauthenticatedAttributes != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            out += "\tunauthenticatedAttributes: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                   unauthenticatedAttributes + "\n";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        return out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
}