Class GeneralName
public final class GeneralName extends Object
GeneralName::= CHOICE {
otherName [0] OtherName,
rfc822Name [1] IA5String,
dNSName [2] IA5String,
x400Address [3] ORAddress,
directoryName [4] Name,
ediPartyName [5] EDIPartyName,
uniformResourceIdentifier [6] IA5String,
iPAddress [7] OCTET STRING,
registeredID [8] OBJECT IDENTIFIER
}
OtherName::= SEQUENCE {
type-id OBJECT IDENTIFIER,
value [0] EXPLICIT ANY DEFINED BY type-id
}
EDIPartyName::= SEQUENCE {
nameAssigner [0] DirectoryString OPTIONAL,
partyName [1] DirectoryString
}
DirectoryString::= CHOICE {
teletexString TeletexString (SIZE (1..MAX)),
printableString PrintableString (SIZE (1..MAX)),
universalString UniversalString (SIZE (1..MAX)),
utf8String UTF8String (SIZE (1..MAX)),
bmpString BMPString (SIZE (1..MAX))
}
This class doesn't support masked addresses like "10.9.8.0/255.255.255.0". These are only necessary for NameConstraints, which are not exposed in the Java certificate API.
- See Also:
NameConstraints,GeneralSubtree
-
Field Summary
Fields Modifier and Type Field Description static ASN1ChoiceASN1static intDIR_NAMEstatic intDNS_NAMEstatic intEDIP_NAMEstatic intIP_ADDRstatic intOTHER_NAMEThe values of the tags of fieldsstatic intREG_IDstatic intRFC822_NAMEstatic intUR_IDstatic intX400_ADDR -
Constructor Summary
Constructors Constructor Description GeneralName(byte[] name)Constructor for type [7] iPAddress.GeneralName(int tag, byte[] name)Constructs an object representing the value of GeneralName.GeneralName(int tag, String name)Makes the GeneralName object from the tag type and corresponding well established string representation of the name value.GeneralName(Name name)GeneralName(EDIPartyName name)GeneralName(ORAddress name)GeneralName(OtherName name) -
Method Summary
Modifier and Type Method Description static voidcheckDNS(String dns)Checks the correctness of the string representation of DNS name as specified in RFC 1034 p.static voidcheckURI(String uri)Checks the correctness of the string representation of URI name.booleanequals(Object other)Compares this instance with the specified object and indicates if they are equal.List<Object>getAsList()Gets a list representation of this GeneralName object.byte[]getEncoded()Returns ASN.1 encoded form of this X.509 GeneralName value.byte[]getEncodedName()ObjectgetName()intgetTag()Returns the tag of the name in the structureinthashCode()Returns an integer hash code for this object.static StringipBytesToStr(byte[] ip)Returns the string form of the given IP address.static byte[]ipStrToBytes(String ip)Returns the bytes of the given IP address or masked IP address.booleanisAcceptable(GeneralName gname)Checks if the other general name is acceptable by this object.static int[]oidStrToInts(String oid)Converts OID into array of ints.StringtoString()Returns a string containing a concise, human-readable description of this object.
-
Field Details
-
OTHER_NAME
public static final int OTHER_NAMEThe values of the tags of fields- See Also:
- Constant Field Values
-
RFC822_NAME
public static final int RFC822_NAME- See Also:
- Constant Field Values
-
DNS_NAME
public static final int DNS_NAME- See Also:
- Constant Field Values
-
X400_ADDR
public static final int X400_ADDR- See Also:
- Constant Field Values
-
DIR_NAME
public static final int DIR_NAME- See Also:
- Constant Field Values
-
EDIP_NAME
public static final int EDIP_NAME- See Also:
- Constant Field Values
-
UR_ID
public static final int UR_ID- See Also:
- Constant Field Values
-
IP_ADDR
public static final int IP_ADDR- See Also:
- Constant Field Values
-
REG_ID
public static final int REG_ID- See Also:
- Constant Field Values
-
ASN1
-
-
Constructor Details
-
GeneralName
Makes the GeneralName object from the tag type and corresponding well established string representation of the name value. The String representation of [7] iPAddress is such as: For IP v4, as specified in RFC 791, the address must contain exactly 4 byte component. For IP v6, as specified in RFC 1883, the address must contain exactly 16 byte component. If GeneralName structure is used as a part of Name Constraints extension, to represent an address range the number of address component is doubled (to 8 and 32 bytes respectively). Note that the names: [0] otherName, [3] x400Address, [5] ediPartyName have no the string representation, so exception will be thrown. To make the GeneralName object with such names use another constructor.- Parameters:
tag- is an integer which value corresponds to the name type.name- is a name value corresponding to the tag.- Throws:
IOException
-
GeneralName
-
GeneralName
-
GeneralName
-
GeneralName
-
GeneralName
Constructor for type [7] iPAddress. name is an array of bytes such as: For IP v4, as specified in RFC 791, the address must contain exactly 4 byte component. For IP v6, as specified in RFC 1883, the address must contain exactly 16 byte component. If GeneralName structure is used as a part of Name Constraints extension, to represent an address range the number of address component is doubled (to 8 and 32 bytes respectively).- Throws:
IllegalArgumentException
-
GeneralName
Constructs an object representing the value of GeneralName.- Parameters:
tag- is an integer which value corresponds to the name type (0-8),name- is a DER encoded for of the name value- Throws:
IOException
-
-
Method Details
-
getTag
public int getTag()Returns the tag of the name in the structure -
getName
- Returns:
- the value of the name. The class of name object depends on the tag as follows: [0] otherName - OtherName object, [1] rfc822Name - String object, [2] dNSName - String object, [3] x400Address - ORAddress object, [4] directoryName - instance of Name object, [5] ediPartyName - EDIPartyName object, [6] uniformResourceIdentifier - String object, [7] iPAddress - array of bytes such as: For IP v4, as specified in RFC 791, the address must contain exactly 4 byte component. For IP v6, as specified in RFC 1883, the address must contain exactly 16 byte component. If GeneralName structure is used as a part of Name Constraints extension, to represent an address range the number of address component is doubled (to 8 and 32 bytes respectively). [8] registeredID - String.
-
equals
Description copied from class:ObjectCompares this instance with the specified object and indicates if they are equal. In order to be equal,omust represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.The default implementation returns
trueonly ifthis == o. See Writing a correctequalsmethod if you intend implementing your ownequalsmethod.The general contract for the
equalsandObject.hashCode()methods is that ifequalsreturnstruefor any two objects, thenhashCode()must return the same value for these objects. This means that subclasses ofObjectusually override either both methods or neither of them.- Overrides:
equalsin classObject- Parameters:
other- the object to compare this instance with.- Returns:
trueif the specified object is equal to thisObject;falseotherwise.- See Also:
Object.hashCode()
-
hashCode
public int hashCode()Description copied from class:ObjectReturns an integer hash code for this object. By contract, any two objects for whichObject.equals(java.lang.Object)returnstruemust return the same hash code value. This means that subclasses ofObjectusually override both methods or neither method.Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCodemethod if you intend implementing your ownhashCodemethod.- Overrides:
hashCodein classObject- Returns:
- this object's hash code.
- See Also:
Object.equals(java.lang.Object)
-
isAcceptable
Checks if the other general name is acceptable by this object. The name is acceptable if it has the same type name and its name value is equal to name value of this object. Also the name is acceptable if this general name object is a part of name constraints and the specified name is satisfied the restriction provided by this object (for more detail see section 4.2.1.11 of rfc 3280). Note that for X400Address [3] check procedure is unclear so method just checks the equality of encoded forms. For otherName [0], ediPartyName [5], and registeredID [8] the check procedure if not defined by rfc 3280 and for names of these types this method also checks only for equality of encoded forms. -
getAsList
Gets a list representation of this GeneralName object. The first entry of the list is an Integer object representing the type of mane (0-8), and the second entry is a value of the name: string or ASN.1 DER encoded form depending on the type as follows: rfc822Name, dNSName, uniformResourceIdentifier names are returned as Strings, using the string formats for those types (rfc 3280) IP v4 address names are returned using dotted quad notation. IP v6 address names are returned in the form "p1:p2:...:p8", where p1-p8 are hexadecimal values representing the eight 16-bit pieces of the address. registeredID name are returned as Strings represented as a series of nonnegative integers separated by periods. And directory names (distinguished names) are returned in RFC 2253 string format. otherName, X400Address, ediPartyName returned as byte arrays containing the ASN.1 DER encoded form of the name. -
toString
Description copied from class:ObjectReturns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toStringmethod if you intend implementing your owntoStringmethod. -
getEncoded
public byte[] getEncoded()Returns ASN.1 encoded form of this X.509 GeneralName value. -
getEncodedName
public byte[] getEncodedName()- Returns:
- the encoded value of the name without the tag associated with the name in the GeneralName structure
- Throws:
IOException
-
checkDNS
Checks the correctness of the string representation of DNS name as specified in RFC 1034 p. 10 and RFC 1123 section 2.1.This permits a wildcard character '*' anywhere in the name; it is up to the application to check which wildcards are permitted. See RFC 6125 for recommended wildcard matching rules.
- Throws:
IOException
-
checkURI
Checks the correctness of the string representation of URI name. The correctness is checked as pointed out in RFC 3280 p. 34.- Throws:
IOException
-
oidStrToInts
Converts OID into array of ints.- Throws:
IOException
-
ipStrToBytes
Returns the bytes of the given IP address or masked IP address.- Throws:
IOException
-
ipBytesToStr
Returns the string form of the given IP address. If the address is not 4 octets for IPv4 or 16 octets for IPv6, an IllegalArgumentException will be thrown.
-