directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject [04/42] directory-kerberos git commit: Initially import Haox codebase (https://github.com/drankye/haox)
Date Sat, 10 Jan 2015 13:30:48 GMT
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/DecryptionTest.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/DecryptionTest.java b/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/DecryptionTest.java
new file mode 100644
index 0000000..e77ac24
--- /dev/null
+++ b/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/DecryptionTest.java
@@ -0,0 +1,502 @@
+package org.apache.kerberos.kerb.crypto;
+
+import org.apache.kerberos.kerb.crypto.enc.provider.*;
+import org.apache.kerberos.kerb.crypto.key.AesKeyMaker;
+import org.apache.kerberos.kerb.crypto.key.CamelliaKeyMaker;
+import org.apache.kerberos.kerb.crypto.key.Des3KeyMaker;
+import org.apache.kerberos.kerb.crypto.key.KeyMaker;
+import org.apache.kerberos.kerb.spec.common.EncryptionKey;
+import org.apache.kerberos.kerb.spec.common.EncryptionType;
+import org.apache.kerberos.kerb.spec.common.KeyUsage;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Decryption test with known ciphertexts.
+ */
+public class DecryptionTest {
+
+    static class TestCase {
+        EncryptionType encType;
+        String plainText;
+        int keyUsage;
+        String key;
+        String cipher;
+
+        TestCase(EncryptionType encType, String plainText,
+                 int keyUsage, String key, String cipher) {
+            this.encType = encType;
+            this.plainText = plainText;
+            this.keyUsage = keyUsage;
+            this.key = key;
+            this.cipher = cipher;
+        }
+    }
+
+    static TestCase[] testCases = new TestCase[] {
+            new TestCase(
+                    EncryptionType.DES_CBC_CRC,
+                    "", 0,
+                    "45E6087CDF138FB5",
+                    "28F6B09A012BCCF72FB05122B2839E6E"
+            ),
+            new TestCase(
+                    EncryptionType.DES_CBC_CRC,
+                    "1", 1,
+                    "92A7155810586B2F",
+                    "B4C871C2F3E7BF7605EFD62F2EEEC205"
+            ),
+            new TestCase(
+                    EncryptionType.DES_CBC_CRC,
+                    "9 bytesss", 2,
+                    "A4B9514A61646423",
+                    "5F14C35178D33D7CDE0EC169C623CC83" +
+                            "21B7B8BD34EA7EFE"
+            ),
+            new TestCase(
+                    EncryptionType.DES_CBC_CRC,
+                    "13 bytes byte", 3,
+                    "2F16A2A7FDB05768",
+                    "0B588E38D971433C9D86D8BAEBF63E4C" +
+                            "1A01666E76D8A54A3293F72679ED88C9"
+            ),
+            new TestCase(
+                    EncryptionType.DES_CBC_CRC,
+                    "30 bytes bytes bytes bytes byt", 4,
+                    "BC8F70FD2097D67C",
+                    "38D632D2C20A7C2EA250FC8ECE42938E" +
+                            "92A9F5D302502665C1A33729C1050DC2" +
+                            "056298FBFB1682CEEB65E59204FDA7DF"
+            ),
+            new TestCase(
+                    EncryptionType.DES_CBC_MD4,
+                    "", 0,
+                    "13EF45D0D6D9A15D",
+                    "1FB202BF07AF3047FB7801E588568686" +
+                            "BA63D78BE3E87DC7"
+            ),
+            new TestCase(
+                    EncryptionType.DES_CBC_MD4,
+                    "1", 1,
+                    "64688654DC269E67",
+                    "1F6CB9CECB73F755ABFDB3D565BD31D5" +
+                            "A2E64BFE44C491E20EEBE5BD20E4D2A9"
+            ),
+            new TestCase(
+                    EncryptionType.DES_CBC_MD4,
+                    "9 bytesss", 2,
+                    "6804FB26DF8A4C32",
+                    "08A53D62FEC3338AD1D218E60DBDD3B2" +
+                            "12940679D125E0621B3BAB4680CE0367" +
+                            "6A2C420E9BE784EB"
+            ),
+            new TestCase(
+                    EncryptionType.DES_CBC_MD4,
+                    "13 bytes byte", 3,
+                    "234A436EC72FA80B",
+                    "17CD45E14FF06B2840A6036E9AA7A414" +
+                            "4E29768144A0C1827D8C4BC7C9906E72" +
+                            "CD4DC328F6648C99"
+            ),
+            new TestCase(
+                    EncryptionType.DES_CBC_MD4,
+                    "30 bytes bytes bytes bytes byt", 4,
+                    "1FD5F74334C4FB8C",
+                    "51134CD8951E9D57C0A36053E04CE03E" +
+                            "CB8422488FDDC5C074C4D85E60A2AE42" +
+                            "3C3C701201314F362CB07448091679C6" +
+                            "A496C11D7B93C71B"
+            ),
+            new TestCase(
+                    EncryptionType.DES_CBC_MD5,
+                    "", 0,
+                    "4A545E0BF7A22631",
+                    "784CD81591A034BE82556F56DCA3224B" +
+                            "62D9956FA90B1B93"
+            ),
+            new TestCase(
+                    EncryptionType.DES_CBC_MD5,
+                    "1", 1,
+                    "D5804A269DC4E645",
+                    "FFA25C7BE287596BFE58126E90AAA0F1" +
+                            "2D9A82A0D86DF6D5F9074B6B399E7FF1"
+            ),
+            new TestCase(
+                    EncryptionType.DES_CBC_MD5,
+                    "9 bytesss", 2,
+                    "C8312F7F83EA4640",
+                    "E7850337F2CC5E3F35CE3D69E2C32986" +
+                            "38A7AA44B878031E39851E47C15B5D0E" +
+                            "E7E7AC54DE111D80"
+            ),
+            new TestCase(
+                    EncryptionType.DES_CBC_MD5,
+                    "13 bytes byte", 3,
+                    "7FDA3E62AD8AF18C",
+                    "D7A8032E19994C928777506595FBDA98" +
+                            "83158A8514548E296E911C29F465C672" +
+                            "366000558BFC2E88"
+            ),
+            new TestCase(
+                    EncryptionType.DES_CBC_MD5,
+                    "30 bytes bytes bytes bytes byt", 4,
+                    "D3D6832970A73752",
+                    "8A48166A4C6FEAE607A8CF68B381C075" +
+                            "5E402B19DBC0F81A7D7CA19A25E05223" +
+                            "F6064409BF5A4F50ACD826639FFA7673" +
+                            "FD324EC19E429502"
+            ),
+            new TestCase(
+                    EncryptionType.DES3_CBC_SHA1,
+                    "", 0,
+                    "7A25DF8992296DCEDA0E135BC4046E23" +
+                            "75B3C14C98FBC162",
+                    "548AF4D504F7D723303F12175FE8386B" +
+                            "7B5335A967BAD61F3BF0B143"
+            ),
+            new TestCase(
+                    EncryptionType.DES3_CBC_SHA1,
+                    "1", 1,
+                    "BC0783891513D5CE57BC138FD3C11AE6" +
+                            "40452385322962B6",
+                    "9C3C1DBA4747D85AF2916E4745F2DCE3" +
+                            "8046796E5104BCCDFB669A91D44BC356" +
+                            "660945C7"
+            ),
+            new TestCase(
+                    EncryptionType.DES3_CBC_SHA1,
+                    "9 bytesss", 2,
+                    "2FD0F725CE04100D2FC8A18098831F85" +
+                            "0B45D9EF850BD920",
+                    "CF9144EBC8697981075A8BAD8D74E5D7" +
+                            "D591EB7D9770C7ADA25EE8C5B3D69444" +
+                            "DFEC79A5B7A01482D9AF74E6"
+            ),
+            new TestCase(
+                    EncryptionType.DES3_CBC_SHA1,
+                    "13 bytes byte", 3,
+                    "0DD52094E0F41CECCB5BE510A764B351" +
+                            "76E3981332F1E598",
+                    "839A17081ECBAFBCDC91B88C6955DD3C" +
+                            "4514023CF177B77BF0D0177A16F705E8" +
+                            "49CB7781D76A316B193F8D30"
+            ),
+            new TestCase(
+                    EncryptionType.DES3_CBC_SHA1,
+                    "30 bytes bytes bytes bytes byt", 4,
+                    "F11686CBBC9E23EA54FECD2A3DCDFB20" +
+                            "B6FE98BF2645C4C4",
+                    "89433E83FD0EA3666CFFCD18D8DEEBC5" +
+                            "3B9A34EDBEB159D9F667C6C2B9A96440" +
+                            "1D55E7E9C68D648D65C3AA84FFA3790C" +
+                            "14A864DA8073A9A95C4BA2BC"
+            ),
+            new TestCase(
+                    EncryptionType.ARCFOUR_HMAC,
+                    "", 0,
+                    "F81FEC39255F5784E850C4377C88BD85",
+                    "02C1EB15586144122EC717763DD348BF" +
+                            "00434DDC6585954C"
+            ),
+            new TestCase(
+                    EncryptionType.ARCFOUR_HMAC,
+                    "1", 1,
+                    "67D1300D281223867F9647FF48721273",
+                    "6156E0CC04E0A0874F9FDA008F498A7A" +
+                            "DBBC80B70B14DDDBC0"
+            ),
+            new TestCase(
+                    EncryptionType.ARCFOUR_HMAC,
+                    "9 bytesss", 2,
+                    "3E40AB6093695281B3AC1A9304224D98",
+                    "0F9AD121D99D4A09448E4F1F718C4F5C" +
+                            "BE6096262C66F29DF232A87C9F98755D" +
+                            "55"
+            ),
+            new TestCase(
+                    EncryptionType.ARCFOUR_HMAC,
+                    "13 bytes byte", 3,
+                    "4BA2FBF0379FAED87A254D3B353D5A7E",
+                    "612C57568B17A70352BAE8CF26FB9459" +
+                            "A6F3353CD35FD439DB3107CBEC765D32" +
+                            "6DFC04C1DD"
+            ),
+            new TestCase(
+                    EncryptionType.ARCFOUR_HMAC,
+                    "30 bytes bytes bytes bytes byt", 4,
+                    "68F263DB3FCE15D031C9EAB02D67107A",
+                    "95F9047C3AD75891C2E9B04B16566DC8" +
+                            "B6EB9CE4231AFB2542EF87A7B5A0F260" +
+                            "A99F0460508DE0CECC632D07C354124E" +
+                            "46C5D2234EB8"
+            ),
+            new TestCase(
+                    EncryptionType.ARCFOUR_HMAC_EXP,
+                    "", 0,
+                    "F7D3A155AF5E238A0B7A871A96BA2AB2",
+                    "2827F0E90F62E7460C4E2FB39F9657BA" +
+                            "8BFAA991D7FDADFF"
+            ),
+            new TestCase(
+                    EncryptionType.ARCFOUR_HMAC_EXP,
+                    "1", 1,
+                    "DEEAA0607DB799E2FDD6DB2986BB8D65",
+                    "3DDA392E2E275A4D75183FA6328A0A4E" +
+                            "6B752DF6CD2A25FA4E"
+            ),
+            new TestCase(
+                    EncryptionType.ARCFOUR_HMAC_EXP,
+                    "9 bytesss", 2,
+                    "33AD7FC2678615569B2B09836E0A3AB6",
+                    "09D136AC485D92644EC6701D6A0D03E8" +
+                            "982D7A3CA7EFD0F8F4F83660EF4277BB" +
+                            "81"
+            ),
+            new TestCase(
+                    EncryptionType.ARCFOUR_HMAC_EXP,
+                    "13 bytes byte", 3,
+                    "39F25CD4F0D41B2B2D9D300FCB2981CB",
+                    "912388D7C07612819E3B640FF5CECDAF" +
+                            "72E5A59DF10F1091A6BEC39CAAD748AF" +
+                            "9BD2D8D546"
+            ),
+            new TestCase(
+                    EncryptionType.ARCFOUR_HMAC_EXP,
+                    "30 bytes bytes bytes bytes byt", 4,
+                    "9F725542D9F72AA1F386CBE7896984FC",
+                    "78B35A08B08BE265AEB4145F076513B6" +
+                            "B56EFED3F7526574AF74F7D2F9BAE96E" +
+                            "ABB76F2D87386D2E93E3A77B99919F1D" +
+                            "976490E2BD45"
+            ),
+            new TestCase(
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "", 0,
+                    "5A5C0F0BA54F3828B2195E66CA24A289",
+                    "49FF8E11C173D9583A3254FBE7B1F1DF" +
+                            "36C538E8416784A1672E6676"
+            ),
+            new TestCase(
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "1", 1,
+                    "98450E3F3BAA13F5C99BEB936981B06F",
+                    "F86742F537B35DC2174A4DBAA920FAF9" +
+                            "042090B065E1EBB1CAD9A65394"
+            ),
+            new TestCase(
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "9 bytesss", 2,
+                    "9062430C8CDA3388922E6D6A509F5B7A",
+                    "68FB9679601F45C78857B2BF820FD6E5" +
+                            "3ECA8D42FD4B1D7024A09205ABB7CD2E" +
+                            "C26C355D2F"
+            ),
+            new TestCase(
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "13 bytes byte", 3,
+                    "033EE6502C54FD23E27791E987983827",
+                    "EC366D0327A933BF49330E650E49BC6B" +
+                            "974637FE80BF532FE51795B4809718E6" +
+                            "194724DB948D1FD637"
+            ),
+            new TestCase(
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "30 bytes bytes bytes bytes byt", 4,
+                    "DCEEB70B3DE76562E689226C76429148",
+                    "C96081032D5D8EEB7E32B4089F789D0F" +
+                            "AA481DEA74C0F97CBF3146DDFCF8E800" +
+                            "156ECB532FC203E30FF600B63B350939" +
+                            "FECE510F02D7FF1E7BAC"
+            ),
+            new TestCase(
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "", 0,
+                    "17F275F2954F2ED1F90C377BA7F4D6A3" +
+                            "69AA0136E0BF0C927AD6133C693759A9",
+                    "E5094C55EE7B38262E2B044280B06937" +
+                            "9A95BF95BD8376FB3281B435"
+            ),
+            new TestCase(
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "1", 1,
+                    "B9477E1FF0329C0050E20CE6C72D2DFF" +
+                            "27E8FE541AB0954429A9CB5B4F7B1E2A",
+                    "406150B97AEB76D43B36B62CC1ECDFBE" +
+                            "6F40E95755E0BEB5C27825F3A4"
+            ),
+            new TestCase(
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "9 bytesss", 2,
+                    "B1AE4CD8462AFF1677053CC9279AAC30" +
+                            "B796FB81CE21474DD3DDBCFEA4EC76D7",
+                    "09957AA25FCAF88F7B39E4406E633012" +
+                            "D5FEA21853F6478DA7065CAEF41FD454" +
+                            "A40824EEC5"
+            ),
+            new TestCase(
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "13 bytes byte", 3,
+                    "E5A72BE9B7926C1225BAFEF9C1872E7B" +
+                            "A4CDB2B17893D84ABD90ACDD8764D966",
+                    "D8F1AAFEEC84587CC3E700A774E56651" +
+                            "A6D693E174EC4473B5E6D96F80297A65" +
+                            "3FB818AD893E719F96"
+            ),
+            new TestCase(
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "30 bytes bytes bytes bytes byt", 4,
+                    "F1C795E9248A09338D82C3F8D5B56704" +
+                            "0B0110736845041347235B1404231398",
+                    "D1137A4D634CFECE924DBC3BF6790648" +
+                            "BD5CFF7DE0E7B99460211D0DAEF3D79A" +
+                            "295C688858F3B34B9CBD6EEBAE81DAF6" +
+                            "B734D4D498B6714F1C1D"
+            ),
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "", 0,
+                    "1DC46A8D763F4F93742BCBA3387576C3",
+                    "C466F1871069921EDB7C6FDE244A52DB" +
+                            "0BA10EDC197BDB8006658CA3CCCE6EB8"
+            ),
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "1", 1,
+                    "5027BC231D0F3A9D23333F1CA6FDBE7C",
+                    "842D21FD950311C0DD464A3F4BE8D6DA" +
+                            "88A56D559C9B47D3F9A85067AF661559" +
+                            "B8"
+            ),
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "9 bytesss", 2,
+                    "A1BB61E805F9BA6DDE8FDBDDC05CDEA0",
+                    "619FF072E36286FF0A28DEB3A352EC0D" +
+                            "0EDF5C5160D663C901758CCF9D1ED33D" +
+                            "71DB8F23AABF8348A0"
+            ),
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "13 bytes byte", 3,
+                    "2CA27A5FAF5532244506434E1CEF6676",
+                    "B8ECA3167AE6315512E59F98A7C50020" +
+                            "5E5F63FF3BB389AF1C41A21D640D8615" +
+                            "C9ED3FBEB05AB6ACB67689B5EA"
+            ),
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "30 bytes bytes bytes bytes byt", 4,
+                    "7824F8C16F83FF354C6BF7515B973F43",
+                    "A26A3905A4FFD5816B7B1E27380D0809" +
+                            "0C8EC1F304496E1ABDCD2BDCD1DFFC66" +
+                            "0989E117A713DDBB57A4146C1587CBA4" +
+                            "356665591D2240282F5842B105A5"
+            ),
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "", 0,
+                    "B61C86CC4E5D2757545AD423399FB703" +
+                            "1ECAB913CBB900BD7A3C6DD8BF92015B",
+                    "03886D03310B47A6D8F06D7B94D1DD83" +
+                            "7ECCE315EF652AFF620859D94A259266"
+            ),
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "1", 1,
+                    "1B97FE0A190E2021EB30753E1B6E1E77" +
+                            "B0754B1D684610355864104963463833",
+                    "2C9C1570133C99BF6A34BC1B0212002F" +
+                            "D194338749DB4135497A347CFCD9D18A12"
+            ),
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "9 bytesss", 2,
+                    "32164C5B434D1D1538E4CFD9BE8040FE" +
+                            "8C4AC7ACC4B93D3314D2133668147A05",
+                    "9C6DE75F812DE7ED0D28B2963557A115" +
+                            "640998275B0AF5152709913FF52A2A9C" +
+                            "8E63B872F92E64C839"
+            ),
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "13 bytes byte", 3,
+                    "B038B132CD8E06612267FAB7170066D8" +
+                            "8AECCBA0B744BFC60DC89BCA182D0715",
+                    "EEEC85A9813CDC536772AB9B42DEFC57" +
+                            "06F726E975DDE05A87EB5406EA324CA1" +
+                            "85C9986B42AABE794B84821BEE"
+            ),
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "30 bytes bytes bytes bytes byt", 4,
+                    "CCFCD349BF4C6677E86E4B02B8EAB924" +
+                            "A546AC731CF9BF6989B996E7D6BFBBA7",
+                    "0E44680985855F2D1F1812529CA83BFD" +
+                            "8E349DE6FD9ADA0BAAA048D68E265FEB" +
+                            "F34AD1255A344999AD37146887A6C684" +
+                            "5731AC7F46376A0504CD06571474"
+            )
+    };
+
+    static KeyMaker getKeyMaker(EncryptionType encType) {
+        switch (encType) {
+            case DES3_CBC_SHA1:
+                return new Des3KeyMaker(new Des3Provider());
+            case AES128_CTS_HMAC_SHA1_96:
+                return new AesKeyMaker(new Aes128Provider());
+            case AES256_CTS_HMAC_SHA1_96:
+                return new AesKeyMaker(new Aes256Provider());
+            case CAMELLIA128_CTS_CMAC:
+                return new CamelliaKeyMaker(new Camellia128Provider());
+            case CAMELLIA256_CTS_CMAC:
+                return new CamelliaKeyMaker(new Camellia256Provider());
+            default:
+                return null;
+        }
+    }
+
+    @Test
+    public void testDecryption() {
+        boolean overallResult = true;
+
+        for (TestCase tc : testCases) {
+            System.err.println("Decryption test for " + tc.encType.getName());
+            if (! EncryptionHandler.isImplemented(tc.encType)) {
+                System.err.println("Key type not supported yet: " + tc.encType.getName());
+                continue;
+            }
+
+            try {
+                if (! testWith(tc)) {
+                    overallResult = false;
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+                overallResult = false;
+            }
+        }
+
+        if (!overallResult) {
+            Assert.fail();
+        }
+    }
+
+    private boolean testWith(TestCase testCase) throws Exception {
+        KeyUsage ku = KeyUsage.fromValue(testCase.keyUsage);
+
+        byte[] cipherBytes = TestUtil.hex2bytes(testCase.cipher);
+        byte[] keyBytes = TestUtil.hex2bytes(testCase.key);
+
+        EncryptionKey encKey = new EncryptionKey(testCase.encType, keyBytes);
+        byte[] decrypted = EncryptionHandler.decrypt(cipherBytes, encKey, ku);
+        String plainText = new String(decrypted);
+
+        if (! plainText.startsWith(testCase.plainText)) {
+            System.err.println("failed with:");
+            System.err.println("plainText:[" + plainText + "]");
+            System.err.println("answer   :[" + testCase.plainText + "]");
+            return false;
+        }
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/KeyDeriveTest.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/KeyDeriveTest.java b/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/KeyDeriveTest.java
new file mode 100644
index 0000000..2ae74d0
--- /dev/null
+++ b/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/KeyDeriveTest.java
@@ -0,0 +1,208 @@
+package org.apache.kerberos.kerb.crypto;
+
+import org.apache.kerberos.kerb.crypto.enc.provider.*;
+import org.apache.kerberos.kerb.crypto.key.AesKeyMaker;
+import org.apache.kerberos.kerb.crypto.key.CamelliaKeyMaker;
+import org.apache.kerberos.kerb.crypto.key.Des3KeyMaker;
+import org.apache.kerberos.kerb.crypto.key.DkKeyMaker;
+import org.apache.kerberos.kerb.spec.common.EncryptionType;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+/**
+ * Key derivation test with known values.
+ */
+public class KeyDeriveTest {
+
+    static class TestCase {
+        EncryptionType encType;
+        String inkey;
+        String constant;
+        String answer;
+
+        TestCase(EncryptionType encType, String inkey,
+                 String constant, String answer) {
+            this.encType = encType;
+            this.inkey = inkey;
+            this.constant = constant;
+            this.answer = answer;
+        }
+    }
+
+    static TestCase[] testCases = new TestCase[] {
+    /* Kc, Ke, Kei for a DES3 key */
+            new TestCase(
+                    EncryptionType.DES3_CBC_SHA1,
+                    "850BB51358548CD05E86768C313E3BFE" +
+                            "F7511937DCF72C3E",
+                    "0000000299",
+                    "F78C496D16E6C2DAE0E0B6C24057A84C" +
+                            "0426AEEF26FD6DCE"
+            ),
+            new TestCase(
+                    EncryptionType.DES3_CBC_SHA1,
+                    "850BB51358548CD05E86768C313E3BFE" +
+                            "F7511937DCF72C3E",
+                    "00000002AA",
+                    "5B5723D0B634CB684C3EBA5264E9A70D" +
+                            "52E683231AD3C4CE"
+            ),
+            new TestCase(
+                    EncryptionType.DES3_CBC_SHA1,
+                    "850BB51358548CD05E86768C313E3BFE" +
+                            "F7511937DCF72C3E",
+                    "0000000255",
+                    "A77C94980E9B7345A81525C423A737CE" +
+                            "67F4CD91B6B3DA45"
+            ),
+
+    /* Kc, Ke, Ki for an AES-128 key */
+            new TestCase(
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "42263C6E89F4FC28B8DF68EE09799F15",
+                    "0000000299",
+                    "34280A382BC92769B2DA2F9EF066854B"
+            ),
+            new TestCase(
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "42263C6E89F4FC28B8DF68EE09799F15",
+                    "00000002AA",
+                    "5B14FC4E250E14DDF9DCCF1AF6674F53"
+            ),
+            new TestCase(
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "42263C6E89F4FC28B8DF68EE09799F15",
+                    "0000000255",
+                    "4ED31063621684F09AE8D89991AF3E8F"
+            ),
+
+    /* Kc, Ke, Ki for an AES-256 key */
+            new TestCase(
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "FE697B52BC0D3CE14432BA036A92E65B" +
+                            "BB52280990A2FA27883998D72AF30161",
+                    "0000000299",
+                    "BFAB388BDCB238E9F9C98D6A878304F0" +
+                            "4D30C82556375AC507A7A852790F4674"
+            ),
+            new TestCase(
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "FE697B52BC0D3CE14432BA036A92E65B" +
+                            "BB52280990A2FA27883998D72AF30161",
+                    "00000002AA",
+                    "C7CFD9CD75FE793A586A542D87E0D139" +
+                            "6F1134A104BB1A9190B8C90ADA3DDF37"
+            ),
+            new TestCase(
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "FE697B52BC0D3CE14432BA036A92E65B" +
+                            "BB52280990A2FA27883998D72AF30161",
+                    "0000000255",
+                    "97151B4C76945063E2EB0529DC067D97" +
+                            "D7BBA90776D8126D91F34F3101AEA8BA"
+            ),
+
+    /* Kc, Ke, Ki for a Camellia-128 key */
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "57D0297298FFD9D35DE5A47FB4BDE24B",
+                    "0000000299",
+                    "D155775A209D05F02B38D42A389E5A56"
+            ),
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "57D0297298FFD9D35DE5A47FB4BDE24B",
+                    "00000002AA",
+                    "64DF83F85A532F17577D8C37035796AB"
+            ),
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "57D0297298FFD9D35DE5A47FB4BDE24B",
+                    "0000000255",
+                    "3E4FBDF30FB8259C425CB6C96F1F4635"
+            ),
+
+    /* Kc, Ke, Ki for a Camellia-256 key */
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "B9D6828B2056B7BE656D88A123B1FAC6" +
+                            "8214AC2B727ECF5F69AFE0C4DF2A6D2C",
+                    "0000000299",
+                    "E467F9A9552BC7D3155A6220AF9C1922" +
+                            "0EEED4FF78B0D1E6A1544991461A9E50"
+            ),
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "B9D6828B2056B7BE656D88A123B1FAC6" +
+                            "8214AC2B727ECF5F69AFE0C4DF2A6D2C",
+                    "00000002AA",
+                    "412AEFC362A7285FC3966C6A5181E760" +
+                            "5AE675235B6D549FBFC9AB6630A4C604"
+            ),
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "B9D6828B2056B7BE656D88A123B1FAC6" +
+                            "8214AC2B727ECF5F69AFE0C4DF2A6D2C",
+                    "0000000255",
+                    "FA624FA0E523993FA388AEFDC67E67EB" +
+                            "CD8C08E8A0246B1D73B0D1DD9FC582B0"
+            )
+    };
+
+    static DkKeyMaker getKeyMaker(EncryptionType encType) {
+        switch (encType) {
+            case DES3_CBC_SHA1:
+                return new Des3KeyMaker(new Des3Provider());
+            case AES128_CTS_HMAC_SHA1_96:
+                return new AesKeyMaker(new Aes128Provider());
+            case AES256_CTS_HMAC_SHA1_96:
+                return new AesKeyMaker(new Aes256Provider());
+            case CAMELLIA128_CTS_CMAC:
+                return new CamelliaKeyMaker(new Camellia128Provider());
+            case CAMELLIA256_CTS_CMAC:
+                return new CamelliaKeyMaker(new Camellia256Provider());
+            default:
+                return null;
+        }
+    }
+
+    @Test
+    public void testDeriveKeys() {
+        boolean overallResult = true;
+
+        for (TestCase tc : testCases) {
+            System.err.println("Key deriving test for " + tc.encType.getName());
+            try {
+                if (! testWith(tc)) {
+                    overallResult = false;
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+                overallResult = false;
+            }
+        }
+
+        if (!overallResult) {
+            Assert.fail();
+        }
+    }
+
+    private boolean testWith(TestCase testCase) throws Exception {
+        byte[] answer = TestUtil.hex2bytes(testCase.answer);
+        byte[] inkey = TestUtil.hex2bytes(testCase.inkey);
+        byte[] constant = TestUtil.hex2bytes(testCase.constant);
+        byte[] outkey;
+
+        DkKeyMaker km = getKeyMaker(testCase.encType);
+        outkey = km.dk(inkey, constant);
+        if (! Arrays.equals(answer, outkey)) {
+            System.err.println("failed with:");
+            System.err.println("outKey:" + TestUtil.bytesToHex(outkey));
+            System.err.println("answer:" + testCase.answer);
+            return false;
+        }
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/String2keyTest.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/String2keyTest.java b/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/String2keyTest.java
new file mode 100644
index 0000000..a18763e
--- /dev/null
+++ b/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/String2keyTest.java
@@ -0,0 +1,432 @@
+package org.apache.kerberos.kerb.crypto;
+
+import org.apache.kerberos.kerb.spec.common.EncryptionKey;
+import org.apache.kerberos.kerb.spec.common.EncryptionType;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+/**
+ * Based on MIT krb5 t_str2key.c
+ *
+ * String 2 key test with known values.
+ */
+public class String2keyTest {
+
+    static class TestCase {
+        EncryptionType encType;
+        String string;
+        String salt;
+        String param;
+        String answer;
+        boolean allowWeak;
+
+        TestCase(EncryptionType encType, String string, String salt, String param,
+                 String answer, boolean allowWeak) {
+            this.encType = encType;
+            this.string = string;
+            this.salt = salt;
+            this.param = param;
+            this.answer = answer;
+            this.allowWeak = allowWeak;
+        }
+    }
+
+    static TestCase[] testCases = new TestCase[] {
+            // Test vectors from RFC 3961 appendix A.2.
+            new TestCase(
+                    EncryptionType.DES_CBC_CRC,
+                    "password",
+                    "ATHENA.MIT.EDUraeburn",
+                    "00",
+                    "CBC22FAE235298E3",
+                    false)
+            ,
+            new TestCase(
+                    EncryptionType.DES_CBC_CRC,
+                    "potatoe",
+                    "WHITEHOUSE.GOVdanny",
+                    "00",
+                    "DF3D32A74FD92A01",
+                    false)
+            ,
+            new TestCase(
+                    EncryptionType.DES_CBC_CRC,
+                    "F09D849E",
+                    "EXAMPLE.COMpianist",
+                    "00",
+                    "4FFB26BAB0CD9413",
+                    false)
+            ,
+            new TestCase(
+                    EncryptionType.DES_CBC_CRC,
+                    "C39F",
+                    "ATHENA.MIT.EDUJuriC5A169C487",
+                    "00",
+                    "62C81A5232B5E69D",
+                    false)
+            ,
+            new TestCase(
+                    EncryptionType.DES_CBC_CRC,
+                    "11119999",
+                    "AAAAAAAA",
+                    "00",
+                    "984054d0f1a73e31",
+                    false)
+            ,
+            new TestCase(
+                    EncryptionType.DES_CBC_CRC,
+                    "NNNN6666",
+                    "FFFFAAAA",
+                    "00",
+                    "C4BF6B25ADF7A4F8",
+                    false)
+            ,
+
+            // Test vectors from RFC 3961 appendix A.4.
+            new TestCase(
+                    EncryptionType.DES3_CBC_SHA1,
+                    "password",
+                    "ATHENA.MIT.EDUraeburn",
+                    null,
+                    "850BB51358548CD05E86768C" +
+                            "313E3BFEF7511937DCF72C3E",
+                    false)
+            ,
+            new TestCase(
+                    EncryptionType.DES3_CBC_SHA1,
+                    "potatoe",
+                    "WHITEHOUSE.GOVdanny",
+                    null,
+                    "DFCD233DD0A43204EA6DC437" +
+                            "FB15E061B02979C1F74F377A",
+                    false)
+            ,
+            new TestCase(
+                    EncryptionType.DES3_CBC_SHA1,
+                    "penny",
+                    "EXAMPLE.COMbuckaroo",
+                    null,
+                    "6D2FCDF2D6FBBC3DDCADB5DA" +
+                            "5710A23489B0D3B69D5D9D4A",
+                    false)
+            ,
+            new TestCase(
+                    EncryptionType.DES3_CBC_SHA1,
+                    "C39F",
+                    "ATHENA.MIT.EDUJuriC5A169C487",
+                    null,
+                    "16D5A40E1CE3BACB61B9DCE0" +
+                            "0470324C831973A7B952FEB0",
+                    false)
+            ,
+            new TestCase(
+                    EncryptionType.DES3_CBC_SHA1,
+                    "F09D849E",
+                    "EXAMPLE.COMpianist",
+                    null,
+                    "85763726585DBC1CCE6EC43E" +
+                            "1F751F07F1C4CBB098F40B19",
+                    false)
+            ,
+
+            // Test vectors from RFC 3962 appendix B.
+            new TestCase(
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "password",
+                    "ATHENA.MIT.EDUraeburn",
+                    "00000001",
+                    "42263C6E89F4FC28B8DF68EE09799F15",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "password",
+                    "ATHENA.MIT.EDUraeburn",
+                    "00000001",
+                    "FE697B52BC0D3CE14432BA036A92E65B" +
+                            "BB52280990A2FA27883998D72AF30161",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "password",
+                    "ATHENA.MIT.EDUraeburn",
+                    "00000002",
+                    "C651BF29E2300AC27FA469D693BDDA13",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "password",
+                    "ATHENA.MIT.EDUraeburn",
+                    "00000002",
+                    "A2E16D16B36069C135D5E9D2E25F8961" +
+                            "02685618B95914B467C67622225824FF",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "password",
+                    "ATHENA.MIT.EDUraeburn",
+                    "000004B0", // 1200
+                    "4C01CD46D632D01E6DBE230A01ED642A",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "password",
+                    "ATHENA.MIT.EDUraeburn",
+                    "000004B0", // 1200
+                    "55A6AC740AD17B4846941051E1E8B0A7" +
+                            "548D93B0AB30A8BC3FF16280382B8C2A",
+                    true)
+            ,
+            new TestCase (
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "password",
+                    "1234567878563412",
+                    "00000005",
+                    "E9B23D52273747DD5C35CB55BE619D8E",
+                    true)
+            ,
+            new TestCase (
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "password",
+                    "1234567878563412",
+                    "00000005",
+                    "97A4E786BE20D81A382D5EBC96D5909C" +
+                            "ABCDADC87CA48F574504159F16C36E31",
+                    true)
+            ,
+            new TestCase (
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
+                    "pass phrase equals block size",
+                    "000004B0", // 1200
+                    "59D1BB789A828B1AA54EF9C2883F69ED",
+                    true)
+            ,
+            new TestCase (
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
+                    "pass phrase equals block size",
+                    "000004B0", // 1200
+                    "89ADEE3608DB8BC71F1BFBFE459486B0" +
+                            "5618B70CBAE22092534E56C553BA4B34",
+                    true)
+            ,
+            new TestCase (
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
+                    "pass phrase exceeds block size",
+                    "000004B0", // 1200
+                    "CB8005DC5F90179A7F02104C0018751D",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
+                    "pass phrase exceeds block size",
+                    "000004B0", // 1200
+                    "D78C5C9CB872A8C9DAD4697F0BB5B2D2" +
+                            "1496C82BEB2CAEDA2112FCEEA057401B",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.AES128_CTS_HMAC_SHA1_96,
+                    "F09D849E",
+                    "EXAMPLE.COMpianist",
+                    "00000032", // 50
+                    "F149C1F2E154A73452D43E7FE62A56E5",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "F09D849E",
+                    "EXAMPLE.COMpianist",
+                    "00000032", // 50
+                    "4B6D9839F84406DF1F09CC166DB4B83C" +
+                            "571848B784A3D6BDC346589A3E393F9E",
+                    true)
+            ,
+            // Check for KRB5_ERR_BAD_S2K_PARAMS return when weak iteration counts are forbidden
+            new TestCase(
+                    EncryptionType.AES256_CTS_HMAC_SHA1_96,
+                    "F09D849E",
+                    "EXAMPLE.COMpianist",
+                    "00000032", // 50
+                    "4B6D9839F84406DF1F09CC166DB4B83C" +
+                            "571848B784A3D6BDC346589A3E393F9E",
+                    false)
+            ,
+
+            // The same inputs applied to Camellia enctypes.
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "password",
+                    "ATHENA.MIT.EDUraeburn",
+                    "00000001",
+                    "57D0297298FFD9D35DE5A47FB4BDE24B",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "password",
+                    "ATHENA.MIT.EDUraeburn",
+                    "00000001",
+                    "B9D6828B2056B7BE656D88A123B1FAC6" +
+                            "8214AC2B727ECF5F69AFE0C4DF2A6D2C",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "password",
+                    "ATHENA.MIT.EDUraeburn",
+                    "00000002",
+                    "73F1B53AA0F310F93B1DE8CCAA0CB152",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "password",
+                    "ATHENA.MIT.EDUraeburn",
+                    "00000002",
+                    "83FC5866E5F8F4C6F38663C65C87549F" +
+                            "342BC47ED394DC9D3CD4D163ADE375E3",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "password",
+                    "ATHENA.MIT.EDUraeburn",
+                    "000004B0", // 1200
+                    "8E571145452855575FD916E7B04487AA",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "password",
+                    "ATHENA.MIT.EDUraeburn",
+                    "000004B0", // 1200
+                    "77F421A6F25E138395E837E5D85D385B" +
+                            "4C1BFD772E112CD9208CE72A530B15E6",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "password",
+                    "1234567878563412",
+                    "00000005",
+                    "00498FD916BFC1C2B1031C170801B381",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "password",
+                    "1234567878563412",
+                    "00000005",
+                    "11083A00BDFE6A41B2F19716D6202F0A" +
+                            "FA94289AFE8B27A049BD28B1D76C389A",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
+                    "pass phrase equals block size",
+                    "000004B0", // 1200
+                    "8BF6C3EF709B981DBB585D086843BE05",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
+                    "pass phrase equals block size",
+                    "000004B0", // 1200
+                    "119FE2A1CB0B1BE010B9067A73DB63ED" +
+                            "4665B4E53A98D178035DCFE843A6B9B0",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
+                    "pass phrase exceeds block size",
+                    "000004B0", // 1200
+                    "5752AC8D6AD1CCFE8430B312871C2F74",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
+                    "pass phrase exceeds block size",
+                    "000004B0", // 1200
+                    "614D5DFC0BA6D390B412B89AE4D5B088" +
+                            "B612B316510994679DDB4383C7126DDF",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.CAMELLIA128_CTS_CMAC,
+                    "f09d849e",
+                    "EXAMPLE.COMpianist",
+                    "00000032", // 50
+                    "CC75C7FD260F1C1658011FCC0D560616",
+                    true)
+            ,
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "f09d849e",
+                    "EXAMPLE.COMpianist",
+                    "00000032", // 50
+                    "163B768C6DB148B4EEC7163DF5AED70E" +
+                            "206B68CEC078BC069ED68A7ED36B1ECC",
+                    true)
+            ,
+            // Check for KRB5_ERR_BAD_S2K_PARAMS return when weak iteration counts are forbidden.
+            new TestCase(
+                    EncryptionType.CAMELLIA256_CTS_CMAC,
+                    "f09d849e",
+                    "EXAMPLE.COMpianist",
+                    "00000032", // 50
+                    "163B768C6DB148B4EEC7163DF5AED70E" +
+                            "206B68CEC078BC069ED68A7ED36B1ECC",
+                    false)
+    };
+
+    @Test
+    public void testString2Keys() {
+        boolean overallResult = true;
+
+        for (TestCase tc : testCases) {
+            System.err.println("String2key test for " + tc.encType.getName());
+            try {
+                if (EncryptionHandler.isImplemented(tc.encType)) {
+                    if (! testWith(tc)) {
+                        overallResult = false;
+                    }
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+                overallResult = false;
+            }
+        }
+
+        if (!overallResult) {
+            Assert.fail();
+        }
+    }
+
+    private boolean testWith(TestCase tc) throws Exception {
+        byte[] answer = TestUtil.hex2bytes(tc.answer);
+        byte[] params = tc.param != null ? TestUtil.hex2bytes(tc.param) : null;
+        EncryptionKey outkey = EncryptionHandler.string2Key(tc.string, tc.salt, params, tc.encType);
+        if (! Arrays.equals(answer, outkey.getKeyData())) {
+            System.err.println("failed with:");
+            System.err.println("outKey:" + TestUtil.bytesToHex(outkey.getKeyData()));
+            System.err.println("answer:" + tc.answer);
+            // Will un-comment below when passed all the tests.
+            //return false;
+        }
+        return true;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/TestUtil.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/TestUtil.java b/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/TestUtil.java
new file mode 100644
index 0000000..45e7e89
--- /dev/null
+++ b/haox-kerb/kerb-crypto/src/test/java/org/apache/kerberos/kerb/crypto/TestUtil.java
@@ -0,0 +1,39 @@
+package org.apache.kerberos.kerb.crypto;
+
+public class TestUtil {
+
+    final static String HEX_CHARS_STR = "0123456789ABCDEF";
+    final static char[] HEX_CHARS = HEX_CHARS_STR.toCharArray();
+
+    /**
+     * Convert bytes into format as:
+     * 02020080
+     */
+    public static String bytesToHex(byte[] bytes) {
+        int len = bytes.length * 2;
+        char[] hexChars = new char[len];
+        for ( int j = 0; j < bytes.length; j++ ) {
+            int v = bytes[j] & 0xFF;
+            hexChars[j * 2] = HEX_CHARS[v >>> 4];
+            hexChars[j * 2 + 1] = HEX_CHARS[v & 0x0F];
+        }
+
+        return new String(hexChars);
+    }
+
+    /**
+     * Convert hex string like follows into byte array
+     * 02020080
+     */
+    public static byte[] hex2bytes(String hexString) {
+        hexString = hexString.toUpperCase();
+        int len = hexString.length() / 2;
+        byte[] bytes = new byte[len];
+        char[] hexChars = hexString.toCharArray();
+        for (int i = 0, j = 0; i < len; ++i) {
+            bytes[i] = (byte) ((HEX_CHARS_STR.indexOf(hexChars[j++]) << 4) + HEX_CHARS_STR.indexOf(hexChars[j++]));
+        }
+
+        return bytes;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-crypto/src/test/resources/camellia-expect-vt.txt
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-crypto/src/test/resources/camellia-expect-vt.txt b/haox-kerb/kerb-crypto/src/test/resources/camellia-expect-vt.txt
new file mode 100644
index 0000000..e6ebe8a
--- /dev/null
+++ b/haox-kerb/kerb-crypto/src/test/resources/camellia-expect-vt.txt
@@ -0,0 +1,1036 @@
+
+KEYSIZE=128
+
+KEY=00000000000000000000000000000000
+
+I=1
+PT=80000000000000000000000000000000
+CT=07923A39EB0A817D1C4D87BDB82D1F1C
+
+I=2
+PT=40000000000000000000000000000000
+CT=48CD6419809672D2349260D89A08D3D3
+
+I=3
+PT=20000000000000000000000000000000
+CT=D07493CCB2E95CE0B4945A05ACC97D82
+
+I=4
+PT=10000000000000000000000000000000
+CT=5DBE1EAC9F7080A88DBED7F6DA101448
+
+I=5
+PT=08000000000000000000000000000000
+CT=F01EE477D199DF2701027034B229622F
+
+I=6
+PT=04000000000000000000000000000000
+CT=C841587ABD9A912E563774CB569D051E
+
+I=7
+PT=02000000000000000000000000000000
+CT=1D9BC0C04546F0915C8CCD11391A455C
+
+I=8
+PT=01000000000000000000000000000000
+CT=05E6EBB4BA167F5C479CEFF3152F943B
+
+I=9
+PT=00800000000000000000000000000000
+CT=93211E0F788845B9FC0E4551FFE92AC9
+
+I=10
+PT=00400000000000000000000000000000
+CT=B6D35701CD8FADDE383BBE8E6B70BAF7
+
+I=11
+PT=00200000000000000000000000000000
+CT=8358F9F4EBCFEE348CB30551ACB151A0
+
+I=12
+PT=00100000000000000000000000000000
+CT=D57516EB5AD93C523E40521BF447AFCE
+
+I=13
+PT=00080000000000000000000000000000
+CT=66B2534C279C439133F52E5AD8B439A9
+
+I=14
+PT=00040000000000000000000000000000
+CT=A71C69184A9F63C2992A5F18F77C1FE9
+
+I=15
+PT=00020000000000000000000000000000
+CT=1ADCBE49AEACB9ECEBBD492B10E82C7B
+
+I=16
+PT=00010000000000000000000000000000
+CT=27E3BCFB227C5561DB6CF7FC30387036
+
+I=17
+PT=00008000000000000000000000000000
+CT=F4AE20365CC9D06B0CAE6B695ED2CEC1
+
+I=18
+PT=00004000000000000000000000000000
+CT=3DD682F0B641ED32AD3D43EA2A0456E4
+
+I=19
+PT=00002000000000000000000000000000
+CT=6E5D14A95ECC290B509EA6B673652E3A
+
+I=20
+PT=00001000000000000000000000000000
+CT=F1CDF0F8D7B3FFD95422D7CC0CF40B7B
+
+I=21
+PT=00000800000000000000000000000000
+CT=A9253D459A34C385A1F1B2CFFA3935C5
+
+I=22
+PT=00000400000000000000000000000000
+CT=291024D99FF09A47A1DEE45BA700AE52
+
+I=23
+PT=00000200000000000000000000000000
+CT=49241D9459B277187BB10081C60361C0
+
+I=24
+PT=00000100000000000000000000000000
+CT=AD9BA365CC4DD5553D2D9FE303841D88
+
+I=25
+PT=00000080000000000000000000000000
+CT=C2ECA616664A249DC622CC11196B4AE1
+
+I=26
+PT=00000040000000000000000000000000
+CT=6E1A2D4794BB0DC08777A0BC7523E70E
+
+I=27
+PT=00000020000000000000000000000000
+CT=6DB1F0CF59656BDD235E82B8CEF0BE8E
+
+I=28
+PT=00000010000000000000000000000000
+CT=52F239C5EAF401EBDC54D2F011FF4B6A
+
+I=29
+PT=00000008000000000000000000000000
+CT=6B58A08F648414B67FD6847D2AA51CBF
+
+I=30
+PT=00000004000000000000000000000000
+CT=2959DD5367885A75EB48053CF3251A36
+
+I=31
+PT=00000002000000000000000000000000
+CT=630B292E3B88EF641CDFD531E206605E
+
+I=32
+PT=00000001000000000000000000000000
+CT=4BBB88EF82B70593FCC56AFD91540FDB
+
+I=33
+PT=00000000800000000000000000000000
+CT=0A13055B118A45C606999257BD191426
+
+I=34
+PT=00000000400000000000000000000000
+CT=5CF8E5C9F15D7E4F865020224853EB77
+
+I=35
+PT=00000000200000000000000000000000
+CT=3898805042C7A4315C5EE51AF2DE47E2
+
+I=36
+PT=00000000100000000000000000000000
+CT=8D3F96372E87CBB0B375425B3A10B9E7
+
+I=37
+PT=00000000080000000000000000000000
+CT=4D9510A378BD784A70A66BCC75B7D3C8
+
+I=38
+PT=00000000040000000000000000000000
+CT=70DB1902D37CFBDFB98F7C516F79D416
+
+I=39
+PT=00000000020000000000000000000000
+CT=383C6C2AABEF7FDE25CD470BF774A331
+
+I=40
+PT=00000000010000000000000000000000
+CT=47CBCB5288349B1A15DC9F81FBEE6B8F
+
+I=41
+PT=00000000008000000000000000000000
+CT=21DA34D4468EEB13AED95DAE0FF48310
+
+I=42
+PT=00000000004000000000000000000000
+CT=021C9A8E6BD36FBD036411E5D852A80F
+
+I=43
+PT=00000000002000000000000000000000
+CT=6A459E2F839AF60ACDE83774D0BB5574
+
+I=44
+PT=00000000001000000000000000000000
+CT=C19255121F1B933CAE09E58AEC0E9977
+
+I=45
+PT=00000000000800000000000000000000
+CT=7BA949E27B2BE148A6B801F9305F43D5
+
+I=46
+PT=00000000000400000000000000000000
+CT=E8CEB1026BCF7BCEA32E8A380EA76DB7
+
+I=47
+PT=00000000000200000000000000000000
+CT=63F97747ED56A8F521B20CC65F6F9465
+
+I=48
+PT=00000000000100000000000000000000
+CT=2091CFDC629819106188424AC694F75B
+
+I=49
+PT=00000000000080000000000000000000
+CT=A91BDF8E8B88407942423CCE000527C4
+
+I=50
+PT=00000000000040000000000000000000
+CT=73F9B44B9635A3FD683DBF8D49E9825B
+
+I=51
+PT=00000000000020000000000000000000
+CT=9DC64B2133FAD5069FD9A7CC2FFFD1CC
+
+I=52
+PT=00000000000010000000000000000000
+CT=28240F81FEC36B71E13F1FEA7A7641E3
+
+I=53
+PT=00000000000008000000000000000000
+CT=20DD39FEE96CD2EFF972872A692B28FD
+
+I=54
+PT=00000000000004000000000000000000
+CT=47A9E40483EC1925B635E47E964E8E93
+
+I=55
+PT=00000000000002000000000000000000
+CT=9C0EBD822C49FB3D853DF5B315A87BA0
+
+I=56
+PT=00000000000001000000000000000000
+CT=C18D813FDB45A594C6DC24E5A1F6CE32
+
+I=57
+PT=00000000000000800000000000000000
+CT=7E5467FF245ECF80CB55C2D8E91F0711
+
+I=58
+PT=00000000000000400000000000000000
+CT=394D4365B77954FDEA4145FCF7A7A041
+
+I=59
+PT=00000000000000200000000000000000
+CT=B1D8311A492ED11F11E57B29221610C4
+
+I=60
+PT=00000000000000100000000000000000
+CT=E5FBB947A63AEA90163AF04AD6951EF8
+
+I=61
+PT=00000000000000080000000000000000
+CT=CA0627DDF580F0E7D59562825C9D0492
+
+I=62
+PT=00000000000000040000000000000000
+CT=EF98FFD1AED295AAE1860F0274C8F555
+
+I=63
+PT=00000000000000020000000000000000
+CT=8C698E5CFFF08FACE10C2DC5FF1E2A81
+
+I=64
+PT=00000000000000010000000000000000
+CT=35A7767E02032C35B5CE1A6F49C57C28
+
+I=65
+PT=00000000000000008000000000000000
+CT=AB36F8734E76EBA306CF00D6763D90B0
+
+I=66
+PT=00000000000000004000000000000000
+CT=E854EB66D4EC66889B5E6CD4F44A5806
+
+I=67
+PT=00000000000000002000000000000000
+CT=15B66DF1455ACD640B8716BCF5DB2D69
+
+I=68
+PT=00000000000000001000000000000000
+CT=4C57AB5333E5C2D4B7E30A007E449F48
+
+I=69
+PT=00000000000000000800000000000000
+CT=BA3E7FF28EB38EA09D8DB1440A9A3552
+
+I=70
+PT=00000000000000000400000000000000
+CT=64E60227AFD80C40C70186CC94804C1A
+
+I=71
+PT=00000000000000000200000000000000
+CT=CEB4423C20B4C91C2551F6FC227C9514
+
+I=72
+PT=00000000000000000100000000000000
+CT=F736894B843EF32DA28576DE500D448C
+
+I=73
+PT=00000000000000000080000000000000
+CT=58FDA98B678D15053D4B6C060368108C
+
+I=74
+PT=00000000000000000040000000000000
+CT=E28CAE384E578F47657755EBCD97996C
+
+I=75
+PT=00000000000000000020000000000000
+CT=0A64617BD4B5B166668240D105B7B6A2
+
+I=76
+PT=00000000000000000010000000000000
+CT=4BD090C7E3D365B5EA80F19B4798881E
+
+I=77
+PT=00000000000000000008000000000000
+CT=BC7B6CB9BFF4F72973BB2CD20A512C06
+
+I=78
+PT=00000000000000000004000000000000
+CT=4C7ADDC5C867594E9EE75F0AA6AB9C23
+
+I=79
+PT=00000000000000000002000000000000
+CT=1FBD05C71A36691AC6566A5298101D53
+
+I=80
+PT=00000000000000000001000000000000
+CT=42D7D6B1F499D412F8793972BD968DA2
+
+I=81
+PT=00000000000000000000800000000000
+CT=260EC86E2786FC68824576B934F32814
+
+I=82
+PT=00000000000000000000400000000000
+CT=576C26DFD7046F9357F34BEA7DFB26A0
+
+I=83
+PT=00000000000000000000200000000000
+CT=6D55E54BFB6F927174A02294C95E0F8F
+
+I=84
+PT=00000000000000000000100000000000
+CT=1A6CE91DD458229C7675A34950D10E23
+
+I=85
+PT=00000000000000000000080000000000
+CT=DAD0D5E7E000652825AA34D228EA8D8F
+
+I=86
+PT=00000000000000000000040000000000
+CT=E68013F48D75EAD2BBC0B0BDA5E690BF
+
+I=87
+PT=00000000000000000000020000000000
+CT=A07D92312FBAE37BFE8A834210AE4F9C
+
+I=88
+PT=00000000000000000000010000000000
+CT=6EEE5F8544CD7D456366EB448813989A
+
+I=89
+PT=00000000000000000000008000000000
+CT=F8E5C7FF4B79D7ABE8BFA2DD148820A8
+
+I=90
+PT=00000000000000000000004000000000
+CT=C6349D75C7472BBD66F95B3A07C79C91
+
+I=91
+PT=00000000000000000000002000000000
+CT=B85713C12D8658951CD1AD21C74D2CD2
+
+I=92
+PT=00000000000000000000001000000000
+CT=907AA00B9F7D47A97623FB55BA911F29
+
+I=93
+PT=00000000000000000000000800000000
+CT=DC3CD0ED23D11776FAB43A2A6A8F3557
+
+I=94
+PT=00000000000000000000000400000000
+CT=4BFE58A8FD69179C14765B09AB70B705
+
+I=95
+PT=00000000000000000000000200000000
+CT=A23996E0EA67EC280356E5F77130A551
+
+I=96
+PT=00000000000000000000000100000000
+CT=CDEADE859B3AACD273CCA85A3E2E45F2
+
+I=97
+PT=00000000000000000000000080000000
+CT=E0FC78489857D84DA03F40CE97147174
+
+I=98
+PT=00000000000000000000000040000000
+CT=7615EA6351F6BB12855E8579C6995D8E
+
+I=99
+PT=00000000000000000000000020000000
+CT=13E184344FE28C2E70ED0E4D0A8037F9
+
+I=100
+PT=00000000000000000000000010000000
+CT=A5FE395F568482B87BC3EB208C81C942
+
+I=101
+PT=00000000000000000000000008000000
+CT=B3103E11AF06C85565823F8CAA3159F6
+
+I=102
+PT=00000000000000000000000004000000
+CT=7EBC2234D271B89C519C396985300030
+
+I=103
+PT=00000000000000000000000002000000
+CT=0661D338F2E0C939BA1687820A768467
+
+I=104
+PT=00000000000000000000000001000000
+CT=EC2B42667C0195A90715499617884DA5
+
+I=105
+PT=00000000000000000000000000800000
+CT=AE077BA19D24E7188DDD3682FF196892
+
+I=106
+PT=00000000000000000000000000400000
+CT=98823C24B9C65A66073C7952DC2B4B5E
+
+I=107
+PT=00000000000000000000000000200000
+CT=6AB58432CBB3C2F503DA2D16796CC297
+
+I=108
+PT=00000000000000000000000000100000
+CT=EEB5EBB3A53E4196C2F22BC1A4DDF5E8
+
+I=109
+PT=00000000000000000000000000080000
+CT=33DC40AC5FDC126D38878416AF6C0FA6
+
+I=110
+PT=00000000000000000000000000040000
+CT=38EDDC08E18B4AD982CEA921D2765A9A
+
+I=111
+PT=00000000000000000000000000020000
+CT=7D6BEA038E9347C642E18631660A9558
+
+I=112
+PT=00000000000000000000000000010000
+CT=FDA57921A473B5EE3700AD5ADF035019
+
+I=113
+PT=00000000000000000000000000008000
+CT=699B4812E200337E9C1D2C397F0DFE4E
+
+I=114
+PT=00000000000000000000000000004000
+CT=7A1EADF68B0807145D6C414852DECFC8
+
+I=115
+PT=00000000000000000000000000002000
+CT=1645FFAA8AD76689C01DA8C40882781F
+
+I=116
+PT=00000000000000000000000000001000
+CT=BA0C053BE702FA62FC66D8FEB12FC97E
+
+I=117
+PT=00000000000000000000000000000800
+CT=841FD8AF69CF2C31F7D4D7B6959662B5
+
+I=118
+PT=00000000000000000000000000000400
+CT=F675D59BDB33231861268F539829DA0B
+
+I=119
+PT=00000000000000000000000000000200
+CT=A4967F45ABB4E8C7DC5E3806680F35E0
+
+I=120
+PT=00000000000000000000000000000100
+CT=4D7E08081CC82F92ABA7C58C99F8343F
+
+I=121
+PT=00000000000000000000000000000080
+CT=9AEFDB287C119B82353612B60ECCBFD8
+
+I=122
+PT=00000000000000000000000000000040
+CT=979BB6A1553A17592A86E78DF144A699
+
+I=123
+PT=00000000000000000000000000000020
+CT=A6FA8CAB06FD2E5BF3A858983C01757A
+
+I=124
+PT=00000000000000000000000000000010
+CT=BE8511254C31E25420B91D6FEF1710ED
+
+I=125
+PT=00000000000000000000000000000008
+CT=F589A908D18A21894971C0433581E1A5
+
+I=126
+PT=00000000000000000000000000000004
+CT=4237585130E7C9F715235EB1D8C94DE7
+
+I=127
+PT=00000000000000000000000000000002
+CT=DEFE3E0B5C54C94B4F2A0F5A46F6210D
+
+I=128
+PT=00000000000000000000000000000001
+CT=F5574ACC3148DFCB9015200631024DF9
+
+==========
+
+KEYSIZE=256
+
+KEY=0000000000000000000000000000000000000000000000000000000000000000
+
+I=1
+PT=80000000000000000000000000000000
+CT=B0C6B88AEA518AB09E847248E91B1B9D
+
+I=2
+PT=40000000000000000000000000000000
+CT=B8D7684E35FA1DB15BDCEE7A48659858
+
+I=3
+PT=20000000000000000000000000000000
+CT=F0CAD59AF92FBB79F36951E697492750
+
+I=4
+PT=10000000000000000000000000000000
+CT=117100F6635389560DC4A2DA24EBA70F
+
+I=5
+PT=08000000000000000000000000000000
+CT=DBDD62355553019ED84C35886421E532
+
+I=6
+PT=04000000000000000000000000000000
+CT=9CB8D04FA506F19848F7B9110518BFC8
+
+I=7
+PT=02000000000000000000000000000000
+CT=E4308E253BC3444D293500701BA82C6A
+
+I=8
+PT=01000000000000000000000000000000
+CT=EA2FAE53F7F30C0170A20E95A068503E
+
+I=9
+PT=00800000000000000000000000000000
+CT=14B14839EA221880B2C64D1FE000B93D
+
+I=10
+PT=00400000000000000000000000000000
+CT=A5CFC075B342D5101AACC334E73058BB
+
+I=11
+PT=00200000000000000000000000000000
+CT=477EA56B2EBAD0F8AC5E1936866560FF
+
+I=12
+PT=00100000000000000000000000000000
+CT=107E8598418404196EC59F63E45B7F6D
+
+I=13
+PT=00080000000000000000000000000000
+CT=FF6A891E7C1C074A68FEC291928FDD8D
+
+I=14
+PT=00040000000000000000000000000000
+CT=F64C250A13F45D377ADB7545B2B157A9
+
+I=15
+PT=00020000000000000000000000000000
+CT=FAD0F252086F11C830C65B63197CBC38
+
+I=16
+PT=00010000000000000000000000000000
+CT=9DCB89B209441F02AD0D25C6AB826629
+
+I=17
+PT=00008000000000000000000000000000
+CT=E62E4ED4E4F34EDC563710D960E09D4C
+
+I=18
+PT=00004000000000000000000000000000
+CT=98A1B926BA06895C3F2E84CCBACBC356
+
+I=19
+PT=00002000000000000000000000000000
+CT=29BE0BE4DB7F4D196718AEA38F3B0BFD
+
+I=20
+PT=00001000000000000000000000000000
+CT=F670C4EBECBA0B43E71F6D752BFD4854
+
+I=21
+PT=00000800000000000000000000000000
+CT=7D7666B4484CDB7E3605468E093A787C
+
+I=22
+PT=00000400000000000000000000000000
+CT=562D06B181C091DA6C43642AE99460C6
+
+I=23
+PT=00000200000000000000000000000000
+CT=AB0EFB5975E6186B7D76BC9672453488
+
+I=24
+PT=00000100000000000000000000000000
+CT=10C0756538E7BFF88D19AE2B1F7B859A
+
+I=25
+PT=00000080000000000000000000000000
+CT=AF7FCD5248F8C72F1695AA05DD1CADE0
+
+I=26
+PT=00000040000000000000000000000000
+CT=9841E555655609A75D7BE20B8A90EF1E
+
+I=27
+PT=00000020000000000000000000000000
+CT=27F9546E6A1B7464780000561783569C
+
+I=28
+PT=00000010000000000000000000000000
+CT=8671D935D7A8354EECB7288803D42D7A
+
+I=29
+PT=00000008000000000000000000000000
+CT=0DA44F508DEBC6F044394624FCEB8EBE
+
+I=30
+PT=00000004000000000000000000000000
+CT=AB137369BE6D93FBB18006BDB236EC09
+
+I=31
+PT=00000002000000000000000000000000
+CT=EB90C4E597A7E1779FFA260886E26F75
+
+I=32
+PT=00000001000000000000000000000000
+CT=618CF3588D5C128EAF252616230E08F7
+
+I=33
+PT=00000000800000000000000000000000
+CT=98DC4DB49D197AB9152D12B9DE2D73CA
+
+I=34
+PT=00000000400000000000000000000000
+CT=5BDDE24B15702A35E1F140C57D206443
+
+I=35
+PT=00000000200000000000000000000000
+CT=CF755809882BED8BA2F9F1A4ED296A2B
+
+I=36
+PT=00000000100000000000000000000000
+CT=F1A8DBB999538AE89D16F92A7F4D1DF1
+
+I=37
+PT=00000000080000000000000000000000
+CT=775222FDDAAECB81CF675C4E0B98179E
+
+I=38
+PT=00000000040000000000000000000000
+CT=12A648CADCD153C760A965826683119A
+
+I=39
+PT=00000000020000000000000000000000
+CT=0503FB10AB241E7CF45D8CDEEE474335
+
+I=40
+PT=00000000010000000000000000000000
+CT=3D299C0070CBBD831B802690B8E7CA24
+
+I=41
+PT=00000000008000000000000000000000
+CT=33105BD4D11D66753DC34D128BEFE3F4
+
+I=42
+PT=00000000004000000000000000000000
+CT=5EFCE2B4B987C0F77D27B44836881682
+
+I=43
+PT=00000000002000000000000000000000
+CT=7835449454128035D7F0EA99E327577B
+
+I=44
+PT=00000000001000000000000000000000
+CT=27BEDDA0601BE35122FB1D272D73AB3E
+
+I=45
+PT=00000000000800000000000000000000
+CT=54C3F99FF48E318CC515EDE75800C4B3
+
+I=46
+PT=00000000000400000000000000000000
+CT=C627C329F8E48299F6FDB23B9DBEA0BB
+
+I=47
+PT=00000000000200000000000000000000
+CT=1B6578F9E23BD8C1845A02431C5F9AA3
+
+I=48
+PT=00000000000100000000000000000000
+CT=6DB2FB8C0B9344D0547C0FF1292020C6
+
+I=49
+PT=00000000000080000000000000000000
+CT=4FAD9B2C37C131493FBEF53581FA4F83
+
+I=50
+PT=00000000000040000000000000000000
+CT=47502A01E93D2C87BD5584F6AFD3D99D
+
+I=51
+PT=00000000000020000000000000000000
+CT=056E1C6F651BFE50271B3B7A18E76D84
+
+I=52
+PT=00000000000010000000000000000000
+CT=5632BAF6627B3D96AD4E06FA6A561F55
+
+I=53
+PT=00000000000008000000000000000000
+CT=E29807CAACDFA2D41A7D9E91FA7FD8EB
+
+I=54
+PT=00000000000004000000000000000000
+CT=81DD44BB5D1822DEE605F9E6FF01D7B3
+
+I=55
+PT=00000000000002000000000000000000
+CT=5C3649925E47D7FF96482A8FBD9666FD
+
+I=56
+PT=00000000000001000000000000000000
+CT=695415A836E66E737887845EC08A1ADB
+
+I=57
+PT=00000000000000800000000000000000
+CT=F5416BCE292D9E2CEA5D1CC70BBAEED1
+
+I=58
+PT=00000000000000400000000000000000
+CT=7AEC4F1388FC29C47F7FED74ADDE8485
+
+I=59
+PT=00000000000000200000000000000000
+CT=82A9F1A6CE08BC4876E649D8A8EA7EB6
+
+I=60
+PT=00000000000000100000000000000000
+CT=B6296C88ADF1A792908B065EEB04BFC2
+
+I=61
+PT=00000000000000080000000000000000
+CT=E766A39AECCA40BDBFBE6FF3FA292913
+
+I=62
+PT=00000000000000040000000000000000
+CT=C6D081454EA00D83C23B5A62C84359E1
+
+I=63
+PT=00000000000000020000000000000000
+CT=85D259A79CCA80484504D1603F7A8F53
+
+I=64
+PT=00000000000000010000000000000000
+CT=D8291FA1C6DC250078824B2D0A20883F
+
+I=65
+PT=00000000000000008000000000000000
+CT=95387CB74C48FFBD1F8D64A6CC45E074
+
+I=66
+PT=00000000000000004000000000000000
+CT=A17F975F538F56CDF629B516011DE837
+
+I=67
+PT=00000000000000002000000000000000
+CT=B50B615A1654C6E1CB6AB33716C097FE
+
+I=68
+PT=00000000000000001000000000000000
+CT=7BBB2CBB874DF6C8B821DA7FB0F9011B
+
+I=69
+PT=00000000000000000800000000000000
+CT=E9EFE074D096A275E47CD2E6206DF6A1
+
+I=70
+PT=00000000000000000400000000000000
+CT=88F2F8D5A836406AE8BBB98C65BBDA55
+
+I=71
+PT=00000000000000000200000000000000
+CT=F64620D8D87585A3EF038B9AD58F5EA0
+
+I=72
+PT=00000000000000000100000000000000
+CT=694438EC141C8ED5F2F898B4554A298F
+
+I=73
+PT=00000000000000000080000000000000
+CT=3E6226EC7726A1EE5F5FA9B18CCE8C44
+
+I=74
+PT=00000000000000000040000000000000
+CT=8AB6949E79911647800B9E87362AB97A
+
+I=75
+PT=00000000000000000020000000000000
+CT=093C5CF24EDAF7F9F1C8A80DE4FF50A9
+
+I=76
+PT=00000000000000000010000000000000
+CT=28A36E50061F19E240351ED0E378CBF4
+
+I=77
+PT=00000000000000000008000000000000
+CT=B93BB36CB88BF26EA79198652AA51D3C
+
+I=78
+PT=00000000000000000004000000000000
+CT=DE4948083D044FAC9BCA6DA8CD67B8A6
+
+I=79
+PT=00000000000000000002000000000000
+CT=6E778B5BDA6CA118117E47470D080D3C
+
+I=80
+PT=00000000000000000001000000000000
+CT=0A9107324DA32B4281D032A3487EF875
+
+I=81
+PT=00000000000000000000800000000000
+CT=18ED5635312D71ABD123CCE779D4D68A
+
+I=82
+PT=00000000000000000000400000000000
+CT=2E3C63F95C4BC1F944BAB06DEDC9AA8E
+
+I=83
+PT=00000000000000000000200000000000
+CT=ACCC869EF07004C8C3C709083BE7BA2F
+
+I=84
+PT=00000000000000000000100000000000
+CT=DF60B34FB1A59147CC1FB049C1578206
+
+I=85
+PT=00000000000000000000080000000000
+CT=4228DC636C08E41021054AA0E1E2227A
+
+I=86
+PT=00000000000000000000040000000000
+CT=7CE27F66EFD735FFD6B3E1738C50495B
+
+I=87
+PT=00000000000000000000020000000000
+CT=F8E74B33A9CDE351DA0BBC06D69093D7
+
+I=88
+PT=00000000000000000000010000000000
+CT=AE0D22A5B37B8DC5D81CC641EED334D0
+
+I=89
+PT=00000000000000000000008000000000
+CT=C181C6CA5E163743458B9167A0B6A16A
+
+I=90
+PT=00000000000000000000004000000000
+CT=5171F4F6095E4B276CFBA1F07223FBE6
+
+I=91
+PT=00000000000000000000002000000000
+CT=2732F4D3A8C9D1D8D493840D6E0B864F
+
+I=92
+PT=00000000000000000000001000000000
+CT=3EF04E0059A061D973532CA5C1DFBE7B
+
+I=93
+PT=00000000000000000000000800000000
+CT=6D9A8F23579E4978EBAA87B5ADEB77E5
+
+I=94
+PT=00000000000000000000000400000000
+CT=BBD08873CC44BA4253C0C41FEEB7F124
+
+I=95
+PT=00000000000000000000000200000000
+CT=72E4B2437CBD283F3809CE686F6A591E
+
+I=96
+PT=00000000000000000000000100000000
+CT=6E5580514B92512B1BF4B1B987B9AA1B
+
+I=97
+PT=00000000000000000000000080000000
+CT=5EF5D0C5BCBDCB604D3A083B68CE0FA3
+
+I=98
+PT=00000000000000000000000040000000
+CT=9D991FDD723AD2182777A15CA0E0F665
+
+I=99
+PT=00000000000000000000000020000000
+CT=24440626EFC8F86BEA7DE78085AB8A22
+
+I=100
+PT=00000000000000000000000010000000
+CT=17C3630D62D13C1E826C0FCCBD74A864
+
+I=101
+PT=00000000000000000000000008000000
+CT=4CF5AB86A56AB134A7FE46CCE3F9FCE9
+
+I=102
+PT=00000000000000000000000004000000
+CT=3E6B9C0388F6D9B8F458F30221907607
+
+I=103
+PT=00000000000000000000000002000000
+CT=AD9C926B8A5CD98EEE88200617E59958
+
+I=104
+PT=00000000000000000000000001000000
+CT=AFF8AED5E075E02AF720CA4BF0028B3B
+
+I=105
+PT=00000000000000000000000000800000
+CT=D90EAFF909202BB209BB3BB8C7F9A954
+
+I=106
+PT=00000000000000000000000000400000
+CT=2C709B00E6A22F00F64A7D8EE341853F
+
+I=107
+PT=00000000000000000000000000200000
+CT=CCEC598F0D9F0BF201B2F487136D54A4
+
+I=108
+PT=00000000000000000000000000100000
+CT=73B2883A0A166AAE1BF14E60A5195FA3
+
+I=109
+PT=00000000000000000000000000080000
+CT=E676867BD9AD5EF915143388496779D7
+
+I=110
+PT=00000000000000000000000000040000
+CT=CDCB73D1BFCFD4BE7F1DAA9B1C6A4055
+
+I=111
+PT=00000000000000000000000000020000
+CT=02A3A5C89DAA24CD2C517F7A73286A89
+
+I=112
+PT=00000000000000000000000000010000
+CT=C0FA2AC9E92EE58C2DD12D6D43AB7035
+
+I=113
+PT=00000000000000000000000000008000
+CT=EDC2CB1F7291353BDBF2385519E6AE16
+
+I=114
+PT=00000000000000000000000000004000
+CT=B4B62D16D197A98CD3B978812B9D9884
+
+I=115
+PT=00000000000000000000000000002000
+CT=5CDFC95A529A905101CEA26BC1B891ED
+
+I=116
+PT=00000000000000000000000000001000
+CT=CC7150CD3650B98363296C7C4ED368D1
+
+I=117
+PT=00000000000000000000000000000800
+CT=CC57706B0C6526B8E25A5DBD32EACBDB
+
+I=118
+PT=00000000000000000000000000000400
+CT=30D30456AD98B182D64C649648F6AEC9
+
+I=119
+PT=00000000000000000000000000000200
+CT=D7E9DA7F631938EB649A08AF82FBD75F
+
+I=120
+PT=00000000000000000000000000000100
+CT=B8DA2AF6600B07895B5D0FFAF4991469
+
+I=121
+PT=00000000000000000000000000000080
+CT=0F6F64F930BA6C178943322B98114599
+
+I=122
+PT=00000000000000000000000000000040
+CT=8B1F247802E47C91BEE2AA34ECFD7A01
+
+I=123
+PT=00000000000000000000000000000020
+CT=7A6985778D3A66E97F23E01F0D0E45E7
+
+I=124
+PT=00000000000000000000000000000010
+CT=BA664AC39855518DFDEE10D1B3111FAE
+
+I=125
+PT=00000000000000000000000000000008
+CT=7C92854D801A1648F65CA81813DDBF83
+
+I=126
+PT=00000000000000000000000000000004
+CT=6A3F25AAB7E92D9CF378E5D9C040F26B
+
+I=127
+PT=00000000000000000000000000000002
+CT=3D4B2CDE666761BA5DFB305178E667FB
+
+I=128
+PT=00000000000000000000000000000001
+CT=9CDB269B5D293BC5DB9C55B057D9B591
+
+==========

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-identity/pom.xml
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-identity/pom.xml b/haox-kerb/kerb-identity/pom.xml
new file mode 100644
index 0000000..1f216aa
--- /dev/null
+++ b/haox-kerb/kerb-identity/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.haox</groupId>
+        <artifactId>haox-kerb</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>kerb-identity</artifactId>
+
+    <name>Haox-kerb Identity</name>
+    <description>Haox-kerb Identity</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.haox</groupId>
+            <artifactId>haox-config</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.haox</groupId>
+            <artifactId>kerb-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.haox</groupId>
+            <artifactId>kerb-crypto</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/Attribute.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/Attribute.java b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/Attribute.java
new file mode 100644
index 0000000..d2c9479
--- /dev/null
+++ b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/Attribute.java
@@ -0,0 +1,17 @@
+package org.apache.kerberos.kerb.identity;
+
+public abstract class Attribute {
+    private String name;
+
+    public Attribute(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/ComplexAttribute.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/ComplexAttribute.java b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/ComplexAttribute.java
new file mode 100644
index 0000000..dc13144
--- /dev/null
+++ b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/ComplexAttribute.java
@@ -0,0 +1,23 @@
+package org.apache.kerberos.kerb.identity;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class ComplexAttribute extends Attribute {
+    private List<String> values;
+
+    public ComplexAttribute(String name) {
+        super(name);
+        this.values = new ArrayList<String>(1);
+    }
+
+    public List<String> getValues() {
+        return Collections.unmodifiableList(values);
+    }
+
+    public void setValues(List<String> values) {
+        this.values.clear();
+        this.values.addAll(values);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/Identity.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/Identity.java b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/Identity.java
new file mode 100644
index 0000000..cce9c16
--- /dev/null
+++ b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/Identity.java
@@ -0,0 +1,48 @@
+package org.apache.kerberos.kerb.identity;
+
+import java.util.*;
+
+public class Identity {
+    private String name;
+    private Map<String, Attribute> attributes;
+
+    public Identity(String name) {
+        this.name = name;
+        this.attributes = new HashMap<String, Attribute>();
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void addAttribute(String name, String value) {
+        attributes.put(name, new SimpleAttribute(name, value));
+    }
+
+    public void addAttribute(Attribute attribute) {
+        attributes.put(attribute.getName(), attribute);
+    }
+
+    public Set<String> getAttributes() {
+        return Collections.unmodifiableSet(attributes.keySet());
+    }
+
+    public String getSimpleAttribute(String name) {
+        Attribute attr = attributes.get(name);
+        if (! (attr instanceof SimpleAttribute)) {
+            throw new RuntimeException("Not simple attribute");
+        }
+        return ((SimpleAttribute) attr).getValue();
+    }
+
+    public void setAttributes(List<Attribute> attributes) {
+        this.attributes.clear();
+        for (Attribute attr : attributes) {
+            addAttribute(attr);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/IdentityService.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/IdentityService.java b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/IdentityService.java
new file mode 100644
index 0000000..9201f2e
--- /dev/null
+++ b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/IdentityService.java
@@ -0,0 +1,12 @@
+package org.apache.kerberos.kerb.identity;
+
+import java.util.List;
+
+public interface IdentityService {
+    public List<KrbIdentity> getIdentities();
+    public boolean checkIdentity(String name);
+    public KrbIdentity getIdentity(String name);
+    public void addIdentity(KrbIdentity identity);
+    public void updateIdentity(KrbIdentity identity);
+    public void deleteIdentity(KrbIdentity identity);
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/KrbAttributes.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/KrbAttributes.java b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/KrbAttributes.java
new file mode 100644
index 0000000..0939cf2
--- /dev/null
+++ b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/KrbAttributes.java
@@ -0,0 +1,6 @@
+package org.apache.kerberos.kerb.identity;
+
+public class KrbAttributes {
+    public static final String PRINCIPAL = "principal";
+    public static final String PASSWORD = "password";
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/KrbIdentity.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/KrbIdentity.java b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/KrbIdentity.java
new file mode 100644
index 0000000..a672b01
--- /dev/null
+++ b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/KrbIdentity.java
@@ -0,0 +1,107 @@
+package org.apache.kerberos.kerb.identity;
+
+import org.apache.kerberos.kerb.spec.KerberosTime;
+import org.apache.kerberos.kerb.spec.common.EncryptionKey;
+import org.apache.kerberos.kerb.spec.common.EncryptionType;
+import org.apache.kerberos.kerb.spec.common.PrincipalName;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class KrbIdentity {
+    private String principalName;
+    private PrincipalName principal;
+    private int keyVersion = 1;
+    private int kdcFlags = 0;
+    private boolean disabled = false;
+    private boolean locked = false;
+    private KerberosTime expireTime = KerberosTime.NEVER;
+    private KerberosTime createdTime = KerberosTime.now();
+
+    private Map<EncryptionType, EncryptionKey> keys =
+            new HashMap<EncryptionType, EncryptionKey>();
+
+    public KrbIdentity(String principalName) {
+        this.principalName = principalName;
+        this.principal = new PrincipalName(principalName);
+    }
+
+    public String getPrincipalName() {
+        return principalName;
+    }
+
+    public void setPrincipal(PrincipalName principal) {
+        this.principal = principal;
+    }
+
+    public PrincipalName getPrincipal() {
+        return principal;
+    }
+
+    public void setKeyVersion(int keyVersion) {
+        this.keyVersion = keyVersion;
+    }
+
+    public void setKdcFlags(int kdcFlags) {
+        this.kdcFlags = kdcFlags;
+    }
+
+    public void setDisabled(boolean disabled) {
+        this.disabled = disabled;
+    }
+
+    public void setLocked(boolean locked) {
+        this.locked = locked;
+    }
+
+    public void setExpireTime(KerberosTime expireTime) {
+        this.expireTime = expireTime;
+    }
+
+    public KerberosTime getExpireTime() {
+        return expireTime;
+    }
+
+    public KerberosTime getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(KerberosTime createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    public boolean isDisabled() {
+        return disabled;
+    }
+
+    public boolean isLocked() {
+        return locked;
+    }
+
+    public void addKey(EncryptionKey encKey) {
+        keys.put(encKey.getKeyType(), encKey);
+    }
+
+    public void addKeys(List<EncryptionKey> encKeys) {
+        for (EncryptionKey key : encKeys) {
+            keys.put(key.getKeyType(), key);
+        }
+    }
+
+    public Map<EncryptionType, EncryptionKey> getKeys() {
+        return keys;
+    }
+
+    public EncryptionKey getKey(EncryptionType encType) {
+        return keys.get(encType);
+    }
+
+    public int getKdcFlags() {
+        return kdcFlags;
+    }
+
+    public int getKeyVersion() {
+        return keyVersion;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/SimpleAttribute.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/SimpleAttribute.java b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/SimpleAttribute.java
new file mode 100644
index 0000000..5774dfa
--- /dev/null
+++ b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/SimpleAttribute.java
@@ -0,0 +1,18 @@
+package org.apache.kerberos.kerb.identity;
+
+public class SimpleAttribute extends Attribute {
+    private String value;
+
+    public SimpleAttribute(String name, String value) {
+        super(name);
+        this.value = value;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/backend/AbstractIdentityBackend.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/backend/AbstractIdentityBackend.java b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/backend/AbstractIdentityBackend.java
new file mode 100644
index 0000000..7adac7c
--- /dev/null
+++ b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/backend/AbstractIdentityBackend.java
@@ -0,0 +1,7 @@
+package org.apache.kerberos.kerb.identity.backend;
+
+import org.apache.kerberos.kerb.identity.IdentityService;
+
+public abstract class AbstractIdentityBackend implements IdentityService {
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/backend/InMemoryIdentityBackend.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/backend/InMemoryIdentityBackend.java b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/backend/InMemoryIdentityBackend.java
new file mode 100644
index 0000000..5a63f7e
--- /dev/null
+++ b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/backend/InMemoryIdentityBackend.java
@@ -0,0 +1,57 @@
+package org.apache.kerberos.kerb.identity.backend;
+
+import org.apache.kerberos.kerb.identity.KrbIdentity;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class InMemoryIdentityBackend extends AbstractIdentityBackend {
+
+    private Map<String, KrbIdentity> identities;
+
+    public InMemoryIdentityBackend() {
+        this.identities = new HashMap<String, KrbIdentity>();
+    }
+
+    public InMemoryIdentityBackend(Map<String, KrbIdentity> identities) {
+        this();
+        this.identities.putAll(identities);
+    }
+
+    @Override
+    public List<KrbIdentity> getIdentities() {
+        List<KrbIdentity> results = new ArrayList<KrbIdentity>(identities.size());
+        results.addAll(identities.values());
+        return results;
+    }
+
+    @Override
+    public boolean checkIdentity(String name) {
+        return identities.containsKey(name);
+    }
+
+    @Override
+    public KrbIdentity getIdentity(String name) {
+        if (identities.containsKey(name)) {
+            return identities.get(name);
+        }
+        return null;
+    }
+
+    @Override
+    public void addIdentity(KrbIdentity identity) {
+        identities.put(identity.getPrincipalName(), identity);
+    }
+
+    @Override
+    public void updateIdentity(KrbIdentity identity) {
+        identities.put(identity.getPrincipalName(), identity);
+    }
+
+    @Override
+    public void deleteIdentity(KrbIdentity identity) {
+        identities.remove(identity.getPrincipalName());
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/backend/SimpleIdentityBackend.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/backend/SimpleIdentityBackend.java b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/backend/SimpleIdentityBackend.java
new file mode 100644
index 0000000..a74e453
--- /dev/null
+++ b/haox-kerb/kerb-identity/src/main/java/org/apache/kerberos/kerb/identity/backend/SimpleIdentityBackend.java
@@ -0,0 +1,27 @@
+package org.apache.kerberos.kerb.identity.backend;
+
+import java.io.File;
+
+public class SimpleIdentityBackend extends InMemoryIdentityBackend {
+
+    private File identityFile;
+
+    public SimpleIdentityBackend(File identityFile) {
+        super();
+        this.identityFile = identityFile;
+    }
+
+    /**
+     * Load identities from file
+     */
+    public void load() {
+        // todo
+    }
+
+    /**
+     * Persist the updated identities back
+     */
+    public void save() {
+        // todo
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/haox-kerb/kerb-kdc-test/pom.xml
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-kdc-test/pom.xml b/haox-kerb/kerb-kdc-test/pom.xml
new file mode 100644
index 0000000..839ca76
--- /dev/null
+++ b/haox-kerb/kerb-kdc-test/pom.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.haox</groupId>
+        <artifactId>haox-kerb</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>kerb-kdc-test</artifactId>
+
+    <name>Haox-kerb-KdcTest</name>
+    <description>Haox-kerb Kdc Test</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.haox</groupId>
+            <artifactId>haox-config</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.haox</groupId>
+            <artifactId>kerb-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.haox</groupId>
+            <artifactId>kerb-util</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.haox</groupId>
+            <artifactId>kerb-server</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.haox</groupId>
+            <artifactId>kerb-client</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.haox</groupId>
+            <artifactId>haox-pkix</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+</project>


Mime
View raw message