APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.x509

public Class DNSName

extends Object
implements GeneralNameInterface
Class Inheritance
All Implemented Interfaces
sun.security.x509.GeneralNameInterface, sun.security.util.DerEncoder
Imports
java.io.IOException, java.util.Locale, sun.security.util.*

This class implements the DNSName as required by the GeneralNames ASN.1 object.

[RFC5280] When the subjectAltName extension contains a domain name system label, the domain name MUST be stored in the dNSName (an IA5String). The name MUST be in the "preferred name syntax", as specified by Section 3.5 of [RFC1034] and as modified by Section 2.1 of [RFC1123]. Note that while uppercase and lowercase letters are allowed in domain names, no significance is attached to the case. In addition, while the string " " is a legal domain name, subjectAltName extensions with a dNSName of " " MUST NOT be used. Finally, the use of the DNS representation for Internet mail addresses (subscriber.example.com instead of [email protected]) MUST NOT be used; such identities are to be encoded as rfc822Name.

Authors
Amit Kapoor, Hemma Prafullchandra

Field Summary

Modifier and TypeField and Description
private static final String
private static final HostnameChecker
private final String

Constructor Summary

AccessConstructor and Description
public
DNSName(DerValue
the encoded DER DNSName.
derValue
)

Create the DNSName object from the passed encoded Der value.

public
DNSName(String
the DNSName.
name
,
boolean
the flag for wildcard checking.
allowWildcard
)

Create the DNSName object with the specified name.

public
DNSName(String
the DNSName.
name
)

Create the DNSName object with the specified name.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

constraint type above
constrains
(GeneralNameInterface
to be checked for being constrained
inputName
,
boolean
whether to match a wildcard in inputName
matchWildcard
)

Return type of constraint inputName places on this name:

  • NAME_DIFF_TYPE = -1: input name is different type from name (i.e. does not constrain).
  • NAME_MATCH = 0: input name matches name.
  • NAME_NARROWS = 1: input name narrows name (is lower in the naming subtree)
  • NAME_WIDENS = 2: input name widens name (is higher in the naming subtree)
  • NAME_SAME_TYPE = 3: input name does not match or narrow name, but is same type.
public int
constrains(GeneralNameInterface inputName)

Implements sun.security.x509.GeneralNameInterface.constrains.

Return type of constraint inputName places on this name:

  • NAME_DIFF_TYPE = -1: input name is different type from name (i.e. does not constrain).
  • NAME_MATCH = 0: input name matches name.
  • NAME_NARROWS = 1: input name narrows name (is lower in the naming subtree)
  • NAME_WIDENS = 2: input name widens name (is higher in the naming subtree)
  • NAME_SAME_TYPE = 3: input name does not match or narrow name, but is same type.
public void
encode(DerOutputStream
the DER stream to encode the DNSName to.
out
)

Implements sun.security.util.DerEncoder.encode.

Encode the DNSName into the DerOutputStream.

public boolean

Returns:

true iff the names are equivalent according to RFC5280.
equals
(Object obj)

Overrides java.lang.Object.equals.

Compares this name with another, for equality.

public String
getName()

Return the actual name value of the GeneralName.

public int
getType()

Implements sun.security.x509.GeneralNameInterface.getType.

Return the type of the GeneralName.

public int

Returns:

the hash code value for this object
hashCode
()

Overrides java.lang.Object.hashCode.

Returns the hash code value for this object.

public int

Returns:

distance of name from root
subtreeDepth
()

Implements sun.security.x509.GeneralNameInterface.subtreeDepth.

Return subtree depth of this name for purposes of determining NameConstraints minimum and maximum bounds and for calculating path lengths in name subtrees.

public String
toString()

Overrides java.lang.Object.toString.

Convert the name into user readable string.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

DNS_ALLOWEDback to summary
private static final String DNS_ALLOWED
HOSTNAME_CHECKERback to summary
private static final HostnameChecker HOSTNAME_CHECKER
nameback to summary
private final String name

Constructor Detail

