Extension.java revision 4782c2cdea4fc7d070c9dac560380cc45852babc
1/*
2 * Copyright 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package java.security.cert;
18
19import java.io.IOException;
20import java.io.OutputStream;
21
22/**
23 * The Extension part of an X.509 certificate (as specified in <a
24 * href="http://www.ietf.org/rfc/rfc3280.txt">RFC 3280 &mdash; Internet X.509
25 * Public Key Infrastructure: Certificate and Certificate Revocation List (CRL)
26 * Profile</p>):
27 *
28 * <pre>
29 *  Extension  ::=  SEQUENCE  {
30 *       extnID      OBJECT IDENTIFIER,
31 *       critical    BOOLEAN DEFAULT FALSE,
32 *       extnValue   OCTET STRING
33 *  }
34 * </pre>
35 *
36 * @since 1.7
37 * @hide
38 */
39public interface Extension {
40    /**
41     * Returns the OID (Object Identifier) for this extension encoded as a
42     * string (e.g., "2.5.29.15").
43     */
44    String getId();
45
46    /**
47     * Returns {@code true} if this extension is critical. If this is true and
48     * an implementation does not understand this extension, it must reject it.
49     * See RFC 3280 section 4.2 for more information.
50     */
51    boolean isCritical();
52
53    /**
54     * The DER-encoded value of this extension.
55     */
56    byte[] getValue();
57
58    /**
59     * Writes the DER-encoded extension to {@code out}.
60     *
61     * @throws IOException when there is an encoding error or error writing to
62     *             {@code out}
63     */
64    void encode(OutputStream out) throws IOException;
65}
66