951N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
951N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
951N/A *
951N/A * This code is free software; you can redistribute it and/or modify it
951N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
951N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
951N/A *
951N/A * This code is distributed in the hope that it will be useful, but WITHOUT
951N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
951N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
951N/A * version 2 for more details (a copy is included in the LICENSE file that
951N/A * accompanied this code).
951N/A *
951N/A * You should have received a copy of the GNU General Public License version
951N/A * 2 along with this work; if not, write to the Free Software Foundation,
951N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
951N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
951N/A */
951N/A
951N/Apackage sun.security.x509;
951N/A
951N/Aimport java.io.IOException;
951N/Aimport java.io.OutputStream;
951N/Aimport java.util.Enumeration;
951N/A
951N/Aimport sun.security.util.*;
951N/A
951N/A/**
951N/A * Represent the OCSP NoCheck Extension from RFC2560.
951N/A * <p>
951N/A * A CA may specify that an OCSP client can trust a responder for the
951N/A * lifetime of the responder's certificate. The CA does so by including
951N/A * the extension id-pkix-ocsp-nocheck. This SHOULD be a non-critical
951N/A * extension. The value of the extension should be NULL. CAs issuing
951N/A * such a certificate should realized that a compromise of the
951N/A * responder's key, is as serious as the compromise of a CA key used to
951N/A * sign CRLs, at least for the validity period of this certificate. CA's
951N/A * may choose to issue this type of certificate with a very short
951N/A * lifetime and renew it frequently.
951N/A * <pre>
951N/A * id-pkix-ocsp-nocheck OBJECT IDENTIFIER ::= { id-pkix-ocsp 5 }
951N/A * </pre>
951N/A *
951N/A * @author Xuelei Fan
951N/A * @see Extension
951N/A * @see CertAttrSet
951N/A */
951N/Apublic class OCSPNoCheckExtension extends Extension
951N/A implements CertAttrSet<String> {
951N/A
951N/A /**
951N/A * Identifier for this attribute, to be used with the
951N/A * get, set, delete methods of Certificate, x509 type.
951N/A */
951N/A public static final String IDENT =
951N/A "x509.info.extensions.OCSPNoCheck";
951N/A /**
951N/A * Attribute names.
951N/A */
951N/A public static final String NAME = "OCSPNoCheck";
951N/A
951N/A /**
951N/A * Create a OCSPNoCheckExtension
951N/A */
951N/A public OCSPNoCheckExtension() throws IOException {
951N/A this.extensionId = PKIXExtensions.OCSPNoCheck_Id;
951N/A this.critical = false;
951N/A this.extensionValue = new byte[0];
951N/A }
951N/A
951N/A /**
951N/A * Create the extension from the passed DER encoded value.
951N/A *
951N/A * @param critical true if the extension is to be treated as critical.
951N/A * @param value an array of DER encoded bytes of the actual value.
951N/A * @exception IOException on error.
951N/A */
951N/A public OCSPNoCheckExtension(Boolean critical, Object value)
951N/A throws IOException {
951N/A
951N/A this.extensionId = PKIXExtensions.OCSPNoCheck_Id;
951N/A this.critical = critical.booleanValue();
951N/A
951N/A // the value should be null, just ignore it here.
951N/A this.extensionValue = new byte[0];
951N/A }
951N/A
951N/A /**
951N/A * Set the attribute value.
951N/A */
951N/A public void set(String name, Object obj) throws IOException {
951N/A throw new IOException("No attribute is allowed by " +
951N/A "CertAttrSet:OCSPNoCheckExtension.");
951N/A }
951N/A
951N/A /**
951N/A * Get the attribute value.
951N/A */
951N/A public Object get(String name) throws IOException {
951N/A throw new IOException("No attribute is allowed by " +
951N/A "CertAttrSet:OCSPNoCheckExtension.");
951N/A }
951N/A
951N/A /**
951N/A * Delete the attribute value.
951N/A */
951N/A public void delete(String name) throws IOException {
951N/A throw new IOException("No attribute is allowed by " +
951N/A "CertAttrSet:OCSPNoCheckExtension.");
951N/A }
951N/A
951N/A /**
951N/A * Return an enumeration of names of attributes existing within this
951N/A * attribute.
951N/A */
951N/A public Enumeration<String> getElements() {
951N/A return (new AttributeNameEnumeration()).elements();
951N/A }
951N/A
951N/A /**
951N/A * Return the name of this attribute.
951N/A */
951N/A public String getName() {
951N/A return NAME;
951N/A }
951N/A}