com.vgrs.xcode.idna
Class Idna

java.lang.Object
  extended by com.vgrs.xcode.idna.Idna

public final class Idna
extends java.lang.Object

Implementation of IDNA2008 Protocol

Ultimately the following will be true:
The Race object uses Utf16 as input and output
The Punycode object uses Unicode as input and output

toAscii
1. Application has Unicode data U32
2. Pass the Unicode data to Idna U32
3. Idna tokenizes the data. *U32
4. Idna runs Unicode through IDNA2008 Protocol if the registration protocol is specified. U32
5. Idna encodes the data using an ACE algorithm U32->U16
6. Idna assembles the labels. U16
7. Idna passes the Utf16 back to the application. U16

- It is not trivial to tokenize the labels as Unicode. We have written
a special object to do so, which allows us to avoid decoding to and
from Unicode just for tokenization.

toUnicode
1. Application has Utf16 (probably Ascii) string U16
2. Pass the Utf16 data to Idna. U16
3. Idna tokenizes the data. U16
4. Idna encodes the data in Unicode. U32 <-U16
5. Idna runs Unicode through IDNA2008 Protocol if the registration protocol is specified.
6. Idna decodes the data to Utf-16. U32->U16
7. Idna decodes the data using an ACE algorithm U32 <-U16
8. Idna assembles the labels *U32
9. Idna asserts IDNA2008 Bidi rules if an RTL label is present in the domain if the registration protocol is specified
10. Idna passes the Unicode back to the application. U32

Version:
1.0 Jun 17, 2010
Author:
nchigurupati

Field Summary
static char ACE_DELIMITER
          Stores the Unicode character used to delimit domain labels in an ASCII Compatible Encoding sequence.
static boolean DEFAULT_REGISTRATION_PROTOCOL
          Indicates whether or not IDNA2008 Protocol rules are applied.
static boolean DEFAULT_TO_UNICODE_EXCEPTION_FLAG
          Indicates whether or not to throw XcodeExceptions from the toUnicode method.
static java.lang.String DELIMITERS
          Stores the list of IDNA compliant delimiters.
static int[] INT_DELIMITERS
          Stores the list of IDNA compliant delimiters.
static int MAX_DOMAIN_LABEL_LENGTH_IN_OCTETS
          RFC 1034 imposes a length restriction of 0 to 63 octets per domain label.
 
Constructor Summary
Idna(Ace ace)
          Construct an Idna object for converting data to and from an ASCII compatible form.
Idna(Ace ace, boolean aToUnicodeExceptionFlag)
          Construct an Idna object for converting data to and from an ASCII compatible form.
Idna(Ace ace, boolean aToUnicodeExceptionFlag, boolean aIsRegistrationProtocol)
          Construct an Idna object for converting data to and from an ASCII compatible form.
 
Method Summary
 char[] domainToAscii(int[] input)
          Converts an array of integers to a character array
 int[] domainToUnicode(char[] input)
          Converts a character array to an integer array
static boolean isDelimiter(int c)
          Checks if the input int is a delimiter
static boolean isDelimiter(java.lang.String s)
          Checks if the input string is a delimiter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INT_DELIMITERS

public static final int[] INT_DELIMITERS
Stores the list of IDNA compliant delimiters.
This variable is hard coded to the value {0x2e,0x3002,0xff0e,0xff61}


DELIMITERS

public static final java.lang.String DELIMITERS
Stores the list of IDNA compliant delimiters.
This variable is hard coded to the value "\ u 0 0 2 e \ u 3 0 0 2 \ u f f 0 e \ u f f 6 1"

See Also:
Constant Field Values

ACE_DELIMITER

public static final char ACE_DELIMITER
Stores the Unicode character used to delimit domain labels in an ASCII Compatible Encoding sequence.
This variable is hard coded to the value 0x002e .

See Also:
Constant Field Values

MAX_DOMAIN_LABEL_LENGTH_IN_OCTETS

public static final int MAX_DOMAIN_LABEL_LENGTH_IN_OCTETS
RFC 1034 imposes a length restriction of 0 to 63 octets per domain label.
This variable is hard coded to the value 63 .

See Also:
Constant Field Values

DEFAULT_TO_UNICODE_EXCEPTION_FLAG

public static final boolean DEFAULT_TO_UNICODE_EXCEPTION_FLAG
Indicates whether or not to throw XcodeExceptions from the toUnicode method. Any error condition in the execution of the toUnicode operation results in the return of the input. This prevents applications from knowing whether an error occured during the process. The Idna object uses an internal flag to indicate whether an exception should be thrown if an error condition occurs. Setting the internal flag to true will allow an error condition to throw an exception to the calling application. The application can then decide whether or not to continue execution.
This variable takes the value false by default.

See Also:
Constant Field Values

DEFAULT_REGISTRATION_PROTOCOL

public static final boolean DEFAULT_REGISTRATION_PROTOCOL
Indicates whether or not IDNA2008 Protocol rules are applied. By default this value is true.

See Also:
Constant Field Values
Constructor Detail

Idna

public Idna(Ace ace)
     throws XcodeException
Construct an Idna object for converting data to and from an ASCII compatible form.

Parameters:
ace - An Ace object to use during conversion.
Throws:
XcodeException

Idna

public Idna(Ace ace,
            boolean aToUnicodeExceptionFlag)
     throws XcodeException
Construct an Idna object for converting data to and from an ASCII compatible form.

Parameters:
ace - An Ace object to use during conversion.
aToUnicodeExceptionFlag - See the description for the DEFAULT_TO_UNICODE_EXCEPTION_FLAG attibute which stores the default value for this parameter.
Throws:
XcodeException

Idna

public Idna(Ace ace,
            boolean aToUnicodeExceptionFlag,
            boolean aIsRegistrationProtocol)
     throws XcodeException
Construct an Idna object for converting data to and from an ASCII compatible form.

Parameters:
ace - An Ace object to use during conversion.
aToUnicodeExceptionFlag - See the description for the DEFAULT_TO_UNICODE_EXCEPTION_FLAG attibute which stores the default value for this parameter.
aIsRegistrationProtocol - Indicates whether or not IDNA2008 Protocol rules are applied
Throws:
XcodeException
Method Detail

isDelimiter

public static boolean isDelimiter(java.lang.String s)
Checks if the input string is a delimiter

Parameters:
s - a string to check
Returns:
true if the s represents one of the DELIMITERS, false if not

isDelimiter

public static boolean isDelimiter(int c)
Checks if the input int is a delimiter

Parameters:
c - an int to check
Returns:
true if the s represents one of the DELIMITERS, false if not

domainToAscii

public char[] domainToAscii(int[] input)
                     throws XcodeException
Converts an array of integers to a character array

Parameters:
input - an int array
Returns:
a character array
Throws:
XcodeException - if the input is null or empty

domainToUnicode

public int[] domainToUnicode(char[] input)
                      throws XcodeException
Converts a character array to an integer array

Parameters:
input - a character array
Returns:
an int array
Throws:
XcodeException - if the input is null or empty


Copyright © 2000-2010 VeriSign Inc. All Rights Reserved