src/java.base/share/classes/sun/security/x509/OCSPNoCheckExtension.java
author igerasim
Tue, 02 Oct 2018 10:19:07 -0700
changeset 51986 c1db377f6300
parent 47216 71c04702a3d5
permissions -rw-r--r--
8200381: Typos in javadoc - missing verb "be" and alike Reviewed-by: lancea, darcy, wetmore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2281
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
     1
/*
51986
c1db377f6300 8200381: Typos in javadoc - missing verb "be" and alike
igerasim
parents: 47216
diff changeset
     2
 * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
2281
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
     4
 *
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
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: 2281
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2281
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2281
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2281
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    10
 *
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    15
 * accompanied this code).
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    16
 *
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2281
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2281
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2281
diff changeset
    23
 * questions.
2281
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    24
 */
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    25
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    26
package sun.security.x509;
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    27
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    28
import java.io.IOException;
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    29
import java.io.OutputStream;
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    30
import java.util.Enumeration;
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    31
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    32
import sun.security.util.*;
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    33
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    34
/**
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    35
 * Represent the OCSP NoCheck Extension from RFC2560.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    36
 * <p>
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    37
 * A CA may specify that an OCSP client can trust a responder for the
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    38
 * lifetime of the responder's certificate. The CA does so by including
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    39
 * the extension id-pkix-ocsp-nocheck. This SHOULD be a non-critical
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    40
 * extension. The value of the extension should be NULL. CAs issuing
51986
c1db377f6300 8200381: Typos in javadoc - missing verb "be" and alike
igerasim
parents: 47216
diff changeset
    41
 * such a certificate should realize that a compromise of the
c1db377f6300 8200381: Typos in javadoc - missing verb "be" and alike
igerasim
parents: 47216
diff changeset
    42
 * responder's key is as serious as the compromise of a CA key used to
2281
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    43
 * sign CRLs, at least for the validity period of this certificate. CA's
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    44
 * may choose to issue this type of certificate with a very short
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    45
 * lifetime and renew it frequently.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    46
 * <pre>
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    47
 * id-pkix-ocsp-nocheck OBJECT IDENTIFIER ::= { id-pkix-ocsp 5 }
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    48
 * </pre>
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    49
 *
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    50
 * @author Xuelei Fan
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    51
 * @see Extension
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    52
 * @see CertAttrSet
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    53
 */
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    54
public class OCSPNoCheckExtension extends Extension
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    55
    implements CertAttrSet<String> {
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    56
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    57
    /**
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    58
     * Identifier for this attribute, to be used with the
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    59
     * get, set, delete methods of Certificate, x509 type.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    60
     */
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    61
    public static final String IDENT =
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    62
                         "x509.info.extensions.OCSPNoCheck";
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    63
    /**
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    64
     * Attribute names.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    65
     */
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    66
    public static final String NAME = "OCSPNoCheck";
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    67
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    68
    /**
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    69
     * Create a OCSPNoCheckExtension
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    70
     */
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    71
    public OCSPNoCheckExtension() throws IOException {
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    72
        this.extensionId = PKIXExtensions.OCSPNoCheck_Id;
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    73
        this.critical = false;
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    74
        this.extensionValue = new byte[0];
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    75
    }
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    76
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    77
    /**
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    78
     * Create the extension from the passed DER encoded value.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    79
     *
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    80
     * @param critical true if the extension is to be treated as critical.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    81
     * @param value an array of DER encoded bytes of the actual value.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    82
     * @exception IOException on error.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    83
     */
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    84
    public OCSPNoCheckExtension(Boolean critical, Object value)
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    85
        throws IOException {
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    86
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    87
        this.extensionId = PKIXExtensions.OCSPNoCheck_Id;
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    88
        this.critical = critical.booleanValue();
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    89
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    90
        // the value should be null, just ignore it here.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    91
        this.extensionValue = new byte[0];
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    92
    }
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    93
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    94
    /**
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    95
     * Set the attribute value.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    96
     */
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    97
    public void set(String name, Object obj) throws IOException {
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    98
        throw new IOException("No attribute is allowed by " +
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
    99
                        "CertAttrSet:OCSPNoCheckExtension.");
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   100
    }
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   101
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   102
    /**
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   103
     * Get the attribute value.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   104
     */
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   105
    public Object get(String name) throws IOException {
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   106
        throw new IOException("No attribute is allowed by " +
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   107
                        "CertAttrSet:OCSPNoCheckExtension.");
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   108
    }
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   109
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   110
    /**
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   111
     * Delete the attribute value.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   112
     */
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   113
    public void delete(String name) throws IOException {
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   114
        throw new IOException("No attribute is allowed by " +
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   115
                        "CertAttrSet:OCSPNoCheckExtension.");
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   116
    }
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   117
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   118
    /**
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   119
     * Return an enumeration of names of attributes existing within this
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   120
     * attribute.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   121
     */
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   122
    public Enumeration<String> getElements() {
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   123
        return (new AttributeNameEnumeration()).elements();
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   124
    }
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   125
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   126
    /**
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   127
     * Return the name of this attribute.
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   128
     */
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   129
    public String getName() {
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   130
        return NAME;
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   131
    }
34fd38495efa 6798714: OCSPResponse class has to check the validity of signing certificate for OCSP response
xuelei
parents:
diff changeset
   132
}