DNSNameback to summary
public DNSName(DerValue derValue) throws IOException

Create the DNSName object from the passed encoded Der value.

Parameters
derValue:DerValue

the encoded DER DNSName.

Exceptions
IOException:
on error.
DNSNameback to summary
public DNSName(String name, boolean allowWildcard) throws IOException

Create the DNSName object with the specified name.

Parameters
name:String

the DNSName.

allowWildcard:boolean

the flag for wildcard checking.

Exceptions
IOException:
if the name is not a valid DNSName
DNSNameback to summary
public DNSName(String name) throws IOException

Create the DNSName object with the specified name.

Parameters
name:String

the DNSName.

Exceptions
IOException:
if the name is not a valid DNSName

Method Detail

constrainsback to summary
public int constrains(GeneralNameInterface inputName, boolean matchWildcard) throws UnsupportedOperationException

Return type of constraint inputName places on this name:

  • NAME_DIFF_TYPE = -1: input name is different type from name (i.e. does not constrain).
  • NAME_MATCH = 0: input name matches name.
  • NAME_NARROWS = 1: input name narrows name (is lower in the naming subtree)
  • NAME_WIDENS = 2: input name widens name (is higher in the naming subtree)
  • NAME_SAME_TYPE = 3: input name does not match or narrow name, but is same type.
. These results are used in checking NameConstraints during certification path verification.

RFC5280: For DNS names, restrictions MUST use the DNSName syntax in Section 4.2.1.6. Any DNS name that can be constructed by simply adding zero or more labels to the left-hand side of the name satisfies the name constraint. For example, www.host.example.com would satisfy the constraint but host1.example.com would not.

RFC6125: Match wildcard pattern in the input name being constrained, any wildcard in this name will be matched as a literal character.

RFC1034: By convention, domain names can be stored with arbitrary case, but domain name comparisons for all present domain functions are done in a case-insensitive manner, assuming an ASCII character set, and a high order zero bit.

Parameters
inputName:GeneralNameInterface

to be checked for being constrained

matchWildcard:boolean

whether to match a wildcard in inputName

Returns:int

constraint type above

Exceptions
UnsupportedOperationException:
if name is not exact match, but narrowing and widening are not supported for this name type.
constrainsback to summary
public int constrains(GeneralNameInterface inputName)

Implements sun.security.x509.GeneralNameInterface.constrains.

Doc from sun.security.x509.GeneralNameInterface.constrains.

Return type of constraint inputName places on this name:

  • NAME_DIFF_TYPE = -1: input name is different type from name (i.e. does not constrain).
  • NAME_MATCH = 0: input name matches name.
  • NAME_NARROWS = 1: input name narrows name (is lower in the naming subtree)
  • NAME_WIDENS = 2: input name widens name (is higher in the naming subtree)
  • NAME_SAME_TYPE = 3: input name does not match or narrow name, but is same type.
. These results are used in checking NameConstraints during certification path verification.
encodeback to summary
public void encode(DerOutputStream out)

Implements sun.security.util.DerEncoder.encode.

Encode the DNSName into the DerOutputStream.

Parameters
out:DerOutputStream

the DER stream to encode the DNSName to.

Annotations
@Override
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Compares this name with another, for equality.

Returns:boolean

true iff the names are equivalent according to RFC5280.

Annotations
@Override
getNameback to summary
public String getName()

Return the actual name value of the GeneralName.

getTypeback to summary
public int getType()

Implements sun.security.x509.GeneralNameInterface.getType.

Return the type of the GeneralName.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns the hash code value for this object.

Returns:int

the hash code value for this object

Annotations
@Override
subtreeDepthback to summary
public int subtreeDepth() throws UnsupportedOperationException

Implements sun.security.x509.GeneralNameInterface.subtreeDepth.

Return subtree depth of this name for purposes of determining NameConstraints minimum and maximum bounds and for calculating path lengths in name subtrees.

Returns:int

distance of name from root

Exceptions
UnsupportedOperationException:
if not supported for this name type
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Convert the name into user readable string.