directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject [24/36] directory-kerby git commit: Consolidated facility and support modules into kerby-common
Date Sat, 16 Jan 2016 09:49:22 GMT
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/PublicKeyDeriver.java
----------------------------------------------------------------------
diff --git a/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/PublicKeyDeriver.java b/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/PublicKeyDeriver.java
new file mode 100644
index 0000000..42c0ef0
--- /dev/null
+++ b/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/PublicKeyDeriver.java
@@ -0,0 +1,79 @@
+/*
+ * $HeadURL: http://juliusdavies.ca/svn/not-yet-commons-ssl/trunk/src/java/org/apache/commons/ssl/Certificates.java $
+ * $Revision: 121 $
+ * $Date: 2007-11-13 21:26:57 -0800 (Tue, 13 Nov 2007) $
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.kerby.util;
+
+import java.math.BigInteger;
+import java.security.GeneralSecurityException;
+import java.security.KeyException;
+import java.security.KeyFactory;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.interfaces.DSAParams;
+import java.security.interfaces.DSAPrivateKey;
+import java.security.interfaces.RSAPrivateCrtKey;
+import java.security.spec.DSAPublicKeySpec;
+import java.security.spec.RSAPublicKeySpec;
+
+/**
+ * Utility class for deriving a public key from a given private key.
+ */
+public class PublicKeyDeriver {
+
+    /**
+     * Utility method for deriving a public key from a given private key.
+     *
+     * @param key private key for which we need a public key (DSA or RSA).
+     * @return the corresponding public key
+     * @throws java.security.GeneralSecurityException if it didn't work
+     */
+    public static PublicKey derivePublicKey(PrivateKey key) throws GeneralSecurityException {
+        if (key instanceof DSAPrivateKey) {
+            DSAPrivateKey dsaKey = (DSAPrivateKey) key;
+            DSAParams keyParams = dsaKey.getParams();
+            BigInteger g = keyParams.getG();
+            BigInteger p = keyParams.getP();
+            BigInteger q = keyParams.getQ();
+            BigInteger x = dsaKey.getX();
+            BigInteger y = q.modPow(x, p);
+            DSAPublicKeySpec keySpec = new DSAPublicKeySpec(y, p, q, g);
+            return KeyFactory.getInstance("DSA").generatePublic(keySpec);
+        } else if (key instanceof RSAPrivateCrtKey) {
+            RSAPrivateCrtKey rsaKey = (RSAPrivateCrtKey) key;
+            BigInteger modulus = rsaKey.getModulus();
+            BigInteger exponent = rsaKey.getPublicExponent();
+            RSAPublicKeySpec keySpec = new RSAPublicKeySpec(modulus, exponent);
+            return KeyFactory.getInstance("RSA").generatePublic(keySpec);
+        } else {
+            throw new KeyException("Private key was not a DSA or RSA key");
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/ReadLine.java
----------------------------------------------------------------------
diff --git a/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/ReadLine.java b/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/ReadLine.java
new file mode 100644
index 0000000..f7a1db0
--- /dev/null
+++ b/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/ReadLine.java
@@ -0,0 +1,116 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author Julius Davies
+ * @author 23-Dec-2007
+ */
+public class ReadLine {
+
+    final InputStream in;
+    final byte[] bytes = new byte[8192];
+    int pos = 0;
+    int avail = 0;
+
+    public ReadLine(InputStream in) {
+        this.in = in;
+    }
+
+    public String next() throws IOException {
+        return next(1);
+    }
+
+    public String next(int lines) throws IOException {
+        if (lines < 1) {
+            lines = 1;
+        }
+        StringBuffer buf = new StringBuffer(128 * lines);
+        if (avail <= 0 || pos >= avail) {
+            pos = 0;
+            avail = in.read(bytes);
+        }
+        while (avail >= 0) {
+            while (pos < avail) {
+                char c = (char) bytes[pos++];
+                switch (c) {
+                    case '\n':
+                    case '\r':
+                        lines--;
+                        if (lines < 1 && buf.length() > 0) {
+                            return buf.toString();
+                        }
+                        break;
+                    default:
+                        buf.append(c);
+                        break;
+                }
+            }
+            pos = 0;
+            avail = in.read(bytes);
+        }
+        return buf.length() > 0 ? buf.toString() : null;
+    }
+
+    public byte[] nextAsBytes() throws IOException {
+        return nextAsBytes(1);
+    }
+
+    public byte[] nextAsBytes(int lines) throws IOException {
+        if (lines < 1) {
+            lines = 1;
+        }
+        byte[] buf = new byte[8192];
+        int bufPos = 0;
+        if (avail <= 0 || pos >= avail) {
+            pos = 0;
+            avail = in.read(bytes);
+        }
+        while (avail >= 0) {
+            while (pos < avail) {
+                byte b = bytes[pos++];
+                switch (b) {
+                    case '\n':
+                    case '\r':
+                        lines--;
+                        if (lines == 0 && bufPos > 0) {
+                            return buf;
+                        }
+                        break;
+                    default:
+                        if (bufPos >= buf.length) {
+                            byte[] moreBuff = new byte[buf.length * 2];
+                            System.arraycopy(buf, 0, moreBuff, 0, buf.length);
+                            buf = moreBuff;
+                        }
+                        buf[bufPos++] = b;
+                        break;
+                }
+            }
+            pos = 0;
+            avail = in.read(bytes);
+        }
+        return bufPos > 0 ? buf : null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/SysUtil.java
----------------------------------------------------------------------
diff --git a/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/SysUtil.java b/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/SysUtil.java
new file mode 100644
index 0000000..d607871
--- /dev/null
+++ b/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/SysUtil.java
@@ -0,0 +1,35 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.util;
+
+import java.io.File;
+
+/**
+ * A system related utility.
+ */
+public final class SysUtil {
+    private SysUtil() { }
+
+    public static File getTempDir() {
+        String tmpDir = System.getProperty("java.io.tmpdir");
+        return new File(tmpDir);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/Utf8.java
----------------------------------------------------------------------
diff --git a/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/Utf8.java b/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/Utf8.java
new file mode 100644
index 0000000..4e57234
--- /dev/null
+++ b/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/Utf8.java
@@ -0,0 +1,34 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.util;
+
+import java.nio.charset.StandardCharsets;
+
+public final class Utf8 {
+    private Utf8() { }
+
+    public static String toString(byte[] bytes) {
+        return new String(bytes, StandardCharsets.UTF_8);
+    }
+
+    public static byte[] toBytes(String s) {
+        return s.getBytes(StandardCharsets.UTF_8);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/Util.java
----------------------------------------------------------------------
diff --git a/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/Util.java b/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/Util.java
new file mode 100644
index 0000000..f8c779e
--- /dev/null
+++ b/kerby-common/kerby-util/src/main/java/org/apache/kerby/util/Util.java
@@ -0,0 +1,422 @@
+/*
+ * $HeadURL: http://juliusdavies.ca/svn/not-yet-commons-ssl/tags/commons-ssl-0.3.16/src/java/org/apache/commons/ssl/Util.java $
+ * $Revision: 180 $
+ * $Date: 2014-09-23 11:33:47 -0700 (Tue, 23 Sep 2014) $
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.kerby.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.nio.charset.Charset;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.cert.Certificate;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
+/**
+ * @author Credit Union Central of British Columbia
+ * @author <a href="http://www.cucbc.com/">www.cucbc.com</a>
+ * @author <a href="mailto:juliusdavies@cucbc.com">juliusdavies@cucbc.com</a>
+ * @since 28-Feb-2006
+ */
+public class Util {
+    public static final int SIZE_KEY = 0;
+    public static final int LAST_READ_KEY = 1;
+
+    /**
+     * True if the Keystores have the same # of entries, have the same set of aliases, and all the certificate-chains
+     * (of the certificate entries) match.   Does not check the private keys for equality, since we
+     * don't bother taking the passwords to get at them.
+     * @param ks1 The first key store
+     * @param ks2 The second key store
+     * @return boolean
+     * @throws KeyStoreException e
+     */
+    public static boolean equals(KeyStore ks1, KeyStore ks2) throws KeyStoreException {
+        if (ks1 == null || ks2 == null) {
+            return ks1 == null && ks2 == null;
+        }
+        Set<String> aliases1 = aliases(ks1);
+        Set<String> aliases2 = aliases(ks2);
+        if (aliases1.equals(aliases2)) {
+            for (String s : aliases1) {
+                if (ks1.isCertificateEntry(s) != ks2.isCertificateEntry(s)) {
+                    return false;
+                }
+                if (ks1.isKeyEntry(s) != ks2.isKeyEntry(s)) {
+                    return false;
+                }
+                if (ks1.isCertificateEntry(s)) {
+                    Certificate[] cc1 = ks1.getCertificateChain(s);
+                    Certificate[] cc2 = ks2.getCertificateChain(s);
+                    if (!Arrays.equals(cc1, cc2)) {
+                        return false;
+                    }
+
+                    Certificate c1 = ks1.getCertificate(s);
+                    Certificate c2 = ks2.getCertificate(s);
+                    if (!c1.equals(c2)) {
+                        return false;
+                    }
+                }
+
+                // should we bother checking keys?   maybe one day....
+            }
+        }
+        return true;
+    }
+
+    private static Set<String> aliases(KeyStore ks) throws KeyStoreException {
+        Set<String> aliases = new TreeSet<String>();
+        Enumeration<String> en = ks.aliases();
+        while (en.hasMoreElements()) {
+            aliases.add(en.nextElement());
+        }
+        return aliases;
+    }
+
+    public static boolean isYes(String yesString) {
+        if (yesString == null) {
+            return false;
+        }
+        String s = yesString.trim().toUpperCase();
+        return "1".equals(s) || "YES".equals(s) || "TRUE".equals(s)
+               || "ENABLE".equals(s) || "ENABLED".equals(s) || "Y".equals(s)
+               || "ON".equals(s);
+    }
+
+    public static String trim(final String s) {
+        if (s == null || "".equals(s)) {
+            return s;
+        }
+        int i = 0;
+        int j = s.length() - 1;
+        while (isWhiteSpace(s.charAt(i))) {
+            i++;
+        }
+        while (isWhiteSpace(s.charAt(j))) {
+            j--;
+        }
+        return j >= i ? s.substring(i, j + 1) : "";
+    }
+
+    public static boolean isWhiteSpace(final char c) {
+        switch (c) {
+            case 0:
+            case ' ':
+            case '\t':
+            case '\n':
+            case '\r':
+            case '\f':
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    public static void pipeStream(InputStream in, OutputStream out)
+        throws IOException {
+        pipeStream(in, out, true);
+    }
+
+    public static void pipeStream(InputStream in, OutputStream out,
+                                  boolean autoClose)
+        throws IOException {
+        byte[] buf = new byte[8192];
+        IOException ioe = null;
+        try {
+            int bytesRead = in.read(buf);
+            while (bytesRead >= 0) {
+                if (bytesRead > 0) {
+                    out.write(buf, 0, bytesRead);
+                }
+                bytesRead = in.read(buf);
+            }
+        } finally {
+            // Probably it's best to let consumer call "close", but I'm usually
+            // the consumer, and I want to be lazy.  [Julius, November 20th, 2006]
+            try {
+                in.close();
+            } catch (IOException e) {
+                ioe = e;
+            }
+            if (autoClose) {
+                try {
+                    out.close();
+                } catch (IOException e) {
+                    ioe = e;
+                }
+            }
+        }
+        if (ioe != null) {
+            throw ioe;
+        }
+    }
+
+    public static byte[] fileToBytes(final File f) throws IOException {
+        return streamToBytes(new FileInputStream(f));
+    }
+
+    public static byte[] streamToBytes(final ByteArrayInputStream in,
+                                       int maxLength) {
+        byte[] buf = new byte[maxLength];
+        int[] status = fill(buf, 0, in);
+        int size = status[SIZE_KEY];
+        if (buf.length != size) {
+            byte[] smallerBuf = new byte[size];
+            System.arraycopy(buf, 0, smallerBuf, 0, size);
+            buf = smallerBuf;
+        }
+        return buf;
+    }
+
+    public static byte[] streamToBytes(final InputStream in, int maxLength)
+        throws IOException {
+        byte[] buf = new byte[maxLength];
+        int[] status = fill(buf, 0, in);
+        int size = status[SIZE_KEY];
+        if (buf.length != size) {
+            byte[] smallerBuf = new byte[size];
+            System.arraycopy(buf, 0, smallerBuf, 0, size);
+            buf = smallerBuf;
+        }
+        return buf;
+    }
+
+    public static byte[] streamToBytes(final InputStream in) throws IOException {
+        byte[] buf = new byte[4096];
+        try {
+            int[] status = fill(buf, 0, in);
+            int size = status[SIZE_KEY];
+            int lastRead = status[LAST_READ_KEY];
+            while (lastRead != -1) {
+                buf = resizeArray(buf);
+                status = fill(buf, size, in);
+                size = status[SIZE_KEY];
+                lastRead = status[LAST_READ_KEY];
+            }
+            if (buf.length != size) {
+                byte[] smallerBuf = new byte[size];
+                System.arraycopy(buf, 0, smallerBuf, 0, size);
+                buf = smallerBuf;
+            }
+        } finally {
+            in.close();
+        }
+        return buf;
+    }
+
+    public static byte[] streamToBytes(final ByteArrayInputStream in) {
+        byte[] buf = new byte[4096];
+        int[] status = fill(buf, 0, in);
+        int size = status[SIZE_KEY];
+        int lastRead = status[LAST_READ_KEY];
+        while (lastRead != -1) {
+            buf = resizeArray(buf);
+            status = fill(buf, size, in);
+            size = status[SIZE_KEY];
+            lastRead = status[LAST_READ_KEY];
+        }
+        if (buf.length != size) {
+            byte[] smallerBuf = new byte[size];
+            System.arraycopy(buf, 0, smallerBuf, 0, size);
+            buf = smallerBuf;
+        }
+        // in.close();  <-- this is a no-op on ByteArrayInputStream.
+        return buf;
+    }
+
+    public static int[] fill(final byte[] buf, final int offset,
+                             final InputStream in)
+        throws IOException {
+        int read = in.read(buf, offset, buf.length - offset);
+        int lastRead = read;
+        if (read == -1) {
+            read = 0;
+        }
+        while (lastRead != -1 && read + offset < buf.length) {
+            lastRead = in.read(buf, offset + read, buf.length - read - offset);
+            if (lastRead != -1) {
+                read += lastRead;
+            }
+        }
+        return new int[]{offset + read, lastRead};
+    }
+
+    public static int[] fill(final byte[] buf, final int offset,
+                             final ByteArrayInputStream in) {
+        int read = in.read(buf, offset, buf.length - offset);
+        int lastRead = read;
+        if (read == -1) {
+            read = 0;
+        }
+        while (lastRead != -1 && read + offset < buf.length) {
+            lastRead = in.read(buf, offset + read, buf.length - read - offset);
+            if (lastRead != -1) {
+                read += lastRead;
+            }
+        }
+        return new int[]{offset + read, lastRead};
+    }
+
+    public static byte[] resizeArray(final byte[] bytes) {
+        byte[] biggerBytes = new byte[bytes.length * 2];
+        System.arraycopy(bytes, 0, biggerBytes, 0, bytes.length);
+        return biggerBytes;
+    }
+
+    public static String pad(String s, final int length, final boolean left) {
+        if (s == null) {
+            s = "";
+        }
+        int diff = length - s.length();
+        if (diff == 0) {
+            return s;
+        } else if (diff > 0) {
+            StringBuffer sb = new StringBuffer();
+            if (left) {
+                for (int i = 0; i < diff; i++) {
+                    sb.append(' ');
+                }
+            }
+            sb.append(s);
+            if (!left) {
+                for (int i = 0; i < diff; i++) {
+                    sb.append(' ');
+                }
+            }
+            return sb.toString();
+        } else {
+            return s;
+        }
+    }
+
+    public static HostPort toAddress(final String target,
+                                     final int defaultPort)
+        throws UnknownHostException {
+        String host = target;
+        int port = defaultPort;
+        StringTokenizer st = new StringTokenizer(target, ":");
+        if (st.hasMoreTokens()) {
+            host = st.nextToken().trim();
+        }
+        if (st.hasMoreTokens()) {
+            port = Integer.parseInt(st.nextToken().trim());
+        }
+        if (st.hasMoreTokens()) {
+            throw new IllegalArgumentException("Invalid host: " + target);
+        }
+        return new HostPort(host, port);
+    }
+
+    public static String cipherToAuthType(String cipher) {
+        if (cipher == null) {
+            return null;
+        }
+
+        // SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA  ==> "DHE_DSS_EXPORT"
+        // SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA      ==> "DHE_DSS"
+        // SSL_RSA_WITH_3DES_EDE_CBC_SHA          ==> "RSA"
+
+        StringTokenizer st = new StringTokenizer(cipher.trim(), "_");
+        if (st.hasMoreTokens()) {
+            st.nextToken();  // always skip first token
+        }
+        if (st.hasMoreTokens()) {
+            String tok = st.nextToken();
+            StringBuffer buf = new StringBuffer();
+            buf.append(tok);
+            if (st.hasMoreTokens()) {
+                tok = st.nextToken();
+                while (!"WITH".equalsIgnoreCase(tok)) {
+                    buf.append('_');
+                    buf.append(tok);
+                    tok = st.nextToken();
+                }
+            }
+            return buf.toString();
+        }
+        throw new IllegalArgumentException("not a valid cipher: " + cipher);
+    }
+
+    /**
+     * Utility method to make sure IP-literals don't trigger reverse-DNS lookups.
+     * @param s The string
+     * @return The InetAddress
+     * @throws UnknownHostException e
+     */
+    public static InetAddress toInetAddress(String s) throws UnknownHostException {
+        byte[] ip = IPAddressParser.parseIPv4Literal(s);
+        if (ip == null) {
+            ip = IPAddressParser.parseIPv6Literal(s);
+        }
+        if (ip != null) {
+            // Strangely, this prevents Java's annoying SSL reverse-DNS lookup that it
+            // normally does, even with literal IP addresses.
+            return InetAddress.getByAddress(s, ip);
+        } else {
+            return InetAddress.getByName(s);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        String s = "line1\n\rline2\n\rline3";
+        ByteArrayInputStream in = new ByteArrayInputStream(s.getBytes(Charset.forName("UTF-8")));
+        ByteArrayReadLine readLine = new ByteArrayReadLine(in);
+        String line = readLine.next();
+        while (line != null) {
+            System.out.println(line);
+            line = readLine.next();
+        }
+
+        System.out.println("--------- test 2 ----------");
+
+        s = "line1\n\rline2\n\rline3\n\r\n\r";
+        in = new ByteArrayInputStream(s.getBytes());
+        readLine = new ByteArrayReadLine(in);
+        line = readLine.next();
+        while (line != null) {
+            System.out.println(line);
+            line = readLine.next();
+        }
+
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-common/kerby-util/src/test/java/org/apache/kerby/util/Base64Test.java
----------------------------------------------------------------------
diff --git a/kerby-common/kerby-util/src/test/java/org/apache/kerby/util/Base64Test.java b/kerby-common/kerby-util/src/test/java/org/apache/kerby/util/Base64Test.java
new file mode 100644
index 0000000..1ae3d82
--- /dev/null
+++ b/kerby-common/kerby-util/src/test/java/org/apache/kerby/util/Base64Test.java
@@ -0,0 +1,109 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.util;
+
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.util.Arrays;
+import java.util.Random;
+
+import static org.junit.Assert.assertTrue;
+
+
+public class Base64Test {
+
+    @Test
+    public void testOrigBase64() throws Exception {
+        Random random = new Random();
+        for (int i = 0; i < 4567; i++) {
+            byte[] buf = new byte[i];
+            random.nextBytes(buf);
+            byte[] enc = Base64.encodeBase64(buf);
+            ByteArrayInputStream in = new ByteArrayInputStream(enc);
+            enc = Util.streamToBytes(in);
+            byte[] dec = Base64.decodeBase64(enc);
+            boolean result = Arrays.equals(buf, dec);
+            if (!result) {
+                System.out.println();
+                System.out.println("testOrigBase64 Failed on : " + i);
+            }
+            assertTrue(result);
+        }
+        for (int i = 5; i < 50; i++) {
+            int testSize = i * 1000 + 123;
+            byte[] buf = new byte[testSize];
+            random.nextBytes(buf);
+            byte[] enc = Base64.encodeBase64(buf);
+            ByteArrayInputStream in = new ByteArrayInputStream(enc);
+            enc = Util.streamToBytes(in);            
+            byte[] dec = Base64.decodeBase64(enc);
+            boolean result = Arrays.equals(buf, dec);
+            if (!result) {
+                System.out.println();
+                System.out.println("testOrigBase64 Failed on : " + testSize);
+            }
+            assertTrue(result);
+        }
+    }
+
+    @Test
+    public void testBase64() throws Exception {
+        Random random = new Random();
+        for (int i = 0; i < 4567; i++) {
+            byte[] buf = new byte[i];
+            random.nextBytes(buf);
+
+            ByteArrayInputStream in = new ByteArrayInputStream(buf);
+            Base64InputStream base64 = new Base64InputStream(in, true);
+            byte[] enc = Util.streamToBytes(base64);
+            in = new ByteArrayInputStream(enc);
+            base64 = new Base64InputStream(in);
+            byte[] dec = Util.streamToBytes(base64);
+
+            boolean result = Arrays.equals(buf, dec);
+            if (!result) {
+                System.out.println();
+                System.out.println("testBase64 Failed on : " + i);
+            }
+            assertTrue(result);
+        }
+        for (int i = 5; i < 50; i++) {
+            int testSize = i * 1000 + 123;
+            byte[] buf = new byte[testSize];
+            random.nextBytes(buf);
+
+            ByteArrayInputStream in = new ByteArrayInputStream(buf);
+            Base64InputStream base64 = new Base64InputStream(in, true);
+            byte[] enc = Util.streamToBytes(base64);
+            in = new ByteArrayInputStream(enc);
+            base64 = new Base64InputStream(in);
+            byte[] dec = Util.streamToBytes(base64);
+
+            boolean result = Arrays.equals(buf, dec);
+            if (!result) {
+                System.out.println();
+                System.out.println("testBase64 Failed on : " + testSize);
+            }
+            assertTrue(result);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-common/kerby-util/src/test/java/org/apache/kerby/util/IPAddressParserTest.java
----------------------------------------------------------------------
diff --git a/kerby-common/kerby-util/src/test/java/org/apache/kerby/util/IPAddressParserTest.java b/kerby-common/kerby-util/src/test/java/org/apache/kerby/util/IPAddressParserTest.java
new file mode 100644
index 0000000..d196886
--- /dev/null
+++ b/kerby-common/kerby-util/src/test/java/org/apache/kerby/util/IPAddressParserTest.java
@@ -0,0 +1,99 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.util;
+
+import org.junit.Test;
+
+import static org.apache.kerby.util.IPAddressParser.parseIPv4Literal;
+import static org.apache.kerby.util.IPAddressParser.parseIPv6Literal;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertNull;
+
+public class IPAddressParserTest {
+
+    @Test
+    public void theTest() {
+
+        // bad ones
+        assertNull("ip6 invalid", parseIPv6Literal(":::"));
+        assertNull("ip6 too many zero-expanders", parseIPv6Literal("1::1::"));
+        assertNull("ip6 .256 invalid", parseIPv6Literal("1::1:255.254.253.256"));
+        assertNull("ip6 too small", parseIPv6Literal("1:2:3:4"));
+        assertNull("ip6 no zero-expander after ip4", parseIPv6Literal("1:255.254.253.252::"));
+        assertNull("ip6 no zero-expander if 7 colons (end)", parseIPv6Literal("1:2:3:4:5:6:7:8::"));
+        assertNull("ip6 no zero-expander if 7 colons (begin)", parseIPv6Literal("::1:2:3:4:5:6:7:8"));
+        assertNull("ip6 88888 too many digits", parseIPv6Literal("1:2:3:4:5:6:7:88888"));
+        assertNull("ip6 missing colons", parseIPv6Literal("abcd"));
+        assertNull("ip6 umm, no", parseIPv6Literal("cookie monster"));
+        assertNull("ip6 empty string is invalid", parseIPv6Literal(""));
+        assertNull("ip6 null is invalid", parseIPv6Literal(null));
+
+        assertNull("ip4 not enough dots", parseIPv4Literal("abcd"));
+        assertNull("ip4 umm, no", parseIPv4Literal("cookie monster"));
+        assertNull("ip4 empty string is invalid", parseIPv4Literal(""));
+        assertNull("ip4 null is invalid", parseIPv4Literal(null));
+        assertNull("ip4 not enough dots 0", parseIPv4Literal("1"));
+        assertNull("ip4 not enough dots 1", parseIPv4Literal("1.2"));
+        assertNull("ip4 not enough dots 2", parseIPv4Literal("1.2.3"));
+        assertNull("ip4 needs digit after final dot", parseIPv4Literal("1.2.3."));
+        assertNull("ip4 [0-9] digits only", parseIPv4Literal("1.2.3.a"));
+        assertNull("ip4 too many dots", parseIPv4Literal("1.2.3.4.5"));
+        assertNull("ip4 0-255 range", parseIPv4Literal("1.2.3.444"));
+        assertNull("ip4 no negatives", parseIPv4Literal("1.2.-3.4"));
+        assertNull("ip4 no brackets", parseIPv4Literal("[1.2.3.4]"));
+
+        // good ones
+        assertArrayEquals(new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, parseIPv6Literal("::"));
+        assertArrayEquals(new byte[]{0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, parseIPv6Literal("1::"));
+        assertArrayEquals(new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, parseIPv6Literal("::1"));
+        assertArrayEquals(new byte[]{0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, parseIPv6Literal("1::1"));
+        assertArrayEquals(new byte[]{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, parseIPv6Literal("100::1"));
+
+        assertArrayEquals(new byte[]{0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -2, -3, -4},
+                parseIPv6Literal("1::1:255.254.253.252"));
+
+        assertArrayEquals(new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -3, -4},
+                parseIPv6Literal("::255.254.253.252"));
+
+        assertArrayEquals(new byte[]{0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, -1, -2, -3, -4},
+                parseIPv6Literal("1:2:3:4:5:6:255.254.253.252"));
+
+        assertArrayEquals(new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 4}, parseIPv6Literal("::1:2:3:4"));
+        assertArrayEquals(new byte[]{0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 4}, parseIPv6Literal("1::2:3:4"));
+        assertArrayEquals(new byte[]{0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 4}, parseIPv6Literal("1:2::3:4"));
+        assertArrayEquals(new byte[]{0, 1, 0, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}, parseIPv6Literal("1:2:3::4"));
+        assertArrayEquals(new byte[]{0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0}, parseIPv6Literal("1:2:3:4::"));
+
+        assertArrayEquals(new byte[]{0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8},
+                parseIPv6Literal("1:2:3:4:5:6:7:8"));
+
+        assertArrayEquals(new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, parseIPv6Literal("[::]"));
+
+        assertArrayEquals(new byte[]{0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8},
+                parseIPv6Literal("[1:2:3:4:5:6:7:8]"));
+
+        assertArrayEquals(new byte[]{17, 17, 34, 34, 51, 51, 68, 68, 85, 85, 102, 102, 119, 119, -120, -120},
+                parseIPv6Literal("1111:2222:3333:4444:5555:6666:7777:8888"));
+
+        assertArrayEquals(new byte[]{0, 0, 0, 0}, parseIPv4Literal("0.0.0.0"));
+        assertArrayEquals(new byte[]{1, 2, 3, 4}, parseIPv4Literal("1.2.3.4"));
+        assertArrayEquals(new byte[]{-1, -1, -1, -1}, parseIPv4Literal("255.255.255.255"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-common/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-common/pom.xml b/kerby-common/pom.xml
new file mode 100644
index 0000000..1c96492
--- /dev/null
+++ b/kerby-common/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License. See accompanying LICENSE file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.kerby</groupId>
+    <artifactId>kerby-all</artifactId>
+    <version>1.0.0-RC2-SNAPSHOT</version>
+  </parent>
+  
+  <artifactId>kerby-common</artifactId>
+  <name>Kerby-common Project</name>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>kerby-asn1</module>
+    <module>kerby-config</module>
+    <module>kerby-util</module>
+  </modules>
+</project>

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-config/README
----------------------------------------------------------------------
diff --git a/kerby-config/README b/kerby-config/README
deleted file mode 100644
index 505efca..0000000
--- a/kerby-config/README
+++ /dev/null
@@ -1,20 +0,0 @@
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
--->
-
-An unified configuration API that crosses various popular configuration formats like XML, JSON, INI and etc.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-config/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-config/pom.xml b/kerby-config/pom.xml
deleted file mode 100644
index 46b90b5..0000000
--- a/kerby-config/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License. See accompanying LICENSE file.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
-  <parent>
-    <groupId>org.apache.kerby</groupId>
-    <artifactId>kerby-all</artifactId>
-    <version>1.0.0-RC2-SNAPSHOT</version>
-  </parent>
-
-  <modelVersion>4.0.0</modelVersion>
-
-  <artifactId>kerby-config</artifactId>
-  <name>Kerby Config</name>
-  <description>Kerby config library</description>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-api</artifactId>
-      <version>${slf4j.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
-      <version>${slf4j.version}</version>
-   </dependency>
-  </dependencies>
-</project>

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-config/src/main/java/org/apache/kerby/config/Conf.java
----------------------------------------------------------------------
diff --git a/kerby-config/src/main/java/org/apache/kerby/config/Conf.java b/kerby-config/src/main/java/org/apache/kerby/config/Conf.java
deleted file mode 100644
index c0bea4b..0000000
--- a/kerby-config/src/main/java/org/apache/kerby/config/Conf.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *  
- *    http://www.apache.org/licenses/LICENSE-2.0
- *  
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *  
- */
-package org.apache.kerby.config;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-/**
- * A general class to describe and store all the config files.
- */
-public class Conf implements Config {
-    private static final Logger LOGGER = LoggerFactory.getLogger(Conf.class);
-
-    private List<ConfigLoader> resourceConfigs;
-    private final ConfigImpl config;
-
-    public Conf() {
-        this.resourceConfigs = new ArrayList<ConfigLoader>(1);
-        this.config = new ConfigImpl("Conf");
-    }
-
-    public void addXmlConfig(File xmlFile) throws IOException {
-        addResource(Resource.createXmlResource(xmlFile));
-    }
-
-    public void addIniConfig(File iniFile) throws IOException {
-        addResource(Resource.createIniResource(iniFile));
-    }
-
-    public void addJsonConfig(File jsonFile) throws IOException {
-        addResource(Resource.createJsonResource(jsonFile));
-    }
-
-    public void addPropertiesConfig(File propertiesFile) throws IOException {
-        addResource(Resource.createPropertiesFileResource(propertiesFile));
-    }
-
-    public void addPropertiesConfig(Properties propertiesConfig) {
-        addResource(Resource.createPropertiesResource(propertiesConfig));
-    }
-
-    public void addMapConfig(Map<String, Object> mapConfig) {
-        addResource(Resource.createMapResource(mapConfig));
-    }
-
-    /**
-     * Load the resource name and content in one step.
-     * Add synchronized to avoid conflicts
-     * @param resource the config resource
-     */
-    public synchronized void addResource(Resource resource) {
-        ConfigLoader loader = getLoader(resource);
-        resourceConfigs.add(loader);
-        Config loaded = loader.load();
-        config.add(loaded);
-    }
-
-    private static ConfigLoader getLoader(Resource resource) {
-        ConfigLoader loader = null;
-
-        Class<? extends ConfigLoader> loaderClass = resource.getFormat().getLoaderClass();
-        try {
-            loader = loaderClass.newInstance();
-        } catch (Exception e) {
-            LOGGER.error("Failed to create " + Conf.class.getPackage().getName()
-                    + " for " + loaderClass.getName(), e);
-            throw new RuntimeException("Failed to create "
-                    + Conf.class.getPackage().getName() + " for " + loaderClass.getName(), e);
-        }
-        loader.setResource(resource);
-        return loader;
-    }
-
-    /**
-     * For users usage, to determine whether to reload config files.
-     * Add synchronized to avoid conflicts
-     */
-    public synchronized void reload() {
-        config.reset();
-        for (ConfigLoader loader : resourceConfigs) {
-            Config loaded = loader.load();
-            config.add(loaded);
-        }
-    }
-
-    @Override
-    public String getResource() {
-        return config.getResource();
-    }
-
-    @Override
-    public Set<String> getNames() {
-        return config.getNames();
-    }
-
-    @Override
-    public String getString(String name) {
-        return config.getString(name);
-    }
-
-    @Override
-    public String getString(ConfigKey name, boolean useDefault) {
-        return config.getString(name, useDefault);
-    }
-
-    @Override
-    public String getString(String name, String defaultValue) {
-        return config.getString(name, defaultValue);
-    }
-
-    /**
-     * Values user sets will be add in config directly.
-     * Add synchronized to avoid conflicts
-     * @param name The property name
-     * @param value The string value
-     */
-    @Override
-    public synchronized void setString(String name, String value) {
-        config.set(name, value);
-    }
-
-    @Override
-    public void setString(ConfigKey name, String value) {
-        setString(name.getPropertyKey(), value);
-    }
-
-    @Override
-    public String getTrimmed(String name) {
-        return config.getTrimmed(name);
-    }
-
-    @Override
-    public String getTrimmed(ConfigKey name) {
-        return config.getTrimmed(name);
-    }
-
-    @Override
-    public Boolean getBoolean(String name) {
-        return config.getBoolean(name);
-    }
-
-    @Override
-    public Boolean getBoolean(ConfigKey name, boolean useDefault) {
-        return config.getBoolean(name, useDefault);
-    }
-
-    @Override
-    public Boolean getBoolean(String name, Boolean defaultValue) {
-        return config.getBoolean(name, defaultValue);
-    }
-
-    @Override
-    public void setBoolean(String name, Boolean value) {
-        setString(name, String.valueOf(value));
-    }
-
-    @Override
-    public void setBoolean(ConfigKey name, Boolean value) {
-        setString(name.getPropertyKey(), String.valueOf(value));
-    }
-
-    @Override
-    public Integer getInt(String name) {
-        return config.getInt(name);
-    }
-
-    @Override
-    public Integer getInt(ConfigKey name, boolean useDefault) {
-        return config.getInt(name, useDefault);
-    }
-
-    @Override
-    public Integer getInt(String name, Integer defaultValue) {
-        return config.getInt(name, defaultValue);
-    }
-
-    @Override
-    public void setInt(String name, Integer value) {
-        setString(name, String.valueOf(value));
-    }
-
-    @Override
-    public void setInt(ConfigKey name, Integer value) {
-        setString(name.getPropertyKey(), String.valueOf(value));
-    }
-
-    @Override
-    public Long getLong(String name) {
-        return config.getLong(name);
-    }
-
-    @Override
-    public Long getLong(ConfigKey name, boolean useDefault) {
-        return config.getLong(name, useDefault);
-    }
-
-    @Override
-    public Long getLong(String name, Long defaultValue) {
-        return config.getLong(name, defaultValue);
-    }
-
-    @Override
-    public void setLong(String name, Long value) {
-        setString(name, String.valueOf(value));
-    }
-
-    @Override
-    public void setLong(ConfigKey name, Long value) {
-        setString(name.getPropertyKey(), String.valueOf(value));
-    }
-
-    @Override
-    public Float getFloat(String name) {
-        return config.getFloat(name);
-    }
-
-    @Override
-    public Float getFloat(ConfigKey name, boolean useDefault) {
-        return config.getFloat(name, useDefault);
-    }
-
-    @Override
-    public Float getFloat(String name, Float defaultValue) {
-        return config.getFloat(name, defaultValue);
-    }
-
-    @Override
-    public void setFloat(String name, Float value) {
-        setString(name, String.valueOf(value));
-    }
-
-    @Override
-    public void setFloat(ConfigKey name, Float value) {
-        setString(name.getPropertyKey(), String.valueOf(value));
-    }
-
-    @Override
-    public List<String> getList(String name) {
-        return config.getList(name);
-    }
-
-    @Override
-    public List<String> getList(String name, String[] defaultValue) {
-        return config.getList(name, defaultValue);
-    }
-
-    @Override
-    public List<String> getList(ConfigKey name) {
-        return config.getList(name);
-    }
-
-    @Override
-    public Config getConfig(String name) {
-        return config.getConfig(name);
-    }
-
-    @Override
-    public Config getConfig(ConfigKey name) {
-        return config.getConfig(name);
-    }
-
-    @Override
-    public Class<?> getClass(String name) throws ClassNotFoundException {
-        return config.getClass(name);
-    }
-
-    @Override
-    public Class<?> getClass(String name, Class<?> defaultValue)
-            throws ClassNotFoundException {
-        return config.getClass(name, defaultValue);
-    }
-
-    @Override
-    public Class<?> getClass(ConfigKey name, boolean useDefault)
-            throws ClassNotFoundException {
-        return config.getClass(name, useDefault);
-    }
-
-    @Override
-    public <T> T getInstance(String name) throws ClassNotFoundException {
-        return config.getInstance(name);
-    }
-
-    @Override
-    public <T> T getInstance(ConfigKey name) throws ClassNotFoundException {
-        return config.getInstance(name);
-    }
-
-    @Override
-    public <T> T getInstance(String name, Class<T> xface) throws ClassNotFoundException {
-        return config.getInstance(name, xface);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-config/src/main/java/org/apache/kerby/config/Config.java
----------------------------------------------------------------------
diff --git a/kerby-config/src/main/java/org/apache/kerby/config/Config.java b/kerby-config/src/main/java/org/apache/kerby/config/Config.java
deleted file mode 100644
index c71405a..0000000
--- a/kerby-config/src/main/java/org/apache/kerby/config/Config.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *  
- *    http://www.apache.org/licenses/LICENSE-2.0
- *  
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *  
- */
-package org.apache.kerby.config;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Config API to get configuration properties from resources, like XML, Json,
- * ini, Java Properties and Map. It doesn't support writing back. It allows to
- * set configuration properties to ease the preparation of a Config.
- */
-public interface Config {
-    String getResource();
-    Set<String> getNames();
-
-    String getString(String name);
-    String getString(ConfigKey name, boolean useDefault);
-    String getString(String name, String defaultValue);
-
-    /**
-     * Set a string value for the specified property
-     * @param name The property name
-     * @param value The string value
-     */
-    void setString(String name, String value);
-
-    /**
-     * Set a string value for the specified property
-     * @param name The config key name
-     * @param value The string value
-     */
-    void setString(ConfigKey name, String value);
-
-    String getTrimmed(String name);
-    String getTrimmed(ConfigKey name);
-    Boolean getBoolean(String name);
-    Boolean getBoolean(ConfigKey name, boolean useDefault);
-    Boolean getBoolean(String name, Boolean defaultValue);
-
-    /**
-     * Set a boolean value for the specified property
-     * @param name The property name
-     * @param value The boolean value
-     */
-    void setBoolean(String name, Boolean value);
-
-    /**
-     * Set a boolean value for the specified property
-     * @param name The config key name
-     * @param value The boolean value
-     */
-    void setBoolean(ConfigKey name, Boolean value);
-
-    Integer getInt(String name);
-    Integer getInt(ConfigKey name, boolean useDefault);
-    Integer getInt(String name, Integer defaultValue);
-
-    /**
-     * Set an int value for the specified property
-     * @param name The property name
-     * @param value The string value
-     */
-    void setInt(String name, Integer value);
-
-    /**
-     * Set an int value for the specified property
-     * @param name The config key name
-     * @param value The int value
-     */
-    void setInt(ConfigKey name, Integer value);
-
-    Long getLong(String name);
-    Long getLong(ConfigKey name, boolean useDefault);
-    Long getLong(String name, Long defaultValue);
-
-    /**
-     * Set a long value for the specified property
-     * @param name The property name
-     * @param value The long value
-     */
-    void setLong(String name, Long value);
-
-    /**
-     * Set a long value for the specified property
-     * @param name The config key name
-     * @param value The long value
-     */
-    void setLong(ConfigKey name, Long value);
-
-    Float getFloat(String name);
-    Float getFloat(ConfigKey name, boolean useDefault);
-    Float getFloat(String name, Float defaultValue);
-
-    /**
-     * Set a float value for the specified property
-     * @param name The property name
-     * @param value The float value
-     */
-    void setFloat(String name, Float value);
-
-    /**
-     * Set a float value for the specified property
-     * @param name The config key name
-     * @param value The float value
-     */
-    void setFloat(ConfigKey name, Float value);
-
-    List<String> getList(String name);
-    List<String> getList(String name, String[] defaultValue);
-    List<String> getList(ConfigKey name);
-    Config getConfig(String name);
-    Config getConfig(ConfigKey name);
-
-    Class<?> getClass(String name) throws ClassNotFoundException;
-    Class<?> getClass(String name, Class<?> defaultValue) throws ClassNotFoundException;
-    Class<?> getClass(ConfigKey name, boolean useDefault) throws ClassNotFoundException;
-    <T> T getInstance(String name) throws ClassNotFoundException;
-    <T> T getInstance(ConfigKey name) throws ClassNotFoundException;
-    <T> T getInstance(String name, Class<T> xface) throws ClassNotFoundException;
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-config/src/main/java/org/apache/kerby/config/ConfigImpl.java
----------------------------------------------------------------------
diff --git a/kerby-config/src/main/java/org/apache/kerby/config/ConfigImpl.java b/kerby-config/src/main/java/org/apache/kerby/config/ConfigImpl.java
deleted file mode 100644
index ec3090f..0000000
--- a/kerby-config/src/main/java/org/apache/kerby/config/ConfigImpl.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
-
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *
- */
-package org.apache.kerby.config;
-
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class ConfigImpl implements Config {
-
-    private String resource;
-    private Map<String, ConfigObject> properties;
-    /**
-     * Config resources
-     */
-    private List<Config> configs;
-
-    protected ConfigImpl(String resource) {
-        this.resource = resource;
-        this.properties = new HashMap<String, ConfigObject>();
-        this.configs = new ArrayList<Config>(0);
-    }
-
-    protected void reset() {
-        this.properties.clear();
-        this.configs.clear();
-    }
-
-    @Override
-    public String getResource() {
-        return resource;
-    }
-
-    @Override
-    public Set<String> getNames() {
-        Set<String>propNames = new HashSet<String>(properties.keySet());
-        for (Config config : configs) {
-            propNames.addAll(config.getNames());
-        }
-        return propNames;
-    }
-
-    @Override
-    public String getString(String name) {
-        String result = null;
-
-        ConfigObject co = properties.get(name);
-        if (co != null) {
-            result = co.getPropertyValue();
-        } else {
-            for (Config config : configs) {
-                result = config.getString(name);
-                if (result != null) {
-                    break;
-                }
-            }
-        }
-
-        return result;
-    }
-
-    @Override
-    public String getString(ConfigKey name, boolean useDefault) {
-        if (useDefault) {
-            return getString(name.getPropertyKey(),
-                    (String) name.getDefaultValue());
-        }
-        return getString(name.getPropertyKey());
-    }
-
-    @Override
-    public String getString(String name, String defaultValue) {
-        String result = getString(name);
-        if (result == null) {
-            result = defaultValue;
-        }
-        return result;
-    }
-
-    @Override
-    public String getTrimmed(String name) {
-        String result = getString(name);
-        if (null != result) {
-            result = result.trim();
-        }
-        return result;
-    }
-
-    @Override
-    public String getTrimmed(ConfigKey name) {
-        return getTrimmed(name.getPropertyKey());
-    }
-
-    @Override
-    public Integer getInt(String name) {
-        Integer result = null;
-        String value = getTrimmed(name);
-        if (value != null) {
-            result = Integer.valueOf(value);
-        }
-        return result;
-    }
-
-    @Override
-    public Integer getInt(ConfigKey name, boolean useDefault) {
-        if (useDefault) {
-            return getInt(name.getPropertyKey(),
-                    getDefaultValueAs(name, Integer.class));
-        }
-        return getInt(name.getPropertyKey());
-    }
-
-    private <T> T getDefaultValueAs(ConfigKey confKey, Class<T> cls) {
-        Object defValue = confKey.getDefaultValue();
-        if (defValue != null && cls != null) {
-            return (T) defValue;
-        }
-        return null;
-    }
-
-    @Override
-    public Integer getInt(String name, Integer defaultValue) {
-        Integer result = getInt(name);
-        if (result == null) {
-            result = defaultValue;
-        }
-        return result;
-    }
-
-    @Override
-    public void setInt(String name, Integer value) {
-        set(name, String.valueOf(value));
-    }
-
-    @Override
-    public void setInt(ConfigKey name, Integer value) {
-        set(name.getPropertyKey(), String.valueOf(value));
-    }
-
-    @Override
-    public Long getLong(String name) {
-        Long result = null;
-        String value = getTrimmed(name);
-        if (value != null) {
-            result = Long.valueOf(value);
-        }
-        return result;
-    }
-
-    @Override
-    public Long getLong(ConfigKey name, boolean useDefault) {
-        if (useDefault) {
-            return getLong(name.getPropertyKey(),
-                getDefaultValueAs(name, Long.class));
-        }
-        return getLong(name.getPropertyKey());
-    }
-
-    @Override
-    public Long getLong(String name, Long defaultValue) {
-        Long result = getLong(name);
-        if (result == null) {
-            result = defaultValue;
-        }
-        return result;
-    }
-
-    @Override
-    public void setLong(String name, Long value) {
-        set(name, String.valueOf(value));
-    }
-
-    @Override
-    public void setLong(ConfigKey name, Long value) {
-        set(name.getPropertyKey(), String.valueOf(value));
-    }
-
-    @Override
-    public Float getFloat(String name) {
-        Float result = null;
-        String value = getTrimmed(name);
-        if (value != null) {
-            result = Float.valueOf(value);
-        }
-        return result;
-    }
-
-    @Override
-    public Float getFloat(ConfigKey name, boolean useDefault) {
-        if (useDefault) {
-            return getFloat(name.getPropertyKey(),
-                    getDefaultValueAs(name, Float.class));
-        }
-        return getFloat(name.getPropertyKey());
-    }
-
-    @Override
-    public Float getFloat(String name, Float defaultValue) {
-        Float result = getFloat(name);
-        if (result == null) {
-            result = defaultValue;
-        }
-        return result;
-    }
-
-    @Override
-    public void setFloat(String name, Float value) {
-        set(name, String.valueOf(value));
-    }
-
-    @Override
-    public void setFloat(ConfigKey name, Float value) {
-        set(name.getPropertyKey(), String.valueOf(value));
-    }
-
-    @Override
-    public Boolean getBoolean(String name) {
-        Boolean result = null;
-        String value = getTrimmed(name);
-        if (value != null) {
-            result = Boolean.valueOf(value);
-        }
-        return result;
-    }
-
-    @Override
-    public Boolean getBoolean(ConfigKey name, boolean useDefault) {
-        if (useDefault) {
-            return getBoolean(name.getPropertyKey(),
-                    (Boolean) name.getDefaultValue());
-        }
-        return getBoolean(name.getPropertyKey());
-    }
-
-    @Override
-    public Boolean getBoolean(String name, Boolean defaultValue) {
-        Boolean result = getBoolean(name);
-        if (result == null) {
-            result = defaultValue;
-        }
-        return result;
-    }
-
-    @Override
-    public void setBoolean(String name, Boolean value) {
-        set(name, String.valueOf(value));
-    }
-
-    @Override
-    public void setBoolean(ConfigKey name, Boolean value) {
-        set(name.getPropertyKey(), String.valueOf(value));
-    }
-
-    @Override
-    public List<String> getList(String name) {
-        List<String> results = null;
-        ConfigObject co = properties.get(name);
-        if (co != null) {
-            results = co.getListValues();
-        } else {
-            for (Config config : configs) {
-                results = config.getList(name);
-                if (results != null) {
-                    break;
-                }
-            }
-        }
-        return results;
-    }
-
-    @Override
-    public List<String> getList(String name, String[] defaultValue) {
-        List<String> results = getList(name);
-        if (results == null) {
-            results = Arrays.asList(defaultValue);
-        }
-        return results;
-    }
-
-    @Override
-    public List<String> getList(ConfigKey name) {
-        if (name.getDefaultValue() != null) {
-            return getList(name.getPropertyKey(), (String[]) name.getDefaultValue());
-        }
-        return getList(name.getPropertyKey());
-    }
-
-    @Override
-    public Config getConfig(String name) {
-        Config result = null;
-        ConfigObject co = properties.get(name);
-        if (co != null) {
-            result = co.getConfigValue();
-        } else {
-            for (Config config : configs) {
-                result = config.getConfig(name);
-                if (result != null) {
-                    break;
-                }
-            }
-        }
-
-        return result;
-    }
-
-    @Override
-    public Config getConfig(ConfigKey name) {
-        return getConfig(name.getPropertyKey());
-    }
-
-    @Override
-    public Class<?> getClass(String name) throws ClassNotFoundException {
-        Class<?> result = null;
-
-        String valueString = getString(name);
-        if (valueString != null) {
-            Class<?> cls = Class.forName(name);
-            result = cls;
-        }
-
-        return result;
-    }
-
-    @Override
-    public Class<?> getClass(String name, Class<?> defaultValue)
-            throws ClassNotFoundException {
-        Class<?> result = getClass(name);
-        if (result == null) {
-            result = defaultValue;
-        }
-        return result;
-    }
-
-    @Override
-    public Class<?> getClass(ConfigKey name, boolean useDefault)
-            throws ClassNotFoundException {
-        if (useDefault) {
-            return getClass(name.getPropertyKey(),
-                    (Class<?>) name.getDefaultValue());
-        }
-        return getClass(name.getPropertyKey());
-    }
-
-    @Override
-    public <T> T getInstance(String name) throws ClassNotFoundException {
-        return getInstance(name, null);
-    }
-
-    @Override
-    public <T> T getInstance(ConfigKey name) throws ClassNotFoundException {
-        return getInstance(name.getPropertyKey());
-    }
-
-    @Override
-    public <T> T getInstance(String name, Class<T> xface) throws ClassNotFoundException {
-        T result = null;
-
-        Class<?> cls = getClass(name, null);
-        if (xface != null && !xface.isAssignableFrom(cls)) {
-            throw new RuntimeException(cls + " does not implement " + xface);
-        }
-        try {
-            result = (T) cls.newInstance();
-        } catch (Exception e) {
-            throw new RuntimeException("Failed to create instance with class " + cls.getName());
-        }
-
-        return result;
-    }
-
-
-    @Override
-    public void setString(String name, String value) {
-        set(name, value);
-    }
-
-    @Override
-    public void setString(ConfigKey name, String value) {
-        set(name.getPropertyKey(), value);
-    }
-
-    protected void set(String name, String value) {
-        ConfigObject co = new ConfigObject(value);
-        set(name, co);
-    }
-
-    protected void set(String name, Config value) {
-        ConfigObject co = new ConfigObject(value);
-        set(name, co);
-    }
-
-    protected void set(String name, ConfigObject value) {
-        this.properties.put(name, value);
-    }
-
-    protected void add(Config config) {
-        if (config != null) {
-            if (this == config) {
-                throw new IllegalArgumentException(
-                        "You can not add a config to itself");
-            }
-            this.configs.add(config);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-config/src/main/java/org/apache/kerby/config/ConfigKey.java
----------------------------------------------------------------------
diff --git a/kerby-config/src/main/java/org/apache/kerby/config/ConfigKey.java b/kerby-config/src/main/java/org/apache/kerby/config/ConfigKey.java
deleted file mode 100644
index 4424f22..0000000
--- a/kerby-config/src/main/java/org/apache/kerby/config/ConfigKey.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *  
- *    http://www.apache.org/licenses/LICENSE-2.0
- *  
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *  
- */
-package org.apache.kerby.config;
-
-public interface ConfigKey {
-    String getPropertyKey();
-    Object getDefaultValue();
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-config/src/main/java/org/apache/kerby/config/ConfigLoader.java
----------------------------------------------------------------------
diff --git a/kerby-config/src/main/java/org/apache/kerby/config/ConfigLoader.java b/kerby-config/src/main/java/org/apache/kerby/config/ConfigLoader.java
deleted file mode 100644
index 6282559..0000000
--- a/kerby-config/src/main/java/org/apache/kerby/config/ConfigLoader.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *  
- *    http://www.apache.org/licenses/LICENSE-2.0
- *  
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *  
- */
-package org.apache.kerby.config;
-
-public abstract class ConfigLoader {
-    private Resource resource;
-    private ConfigImpl config;
-
-    protected void setResource(Resource resource) {
-        this.resource = resource;
-    }
-
-    protected void setConfig(ConfigImpl config) {
-        this.config = config;
-    }
-
-    public Config load() {
-        if (config == null) {
-            config = new ConfigImpl(resource.getName());
-        }
-        config.reset();
-
-        try {
-            loadConfig(config, resource);
-        } catch (Exception e) {
-            throw new RuntimeException("Failed to load " + ConfigLoader.class.getPackage().getName(), e);
-        }
-
-        return this.config;
-    }
-
-    protected abstract void loadConfig(ConfigImpl config, Resource resource) throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-config/src/main/java/org/apache/kerby/config/ConfigObject.java
----------------------------------------------------------------------
diff --git a/kerby-config/src/main/java/org/apache/kerby/config/ConfigObject.java b/kerby-config/src/main/java/org/apache/kerby/config/ConfigObject.java
deleted file mode 100644
index 2be3972..0000000
--- a/kerby-config/src/main/java/org/apache/kerby/config/ConfigObject.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *  
- *    http://www.apache.org/licenses/LICENSE-2.0
- *  
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *  
- */
-package org.apache.kerby.config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ConfigObject {
-    protected static enum ValueType { PROPERTY, LIST, CONFIG };
-
-    private ValueType valueType;
-    private Object value;
-
-    public ConfigObject(String value) {
-        this.value = value;
-        this.valueType = ValueType.PROPERTY;
-    }
-
-    public ConfigObject(String[] values) {
-        List<String> valuesList = new ArrayList<String>();
-        for (String v : values) {
-            valuesList.add(v);
-        }
-
-        this.value = valuesList;
-        this.valueType = ValueType.LIST;
-    }
-
-    public ConfigObject(List<String> values) {
-        if (values != null) {
-            this.value = new ArrayList<String>(values);
-        } else {
-            this.value = new ArrayList<String>();
-        }
-        this.valueType = ValueType.LIST;
-    }
-
-    public ConfigObject(Config value) {
-        this.value = value;
-        this.valueType = ValueType.CONFIG;
-    }
-
-    public String getPropertyValue() {
-        String result = null;
-        if (valueType == ValueType.PROPERTY) {
-            result = (String) value;
-        }
-        return result;
-    }
-
-    @SuppressWarnings("unchecked")
-    public List<String> getListValues() {
-        List<String> results = null;
-        if (valueType == ValueType.LIST && value instanceof List<?>) {
-            results = (List<String>) value;
-        }
-
-        return results;
-    }
-
-    public Config getConfigValue() {
-        Config result = null;
-        if (valueType == ValueType.CONFIG) {
-            result = (Config) value;
-        }
-        return result;
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-config/src/main/java/org/apache/kerby/config/Configurable.java
----------------------------------------------------------------------
diff --git a/kerby-config/src/main/java/org/apache/kerby/config/Configurable.java b/kerby-config/src/main/java/org/apache/kerby/config/Configurable.java
deleted file mode 100644
index fd41dab..0000000
--- a/kerby-config/src/main/java/org/apache/kerby/config/Configurable.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- *
- */
-package org.apache.kerby.config;
-
-/**
- * An interface for constructs that desire to be configurable thru the framework.
- */
-public interface Configurable {
-
-    void setConfig(Config config);
-
-    Config getConfig();
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-config/src/main/java/org/apache/kerby/config/Configured.java
----------------------------------------------------------------------
diff --git a/kerby-config/src/main/java/org/apache/kerby/config/Configured.java b/kerby-config/src/main/java/org/apache/kerby/config/Configured.java
deleted file mode 100644
index eadfb54..0000000
--- a/kerby-config/src/main/java/org/apache/kerby/config/Configured.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- *
- */
-package org.apache.kerby.config;
-
-/**
- * An abstract for constructs that desire to be configurable.
- */
-public class Configured implements Configurable {
-    private Config config;
-
-    public Configured() {
-        config = null;
-    }
-
-    public Configured(Config config) {
-        this.config = config;
-    }
-
-    @Override
-    public Config getConfig() {
-        return config;
-    }
-
-    @Override
-    public void setConfig(Config config) {
-        this.config = config;
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-config/src/main/java/org/apache/kerby/config/IniConfigLoader.java
----------------------------------------------------------------------
diff --git a/kerby-config/src/main/java/org/apache/kerby/config/IniConfigLoader.java b/kerby-config/src/main/java/org/apache/kerby/config/IniConfigLoader.java
deleted file mode 100644
index 5c673b2..0000000
--- a/kerby-config/src/main/java/org/apache/kerby/config/IniConfigLoader.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *
- */
-package org.apache.kerby.config;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-
-public class IniConfigLoader extends ConfigLoader {
-    private static final String COMMENT_SYMBOL = "#";
-
-    private ConfigImpl rootConfig;
-    private ConfigImpl currentConfig;
-
-    /**
-     *  Load configs form the INI configuration format file.
-     */
-    @Override
-    protected void loadConfig(ConfigImpl config, Resource resource) throws IOException {
-        rootConfig = config;
-        currentConfig = config;
-
-        InputStream is = (InputStream) resource.getResource();
-        BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
-
-        String line;
-        while ((line = reader.readLine()) != null) {
-            parseLine(line);
-        }
-        reader.close();
-    }
-
-    private void parseLine(String line) {
-        if (line == null) {
-            return;
-        }
-        
-        line = line.trim();
-
-        if (line.startsWith(COMMENT_SYMBOL)) {
-            return;
-        }
-
-        if (line.matches("\\[.*\\]")) {
-            String subConfigName = line.replaceFirst("\\[(.*)\\]", "$1");
-            ConfigImpl subConfig = new ConfigImpl(subConfigName);
-            rootConfig.set(subConfigName, subConfig);
-            currentConfig = subConfig;
-        } else if (line.matches(".*=.*")) {
-            int i = line.indexOf('=');
-            String name = line.substring(0, i).trim();
-            String value = line.substring(i + 1).trim();
-            currentConfig.set(name, value);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-config/src/main/java/org/apache/kerby/config/JsonConfigLoader.java
----------------------------------------------------------------------
diff --git a/kerby-config/src/main/java/org/apache/kerby/config/JsonConfigLoader.java b/kerby-config/src/main/java/org/apache/kerby/config/JsonConfigLoader.java
deleted file mode 100644
index 5a51175..0000000
--- a/kerby-config/src/main/java/org/apache/kerby/config/JsonConfigLoader.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *  
- *    http://www.apache.org/licenses/LICENSE-2.0
- *  
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *  
- */
-package org.apache.kerby.config;
-
-public class JsonConfigLoader extends ConfigLoader {
-    @Override
-    protected void loadConfig(ConfigImpl config, Resource resource) {
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9e4dbd6e/kerby-config/src/main/java/org/apache/kerby/config/MapConfigLoader.java
----------------------------------------------------------------------
diff --git a/kerby-config/src/main/java/org/apache/kerby/config/MapConfigLoader.java b/kerby-config/src/main/java/org/apache/kerby/config/MapConfigLoader.java
deleted file mode 100644
index 3ba5d4c..0000000
--- a/kerby-config/src/main/java/org/apache/kerby/config/MapConfigLoader.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *  
- *    http://www.apache.org/licenses/LICENSE-2.0
- *  
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *  
- */
-package org.apache.kerby.config;
-
-import java.util.Iterator;
-import java.util.Map;
-
-public class MapConfigLoader extends ConfigLoader {
-    @Override
-    protected void loadConfig(ConfigImpl config, Resource resource) {
-        @SuppressWarnings("unchecked")
-        Map<String, Object> mapConfig = (Map<String, Object>) resource.getResource();
-        Iterator<Map.Entry<String, Object>> iter = mapConfig.entrySet().iterator();
-        if (iter.hasNext()) {
-            Map.Entry entry = iter.next();
-            if (entry.getValue() instanceof String) {
-                //insert StringMap
-                loadStringMap(config, mapConfig);
-            }   else {
-                //insert objectMap
-                loadObjectMap(config, mapConfig);
-            }
-        }
-    }
-
-    private void loadStringMap(ConfigImpl config, Map<String, Object> stringMap) {
-        for (Map.Entry<String, Object> entry: stringMap.entrySet()) {
-            config.set(entry.getKey(), (String) entry.getValue());
-        }
-    }
-
-    private void loadObjectMap(ConfigImpl config, Map<String, Object> objectMap) {
-        for (Map.Entry<String, Object> entry: objectMap.entrySet()) {
-            String key = entry.getKey();
-            Object value = entry.getValue();
-
-            if (value instanceof Map) {
-                ConfigImpl subConfig = new ConfigImpl(key); //new section
-                loadSubmap(subConfig, (Map) value);
-                config.add(subConfig);
-            }   else {
-                throw new RuntimeException("Unable to resolve config:" + key);
-            }
-        }
-    }
-
-    private void loadSubmap(ConfigImpl config, Map<String, Object> map) {
-        for (Map.Entry<String, Object> entry: map.entrySet()) {
-            String key = entry.getKey();
-            Object value = entry.getValue();
-
-            if (value instanceof String) {
-                config.set(key, (String) value);
-            }
-            if (value instanceof Map) {
-                ConfigImpl subConfig = new ConfigImpl(key);
-                loadSubmap(subConfig, (Map) value);
-                config.add(subConfig);
-            }
-        }
-    }
-}


Mime
View raw message