package org.bouncycastle.test.est.examples;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

class SuffixList
{

    static Set<String> loadSuffixes(String file)
        throws Exception
    {
        FileInputStream fin = new FileInputStream(file);
        String line = null;
        BufferedReader bin = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
        ArrayList<String> suffixes = new ArrayList<String>();

        while ((line = bin.readLine()) != null)
        {
            if (line.length() == 0 || (line.startsWith("//") && !line.startsWith("// xn--")))
            {
                continue;
            }

            if (line.startsWith("!"))
            {
                continue;
            }

            line = line.trim();
            if (line.startsWith("// xn--"))
            {
                String[] j = line.split(" ");
                suffixes.add(j[1]);
            }
            else
            {
                suffixes.add(line);
            }
        }

        bin.close();

        for (int t = 0; t < suffixes.size(); t++)
        {
            String j = suffixes.get(t);
            if (!j.startsWith("*."))
            {
                j = "*." + j;
            }
            suffixes.set(t, j);
        }

        HashSet<String> set = new HashSet<String>();
        for (String s : suffixes)
        {
            set.add(s);
        }




        return set;
    }

}

@@ -1300,17 +1300,16 @@
     if (
-!
 j.starts
@@ -1319,28 +1319,16 @@
 h(%22*.%22))
-%0A           
  %7B%0A     
@@ -1346,16 +1346,22 @@
 j = 
-%22*.%22 + j
+j.substring(2)
 ;%0A  
@@ -1546,20 +1546,16 @@
       %7D%0A
-%0A%0A%0A%0A
         
@@ -1572,11 +1572,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

Remove any leading '*.' that may be present in the suffix list.