public class NameConstraintsExtension extends Extension implements java.lang.Cloneable
The name constraints extension provides permitted and excluded subtrees that place restrictions on names that may be included within a certificate issued by a given CA. Restrictions may apply to the subject distinguished name or subject alternative names. Any name matching a restriction in the excluded subtrees field is invalid regardless of information appearing in the permitted subtrees.
The ASN.1 syntax for this is:
NameConstraints ::= SEQUENCE {
permittedSubtrees [0] GeneralSubtrees OPTIONAL,
excludedSubtrees [1] GeneralSubtrees OPTIONAL
}
GeneralSubtrees ::= SEQUENCE SIZE (1..MAX) OF GeneralSubtree
Extension| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
NAME |
critical, extensionId, extensionValue| Constructor and Description |
|---|
NameConstraintsExtension(java.lang.Boolean critical,
java.lang.Object value)
Create the extension from the passed DER encoded value.
|
NameConstraintsExtension(GeneralSubtrees permitted,
GeneralSubtrees excluded)
The default constructor for this class.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Clone all objects that may be modified during certificate validation.
|
void |
encode(com.tencent.kona.sun.security.util.DerOutputStream out)
Write the extension to the OutputStream.
|
GeneralSubtrees |
getExcludedSubtrees() |
java.lang.String |
getName()
Return the name of this extension.
|
GeneralSubtrees |
getPermittedSubtrees() |
void |
merge(NameConstraintsExtension newConstraints)
Merge additional name constraints with existing ones.
|
java.lang.String |
toString()
Return the printable string.
|
boolean |
verify(GeneralNameInterface name)
check whether a name conforms to these NameConstraints.
|
boolean |
verify(java.security.cert.X509Certificate cert)
check whether a certificate conforms to these NameConstraints.
|
encode, equals, getExtensionId, getExtensionValue, getId, getValue, hashCode, isCritical, newExtensionpublic static final java.lang.String NAME
public NameConstraintsExtension(GeneralSubtrees permitted, GeneralSubtrees excluded)
permitted - the permitted GeneralSubtrees (null for optional).excluded - the excluded GeneralSubtrees (null for optional).public NameConstraintsExtension(java.lang.Boolean critical,
java.lang.Object value)
throws java.io.IOException
critical - true if the extension is to be treated as critical.value - an array of DER encoded bytes of the actual value.java.lang.ClassCastException - if value is not an array of bytesjava.io.IOException - on error.public java.lang.String toString()
public void encode(com.tencent.kona.sun.security.util.DerOutputStream out)
public GeneralSubtrees getPermittedSubtrees()
public GeneralSubtrees getExcludedSubtrees()
public java.lang.String getName()
public void merge(NameConstraintsExtension newConstraints) throws java.io.IOException
IETF RFC 5280 specifies the processing of Name Constraints as follows:
(j) If permittedSubtrees is present in the certificate, set the constrained subtrees state variable to the intersection of its previous value and the value indicated in the extension field.
(k) If excludedSubtrees is present in the certificate, set the excluded subtrees state variable to the union of its previous value and the value indicated in the extension field.
newConstraints - additional NameConstraints to be appliedjava.io.IOException - on errorpublic boolean verify(java.security.cert.X509Certificate cert)
throws java.io.IOException
cert - X509Certificate to be verifiedjava.io.IOException - on errorpublic boolean verify(GeneralNameInterface name) throws java.io.IOException
name - GeneralNameInterface name to be verifiedjava.io.IOException - on errorpublic java.lang.Object clone()
clone in class java.lang.Object