1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 */
17
18package java.security.cert;
19
20import java.util.Set;
21
22/**
23 * The interface specifying an X.509 Certificate or CRL extension.
24 */
25public interface X509Extension {
26
27    /**
28     * Returns the set of OIDs of the extension(s) marked as CRITICAL, that this
29     * implementation manages.
30     *
31     * @return the set of extension OIDs marked as CRITIAL, an empty set if none
32     *         are marked as CRITICAL, or {@code null} if no extensions are
33     *         present.
34     */
35    public Set<String> getCriticalExtensionOIDs();
36
37    /**
38     * Returns the extension value as DER-encoded OCTET string for the specified
39     * OID.
40     *
41     * @param oid
42     *            the object identifier to get the extension value for.
43     * @return the extension value as DER-encoded OCTET string, or {@code null}
44     *         if no extension for the specified OID can be found.
45     */
46    public byte[] getExtensionValue(String oid);
47
48    /**
49     * Returns the set of OIDs of the extension(s) marked as NON-CRITICAL, that
50     * this implementation manages.
51     *
52     * @return the set of extension OIDs marked as NON-CRITIAL, an empty set if
53     *         none are marked as NON-.CRITICAL, or {@code null} if no
54     *         extensions are present.
55     */
56    public Set<String> getNonCriticalExtensionOIDs();
57
58    /**
59     * Returns whether this instance has an extension marked as CRITICAL that it
60     * cannot support.
61     *
62     * @return {@code true} if an unsupported CRITICAL extension is present,
63     *         {@code false} otherwise.
64     */
65    public boolean hasUnsupportedCriticalExtension();
66}
67