Class IPAddressName
java.lang.Object
org.mozilla.jss.netscape.security.x509.IPAddressName
- All Implemented Interfaces:
Serializable
,GeneralNameInterface
This class implements the IPAddressName as required by the GeneralNames
ASN.1 object.
- Version:
- 1.2
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]
protected static final char
protected static final char
private static final long
Fields inherited from interface org.mozilla.jss.netscape.security.x509.GeneralNameInterface
NAME_ANY, NAME_DIRECTORY, NAME_DNS, NAME_EDI, NAME_IP, NAME_OID, NAME_RFC822, NAME_URI, NAME_X400
-
Constructor Summary
ConstructorsConstructorDescriptionIPAddressName
(byte[] address) Create the IPAddressName object with the specified name.Create the IPAddressName object with a string representing the ip address.IPAddressName
(String s, String netmask) Create the IPAddressName object with a string representing the ip address and a string representing the netmask, with encoding having ip address encoding followed by the netmask encoding.IPAddressName
(String s, CIDRNetmask mask) IP address with CIDR netmaskIPAddressName
(DerValue derValue) Create the IPAddressName object from the passed encoded Der value. -
Method Summary
Modifier and TypeMethodDescriptionvoid
encode
(DerOutputStream out) Encode the IPAddress name into the DerOutputStream.static int
fillIPv4Address
(String s, byte[] address, int start) Gets an IP v4 address in the form n.n.n.n.static int
fillIPv6Address
(String s, byte[] address, int start) Gets an IP address in the forms as defined in RFC1884:
x:x:x:x:x:x:x:x ...::xxx (using :: shorthand) ...:n.n.n.n (with n.n.n.n at the end)int
getType()
Return the type of the GeneralName.private static byte[]
parseAddress
(boolean withNetmask, String s) Initialise and return a byte[] and write the IP address into it.private static int
read16BitInt
(ByteBuffer buf) Read big-endian 16-bit int from buffer (advancing cursor)toString()
Return a printable string of IPaddressboolean
Whether the name is valid as a single name (e.g.boolean
Whether the name is valid as a subtree name (e.g.private static void
writeIPv4
(StringBuilder r, ByteBuffer buf) private static void
writeIPv6
(StringBuilder r, ByteBuffer buf)
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
address
private byte[] address -
IPv4_LEN
protected static final char IPv4_LEN- See Also:
-
IPv6_LEN
protected static final char IPv6_LEN- See Also:
-
-
Constructor Details
-
IPAddressName
Create the IPAddressName object from the passed encoded Der value.- Parameters:
derValue
- the encoded DER IPAddressName.- Throws:
IOException
- on error.
-
IPAddressName
public IPAddressName(byte[] address) Create the IPAddressName object with the specified name.- Parameters:
address
- the IPAddressName.
-
IPAddressName
Create the IPAddressName object with a string representing the ip address and a string representing the netmask, with encoding having ip address encoding followed by the netmask encoding. This form is needed for name constraints extension.- Parameters:
s
- the ip address in the format: n.n.n.n or x:x:x:x:x:x:x:x (RFC 1884)netmask
- the netmask address in the format: n.n.n.n or x:x:x:x:x:x:x:x (RFC 1884)
-
IPAddressName
IP address with CIDR netmask- Parameters:
s
- a single IPv4 or IPv6 addressmask
- a CIDR netmask
-
IPAddressName
Create the IPAddressName object with a string representing the ip address.- Parameters:
s
- the ip address in the format: n.n.n.n or x:x:x:x:x:x:x:x
-
-
Method Details
-
parseAddress
Initialise and return a byte[] and write the IP address into it. If withNetmask == true, the byte[] will be double the size, with the latter half uninitialised.- Returns:
- byte[] of length 4 or 16 if withNetmask == false, or length 8 or 32 if withNetmask == true.
-
getType
public int getType()Return the type of the GeneralName.- Specified by:
getType
in interfaceGeneralNameInterface
-
validSingle
public boolean validSingle()Description copied from interface:GeneralNameInterface
Whether the name is valid as a single name (e.g. for use in Subject Alternative Name extension).- Specified by:
validSingle
in interfaceGeneralNameInterface
-
validSubtree
public boolean validSubtree()Description copied from interface:GeneralNameInterface
Whether the name is valid as a subtree name (e.g. for use in Name Constraints extension)- Specified by:
validSubtree
in interfaceGeneralNameInterface
-
encode
Encode the IPAddress name into the DerOutputStream.- Specified by:
encode
in interfaceGeneralNameInterface
- Parameters:
out
- the DER stream to encode the IPAddressName to.- Throws:
IOException
- on encoding errors.
-
toString
Return a printable string of IPaddress -
writeIPv4
-
writeIPv6
-
read16BitInt
Read big-endian 16-bit int from buffer (advancing cursor) -
fillIPv4Address
Gets an IP v4 address in the form n.n.n.n. -
fillIPv6Address
Gets an IP address in the forms as defined in RFC1884:
- x:x:x:x:x:x:x:x
- ...::xxx (using :: shorthand)
- ...:n.n.n.n (with n.n.n.n at the end)
-