You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by dr...@apache.org on 2015/01/22 01:56:34 UTC
[10/50] [abbrv] directory-kerberos git commit: Many changes with
newname
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-pkix/src/main/resources/cacert.pem
----------------------------------------------------------------------
diff --git a/lib/haox-pkix/src/main/resources/cacert.pem b/lib/haox-pkix/src/main/resources/cacert.pem
deleted file mode 100644
index 6b91561..0000000
--- a/lib/haox-pkix/src/main/resources/cacert.pem
+++ /dev/null
@@ -1,23 +0,0 @@
------BEGIN CERTIFICATE-----
-MIID6zCCAtOgAwIBAgIJAMrZoeDxTzwWMA0GCSqGSIb3DQEBBQUAMIGLMQswCQYD
-VQQGEwJjaDERMA8GA1UECAwIc2hhbmdoYWkxETAPBgNVBAcMCHNoYW5naGFpMQ4w
-DAYDVQQKDAVpbnRlbDEQMA4GA1UECwwHYmlnZGF0YTEQMA4GA1UEAwwHYmlnZGF0
-YTEiMCAGCSqGSIb3DQEJARYTa2FpLnpoZW5nQGludGVsLmNvbTAeFw0xNDA1MTMx
-MzEzMjdaFw0yNDA1MTAxMzEzMjdaMIGLMQswCQYDVQQGEwJjaDERMA8GA1UECAwI
-c2hhbmdoYWkxETAPBgNVBAcMCHNoYW5naGFpMQ4wDAYDVQQKDAVpbnRlbDEQMA4G
-A1UECwwHYmlnZGF0YTEQMA4GA1UEAwwHYmlnZGF0YTEiMCAGCSqGSIb3DQEJARYT
-a2FpLnpoZW5nQGludGVsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
-ggEBAMCznJJ02ZUjCPvAwnBmfPs0akb5QRc/NKu8kCtAPWzgHS2JPTQfJhkDbTAD
-eIlg8IeJpOdrYnzdaBCzgxqjSkls+vxjYotOU0Zbrpy2bj0lRDqdYbNsiuConKgT
-MeuDEd/4ZI0X9NWLAi06Iv1F4mHXf36c6uqiUWTtXiofogrFUoTRwACKR2qeC95X
-Py+FDmpS9lz0mo0vDWjetLQC2IBngjjPFdR16n87QDIWfRBkk66rn7rEA6Li66b/
-cToajMSA/n+2Ud1mntSY4RdDdd0TBtAq9RrXtUOfzGaE7S6t+FtYyEprvT4FdOTU
-uyYgSNaI9ANVP1zhQ9LACKuudOECAwEAAaNQME4wHQYDVR0OBBYEFD91SVOejfwx
-u33+5N0TdYbHJbgAMB8GA1UdIwQYMBaAFD91SVOejfwxu33+5N0TdYbHJbgAMAwG
-A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADsONtUqGNBPBXnRowcJwv+Y
-F1Vea+4dkBwYbhkiO6H5XMKr+waOnOD2eAvgP4aeYg/a0xOzzETRD9wi1Z1P1ZMy
-d/NzHQjj4egPENwDv1PH2voZgsXXzXIqUMOtz9t12TuJUrSA2SBW1tz/evckHhNY
-fHg4ThvTIgwEdV/yvrOEBLV9dXG5IhhF+NW1MegTGkt4SpOoH1pi3o9VekVRnix9
-xrIdaC4Ee6vQaR603HwDS9Y+a1c2KU7QoLX8Vaa904cQ+rxhGsTAkocnZXeo6Hl5
-V8BlDYXxeP86fzcWi04ll2BmEEw/RimHEOLpGqxTVHJ5p5BVSCHP8aCD0VJheaU=
------END CERTIFICATE-----
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-pkix/src/main/resources/cakey.pem
----------------------------------------------------------------------
diff --git a/lib/haox-pkix/src/main/resources/cakey.pem b/lib/haox-pkix/src/main/resources/cakey.pem
deleted file mode 100644
index 66dc806..0000000
--- a/lib/haox-pkix/src/main/resources/cakey.pem
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEowIBAAKCAQEAwLOcknTZlSMI+8DCcGZ8+zRqRvlBFz80q7yQK0A9bOAdLYk9
-NB8mGQNtMAN4iWDwh4mk52tifN1oELODGqNKSWz6/GNii05TRluunLZuPSVEOp1h
-s2yK4KicqBMx64MR3/hkjRf01YsCLToi/UXiYdd/fpzq6qJRZO1eKh+iCsVShNHA
-AIpHap4L3lc/L4UOalL2XPSajS8NaN60tALYgGeCOM8V1HXqfztAMhZ9EGSTrquf
-usQDouLrpv9xOhqMxID+f7ZR3Wae1JjhF0N13RMG0Cr1Gte1Q5/MZoTtLq34W1jI
-Smu9PgV05NS7JiBI1oj0A1U/XOFD0sAIq6504QIDAQABAoIBAHqFeMax3unxBbQ0
-Aiy/LTX3RJ9tuZITUOTklnG5fZStBkA+oxhxuaJryE+f1VLbvPMgdCXj5BHqIFGG
-IZSdQA1hak9wzWYvXck9X88qOvtLp47xI/6Vw9NFwZ0n3zST+JiD8UK4eaYQpUim
-Tzrj5SU6hEi3crHOlJvsRFPaGwhnA9wycoOo4o22XBj3C8Hwzi4vWcKXH/RCSwZQ
-zFuYbe77Pn9Sv5q5zdglkmm7wngoVt/aKQke/Vk+Eincx1V12b05DNLjugo6FWQh
-0f2MmHpvqNSHs9USC5+y2lKQ1JNHh7mnpPCXkZEH4V7q+3mKVzl9tXzj9Gul20pw
-tneD6WUCgYEA9QUrQoWHKeVMjeukHjDJa2KjRLMmg9YRQyVABH9+nQTp1jYUjMRA
-GUoUx91gG6gjjJD/xvor/U0Fh3vKtZE93c+avrcaYDwf3q/L4gh+3b87lVDfzjrp
-L+MPTpEzWiyyLfr/kLA0TgUjnrj9bav5uDps8mJpNf8s9ZP1/QDhF5sCgYEAyVZA
-pHSIyBI2GT0+92JXvYDK/ZfV5m4RGHaG/PMDoU4IbGbjHVyzzsyzDUgvOASXwfF8
-YzwX7Tf95RZw12P/Jepxt0vqBJPKUCsMLUrmANQvN1Pz8+Vk6UADLM7kNc06MqB9
-/U3GKCFZZuedEhbgXnEV9gzelhILImJGZMxG0zMCgYApymnofLHjGXMHOcvSQmv4
-XuiODShikB59n1rd6YkE6xOfL7YtlEOCjLoipMWBshnuHcUigQUDvSFWTGz0rwMo
-VAKGyOA8zcR5zO4vbVeGJtnYy+SAXlfrjQTNV8K0fK8fXJI+cW9aZ1H9/ntrO0vq
-ejye0t4zEYTvlf782iuKRQKBgQCnTQ7mGRfX+JoPmv8JniR+idkjpNnPYsK96y/8
-XQs1LJx/R3eN3IxlWV+nt8XU7KwWMs5Dv5m6Ov61MFKQCL3qCch4oZJSP2Sr/Tlf
-IY/CPI8HkLF0h7e0wsZgo4Kq2mBz1T0cEVaJ3jxl8Cxq7at/jsTK8qK7XT73UWZh
-OAXaVQKBgDmg2QTX7c0/dbDMOuw18g3xfE/oqU+VWT784wtvpcdjHR+KAVLWHG8l
-oc/bm8Bs0o0f5dfH7uUvWdP6JMvbgYZBgIMqw+iH8P2lFCLzIRf0me/l+r0Oi64U
-5jp9K+7Ggc7S0SSnCLmBLMN5lXQZbhzks1La7DZmFeAz8rOEnlUB
------END RSA PRIVATE KEY-----
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-pkix/src/main/resources/extensions.kdc
----------------------------------------------------------------------
diff --git a/lib/haox-pkix/src/main/resources/extensions.kdc b/lib/haox-pkix/src/main/resources/extensions.kdc
deleted file mode 100644
index 8052f71..0000000
--- a/lib/haox-pkix/src/main/resources/extensions.kdc
+++ /dev/null
@@ -1,36 +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.
-[kdc_cert]
-basicConstraints=CA:FALSE
-keyUsage=nonRepudiation,digitalSignature,keyEncipherment,keyAgreement
-extendedKeyUsage=1.3.6.1.5.2.3.5
-subjectKeyIdentifier=hash
-authorityKeyIdentifier=keyid,issuer
-issuerAltName=issuer:copy
-subjectAltName=otherName:1.3.6.1.5.2.2;SEQUENCE:kdc_princ_name
-
-[kdc_princ_name]
-realm=EXP:0,GeneralString:${ENV::REALM}
-principal_name=EXP:1,SEQUENCE:kdc_principal_seq
-
-[kdc_principal_seq]
-name_type=EXP:0,INTEGER:1
-name_string=EXP:1,SEQUENCE:kdc_principals
-
-[kdc_principals]
-princ1=GeneralString:krbtgt
-princ2=GeneralString:${ENV::REALM}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-pkix/src/main/resources/kdccert.pem
----------------------------------------------------------------------
diff --git a/lib/haox-pkix/src/main/resources/kdccert.pem b/lib/haox-pkix/src/main/resources/kdccert.pem
deleted file mode 100644
index 67e538c..0000000
--- a/lib/haox-pkix/src/main/resources/kdccert.pem
+++ /dev/null
@@ -1,26 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIEYjCCA0qgAwIBAgIJAL2ZFUkXCgK2MA0GCSqGSIb3DQEBBQUAMIGLMQswCQYD
-VQQGEwJjaDERMA8GA1UECAwIc2hhbmdoYWkxETAPBgNVBAcMCHNoYW5naGFpMQ4w
-DAYDVQQKDAVpbnRlbDEQMA4GA1UECwwHYmlnZGF0YTEQMA4GA1UEAwwHYmlnZGF0
-YTEiMCAGCSqGSIb3DQEJARYTa2FpLnpoZW5nQGludGVsLmNvbTAeFw0xNDA1MTMx
-MzI3MjFaFw0xNTA1MTMxMzI3MjFaMIGLMQswCQYDVQQGEwJjaDERMA8GA1UECAwI
-c2hhbmdoYWkxETAPBgNVBAcMCHNoYW5naGFpMQ4wDAYDVQQKDAVpbnRlbDEQMA4G
-A1UECwwHYmlnZGF0YTEQMA4GA1UEAwwHYmlnZGF0YTEiMCAGCSqGSIb3DQEJARYT
-a2FpLnpoZW5nQGludGVsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
-ggEBAMs0jF1fi5AVMunQ/jpxgSjRlpmVQyT//LrwBmyI77C+hCD4z/InoG4q2tl5
-fAH+2n7HHgon4E0QXyRxAz0+Ugun7qHW9oT2pnxoc1l8seyGNMK9adsxLpCv7RXK
-quqLcj34UQCzRDKxgkH5UBwxGY0kId0W1MqPh1LZRZIk1hakREC4DBj+slnDkN0s
-nh8pC/8q/hTPJ9QrqWT6oc1FjMVKz3FxFbxXELYxg4M6SXnzGzdWa3xSe4Ou0QO2
-EwncQUoo8N6plOKX5lncDhC2usT//AZHvKdcVmOwX0ByxZqGQIXk7g1kbsbG5m45
-JMjt/HnOQcfg88iSLKJZu+ODw00CAwEAAaOBxjCBwzAJBgNVHRMEAjAAMAsGA1Ud
-DwQEAwID6DASBgNVHSUECzAJBgcrBgEFAgMFMB0GA1UdDgQWBBS8Bmb9kTUkw61e
-Is+9KDV5U6JjyjAfBgNVHSMEGDAWgBQ/dUlTno38Mbt9/uTdE3WGxyW4ADAJBgNV
-HRIEAjAAMEoGA1UdEQRDMEGgPwYGKwYBBQICoDUwM6AOGwxTSC5JTlRFTC5DT02h
-ITAfoAMCAQGhGDAWGwZrcmJ0Z3QbDFNILklOVEVMLkNPTTANBgkqhkiG9w0BAQUF
-AAOCAQEAS/I0zH9ByFcXTF56I5aPmPdzYKpIpFF6Kkwyw0M2EuIcTcpDl74/xmq9
-YPHS6TSDAt3wHzs9JQlSWah04L0R+IgHVacLRgdXfTWqglFFH/pve3p49WCrYmWz
-txQeRV5dxzaE3oTdDq15DRkUJmt0GIk1x6ehrGZOpIL8oTFmVmnR7EgrKWlIMYCs
-R/GkEuCH15wadom/Hw5Db1KLPEjxCdwy947guOh4SO0fcW3h55V3troS/46TbVFF
-FvNSqGD+19/QM/MhLIy5OnTxOio8M9zp+yfDlzLnpbMi0ZO6tLvB4XhjvP0as34c
-5vCA/8HPfaearSyAYi2Ir9vT3O9J/w==
------END CERTIFICATE-----
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-pkix/src/main/resources/kdckey.pem
----------------------------------------------------------------------
diff --git a/lib/haox-pkix/src/main/resources/kdckey.pem b/lib/haox-pkix/src/main/resources/kdckey.pem
deleted file mode 100644
index c9e75e2..0000000
--- a/lib/haox-pkix/src/main/resources/kdckey.pem
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEpAIBAAKCAQEAyzSMXV+LkBUy6dD+OnGBKNGWmZVDJP/8uvAGbIjvsL6EIPjP
-8iegbira2Xl8Af7afsceCifgTRBfJHEDPT5SC6fuodb2hPamfGhzWXyx7IY0wr1p
-2zEukK/tFcqq6otyPfhRALNEMrGCQflQHDEZjSQh3RbUyo+HUtlFkiTWFqREQLgM
-GP6yWcOQ3SyeHykL/yr+FM8n1CupZPqhzUWMxUrPcXEVvFcQtjGDgzpJefMbN1Zr
-fFJ7g67RA7YTCdxBSijw3qmU4pfmWdwOELa6xP/8Bke8p1xWY7BfQHLFmoZAheTu
-DWRuxsbmbjkkyO38ec5Bx+DzyJIsolm744PDTQIDAQABAoIBAQC4Byb3iQgDvK8X
-QcZ7dz/Zj7Yr8RmV8J8ZTTcEJB+umVtf4PWyAGEyZG0+dt7vj7ahCgMSf3qLUEBZ
-6F9en4n+NF/RAbTQRfAQyydr65nW8tPlaVTsxWW+cxTrn1eagh88MB5r2+3vWwL0
-bK04Wt8hC4//giXELKgJR+vRprqcVRgy11nYaTP59IDdg4YscbHfc/LYa7ABQ1G5
-5NKtjMy13UvtD/4C3TS1NpL2xtzAgQRe3XFDIyOmv476Ts1boqSHBFX+MXmLBAfi
-8Qhaj1DO8A0HS/c4egcL6esCe4kcgtCuq66n8JzOlVbCDGOYIUkUyQ9Nfo31M5i5
-XhqF9CsBAoGBAP7PqkncLAvyjHQKPpDyWCBtkV7z+DWRZRPz4w8tit+TiAv6hRF7
-kK+NUhP1mBuS4duyEV58B8LWOR0ir7ftbL0/unxR1XWMOvTEHr/9lG1sKZoI0dJS
-Ee+VvuVFwdm/ABxfnveGCRrSHY7GAvFln3gC1Cst3NPPKbpznb3FiH/JAoGBAMwn
-P1Labt/OuzB70Vxve3TCeFA6jYzcYdA3riv1V0FIWoNgcQ742b0+6HDpEQgn4Rdb
-KiKz8hSplM1nx8NyWwS9r7gRQ9HIc0qC5S4A0A9QEbdKrkUiQDlwHgdDKPPCWih9
-qH05etiQ044BtOq7uXsWYqiIomOW/XyDUEhbRRFlAoGALmVnj01Mo9xFILfgzomh
-7D2nE4/+qNpRekGVHWVgfPci9XNnGVjTbnOf90xnptWm1Fbm/Lo+u4ZAHgL71dSg
-UREyhoJsCJxA++Jd6v1kMkxYgtiKQ+53n5U3jg2Wj2xMu93ZVx6Lt9t8UEvTq1qi
-n7p8IWSXaeW1pmJ43V4DTakCgYAFcSpj+ASqnKUqxrIvB52/4As7AESTs7A7z7Ap
-5dFcoSQgimqZHpMXU1z43Y2hrQZ4C+sUn71dRaP80b5mfF7mwnOzsWogZnqESvb3
-AfiJ3/WI8Emy+BXEMjPqt6SY0t56Y9cg925J5ZpuF6eN9lEccd1RZssFYpoBPrLe
-KuitbQKBgQC3DNejUqol2max6rf4h/GnwLE2BOTmFLnswexlw76p/63Jo1SaVpk7
-9nAltsqNCl4L/eAJ8hJdeTE5YVjYsgAVJrXZbiRfxHBMeHj9g0d1VafGqdomKf0R
-7Qytlcvsw8jn96ckEMPPLJF0bX5cu9S6lMyEbb6Ih41P13uvgP6ufg==
------END RSA PRIVATE KEY-----
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-pkix/src/main/resources/usercert.pem
----------------------------------------------------------------------
diff --git a/lib/haox-pkix/src/main/resources/usercert.pem b/lib/haox-pkix/src/main/resources/usercert.pem
deleted file mode 100644
index 67e538c..0000000
--- a/lib/haox-pkix/src/main/resources/usercert.pem
+++ /dev/null
@@ -1,26 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIEYjCCA0qgAwIBAgIJAL2ZFUkXCgK2MA0GCSqGSIb3DQEBBQUAMIGLMQswCQYD
-VQQGEwJjaDERMA8GA1UECAwIc2hhbmdoYWkxETAPBgNVBAcMCHNoYW5naGFpMQ4w
-DAYDVQQKDAVpbnRlbDEQMA4GA1UECwwHYmlnZGF0YTEQMA4GA1UEAwwHYmlnZGF0
-YTEiMCAGCSqGSIb3DQEJARYTa2FpLnpoZW5nQGludGVsLmNvbTAeFw0xNDA1MTMx
-MzI3MjFaFw0xNTA1MTMxMzI3MjFaMIGLMQswCQYDVQQGEwJjaDERMA8GA1UECAwI
-c2hhbmdoYWkxETAPBgNVBAcMCHNoYW5naGFpMQ4wDAYDVQQKDAVpbnRlbDEQMA4G
-A1UECwwHYmlnZGF0YTEQMA4GA1UEAwwHYmlnZGF0YTEiMCAGCSqGSIb3DQEJARYT
-a2FpLnpoZW5nQGludGVsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
-ggEBAMs0jF1fi5AVMunQ/jpxgSjRlpmVQyT//LrwBmyI77C+hCD4z/InoG4q2tl5
-fAH+2n7HHgon4E0QXyRxAz0+Ugun7qHW9oT2pnxoc1l8seyGNMK9adsxLpCv7RXK
-quqLcj34UQCzRDKxgkH5UBwxGY0kId0W1MqPh1LZRZIk1hakREC4DBj+slnDkN0s
-nh8pC/8q/hTPJ9QrqWT6oc1FjMVKz3FxFbxXELYxg4M6SXnzGzdWa3xSe4Ou0QO2
-EwncQUoo8N6plOKX5lncDhC2usT//AZHvKdcVmOwX0ByxZqGQIXk7g1kbsbG5m45
-JMjt/HnOQcfg88iSLKJZu+ODw00CAwEAAaOBxjCBwzAJBgNVHRMEAjAAMAsGA1Ud
-DwQEAwID6DASBgNVHSUECzAJBgcrBgEFAgMFMB0GA1UdDgQWBBS8Bmb9kTUkw61e
-Is+9KDV5U6JjyjAfBgNVHSMEGDAWgBQ/dUlTno38Mbt9/uTdE3WGxyW4ADAJBgNV
-HRIEAjAAMEoGA1UdEQRDMEGgPwYGKwYBBQICoDUwM6AOGwxTSC5JTlRFTC5DT02h
-ITAfoAMCAQGhGDAWGwZrcmJ0Z3QbDFNILklOVEVMLkNPTTANBgkqhkiG9w0BAQUF
-AAOCAQEAS/I0zH9ByFcXTF56I5aPmPdzYKpIpFF6Kkwyw0M2EuIcTcpDl74/xmq9
-YPHS6TSDAt3wHzs9JQlSWah04L0R+IgHVacLRgdXfTWqglFFH/pve3p49WCrYmWz
-txQeRV5dxzaE3oTdDq15DRkUJmt0GIk1x6ehrGZOpIL8oTFmVmnR7EgrKWlIMYCs
-R/GkEuCH15wadom/Hw5Db1KLPEjxCdwy947guOh4SO0fcW3h55V3troS/46TbVFF
-FvNSqGD+19/QM/MhLIy5OnTxOio8M9zp+yfDlzLnpbMi0ZO6tLvB4XhjvP0as34c
-5vCA/8HPfaearSyAYi2Ir9vT3O9J/w==
------END CERTIFICATE-----
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-pkix/src/main/resources/userkey.pem
----------------------------------------------------------------------
diff --git a/lib/haox-pkix/src/main/resources/userkey.pem b/lib/haox-pkix/src/main/resources/userkey.pem
deleted file mode 100644
index c9e75e2..0000000
--- a/lib/haox-pkix/src/main/resources/userkey.pem
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEpAIBAAKCAQEAyzSMXV+LkBUy6dD+OnGBKNGWmZVDJP/8uvAGbIjvsL6EIPjP
-8iegbira2Xl8Af7afsceCifgTRBfJHEDPT5SC6fuodb2hPamfGhzWXyx7IY0wr1p
-2zEukK/tFcqq6otyPfhRALNEMrGCQflQHDEZjSQh3RbUyo+HUtlFkiTWFqREQLgM
-GP6yWcOQ3SyeHykL/yr+FM8n1CupZPqhzUWMxUrPcXEVvFcQtjGDgzpJefMbN1Zr
-fFJ7g67RA7YTCdxBSijw3qmU4pfmWdwOELa6xP/8Bke8p1xWY7BfQHLFmoZAheTu
-DWRuxsbmbjkkyO38ec5Bx+DzyJIsolm744PDTQIDAQABAoIBAQC4Byb3iQgDvK8X
-QcZ7dz/Zj7Yr8RmV8J8ZTTcEJB+umVtf4PWyAGEyZG0+dt7vj7ahCgMSf3qLUEBZ
-6F9en4n+NF/RAbTQRfAQyydr65nW8tPlaVTsxWW+cxTrn1eagh88MB5r2+3vWwL0
-bK04Wt8hC4//giXELKgJR+vRprqcVRgy11nYaTP59IDdg4YscbHfc/LYa7ABQ1G5
-5NKtjMy13UvtD/4C3TS1NpL2xtzAgQRe3XFDIyOmv476Ts1boqSHBFX+MXmLBAfi
-8Qhaj1DO8A0HS/c4egcL6esCe4kcgtCuq66n8JzOlVbCDGOYIUkUyQ9Nfo31M5i5
-XhqF9CsBAoGBAP7PqkncLAvyjHQKPpDyWCBtkV7z+DWRZRPz4w8tit+TiAv6hRF7
-kK+NUhP1mBuS4duyEV58B8LWOR0ir7ftbL0/unxR1XWMOvTEHr/9lG1sKZoI0dJS
-Ee+VvuVFwdm/ABxfnveGCRrSHY7GAvFln3gC1Cst3NPPKbpznb3FiH/JAoGBAMwn
-P1Labt/OuzB70Vxve3TCeFA6jYzcYdA3riv1V0FIWoNgcQ742b0+6HDpEQgn4Rdb
-KiKz8hSplM1nx8NyWwS9r7gRQ9HIc0qC5S4A0A9QEbdKrkUiQDlwHgdDKPPCWih9
-qH05etiQ044BtOq7uXsWYqiIomOW/XyDUEhbRRFlAoGALmVnj01Mo9xFILfgzomh
-7D2nE4/+qNpRekGVHWVgfPci9XNnGVjTbnOf90xnptWm1Fbm/Lo+u4ZAHgL71dSg
-UREyhoJsCJxA++Jd6v1kMkxYgtiKQ+53n5U3jg2Wj2xMu93ZVx6Lt9t8UEvTq1qi
-n7p8IWSXaeW1pmJ43V4DTakCgYAFcSpj+ASqnKUqxrIvB52/4As7AESTs7A7z7Ap
-5dFcoSQgimqZHpMXU1z43Y2hrQZ4C+sUn71dRaP80b5mfF7mwnOzsWogZnqESvb3
-AfiJ3/WI8Emy+BXEMjPqt6SY0t56Y9cg925J5ZpuF6eN9lEccd1RZssFYpoBPrLe
-KuitbQKBgQC3DNejUqol2max6rf4h/GnwLE2BOTmFLnswexlw76p/63Jo1SaVpk7
-9nAltsqNCl4L/eAJ8hJdeTE5YVjYsgAVJrXZbiRfxHBMeHj9g0d1VafGqdomKf0R
-7Qytlcvsw8jn96ckEMPPLJF0bX5cu9S6lMyEbb6Ih41P13uvgP6ufg==
------END RSA PRIVATE KEY-----
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-pkix/src/test/java/org/haox/pki/PkixTest.java
----------------------------------------------------------------------
diff --git a/lib/haox-pkix/src/test/java/org/haox/pki/PkixTest.java b/lib/haox-pkix/src/test/java/org/haox/pki/PkixTest.java
deleted file mode 100644
index 5f9b7f6..0000000
--- a/lib/haox-pkix/src/test/java/org/haox/pki/PkixTest.java
+++ /dev/null
@@ -1,60 +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.haox.pki;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.GeneralSecurityException;
-import java.security.PrivateKey;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.util.List;
-
-/**
- openssl genrsa -out cakey.pem 2048
- openssl req -key cakey.pem -new -x509 -out cacert.pem -days 3650
- vi extensions.kdc
- openssl genrsa -out kdckey.pem 2048
- openssl req -new -out kdc.req -key kdckey.pem
- env REALM=SH.INTEL.COM openssl x509 -req -in kdc.req -CAkey cakey.pem \
- -CA cacert.pem -out kdc.pem -days 365 -extfile extensions.kdc -extensions kdc_cert -CAcreateserial
- */
-public class PkixTest {
-
- @Test
- public void loadCert() throws CertificateException, IOException {
- InputStream res = getClass().getResourceAsStream("/usercert.pem");
- List<Certificate> certs = Pkix.getCerts(res);
- Certificate userCert = certs.iterator().next();
-
- Assert.assertNotNull(userCert);
- }
-
- @Test
- public void loadKey() throws GeneralSecurityException, IOException {
- InputStream res = getClass().getResourceAsStream("/userkey.pem");
- PrivateKey key = Pkix.getPrivateKey(res, null);
-
- Assert.assertNotNull(key);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-token/pom.xml
----------------------------------------------------------------------
diff --git a/lib/haox-token/pom.xml b/lib/haox-token/pom.xml
deleted file mode 100644
index 41fc52e..0000000
--- a/lib/haox-token/pom.xml
+++ /dev/null
@@ -1,44 +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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.haox</groupId>
- <artifactId>lib</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>haox-token</artifactId>
- <name>Haox-token Project</name>
- <version>1.0-SNAPSHOT</version>
- <packaging>jar</packaging>
-
- <dependencies>
- <dependency>
- <groupId>com.nimbusds</groupId>
- <artifactId>nimbus-jose-jwt</artifactId>
- <version>3.2</version>
- </dependency>
- <dependency>
- <groupId>org.haox</groupId>
- <artifactId>haox-asn1</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-token/src/main/java/org/haox/token/AuthzDataEntry.java
----------------------------------------------------------------------
diff --git a/lib/haox-token/src/main/java/org/haox/token/AuthzDataEntry.java b/lib/haox-token/src/main/java/org/haox/token/AuthzDataEntry.java
deleted file mode 100644
index 81f0987..0000000
--- a/lib/haox-token/src/main/java/org/haox/token/AuthzDataEntry.java
+++ /dev/null
@@ -1,52 +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.haox.token;
-
-import org.apache.haox.asn1.type.Asn1FieldInfo;
-import org.apache.haox.asn1.type.Asn1Integer;
-import org.apache.haox.asn1.type.Asn1OctetString;
-import org.apache.haox.asn1.type.Asn1SequenceType;
-
-/**
- AuthorizationData ::= SEQUENCE OF SEQUENCE {
- ad-type [0] Int32,
- ad-data [1] OCTET STRING
- }
- */
-public class AuthzDataEntry extends Asn1SequenceType {
- static int AD_TYPE = 0;
- static int AD_DATA = 1;
-
- public AuthzDataEntry() {
- super(new Asn1FieldInfo[] {
- new Asn1FieldInfo(AD_TYPE, Asn1Integer.class),
- new Asn1FieldInfo(AD_DATA, Asn1OctetString.class)
- });
- }
-
- public int getAuthzType() {
- Integer value = getFieldAsInteger(AD_TYPE);
- return value;
- }
-
- public byte[] getAuthzData() {
- return getFieldAsOctets(AD_DATA);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-token/src/main/java/org/haox/token/KerbToken.java
----------------------------------------------------------------------
diff --git a/lib/haox-token/src/main/java/org/haox/token/KerbToken.java b/lib/haox-token/src/main/java/org/haox/token/KerbToken.java
deleted file mode 100644
index a012628..0000000
--- a/lib/haox-token/src/main/java/org/haox/token/KerbToken.java
+++ /dev/null
@@ -1,47 +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.haox.token;
-
-import java.util.Map;
-
-public class KerbToken {
-
- private Map<String, Object> attributes;
-
- public KerbToken(Map<String, Object> attributes) {
- this.attributes = attributes;
- }
-
- public Map<String, Object> getAttributes() {
- return attributes;
- }
-
- public String getPrincipal() {
- return (String) attributes.get("sub");
- }
-
- public String[] getGroups() {
- String grp = (String) attributes.get("group");
- if (grp != null) {
- return new String[] { grp };
- }
- return new String[0];
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-token/src/main/java/org/haox/token/TokenCache.java
----------------------------------------------------------------------
diff --git a/lib/haox-token/src/main/java/org/haox/token/TokenCache.java b/lib/haox-token/src/main/java/org/haox/token/TokenCache.java
deleted file mode 100644
index c802051..0000000
--- a/lib/haox-token/src/main/java/org/haox/token/TokenCache.java
+++ /dev/null
@@ -1,82 +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.haox.token;
-
-import java.io.*;
-
-public class TokenCache {
- private static final String DEFAULT_TOKEN_CACHE_PATH = ".tokenauth";
- private static final String TOKEN_CACHE_FILE = ".tokenauth.token";
-
- public static String readToken(String tokenCacheFile) {
- File cacheFile = null;
-
- if (tokenCacheFile != null && ! tokenCacheFile.isEmpty()) {
- cacheFile = new File(tokenCacheFile);
- if (!cacheFile.exists()) {
- throw new RuntimeException("Invalid token cache specified: " + tokenCacheFile);
- };
- } else {
- cacheFile = getDefaultTokenCache();
- if (!cacheFile.exists()) {
- throw new RuntimeException("No token cache available by default");
- };
- }
-
- String token = null;
- try {
- BufferedReader reader = new BufferedReader(new FileReader(cacheFile));
- String line = reader.readLine();
- reader.close();
- if (line != null) {
- token = line;
- }
- } catch (IOException ex) {
- //NOP
- }
-
- return token;
- }
-
- public static void writeToken(String token) {
- File cacheFile = getDefaultTokenCache();
-
- try {
- Writer writer = new FileWriter(cacheFile);
- writer.write(token.toString());
- writer.close();
- // sets read-write permissions to owner only
- cacheFile.setReadable(false, false);
- cacheFile.setReadable(true, true);
- cacheFile.setWritable(true, true);
- }
- catch (IOException ioe) {
- // if case of any error we just delete the cache, if user-only
- // write permissions are not properly set a security exception
- // is thrown and the file will be deleted.
- cacheFile.delete();
- }
- }
-
- public static File getDefaultTokenCache() {
- String homeDir = System.getProperty("user.home", DEFAULT_TOKEN_CACHE_PATH);
- return new File(homeDir, TOKEN_CACHE_FILE);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-token/src/main/java/org/haox/token/TokenExtractor.java
----------------------------------------------------------------------
diff --git a/lib/haox-token/src/main/java/org/haox/token/TokenExtractor.java b/lib/haox-token/src/main/java/org/haox/token/TokenExtractor.java
deleted file mode 100644
index f6891fa..0000000
--- a/lib/haox-token/src/main/java/org/haox/token/TokenExtractor.java
+++ /dev/null
@@ -1,101 +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.haox.token;
-
-import com.sun.security.jgss.AuthorizationDataEntry;
-import com.sun.security.jgss.ExtendedGSSContext;
-import com.sun.security.jgss.InquireType;
-import org.apache.haox.asn1.type.Asn1SequenceOf;
-import org.ietf.jgss.GSSContext;
-import org.ietf.jgss.GSSException;
-
-import java.io.IOException;
-import java.util.List;
-
-public class TokenExtractor {
- static final int JWT_AUTHZ_DATA_TYPE = 81;
- public static final int AD_IF_RELEVANT_TYPE = 1;
-
- /**
- AuthorizationData ::= SEQUENCE OF SEQUENCE {
- ad-type [0] Int32,
- ad-data [1] OCTET STRING
- }
- */
- public static class AuthorizationData extends Asn1SequenceOf<AuthzDataEntry> {
-
- }
-
- public static KerbToken checkAuthzData(GSSContext context) throws GSSException, IOException {
- System.out.println("Looking for token from authorization data in GSSContext");
-
- Object authzData = null;
- if (context instanceof ExtendedGSSContext) {
- ExtendedGSSContext ex = (ExtendedGSSContext)context;
- authzData = ex.inquireSecContext(
- InquireType.KRB5_GET_AUTHZ_DATA);
- }
-
- if (authzData != null) {
- AuthorizationDataEntry[] authzEntries = (AuthorizationDataEntry[]) authzData;
- KerbToken resultToken = null;
- for (int i = 0; i < authzEntries.length; ++i) {
- resultToken = getAuthzToken(authzEntries[i]);
- if (resultToken != null) {
- return resultToken;
- }
- }
- }
- return null;
- }
-
- public static KerbToken getAuthzToken(AuthorizationDataEntry authzDataEntry) throws IOException {
- if (authzDataEntry.getType() == AD_IF_RELEVANT_TYPE) {
- String token = getToken(authzDataEntry);
- if (token == null) {
- return null;
- }
-
- try {
- return TokenTool.fromJwtToken(token);
- } catch (Exception e) {
- // noop when not jwt token
- }
- }
-
- return null;
- }
-
- public static String getToken(AuthorizationDataEntry authzDataEntry) throws IOException {
- List<AuthzDataEntry> entries = decode(authzDataEntry);
- for (AuthzDataEntry entry : entries) {
- if (entry.getAuthzType() == JWT_AUTHZ_DATA_TYPE) {
- return new String(entry.getAuthzData());
- }
- }
- return null;
- }
-
- public static List<AuthzDataEntry> decode(AuthorizationDataEntry authzDataEntry) throws IOException {
- AuthorizationData authzData = new AuthorizationData();
- authzData.decode(authzDataEntry.getData());
- return authzData.getElements();
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-token/src/main/java/org/haox/token/TokenTool.java
----------------------------------------------------------------------
diff --git a/lib/haox-token/src/main/java/org/haox/token/TokenTool.java b/lib/haox-token/src/main/java/org/haox/token/TokenTool.java
deleted file mode 100644
index 7c590f4..0000000
--- a/lib/haox-token/src/main/java/org/haox/token/TokenTool.java
+++ /dev/null
@@ -1,124 +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.haox.token;
-
-import com.nimbusds.jose.PlainHeader;
-import com.nimbusds.jwt.JWT;
-import com.nimbusds.jwt.JWTClaimsSet;
-import com.nimbusds.jwt.PlainJWT;
-
-import java.text.ParseException;
-import java.util.*;
-
-public class TokenTool {
-
- public static JWT issueToken(String principal, String group, String role) {
- // must have for kerb-token
- String krbPrincipal = principal + "@SH.INTEL.COM";
-
- PlainHeader header = new PlainHeader();
- //header.setCustomParameter("krbPrincipal", krbPrincipal);
-
- JWTClaimsSet jwtClaims = new JWTClaimsSet();
-
- String iss = "token-service";
- jwtClaims.setIssuer(iss);
-
- String sub = principal;
- jwtClaims.setSubject(sub);
-
- // must have for kerb-token
- jwtClaims.setSubject(krbPrincipal);
-
- jwtClaims.setClaim("group", group);
- if (role != null) {
- jwtClaims.setClaim("role", role);
- }
-
- List<String> aud = new ArrayList<String>();
- aud.add("krb5kdc-with-token-extension");
- jwtClaims.setAudience(aud);
-
- // Set expiration in 60 minutes
- final Date NOW = new Date(new Date().getTime() / 1000 * 1000);
- Date exp = new Date(NOW.getTime() + 1000 * 60 * 60);
- jwtClaims.setExpirationTime(exp);
-
- Date nbf = NOW;
- jwtClaims.setNotBeforeTime(nbf);
-
- Date iat = NOW;
- jwtClaims.setIssueTime(iat);
-
- String jti = UUID.randomUUID().toString();
- jwtClaims.setJWTID(jti);
-
- PlainJWT jwt = new PlainJWT(header, jwtClaims);
- return jwt;
- }
-
- public static JWT decodeToken(String token) throws ParseException {
- PlainJWT jwt = PlainJWT.parse(token);
-
- return jwt;
- }
-
- public static KerbToken fromJwtToken(String token) throws ParseException {
- Map<String, Object> attrs = decodeAndExtractTokenAttributes(token);
- return new KerbToken(attrs);
- }
-
- public static Map<String, Object> decodeAndExtractTokenAttributes(String token) throws ParseException {
- PlainJWT jwt = PlainJWT.parse(token);
-
- Map<String, Object> attrs = new HashMap<String, Object>();
- attrs.putAll(jwt.getJWTClaimsSet().getAllClaims());
- //attrs.putAll(jwt.getHeader().getCustomParameters());
-
- return attrs;
- }
-
- public static void main(String[] args) throws ParseException {
- String principal, group, role = null;
-
- if (args.length != 2 && args.length != 3) {
- System.out.println("This is a simple token issuing tool just for kerb-token PoC usage\n");
- System.out.println("tokeninit <username> <group> [role]\n");
- System.exit(1);
- }
- principal = args[0];
- group = args[1];
- if (args.length > 2) {
- role = args[2];
- }
-
- JWT jwt = issueToken(principal, group, role);
- String token = jwt.serialize();
-
- TokenCache.writeToken(token);
- System.out.println("Issued token: " + token);
-
- /*
- JWT jwt2 = decodeToken(token);
- String krbPrincipal = (String) jwt2.getHeader().getCustomParameter("krbPrincipal");
- System.out.println("Decoded token with krbprincipal: " + krbPrincipal);
- */
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-util/pom.xml
----------------------------------------------------------------------
diff --git a/lib/haox-util/pom.xml b/lib/haox-util/pom.xml
deleted file mode 100644
index 589c27b..0000000
--- a/lib/haox-util/pom.xml
+++ /dev/null
@@ -1,31 +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/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <artifactId>lib</artifactId>
- <groupId>org.haox</groupId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>haox-util</artifactId>
-
- <name>Haox Util</name>
- <description>Haox common util, without any 3rd party dependency</description>
-
- <dependencies>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/haox-util/src/main/java/org/haox/util/HexUtil.java
----------------------------------------------------------------------
diff --git a/lib/haox-util/src/main/java/org/haox/util/HexUtil.java b/lib/haox-util/src/main/java/org/haox/util/HexUtil.java
deleted file mode 100644
index f596b9f..0000000
--- a/lib/haox-util/src/main/java/org/haox/util/HexUtil.java
+++ /dev/null
@@ -1,58 +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.haox.util;
-
-public class HexUtil {
-
- 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/7d9261af/lib/kerby-config/README
----------------------------------------------------------------------
diff --git a/lib/kerby-config/README b/lib/kerby-config/README
new file mode 100644
index 0000000..37eb019
--- /dev/null
+++ b/lib/kerby-config/README
@@ -0,0 +1 @@
+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-kerberos/blob/7d9261af/lib/kerby-config/pom.xml
----------------------------------------------------------------------
diff --git a/lib/kerby-config/pom.xml b/lib/kerby-config/pom.xml
new file mode 100644
index 0000000..1499d09
--- /dev/null
+++ b/lib/kerby-config/pom.xml
@@ -0,0 +1,37 @@
+<?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>lib</artifactId>
+ <version>1.0-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>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/kerby-config/src/main/java/org/apache/kerby/config/Conf.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/Conf.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/Conf.java
new file mode 100644
index 0000000..3327fa3
--- /dev/null
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/Conf.java
@@ -0,0 +1,285 @@
+/**
+ * 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.*;
+
+public class Conf implements Config {
+ private static final Logger logger = LoggerFactory.getLogger(Conf.class);
+
+ private List<ConfigLoader> resourceConfigs;
+ private final ConfigImpl config;
+ private boolean needReload;
+
+ public Conf() {
+ this.resourceConfigs = new ArrayList<ConfigLoader>(1);
+ this.config = new ConfigImpl("Conf");
+ this.needReload = true;
+ }
+
+ 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, String> mapConfig) {
+ addResource(Resource.createMapResource(mapConfig));
+ }
+
+ public void addResource(Resource resource) {
+ ConfigLoader loader = getLoader(resource);
+ resourceConfigs.add(loader);
+ needReload = true;
+ }
+
+ private static ConfigLoader getLoader(Resource resource) {
+ ConfigLoader loader = null;
+
+ Class<? extends ConfigLoader> loaderClass = resource.getFormat().getLoaderClass();
+ try {
+ loader = loaderClass.newInstance();
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to create org.haox.config loader for " + loaderClass.getName(), e);
+ }
+ loader.setResource(resource);
+ return loader;
+ }
+
+ private void checkAndLoad() {
+ if (needReload) {
+ reload();
+ needReload = false;
+ }
+ }
+
+ public void reload() {
+ config.reset();
+ if (resourceConfigs.size() == 1) {
+ ConfigLoader loader = resourceConfigs.get(0);
+ loader.setConfig(config);
+ loader.load();
+ } else {
+ for (ConfigLoader loader : resourceConfigs) {
+ Config loaded = loader.load();
+ config.add(loaded);
+ }
+ }
+ }
+
+ @Override
+ public String getResource() {
+ checkAndLoad();
+ return config.getResource();
+ }
+
+ @Override
+ public Set<String> getNames() {
+ checkAndLoad();
+ return config.getNames();
+ }
+
+ @Override
+ public String getString(String name) {
+ checkAndLoad();
+ return config.getString(name);
+ }
+
+ @Override
+ public String getString(ConfigKey name) {
+ checkAndLoad();
+ return config.getString(name);
+ }
+
+ @Override
+ public String getString(String name, String defaultValue) {
+ checkAndLoad();
+ return config.getString(name, defaultValue);
+ }
+
+ @Override
+ public String getTrimmed(String name) {
+ checkAndLoad();
+ return config.getTrimmed(name);
+ }
+
+ @Override
+ public String getTrimmed(ConfigKey name) {
+ checkAndLoad();
+ return config.getTrimmed(name);
+ }
+
+ @Override
+ public Boolean getBoolean(String name) {
+ checkAndLoad();
+ return config.getBoolean(name);
+ }
+
+ @Override
+ public Boolean getBoolean(ConfigKey name) {
+ checkAndLoad();
+ return config.getBoolean(name);
+ }
+
+ @Override
+ public Boolean getBoolean(String name, boolean defaultValue) {
+ checkAndLoad();
+ return config.getBoolean(name, defaultValue);
+ }
+
+ @Override
+ public Integer getInt(String name) {
+ checkAndLoad();
+ return config.getInt(name);
+ }
+
+ @Override
+ public Integer getInt(ConfigKey name) {
+ checkAndLoad();
+ return config.getInt(name);
+ }
+
+ @Override
+ public Integer getInt(String name, int defaultValue) {
+ checkAndLoad();
+ return config.getInt(name, defaultValue);
+ }
+
+ @Override
+ public Long getLong(String name) {
+ checkAndLoad();
+ return config.getLong(name);
+ }
+
+ @Override
+ public Long getLong(ConfigKey name) {
+ checkAndLoad();
+ return config.getLong(name);
+ }
+
+ @Override
+ public Long getLong(String name, long defaultValue) {
+ checkAndLoad();
+ return config.getLong(name, defaultValue);
+ }
+
+ @Override
+ public Float getFloat(String name) {
+ checkAndLoad();
+ return config.getFloat(name);
+ }
+
+ @Override
+ public Float getFloat(ConfigKey name) {
+ checkAndLoad();
+ return config.getFloat(name);
+ }
+
+ @Override
+ public Float getFloat(String name, float defaultValue) {
+ checkAndLoad();
+ return config.getFloat(name, defaultValue);
+ }
+
+ @Override
+ public List<String> getList(String name) {
+ checkAndLoad();
+ return config.getList(name);
+ }
+
+ @Override
+ public List<String> getList(String name, String[] defaultValue) {
+ checkAndLoad();
+ return config.getList(name, defaultValue);
+ }
+
+ @Override
+ public List<String> getList(ConfigKey name) {
+ checkAndLoad();
+ return config.getList(name);
+ }
+
+ @Override
+ public Config getConfig(String name) {
+ checkAndLoad();
+ return config.getConfig(name);
+ }
+
+ @Override
+ public Config getConfig(ConfigKey name) {
+ checkAndLoad();
+ return config.getConfig(name);
+ }
+
+ @Override
+ public Class<?> getClass(String name) throws ClassNotFoundException {
+ checkAndLoad();
+ return config.getClass(name);
+ }
+
+ @Override
+ public Class<?> getClass(String name, Class<?> defaultValue) throws ClassNotFoundException {
+ checkAndLoad();
+ return config.getClass(name, defaultValue);
+ }
+
+ @Override
+ public Class<?> getClass(ConfigKey name) throws ClassNotFoundException {
+ checkAndLoad();
+ return config.getClass(name);
+ }
+
+ @Override
+ public <T> T getInstance(String name) throws ClassNotFoundException {
+ checkAndLoad();
+ return config.getInstance(name);
+ }
+
+ @Override
+ public <T> T getInstance(ConfigKey name) throws ClassNotFoundException {
+ checkAndLoad();
+ return config.getInstance(name);
+ }
+
+ @Override
+ public <T> T getInstance(String name, Class<T> xface) throws ClassNotFoundException {
+ checkAndLoad();
+ return config.getInstance(name, xface);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/kerby-config/src/main/java/org/apache/kerby/config/Config.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/Config.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/Config.java
new file mode 100644
index 0000000..14bfb16
--- /dev/null
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/Config.java
@@ -0,0 +1,58 @@
+/**
+ * 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;
+
+public interface Config {
+ public String getResource();
+ public Set<String> getNames();
+
+ public String getString(String name);
+ public String getString(ConfigKey name);
+ public String getString(String name, String defaultValue);
+ public String getTrimmed(String name);
+ public String getTrimmed(ConfigKey name);
+ public Boolean getBoolean(String name);
+ public Boolean getBoolean(ConfigKey name);
+ public Boolean getBoolean(String name, boolean defaultValue);
+ public Integer getInt(String name);
+ public Integer getInt(ConfigKey name);
+ public Integer getInt(String name, int defaultValue);
+ public Long getLong(String name);
+ public Long getLong(ConfigKey name);
+ public Long getLong(String name, long defaultValue);
+ public Float getFloat(String name);
+ public Float getFloat(ConfigKey name);
+ public Float getFloat(String name, float defaultValue);
+ public List<String> getList(String name);
+ public List<String> getList(String name, String[] defaultValue);
+ public List<String> getList(ConfigKey name);
+ public Config getConfig(String name);
+ public Config getConfig(ConfigKey name);
+
+ public Class<?> getClass(String name) throws ClassNotFoundException;
+ public Class<?> getClass(String name, Class<?> defaultValue) throws ClassNotFoundException;
+ public Class<?> getClass(ConfigKey name) throws ClassNotFoundException;
+ public <T> T getInstance(String name) throws ClassNotFoundException;
+ public <T> T getInstance(ConfigKey name) throws ClassNotFoundException;
+ public <T> T getInstance(String name, Class<T> xface) throws ClassNotFoundException;
+}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigImpl.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigImpl.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigImpl.java
new file mode 100644
index 0000000..629446e
--- /dev/null
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigImpl.java
@@ -0,0 +1,346 @@
+/**
+ * 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.util.*;
+
+public class ConfigImpl implements Config {
+ private static final Logger logger = LoggerFactory.getLogger(Config.class);
+
+ private String resource;
+ private Map<String, ConfigObject> properties;
+ /**
+ * Config resources
+ */
+ private List<Config> configs;
+
+ private Set<String> propNames;
+
+ 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() {
+ reloadNames();
+ return propNames;
+ }
+
+ @Override
+ public String getString(String name) {
+ String result = null;
+
+ ConfigObject co = properties.get(name);
+ if (co != null) {
+ result = co.getPropertyValue();
+ }
+
+ if (result == null) {
+ for (Config config : configs) {
+ result = config.getString(name);
+ if (result != null) break;
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public String getString(ConfigKey name) {
+ if (name.getDefaultValue() != null) {
+ 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) {
+ if (name.getDefaultValue() != null) {
+ return getInt(name.getPropertyKey(), (Integer) name.getDefaultValue());
+ }
+ return getInt(name.getPropertyKey());
+ }
+
+ @Override
+ public Integer getInt(String name, int defaultValue) {
+ Integer result = getInt(name);
+ if (result == null) {
+ result = defaultValue;
+ }
+ return result;
+ }
+
+ @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) {
+ if (name.getDefaultValue() != null) {
+ return getLong(name.getPropertyKey(), (Long) name.getDefaultValue());
+ }
+ 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 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) {
+ if (name.getDefaultValue() != null) {
+ return getFloat(name.getPropertyKey(), (Float) name.getDefaultValue());
+ }
+ 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 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) {
+ if (name.getDefaultValue() != null) {
+ 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 List<String> getList(String name) {
+ List<String> results = null;
+ ConfigObject co = properties.get(name);
+ if (co != null) {
+ results = co.getListValues();
+ }
+ 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();
+ }
+ 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) throws ClassNotFoundException {
+ if (name.getDefaultValue() != null) {
+ 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;
+ }
+
+ 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) {
+ this.configs.add(config);
+ }
+
+ private void reloadNames() {
+ if (propNames != null) {
+ propNames.clear();
+ }
+ propNames = new HashSet<String>(properties.keySet());
+ for (Config config : configs) {
+ propNames.addAll(config.getNames());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigKey.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigKey.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigKey.java
new file mode 100644
index 0000000..47f7727
--- /dev/null
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigKey.java
@@ -0,0 +1,25 @@
+/**
+ * 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 {
+ public String getPropertyKey();
+ public Object getDefaultValue();
+}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigLoader.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigLoader.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigLoader.java
new file mode 100644
index 0000000..476ed4c
--- /dev/null
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigLoader.java
@@ -0,0 +1,50 @@
+/**
+ * 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 org.haox.config", e);
+ }
+
+ return this.config;
+ }
+
+ protected abstract void loadConfig(ConfigImpl config, Resource resource) throws Exception;
+}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigObject.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigObject.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigObject.java
new file mode 100644
index 0000000..c915af6
--- /dev/null
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigObject.java
@@ -0,0 +1,80 @@
+/**
+ * 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 VALUE_TYPE { PROPERTY, LIST, CONFIG };
+
+ private VALUE_TYPE valueType;
+ private Object value;
+
+ public ConfigObject(String value) {
+ this.value = value;
+ this.valueType = VALUE_TYPE.PROPERTY;
+ }
+
+ public ConfigObject(String[] values) {
+ List<String> valuesList = new ArrayList<String>();
+ for (String v : values) {
+ valuesList.add(v);
+ }
+
+ this.value = valuesList;
+ this.valueType = VALUE_TYPE.LIST;
+ }
+
+ public ConfigObject(List<String> values) {
+ this.value = new ArrayList<String>(values);
+ this.valueType = VALUE_TYPE.LIST;
+ }
+
+ public ConfigObject(Config value) {
+ this.value = value;
+ this.valueType = VALUE_TYPE.CONFIG;
+ }
+
+ public String getPropertyValue() {
+ String result = null;
+ if (valueType == VALUE_TYPE.PROPERTY) {
+ result = (String) value;
+ }
+ return result;
+ }
+
+ public List<String> getListValues() {
+ List<String> results = null;
+ if (valueType == VALUE_TYPE.LIST) {
+ results = (List<String>) value;
+ }
+
+ return results;
+ }
+
+ public Config getConfigValue() {
+ Config result = null;
+ if (valueType == VALUE_TYPE.CONFIG) {
+ result = (Config) value;
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/kerby-config/src/main/java/org/apache/kerby/config/IniConfigLoader.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/IniConfigLoader.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/IniConfigLoader.java
new file mode 100644
index 0000000..cf9f56b
--- /dev/null
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/IniConfigLoader.java
@@ -0,0 +1,69 @@
+/**
+ * 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;
+
+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));
+
+ String line;
+ while ((line = reader.readLine()) != null) {
+ parseLine(line);
+ }
+ }
+
+ private void parseLine(String line) {
+ 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-kerberos/blob/7d9261af/lib/kerby-config/src/main/java/org/apache/kerby/config/JsonConfigLoader.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/JsonConfigLoader.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/JsonConfigLoader.java
new file mode 100644
index 0000000..5a51175
--- /dev/null
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/JsonConfigLoader.java
@@ -0,0 +1,27 @@
+/**
+ * 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-kerberos/blob/7d9261af/lib/kerby-config/src/main/java/org/apache/kerby/config/MapConfigLoader.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/MapConfigLoader.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/MapConfigLoader.java
new file mode 100644
index 0000000..f83517f
--- /dev/null
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/MapConfigLoader.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.config;
+
+import java.util.Map;
+
+public class MapConfigLoader extends ConfigLoader {
+ @Override
+ protected void loadConfig(ConfigImpl config, Resource resource) {
+ Map<String, String> mapConfig = (Map<String, String>) resource.getResource();
+ String value;
+ for (String key : mapConfig.keySet()) {
+ value = mapConfig.get(key);
+ config.set(key, value);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/kerby-config/src/main/java/org/apache/kerby/config/PropertiesConfigLoader.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/PropertiesConfigLoader.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/PropertiesConfigLoader.java
new file mode 100644
index 0000000..e0b9782
--- /dev/null
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/PropertiesConfigLoader.java
@@ -0,0 +1,43 @@
+/**
+ * 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.Properties;
+
+public class PropertiesConfigLoader extends ConfigLoader {
+
+ @Override
+ protected void loadConfig(ConfigImpl config, Resource resource) throws Exception {
+ Properties propConfig = (Properties) resource.getResource();
+ loadConfig(config, propConfig);
+ }
+
+ protected void loadConfig(ConfigImpl config, Properties propConfig) {
+ Object value;
+ for (Object key : propConfig.keySet()) {
+ if (key instanceof String) {
+ value = propConfig.getProperty((String) key);
+ if (value != null && value instanceof String) {
+ config.set((String) key, (String) value);
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/kerby-config/src/main/java/org/apache/kerby/config/PropertiesFileConfigLoader.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/PropertiesFileConfigLoader.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/PropertiesFileConfigLoader.java
new file mode 100644
index 0000000..ba8660f
--- /dev/null
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/PropertiesFileConfigLoader.java
@@ -0,0 +1,33 @@
+/**
+ * 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.InputStream;
+import java.util.Properties;
+
+public class PropertiesFileConfigLoader extends PropertiesConfigLoader {
+
+ @Override
+ protected void loadConfig(ConfigImpl config, Resource resource) throws Exception {
+ Properties propConfig = new Properties();
+ propConfig.load((InputStream) resource.getResource());
+ loadConfig(config, propConfig);
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/lib/kerby-config/src/main/java/org/apache/kerby/config/Resource.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/Resource.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/Resource.java
new file mode 100644
index 0000000..9da0405
--- /dev/null
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/Resource.java
@@ -0,0 +1,119 @@
+/**
+ * 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.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Map;
+import java.util.Properties;
+
+public class Resource {
+ public static enum Format {
+ XML_FILE(XmlConfigLoader.class),
+ INI_FILE(IniConfigLoader.class),
+ JSON_FILE(JsonConfigLoader.class),
+ PROPERTIES_FILE(PropertiesFileConfigLoader.class),
+ MAP(MapConfigLoader.class),
+ PROPERTIES(PropertiesConfigLoader.class);
+
+ private Class<? extends ConfigLoader> loaderClass;
+
+ private Format(Class<? extends ConfigLoader> loaderClass) {
+ this.loaderClass = loaderClass;
+ }
+
+ public Class<? extends ConfigLoader> getLoaderClass() {
+ return loaderClass;
+ }
+ }
+
+ private String name;
+ private Object resource;
+ private Format format;
+
+ public static Resource createXmlResource(File xmlFile) throws IOException {
+ return new Resource(xmlFile.getName(), xmlFile, Format.XML_FILE);
+ }
+
+ public static Resource createIniResource(File iniFile) throws IOException {
+ return new Resource(iniFile.getName(), iniFile, Format.INI_FILE);
+ }
+
+ public static Resource createJsonResource(File jsonFile) throws IOException {
+ return new Resource(jsonFile.getName(), jsonFile, Format.JSON_FILE);
+ }
+
+ public static Resource createXmlResource(URL xmlUrl) throws IOException {
+ return new Resource(xmlUrl, Format.XML_FILE);
+ }
+
+ public static Resource createIniResource(URL iniUrl) throws IOException {
+ return new Resource(iniUrl, Format.INI_FILE);
+ }
+
+ public static Resource createJsonResource(URL jsonUrl) throws IOException {
+ return new Resource(jsonUrl, Format.JSON_FILE);
+ }
+
+ public static Resource createMapResource(Map<String,String> mapConfig) {
+ return new Resource("mapConfig", mapConfig, Format.MAP);
+ }
+
+ public static Resource createPropertiesFileResource(File propFile) throws IOException {
+ return new Resource(propFile.getName(), propFile, Format.PROPERTIES_FILE);
+ }
+
+ public static Resource createPropertiesResource(Properties propertiesConfig) {
+ return new Resource("propConfig", propertiesConfig, Format.PROPERTIES);
+ }
+
+ private Resource(String name, File resourceFile, Format format) throws FileNotFoundException {
+ this(name, new FileInputStream(resourceFile), format);
+ }
+
+ private Resource(URL resourceUrl, Format format) throws IOException {
+ this(resourceUrl.toString(), resourceUrl.openStream(), format);
+ }
+
+ private Resource(String name, Object resourceStream, Format format) {
+ this.name = name;
+ this.resource = resourceStream;
+ this.format = format;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Object getResource() {
+ return resource;
+ }
+
+ public Format getFormat() {
+ return format;
+ }
+}
\ No newline at end of file