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:57:08 UTC
[44/50] [abbrv] directory-kerberos git commit: Many changes with
newname
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/main/resources/exceptions.properties
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/main/resources/exceptions.properties b/haox-kerb/kerb-core-test/src/main/resources/exceptions.properties
deleted file mode 100644
index c9cc814..0000000
--- a/haox-kerb/kerb-core-test/src/main/resources/exceptions.properties
+++ /dev/null
@@ -1,55 +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.
-object.cast.fail=Unable to cast object from {0} to {1}.
-
-spnego.token.empty=Empty SPNego token.
-spnego.token.invalid=Not a valid SPNego token: {0}.
-spnego.token.malformed=Malformed SPNego token.
-spnego.field.invalid=Not a valid SPNego token field: {0}.
-
-
-kerberos.object.cast=Unable to cast Kerberos object from {0} to {1}.
-kerberos.token.empty=Empty Kerberos token.
-kerberos.token.invalid=Not a Kerberos token.
-kerberos.token.malformed=Malformed Kerberos token.
-kerberos.kdcReq.empty=Empty message.
-kerberos.kdcReq.invalid=Not a KRB_AP_REQ message.
-kerberos.ticket.empty=Empty Kerberos ticket.
-kerberos.ticket.invalid=Not a Kerberos v5 ticket.
-kerberos.ticket.malformed=Malformed Kerberos ticket.
-kerberos.field.invalid=Not a valid Kerberos ticket field: {0}.
-kerberos.field.malformed=Malformed Kerberos ticket field.
-kerberos.key.notfound=Unable to find appropriate key of type {0}.
-kerberos.version.invalid=Invalid version of Kerberos ticket: {0}.
-kerberos.login.fail=Unable to get server keys.
-kerberos.decrypt.fail=Unable to decrypt encrypted data using key of type {0}.
-
-pac.token.empty=Empty PAC token.
-pac.token.malformed=Malformed PAC token.
-pac.logoninfo.malformed=Malformed PAC logon info.
-pac.signature.malformed=Malformed PAC signature.
-pac.signature.invalid=Invalid PAC signature.
-pac.string.notempty=String not empty while expected null.
-pac.string.malformed.size=Inconsistent string lengths.
-pac.string.invalid.size=Inconsistent string size: {1}, expecting {0}.
-pac.groups.invalid.size=Group count ({0}) doesn't match the real number of groups ({1}) in the PAC.
-pac.extrasids.invalid.size=Extra SID count ({0}) doesn't match the real number of extra SID ({1}) in the PAC.
-pac.resourcegroups.invalid.size=Resource group count ({0}) doesn't match the real number of resource groups ({1}) in the PAC.
-pac.sid.malformed.size=Inconsistent SID length.
-pac.subauthority.malformed.size=Incorrect byte array length: {0}; must be multiple of 4.
-pac.version.invalid=Invalid version of PAC token: {0}.
-pac.check.fail=Unable to check PAC signature.
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/main/resources/rc4-kerberos-data
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/main/resources/rc4-kerberos-data b/haox-kerb/kerb-core-test/src/main/resources/rc4-kerberos-data
deleted file mode 100644
index 6be7086..0000000
Binary files a/haox-kerb/kerb-core-test/src/main/resources/rc4-kerberos-data and /dev/null differ
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/main/resources/rc4-key-data
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/main/resources/rc4-key-data b/haox-kerb/kerb-core-test/src/main/resources/rc4-key-data
deleted file mode 100644
index 64f9d9c..0000000
--- a/haox-kerb/kerb-core-test/src/main/resources/rc4-key-data
+++ /dev/null
@@ -1 +0,0 @@
-l�܇y#�l�mv��k�
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/main/resources/rc4-pac-data
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/main/resources/rc4-pac-data b/haox-kerb/kerb-core-test/src/main/resources/rc4-pac-data
deleted file mode 100644
index df45f91..0000000
Binary files a/haox-kerb/kerb-core-test/src/main/resources/rc4-pac-data and /dev/null differ
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/main/resources/rc4-spnego-data
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/main/resources/rc4-spnego-data b/haox-kerb/kerb-core-test/src/main/resources/rc4-spnego-data
deleted file mode 100644
index 91cbe26..0000000
Binary files a/haox-kerb/kerb-core-test/src/main/resources/rc4-spnego-data and /dev/null differ
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/main/resources/server.keytab
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/main/resources/server.keytab b/haox-kerb/kerb-core-test/src/main/resources/server.keytab
deleted file mode 100644
index b44347c..0000000
Binary files a/haox-kerb/kerb-core-test/src/main/resources/server.keytab and /dev/null differ
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/main/resources/tgsrep.token
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/main/resources/tgsrep.token b/haox-kerb/kerb-core-test/src/main/resources/tgsrep.token
deleted file mode 100644
index 25d6270..0000000
Binary files a/haox-kerb/kerb-core-test/src/main/resources/tgsrep.token and /dev/null differ
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/main/resources/tgsreq.token
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/main/resources/tgsreq.token b/haox-kerb/kerb-core-test/src/main/resources/tgsreq.token
deleted file mode 100644
index 69f6b46..0000000
Binary files a/haox-kerb/kerb-core-test/src/main/resources/tgsreq.token and /dev/null differ
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/README.txt
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/README.txt b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/README.txt
deleted file mode 100644
index f1e0a3f..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/README.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-This project is simple for integration testing purpose. It's inspired by and originated from JaasLaunge.
-Eventually I will replace most of the codes by mine or get the granting permission of the author.
-
-http://jaaslounge.sourceforge.net/
-
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/AuthzDataUtil.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/AuthzDataUtil.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/AuthzDataUtil.java
deleted file mode 100644
index 77c1548..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/AuthzDataUtil.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.kerberos;
-
-import org.apache.kerberos.kerb.KrbException;
-import org.apache.kerberos.kerb.codec.pac.Pac;
-import org.apache.kerberos.kerb.spec.common.AuthorizationData;
-import org.apache.kerberos.kerb.spec.common.AuthorizationDataEntry;
-import org.apache.kerberos.kerb.spec.common.AuthorizationType;
-
-import java.io.IOException;
-import java.util.List;
-
-public class AuthzDataUtil {
-
- public static Pac getPac(AuthorizationData authzData, byte[] serverKey) throws IOException, KrbException {
- AuthorizationDataEntry ifRelevantAd = null;
- for (AuthorizationDataEntry entry : authzData.getElements()) {
- if (entry.getAuthzType() == AuthorizationType.AD_IF_RELEVANT) {
- ifRelevantAd = entry;
- break;
- }
- }
-
- if (ifRelevantAd != null) {
- List<AuthorizationDataEntry> entries = decode(ifRelevantAd);
- for (AuthorizationDataEntry entry : entries) {
- if (entry.getAuthzType() == AuthorizationType.AD_WIN2K_PAC) {
- return decodeAsPac(entry, serverKey);
- }
- }
- }
-
- return null;
- }
-
- public static List<AuthorizationDataEntry> decode(AuthorizationDataEntry entry) throws IOException {
- AuthorizationData authzData = new AuthorizationData();
- authzData.decode(entry.getAuthzData());
- return authzData.getElements();
- }
-
- public static Pac decodeAsPac(AuthorizationDataEntry entry, byte[] key) throws IOException, KrbException {
- if (entry.getAuthzType() != AuthorizationType.AD_WIN2K_PAC) {
- throw new IllegalArgumentException("Not AD_WIN2K_PAC type: " + entry.getAuthzType().name());
- }
-
- return new Pac(entry.getAuthzData(), key);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosApRequest.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosApRequest.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosApRequest.java
deleted file mode 100644
index bb2ad72..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosApRequest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.kerberos;
-
-
-import org.apache.kerberos.kerb.KrbException;
-import org.apache.kerberos.kerb.codec.KrbCodec;
-import org.apache.kerberos.kerb.spec.ap.ApOptions;
-import org.apache.kerberos.kerb.spec.ap.ApReq;
-import org.apache.kerberos.kerb.spec.common.EncryptionKey;
-
-import java.io.IOException;
-
-public class KerberosApRequest {
- private ApReq apReq;
- private KerberosTicket ticket;
-
- public KerberosApRequest(byte[] token, EncryptionKey key) throws Exception {
- if(token.length <= 0) {
- throw new IOException("kerberos request empty");
- }
-
- apReq = KrbCodec.decode(token, ApReq.class);
- ticket = new KerberosTicket(apReq.getTicket(), apReq.getApOptions(), key);
- }
-
- public ApOptions getApOptions() throws KrbException {
- return apReq.getApOptions();
- }
-
- public KerberosTicket getTicket() {
- return ticket;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosConstants.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosConstants.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosConstants.java
deleted file mode 100644
index a09e349..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosConstants.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.kerberos;
-
-public interface KerberosConstants {
-
- static final String KERBEROS_OID = "1.2.840.113554.1.2.2";
- static final String KERBEROS_VERSION = "5";
-
- static final String KERBEROS_AP_REQ = "14";
-
- static final int AF_INTERNET = 2;
- static final int AF_CHANET = 5;
- static final int AF_XNS = 6;
- static final int AF_ISO = 7;
-
- static final int AUTH_DATA_RELEVANT = 1;
- static final int AUTH_DATA_PAC = 128;
-
- static final int DES_ENC_TYPE = 3;
- static final int RC4_ENC_TYPE = 23;
- static final String RC4_ALGORITHM = "ARCFOUR";
- static final String HMAC_ALGORITHM = "HmacMD5";
- static final int CONFOUNDER_SIZE = 8;
- static final int CHECKSUM_SIZE = 16;
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosCredentials.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosCredentials.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosCredentials.java
deleted file mode 100644
index a512b5f..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosCredentials.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.kerberos;
-
-import org.apache.kerberos.kerb.keytab.Keytab;
-import org.apache.kerberos.kerb.keytab.KeytabEntry;
-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.io.IOException;
-import java.io.InputStream;
-
-public class KerberosCredentials {
-
- private static Keytab keytab;
-
- private static void init() throws IOException {
- InputStream kis = KerberosCredentials.class.getResourceAsStream("/server.keytab");
- keytab = new Keytab();
- keytab.load(kis);
- }
-
- public static EncryptionKey getServerKey(EncryptionType etype) throws IOException {
- if (keytab == null) {
- init();
- }
-
- for (PrincipalName principal : keytab.getPrincipals()) {
- for (KeytabEntry entry : keytab.getKeytabEntries(principal)) {
- if (entry.getKey().getKeyType() == etype) {
- return entry.getKey();
- }
- }
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosTicket.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosTicket.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosTicket.java
deleted file mode 100644
index 805db38..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosTicket.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.kerberos;
-
-import org.apache.kerberos.kerb.KrbException;
-import org.apache.kerberos.kerb.codec.KrbCodec;
-import org.apache.kerberos.kerb.crypto.EncryptionHandler;
-import org.apache.kerberos.kerb.spec.ap.ApOptions;
-import org.apache.kerberos.kerb.spec.common.AuthorizationData;
-import org.apache.kerberos.kerb.spec.common.EncryptedData;
-import org.apache.kerberos.kerb.spec.common.EncryptionKey;
-import org.apache.kerberos.kerb.spec.common.KeyUsage;
-import org.apache.kerberos.kerb.spec.ticket.EncTicketPart;
-import org.apache.kerberos.kerb.spec.ticket.Ticket;
-
-import java.util.Arrays;
-
-public class KerberosTicket {
- private String serverPrincipalName;
- private String serverRealm;
- private Ticket ticket;
-
- public KerberosTicket(Ticket ticket, ApOptions apOptions, EncryptionKey key)
- throws Exception {
- this.ticket = ticket;
-
- byte[] decrypted = EncryptionHandler.decrypt(
- ticket.getEncryptedEncPart(), key, KeyUsage.KDC_REP_TICKET);
-
- EncTicketPart encPart = KrbCodec.decode(decrypted, EncTicketPart.class);
- ticket.setEncPart(encPart);
-
- /**
- * Also test encryption by the way
- */
- EncryptedData encrypted = EncryptionHandler.encrypt(
- decrypted, key, KeyUsage.KDC_REP_TICKET);
-
- byte[] decrypted2 = EncryptionHandler.decrypt(
- encrypted, key, KeyUsage.KDC_REP_TICKET);
- if (!Arrays.equals(decrypted, decrypted2)) {
- throw new KrbException("Encryption checking failed after decryption");
- }
- }
-
- public String getUserPrincipalName() throws KrbException {
- return ticket.getEncPart().getCname().getName();
- }
-
- public String getUserRealm() throws KrbException {
- return ticket.getEncPart().getCrealm();
- }
-
- public String getServerPrincipalName() throws KrbException {
- return ticket.getSname().getName();
- }
-
- public String getServerRealm() throws KrbException {
- return ticket.getRealm();
- }
-
- public AuthorizationData getAuthorizationData() throws KrbException {
- return ticket.getEncPart().getAuthorizationData();
- }
-
- public Ticket getTicket() {
- return ticket;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosToken.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosToken.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosToken.java
deleted file mode 100644
index 26e2db8..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/kerberos/KerberosToken.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.apache.kerberos.kerb.codec.kerberos;
-
-import org.apache.haox.asn1.Asn1InputBuffer;
-import org.apache.haox.asn1.type.Asn1Item;
-import org.apache.kerberos.kerb.spec.common.EncryptionKey;
-
-import java.io.IOException;
-
-public class KerberosToken {
-
- private KerberosApRequest apRequest;
-
- public KerberosToken(byte[] token) throws Exception {
- this(token, null);
- }
-
- public KerberosToken(byte[] token, EncryptionKey key) throws Exception {
-
- if(token.length <= 0)
- throw new IOException("kerberos.token.empty");
-
- Asn1InputBuffer buffer = new Asn1InputBuffer(token);
-
- Asn1Item value = (Asn1Item) buffer.read();
- if(! value.isAppSpecific() && ! value.isConstructed())
- throw new IOException("kerberos.token.malformed");
-
- buffer = new Asn1InputBuffer(value.getBodyContent());
- buffer.skipNext();
-
- buffer.skipBytes(2);
-
- apRequest = new KerberosApRequest(buffer.readAllLeftBytes(), key);
- }
-
- public KerberosApRequest getApRequest() {
- return apRequest;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/Pac.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/Pac.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/Pac.java
deleted file mode 100644
index 560ed17..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/Pac.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.pac;
-
-import org.apache.kerberos.kerb.KrbException;
-import org.apache.kerberos.kerb.crypto.CheckSumHandler;
-import org.apache.kerberos.kerb.spec.common.CheckSum;
-import org.apache.kerberos.kerb.spec.common.KeyUsage;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-
-public class Pac {
-
- private PacLogonInfo logonInfo;
- private PacCredentialType credentialType;
- private PacSignature serverSignature;
- private PacSignature kdcSignature;
-
- public Pac(byte[] data, byte[] key) throws KrbException {
- byte[] checksumData = data.clone();
- try {
- PacDataInputStream pacStream = new PacDataInputStream(new DataInputStream(
- new ByteArrayInputStream(data)));
-
- if(data.length <= 8)
- throw new IOException("pac.token.empty");
-
- int bufferCount = pacStream.readInt();
- int version = pacStream.readInt();
-
- if(version != PacConstants.PAC_VERSION) {
- Object[] args = new Object[]{version};
- throw new IOException("pac.version.invalid");
- }
-
- for(int bufferIndex = 0; bufferIndex < bufferCount; bufferIndex++) {
- int bufferType = pacStream.readInt();
- int bufferSize = pacStream.readInt();
- long bufferOffset = pacStream.readLong();
- byte[] bufferData = new byte[bufferSize];
- System.arraycopy(data, (int)bufferOffset, bufferData, 0, bufferSize);
-
- switch (bufferType) {
- case PacConstants.LOGON_INFO:
- // PAC Credential Information
- logonInfo = new PacLogonInfo(bufferData);
- break;
- case PacConstants.CREDENTIAL_TYPE:
- // PAC Credential Type
- credentialType = new PacCredentialType(bufferData);
- break;
- case PacConstants.SERVER_CHECKSUM:
- // PAC Server Signature
- serverSignature = new PacSignature(bufferData);
- // Clear signature from checksum copy
- for(int i = 0; i < bufferSize; i++)
- checksumData[(int)bufferOffset + 4 + i] = 0;
- break;
- case PacConstants.PRIVSVR_CHECKSUM:
- // PAC KDC Signature
- kdcSignature = new PacSignature(bufferData);
- // Clear signature from checksum copy
- for(int i = 0; i < bufferSize; i++)
- checksumData[(int)bufferOffset + 4 + i] = 0;
- break;
- default:
- }
- }
- } catch(IOException e) {
- throw new KrbException("pac.token.malformed", e);
- }
-
- CheckSum checksum = new CheckSum(serverSignature.getType(), serverSignature.getChecksum());
- if (! CheckSumHandler.verifyWithKey(checksum, checksumData, key, KeyUsage.APP_DATA_CKSUM)) {
- throw new KrbException("Check sum verifying failed");
- }
- }
-
- public PacLogonInfo getLogonInfo() {
- return logonInfo;
- }
-
- public PacCredentialType getCredentialType() {
- return credentialType;
- }
-
- public PacSignature getServerSignature() {
- return serverSignature;
- }
-
- public PacSignature getKdcSignature() {
- return kdcSignature;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacConstants.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacConstants.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacConstants.java
deleted file mode 100644
index c076d4e..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacConstants.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.pac;
-
-public interface PacConstants {
-
- static final int PAC_VERSION = 0;
-
- static final int LOGON_INFO = 1;
- static final int CREDENTIAL_TYPE = 2;
- static final int SERVER_CHECKSUM = 6;
- static final int PRIVSVR_CHECKSUM = 7;
-
- static final int LOGON_EXTRA_SIDS = 0x20;
- static final int LOGON_RESOURCE_GROUPS = 0x200;
-
- static final long FILETIME_BASE = -11644473600000L;
-
- static final int MD5_KRB_SALT = 17;
- static final int MD5_BLOCK_LENGTH = 64;
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacCredentialType.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacCredentialType.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacCredentialType.java
deleted file mode 100644
index 8d42528..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacCredentialType.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.pac;
-
-import java.io.IOException;
-
-public class PacCredentialType {
-
- private static final int MINIMAL_BUFFER_SIZE = 32;
-
- private byte[] credentialType;
-
- public PacCredentialType(byte[] data) throws IOException {
- credentialType = data;
- if(!isCredentialTypeCorrect()) {
- throw new IOException("pac.credentialtype.malformed");
- }
- }
-
- public boolean isCredentialTypeCorrect() {
- return credentialType != null && credentialType.length < MINIMAL_BUFFER_SIZE;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacDataInputStream.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacDataInputStream.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacDataInputStream.java
deleted file mode 100644
index 81f41e5..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacDataInputStream.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.pac;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.util.Date;
-
-public class PacDataInputStream {
-
- private DataInputStream dis;
- private int size;
-
- public PacDataInputStream(InputStream in) throws IOException {
- dis = new DataInputStream(in);
- size = in.available();
- }
-
- public void align(int mask) throws IOException {
- int position = size - dis.available();
- int shift = position & mask - 1;
- if(mask != 0 && shift != 0)
- dis.skip(mask - shift);
- }
-
- public int available() throws IOException {
- return dis.available();
- }
-
- public void readFully(byte[] b) throws IOException {
- dis.readFully(b);
- }
-
- public void readFully(byte[] b, int off, int len) throws IOException {
- dis.readFully(b, off, len);
- }
-
- public char readChar() throws IOException {
- align(2);
- return dis.readChar();
- }
-
- public byte readByte() throws IOException {
- return dis.readByte();
- }
-
- public short readShort() throws IOException {
- align(2);
- return Short.reverseBytes((short)dis.readShort());
- }
-
- public int readInt() throws IOException {
- align(4);
- return Integer.reverseBytes(dis.readInt());
- }
-
- public long readLong() throws IOException {
- align(8);
- return Long.reverseBytes(dis.readLong());
- }
-
- public int readUnsignedByte() throws IOException {
- return ((int)readByte()) & 0xff;
- }
-
- public long readUnsignedInt() throws IOException {
- return ((long)readInt()) & 0xffffffffL;
- }
-
- public int readUnsignedShort() throws IOException {
- return ((int)readShort()) & 0xffff;
- }
-
- public Date readFiletime() throws IOException {
- Date date = null;
-
- long last = readUnsignedInt();
- long first = readUnsignedInt();
- if(first != 0x7fffffffL && last != 0xffffffffL) {
- BigInteger lastBigInt = BigInteger.valueOf(last);
- BigInteger firstBigInt = BigInteger.valueOf(first);
- BigInteger completeBigInt = lastBigInt.add(firstBigInt.shiftLeft(32));
- completeBigInt = completeBigInt.divide(BigInteger.valueOf(10000L));
- completeBigInt = completeBigInt.add(BigInteger.valueOf(PacConstants.FILETIME_BASE));
- date = new Date(completeBigInt.longValue());
- }
-
- return date;
- }
-
- public PacUnicodeString readUnicodeString() throws IOException {
- short length = readShort();
- short maxLength = readShort();
- int pointer = readInt();
-
- if(maxLength < length) {
- throw new IOException("pac.string.malformed.size");
- }
-
- return new PacUnicodeString(length, maxLength, pointer);
- }
-
- public String readString() throws IOException {
- int totalChars = readInt();
- int unusedChars = readInt();
- int usedChars = readInt();
-
- if(unusedChars > totalChars || usedChars > totalChars - unusedChars)
- throw new IOException("pac.string.malformed.size");
-
- dis.skip(unusedChars * 2);
- char[] chars = new char[usedChars];
- for(int l = 0; l < usedChars; l++)
- chars[l] = (char)readShort();
-
- return new String(chars);
- }
-
- public PacSid readId() throws IOException {
- byte[] bytes = new byte[4];
- readFully(bytes);
-
- return PacSid.createFromSubs(bytes);
- }
-
- public PacSid readSid() throws IOException {
- int sidSize = readInt();
-
- byte[] bytes = new byte[8 + sidSize * 4];
- readFully(bytes);
-
- return new PacSid(bytes);
- }
-
- public int skipBytes(int n) throws IOException {
- return dis.skipBytes(n);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacGroup.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacGroup.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacGroup.java
deleted file mode 100644
index 3f159ff..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacGroup.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.pac;
-
-public class PacGroup {
-
- private PacSid id;
- private int attributes;
-
- public PacGroup(PacSid id, int attributes) {
- super();
- this.id = id;
- this.attributes = attributes;
- }
-
- public PacSid getId() {
- return id;
- }
-
- public int getAttributes() {
- return attributes;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacLogonInfo.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacLogonInfo.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacLogonInfo.java
deleted file mode 100644
index 61d436e..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacLogonInfo.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.pac;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.util.Date;
-
-public class PacLogonInfo {
-
- private Date logonTime;
- private Date logoffTime;
- private Date kickOffTime;
- private Date pwdLastChangeTime;
- private Date pwdCanChangeTime;
- private Date pwdMustChangeTime;
- private short logonCount;
- private short badPasswordCount;
- private String userName;
- private String userDisplayName;
- private String logonScript;
- private String profilePath;
- private String homeDirectory;
- private String homeDrive;
- private String serverName;
- private String domainName;
- private PacSid userSid;
- private PacSid groupSid;
- private PacSid[] groupSids;
- private PacSid[] resourceGroupSids;
- private PacSid[] extraSids;
- private int userAccountControl;
- private int userFlags;
-
- public PacLogonInfo(byte[] data) throws IOException {
- try {
- PacDataInputStream pacStream = new PacDataInputStream(new DataInputStream(
- new ByteArrayInputStream(data)));
-
- // Skip firsts
- pacStream.skipBytes(20);
-
- // Dates
- logonTime = pacStream.readFiletime();
- logoffTime = pacStream.readFiletime();
- kickOffTime = pacStream.readFiletime();
- pwdLastChangeTime = pacStream.readFiletime();
- pwdCanChangeTime = pacStream.readFiletime();
- pwdMustChangeTime = pacStream.readFiletime();
-
- // User related strings as UnicodeStrings
- PacUnicodeString userNameString = pacStream.readUnicodeString();
- PacUnicodeString userDisplayNameString = pacStream.readUnicodeString();
- PacUnicodeString logonScriptString = pacStream.readUnicodeString();
- PacUnicodeString profilePathString = pacStream.readUnicodeString();
- PacUnicodeString homeDirectoryString = pacStream.readUnicodeString();
- PacUnicodeString homeDriveString = pacStream.readUnicodeString();
-
- // Some counts
- logonCount = pacStream.readShort();
- badPasswordCount = pacStream.readShort();
-
- // IDs for user
- PacSid userId = pacStream.readId();
- PacSid groupId = pacStream.readId();
-
- // Groups information
- int groupCount = pacStream.readInt();
- int groupPointer = pacStream.readInt();
-
- // User flags about PAC Logon Info content
- userFlags = pacStream.readInt();
- boolean hasExtraSids = (userFlags & PacConstants.LOGON_EXTRA_SIDS) == PacConstants.LOGON_EXTRA_SIDS;
- boolean hasResourceGroups = (userFlags & PacConstants.LOGON_RESOURCE_GROUPS) == PacConstants.LOGON_RESOURCE_GROUPS;
-
- // Skip some reserved fields (User Session Key)
- pacStream.skipBytes(16);
-
- // Server related strings as UnicodeStrings
- PacUnicodeString serverNameString = pacStream.readUnicodeString();
- PacUnicodeString domainNameString = pacStream.readUnicodeString();
-
- // ID for domain (used with relative IDs to get SIDs)
- int domainIdPointer = pacStream.readInt();
-
- // Skip some reserved fields
- pacStream.skipBytes(8);
-
- userAccountControl = pacStream.readInt();
-
- // Skip some reserved fields
- pacStream.skipBytes(28);
-
- // Extra SIDs information
- int extraSidCount = pacStream.readInt();
- int extraSidPointer = pacStream.readInt();
-
- // ID for resource groups domain (used with IDs to get SIDs)
- int resourceDomainIdPointer = pacStream.readInt();
-
- // Resource groups information
- int resourceGroupCount = pacStream.readInt();
- int resourceGroupPointer = pacStream.readInt();
-
- // User related strings
- userName = userNameString.check(pacStream.readString());
- userDisplayName = userDisplayNameString.check(pacStream.readString());
- logonScript = logonScriptString.check(pacStream.readString());
- profilePath = profilePathString.check(pacStream.readString());
- homeDirectory = homeDirectoryString.check(pacStream.readString());
- homeDrive = homeDriveString.check(pacStream.readString());
-
- // Groups data
- PacGroup[] groups = new PacGroup[0];
- if(groupPointer != 0) {
- int realGroupCount = pacStream.readInt();
- if(realGroupCount != groupCount) {
- Object[] args = new Object[]{groupCount, realGroupCount};
- throw new IOException("pac.groups.invalid.size");
- }
- groups = new PacGroup[groupCount];
- for(int i = 0; i < groupCount; i++) {
- pacStream.align(4);
- PacSid id = pacStream.readId();
- int attributes = pacStream.readInt();
- groups[i] = new PacGroup(id, attributes);
- }
- }
-
- // Server related strings
- serverName = serverNameString.check(pacStream.readString());
- domainName = domainNameString.check(pacStream.readString());
-
- // ID for domain (used with relative IDs to get SIDs)
- PacSid domainId = null;
- if(domainIdPointer != 0)
- domainId = pacStream.readSid();
-
- // Extra SIDs data
- PacSidAttributes[] extraSidAtts = new PacSidAttributes[0];
- if(hasExtraSids && extraSidPointer != 0) {
- int realExtraSidCount = pacStream.readInt();
- if(realExtraSidCount != extraSidCount) {
- Object[] args = new Object[]{extraSidCount, realExtraSidCount};
- throw new IOException("pac.extrasids.invalid.size");
- }
- extraSidAtts = new PacSidAttributes[extraSidCount];
- int[] pointers = new int[extraSidCount];
- int[] attributes = new int[extraSidCount];
- for(int i = 0; i < extraSidCount; i++) {
- pointers[i] = pacStream.readInt();
- attributes[i] = pacStream.readInt();
- }
- for(int i = 0; i < extraSidCount; i++) {
- PacSid sid = (pointers[i] != 0) ? pacStream.readSid() : null;
- extraSidAtts[i] = new PacSidAttributes(sid, attributes[i]);
- }
- }
-
- // ID for resource domain (used with relative IDs to get SIDs)
- PacSid resourceDomainId = null;
- if(resourceDomainIdPointer != 0)
- resourceDomainId = pacStream.readSid();
-
- // Resource groups data
- PacGroup[] resourceGroups = new PacGroup[0];
- if(hasResourceGroups && resourceGroupPointer != 0) {
- int realResourceGroupCount = pacStream.readInt();
- if(realResourceGroupCount != resourceGroupCount) {
- Object[] args = new Object[]{resourceGroupCount, realResourceGroupCount};
- throw new IOException("pac.resourcegroups.invalid.size");
- }
- resourceGroups = new PacGroup[resourceGroupCount];
- for(int i = 0; i < resourceGroupCount; i++) {
- PacSid id = pacStream.readSid();
- int attributes = pacStream.readInt();
- resourceGroups[i] = new PacGroup(id, attributes);
- }
- }
-
- // Extract Extra SIDs
- extraSids = new PacSid[extraSidAtts.length];
- for(int i = 0; i < extraSidAtts.length; i++) {
- extraSids[i] = extraSidAtts[i].getId();
- }
-
- // Compute Resource Group IDs with Resource Domain ID to get SIDs
- resourceGroupSids = new PacSid[resourceGroups.length];
- for(int i = 0; i < resourceGroups.length; i++) {
- resourceGroupSids[i] = PacSid.append(resourceDomainId, resourceGroups[i].getId());
- }
-
- // Compute User IDs with Domain ID to get User SIDs
- // First extra is user if userId is empty
- if(!userId.isEmpty() && !userId.isBlank()) {
- userSid = PacSid.append(domainId, userId);
- } else if(extraSids.length > 0) {
- userSid = extraSids[0];
- }
- groupSid = PacSid.append(domainId, groupId);
-
- // Compute Group IDs with Domain ID to get Group SIDs
- groupSids = new PacSid[groups.length];
- for(int i = 0; i < groups.length; i++) {
- groupSids[i] = PacSid.append(domainId, groups[i].getId());
- }
- } catch(IOException e) {
- throw new IOException("pac.logoninfo.malformed", e);
- }
- }
-
- public Date getLogonTime() {
- return logonTime;
- }
-
- public Date getLogoffTime() {
- return logoffTime;
- }
-
- public Date getKickOffTime() {
- return kickOffTime;
- }
-
- public Date getPwdLastChangeTime() {
- return pwdLastChangeTime;
- }
-
- public Date getPwdCanChangeTime() {
- return pwdCanChangeTime;
- }
-
- public Date getPwdMustChangeTime() {
- return pwdMustChangeTime;
- }
-
- public short getLogonCount() {
- return logonCount;
- }
-
- public short getBadPasswordCount() {
- return badPasswordCount;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public String getUserDisplayName() {
- return userDisplayName;
- }
-
- public String getLogonScript() {
- return logonScript;
- }
-
- public String getProfilePath() {
- return profilePath;
- }
-
- public String getHomeDirectory() {
- return homeDirectory;
- }
-
- public String getHomeDrive() {
- return homeDrive;
- }
-
- public String getServerName() {
- return serverName;
- }
-
- public String getDomainName() {
- return domainName;
- }
-
- public PacSid getUserSid() {
- return userSid;
- }
-
- public PacSid getGroupSid() {
- return groupSid;
- }
-
- public PacSid[] getGroupSids() {
- return groupSids;
- }
-
- public PacSid[] getResourceGroupSids() {
- return resourceGroupSids;
- }
-
- public PacSid[] getExtraSids() {
- return extraSids;
- }
-
- public int getUserAccountControl() {
- return userAccountControl;
- }
-
- public int getUserFlags() {
- return userFlags;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacSid.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacSid.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacSid.java
deleted file mode 100644
index ad73d0e..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacSid.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.pac;
-
-import java.io.IOException;
-
-public class PacSid {
-
- private static final String FORMAT = "%1$02x";
-
- private byte revision;
- private byte subCount;
- private byte[] authority;
- private byte[] subs;
-
- public PacSid(byte[] bytes) throws IOException {
- if(bytes.length < 8 || ((bytes.length - 8) % 4) != 0
- || ((bytes.length - 8) / 4) != bytes[1])
- throw new IOException("pac.sid.malformed.size");
-
- this.revision = bytes[0];
- this.subCount = bytes[1];
- this.authority = new byte[6];
- System.arraycopy(bytes, 2, this.authority, 0, 6);
- this.subs = new byte[bytes.length - 8];
- System.arraycopy(bytes, 8, this.subs, 0, bytes.length - 8);
- }
-
- public PacSid(PacSid sid) {
- this.revision = sid.revision;
- this.subCount = sid.subCount;
- this.authority = new byte[6];
- System.arraycopy(sid.authority, 0, this.authority, 0, 6);
- this.subs = new byte[sid.subs.length];
- System.arraycopy(sid.subs, 0, this.subs, 0, sid.subs.length);
- }
-
- public String toString() {
- StringBuilder builder = new StringBuilder();
-
- builder.append("\\").append(String.format(FORMAT, ((int)revision) & 0xff));
- builder.append("\\").append(String.format(FORMAT, ((int)subCount) & 0xff));
- for(int i = 0; i < authority.length; i++) {
- int unsignedByte = ((int)authority[i]) & 0xff;
- builder.append("\\").append(String.format(FORMAT, unsignedByte));
- }
- for(int i = 0; i < subs.length; i++) {
- int unsignedByte = ((int)subs[i]) & 0xff;
- builder.append("\\").append(String.format(FORMAT, unsignedByte));
- }
-
- return builder.toString();
- }
-
- public boolean isEmpty() {
- return subCount == 0;
- }
-
- public boolean isBlank() {
- boolean blank = true;
- for(byte sub : subs)
- blank = blank && (sub == 0);
- return blank;
- }
-
- public byte[] getBytes() {
- byte[] bytes = new byte[8 + subCount * 4];
- bytes[0] = revision;
- bytes[1] = subCount;
- System.arraycopy(authority, 0, bytes, 2, 6);
- System.arraycopy(subs, 0, bytes, 8, subs.length);
-
- return bytes;
- }
-
- public static String toString(byte[] bytes) {
- StringBuilder builder = new StringBuilder();
-
- for(int i = 0; i < bytes.length; i++) {
- int unsignedByte = ((int)bytes[i]) & 0xff;
- builder.append("\\").append(String.format(FORMAT, unsignedByte));
- }
-
- return builder.toString();
- }
-
- public static PacSid createFromSubs(byte[] bytes) throws IOException {
- if((bytes.length % 4) != 0) {
- Object[] args = new Object[]{bytes.length};
- throw new IOException("pac.subauthority.malformed.size");
- }
-
- byte[] sidBytes = new byte[8 + bytes.length];
- sidBytes[0] = 1;
- sidBytes[1] = (byte)(bytes.length / 4);
- System.arraycopy(new byte[]{0, 0, 0, 0, 0, 5}, 0, sidBytes, 2, 6);
- System.arraycopy(bytes, 0, sidBytes, 8, bytes.length);
-
- return new PacSid(sidBytes);
- }
-
- public static PacSid append(PacSid sid1, PacSid sid2) {
- PacSid sid = new PacSid(sid1);
-
- sid.subCount += sid2.subCount;
- sid.subs = new byte[sid.subCount * 4];
- System.arraycopy(sid1.subs, 0, sid.subs, 0, sid1.subs.length);
- System.arraycopy(sid2.subs, 0, sid.subs, sid1.subs.length, sid2.subs.length);
-
- return sid;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacSidAttributes.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacSidAttributes.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacSidAttributes.java
deleted file mode 100644
index 7bb035c..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacSidAttributes.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.pac;
-
-public class PacSidAttributes {
-
- private PacSid id;
- private int attributes;
-
- public PacSidAttributes(PacSid id, int attributes) {
- super();
- this.id = id;
- this.attributes = attributes;
- }
-
- public PacSid getId() {
- return id;
- }
-
- public int getAttributes() {
- return attributes;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacSignature.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacSignature.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacSignature.java
deleted file mode 100644
index a0a4607..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacSignature.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.apache.kerberos.kerb.codec.pac;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-
-public class PacSignature {
-
- private int type;
- private byte[] checksum;
-
- public PacSignature(byte[] data) throws IOException {
- try {
- PacDataInputStream bufferStream = new PacDataInputStream(new DataInputStream(
- new ByteArrayInputStream(data)));
-
- type = bufferStream.readInt();
- checksum = new byte[bufferStream.available()];
- bufferStream.readFully(checksum);
- } catch(IOException e) {
- throw new IOException("pac.signature.malformed", e);
- }
- }
-
- public int getType() {
- return type;
- }
-
- public byte[] getChecksum() {
- return checksum;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacUnicodeString.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacUnicodeString.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacUnicodeString.java
deleted file mode 100644
index 44f8fb0..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/pac/PacUnicodeString.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.pac;
-
-import java.io.IOException;
-
-public class PacUnicodeString {
-
- private short length;
- private short maxLength;
- private int pointer;
-
- public PacUnicodeString(short length, short maxLength, int pointer) {
- super();
- this.length = length;
- this.maxLength = maxLength;
- this.pointer = pointer;
- }
-
- public short getLength() {
- return length;
- }
-
- public short getMaxLength() {
- return maxLength;
- }
-
- public int getPointer() {
- return pointer;
- }
-
- public String check(String string) throws IOException {
- if(pointer == 0 && string != null)
- throw new IOException("pac.string.notempty");
-
- int expected = length / 2;
- if(string.length() != expected) {
- Object[] args = new Object[]{expected, string.length()};
- throw new IOException("pac.string.invalid.size");
- }
-
- return string;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoConstants.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoConstants.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoConstants.java
deleted file mode 100644
index 4a5024f..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoConstants.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.spnego;
-
-public interface SpnegoConstants {
-
- static final String SPNEGO_MECHANISM = "1.3.6.1.5.5.2";
- static final String KERBEROS_MECHANISM = "1.2.840.113554.1.2.2";
- static final String LEGACY_KERBEROS_MECHANISM = "1.2.840.48018.1.2.2";
- static final String NTLMSSP_MECHANISM = "1.3.6.1.4.1.311.2.2.10";
-
- static final String SPNEGO_OID = SPNEGO_MECHANISM;
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoInitToken.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoInitToken.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoInitToken.java
deleted file mode 100644
index bf8b0ca..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoInitToken.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.spnego;
-
-import java.io.IOException;
-
-public class SpnegoInitToken extends SpnegoToken {
-
- public static final int DELEGATION = 0x40;
- public static final int MUTUAL_AUTHENTICATION = 0x20;
- public static final int REPLAY_DETECTION = 0x10;
- public static final int SEQUENCE_CHECKING = 0x08;
- public static final int ANONYMITY = 0x04;
- public static final int CONFIDENTIALITY = 0x02;
- public static final int INTEGRITY = 0x01;
-
- private String[] mechanisms;
- private int contextFlags;
-
- public SpnegoInitToken(byte[] token) throws IOException {
-
- }
-
- public int getContextFlags() {
- return contextFlags;
- }
-
- public boolean getContextFlag(int flag) {
- return (getContextFlags() & flag) == flag;
- }
-
- public String[] getMechanisms() {
- return mechanisms;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoTargToken.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoTargToken.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoTargToken.java
deleted file mode 100644
index f31ba60..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoTargToken.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.spnego;
-
-import java.io.IOException;
-
-public class SpnegoTargToken extends SpnegoToken {
-
- public static final int UNSPECIFIED_RESULT = -1;
- public static final int ACCEPT_COMPLETED = 0;
- public static final int ACCEPT_INCOMPLETE = 1;
- public static final int REJECTED = 2;
-
- private int result = UNSPECIFIED_RESULT;
-
- public SpnegoTargToken(byte[] token) throws IOException {
-
- }
-
- public int getResult() {
- return result;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoToken.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoToken.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoToken.java
deleted file mode 100644
index 170a4b0..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/spnego/SpnegoToken.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.spnego;
-
-import java.io.IOException;
-
-public abstract class SpnegoToken {
-
- // Default max size as 65K
- public static int TOKEN_MAX_SIZE = 66560;
-
- protected byte[] mechanismToken;
- protected byte[] mechanismList;
- protected String mechanism;
-
- public static SpnegoToken parse(byte[] token) throws IOException {
- SpnegoToken spnegoToken = null;
-
- if(token.length <= 0)
- throw new IOException("spnego.token.empty");
-
- switch (token[0]) {
- case (byte)0x60:
- spnegoToken = new SpnegoInitToken(token);
- break;
- case (byte)0xa1:
- spnegoToken = new SpnegoTargToken(token);
- break;
- default:
- spnegoToken = null;
- Object[] args = new Object[]{token[0]};
- throw new IOException("spnego.token.invalid");
- }
-
- return spnegoToken;
- }
-
- public byte[] getMechanismToken() {
- return mechanismToken;
- }
-
- public byte[] getMechanismList() {
- return mechanismList;
- }
-
- public String getMechanism() {
- return mechanism;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/CodecTest.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/CodecTest.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/CodecTest.java
deleted file mode 100644
index 3fd89c2..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/CodecTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.test;
-
-import org.apache.kerberos.kerb.KrbException;
-import org.apache.kerberos.kerb.codec.KrbCodec;
-import org.apache.kerberos.kerb.spec.common.CheckSum;
-import org.apache.kerberos.kerb.spec.common.CheckSumType;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.Arrays;
-
-public class CodecTest {
-
- @Test
- public void testCodec() throws KrbException {
- CheckSum mcs = new CheckSum();
- mcs.setCksumtype(CheckSumType.CRC32);
- mcs.setChecksum(new byte[] {0x10});
- byte[] bytes = KrbCodec.encode(mcs);
- Assert.assertNotNull(bytes);
-
- CheckSum restored = KrbCodec.decode(bytes, CheckSum.class);
- Assert.assertNotNull(restored);
- Assert.assertEquals(mcs.getCksumtype(), restored.getCksumtype());
- Assert.assertTrue(Arrays.equals(mcs.getChecksum(), restored.getChecksum()));
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/CodecTestUtil.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/CodecTestUtil.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/CodecTestUtil.java
deleted file mode 100644
index 87c5a0f..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/CodecTestUtil.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.test;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-public class CodecTestUtil {
- /*package*/ static byte[] readBinaryFile(String path) throws IOException {
- InputStream is = CodecTestUtil.class.getResourceAsStream(path);
- byte[] bytes = new byte[is.available()];
- is.read(bytes);
- return bytes;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/TestAsRepCodec.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/TestAsRepCodec.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/TestAsRepCodec.java
deleted file mode 100644
index 7b9c9f4..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/TestAsRepCodec.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.test;
-
-import org.apache.kerberos.kerb.spec.common.KrbMessageType;
-import org.apache.kerberos.kerb.spec.common.NameType;
-import org.apache.kerberos.kerb.spec.common.PrincipalName;
-import org.apache.kerberos.kerb.spec.kdc.AsRep;
-import org.apache.kerberos.kerb.spec.kdc.EncKdcRepPart;
-import org.apache.kerberos.kerb.spec.ticket.EncTicketPart;
-import org.apache.kerberos.kerb.spec.ticket.Ticket;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-/**
- * Test AsRep message using a real 'correct' network packet captured from MS-AD to detective programming errors
- * and compatibility issues particularly regarding Kerberos crypto.
- */
-public class TestAsRepCodec {
-
- @Test
- public void test() throws IOException {
- byte[] bytes = CodecTestUtil.readBinaryFile("/asrep.token");
- ByteBuffer asRepToken = ByteBuffer.wrap(bytes);
-
- AsRep asRep = new AsRep();
- asRep.decode(asRepToken);
-
- Assert.assertEquals(asRep.getPvno(), 5);
- Assert.assertEquals(asRep.getMsgType(), KrbMessageType.AS_REP);
- Assert.assertEquals(asRep.getCrealm(), "DENYDC.COM");
-
- PrincipalName cname = asRep.getCname();
- Assert.assertEquals(cname.getNameType(), NameType.NT_PRINCIPAL);
- Assert.assertEquals(cname.getNameStrings().size(), 1);
- Assert.assertEquals(cname.getNameStrings().get(0), "u5");
-
- Ticket ticket = asRep.getTicket();
- Assert.assertEquals(ticket.getTktvno(), 5);
- Assert.assertEquals(ticket.getRealm(), "DENYDC.COM");
- PrincipalName sname = ticket.getSname();
- Assert.assertEquals(sname.getNameType(), NameType.NT_SRV_INST);
- Assert.assertEquals(sname.getNameStrings().size(), 2);
- Assert.assertEquals(sname.getNameStrings().get(0), "krbtgt");
- Assert.assertEquals(sname.getNameStrings().get(1), "DENYDC.COM");
- //EncTicketPart encTicketPart = ticket.getEncPart();//FIXME
- //Assert.assertEquals(encTicketPart.getKey().getKvno(), 2);
- //Assert.assertEquals(encTicketPart.getKey().getKeyType().getValue(), 0x0017);
- //TODO decode cinpher
-
- //EncKdcRepPart encKdcRepPart = asRep.getEncPart();//FIXME
- //Assert.assertEquals(encKdcRepPart.getKey().getKeyType().getValue(), 0x0017);
- //Assert.assertEquals(encKdcRepPart.getKey().getKvno(), 7);
- //TODO decode cinpher
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/7d9261af/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/TestAsReqCodec.java
----------------------------------------------------------------------
diff --git a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/TestAsReqCodec.java b/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/TestAsReqCodec.java
deleted file mode 100644
index d714291..0000000
--- a/haox-kerb/kerb-core-test/src/test/java/org/apache/kerberos/kerb/codec/test/TestAsReqCodec.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerberos.kerb.codec.test;
-
-import org.apache.kerberos.kerb.spec.common.EncryptionType;
-import org.apache.kerberos.kerb.spec.common.HostAddrType;
-import org.apache.kerberos.kerb.spec.common.KrbMessageType;
-import org.apache.kerberos.kerb.spec.common.NameType;
-import org.apache.kerberos.kerb.spec.kdc.AsReq;
-import org.apache.kerberos.kerb.spec.pa.PaDataType;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.SimpleTimeZone;
-
-/**
- * Test AsReq message using a real 'correct' network packet captured from MS-AD to detective programming errors
- * and compatibility issues particularly regarding Kerberos crypto.
- */
-public class TestAsReqCodec {
-
- @Test
- public void test() throws IOException, ParseException {
- byte[] bytes = CodecTestUtil.readBinaryFile("/asreq.token");
- ByteBuffer asreqToken = ByteBuffer.wrap(bytes);
-
- AsReq asReq = new AsReq();
- asReq.decode(asreqToken);
-
- Assert.assertEquals(asReq.getPvno(), 5);
- Assert.assertEquals(asReq.getMsgType(), KrbMessageType.AS_REQ);
-
- Assert.assertEquals(asReq.getPaData().findEntry(PaDataType.ENC_TIMESTAMP).getPaDataType(), PaDataType.ENC_TIMESTAMP);
- byte[] paDataEncTimestampValue = Arrays.copyOfRange(bytes, 33, 96);
- byte[] paDataEncTimestampRealValue = asReq.getPaData().findEntry(PaDataType.ENC_TIMESTAMP).getPaDataValue();
- Assert.assertTrue(Arrays.equals(paDataEncTimestampValue, paDataEncTimestampRealValue));
- Assert.assertEquals(asReq.getPaData().findEntry(PaDataType.PAC_REQUEST).getPaDataType(), PaDataType.PAC_REQUEST);
- byte[] paPacRequestValue = Arrays.copyOfRange(bytes, 108, 115);
- byte[] paPacRequestRealValue = asReq.getPaData().findEntry(PaDataType.PAC_REQUEST).getPaDataValue();
- Assert.assertTrue(Arrays.equals(paPacRequestValue, paPacRequestRealValue));
-
- Assert.assertEquals(asReq.getReqBody().getKdcOptions().getPadding(), 0);
- Assert.assertTrue(Arrays.equals(asReq.getReqBody().getKdcOptions().getValue(), Arrays.copyOfRange(bytes, 126, 130)));
-
- Assert.assertEquals(asReq.getReqBody().getCname().getNameType(), NameType.NT_PRINCIPAL);
- Assert.assertEquals(asReq.getReqBody().getCname().getName(), "des");
- Assert.assertEquals(asReq.getReqBody().getRealm(), "DENYDC");
- Assert.assertEquals(asReq.getReqBody().getSname().getNameType(), NameType.NT_SRV_INST);
- Assert.assertEquals(asReq.getReqBody().getSname().getNameStrings().get(0), "krbtgt");
- Assert.assertEquals(asReq.getReqBody().getSname().getNameStrings().get(1), "DENYDC");
-
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
- sdf.setTimeZone(new SimpleTimeZone(0, "Z"));
- Date date = sdf.parse("20370913024805");
- Assert.assertEquals(asReq.getReqBody().getTill().getTime(), date.getTime());
- Assert.assertEquals(asReq.getReqBody().getRtime().getTime(), date.getTime());
-
- Assert.assertEquals(asReq.getReqBody().getNonce(), 197451134);
-
- List<EncryptionType> types = asReq.getReqBody().getEtypes();
- Assert.assertEquals(types.get(0).getValue(), 0x0017);
- //Assert.assertEquals(types.get(1).getValue(), 0xff7b);//FIXME
- //Assert.assertEquals(types.get(2).getValue(), 0x0080);//FIXME
- Assert.assertEquals(types.get(3).getValue(), 0x0003);
- Assert.assertEquals(types.get(4).getValue(), 0x0001);
- Assert.assertEquals(types.get(5).getValue(), 0x0018);
- //Assert.assertEquals(types.get(6).getValue(), 0xff79);//FIXME
-
- Assert.assertEquals(asReq.getReqBody().getAddresses().getElements().size(), 1);
- Assert.assertEquals(asReq.getReqBody().getAddresses().getElements().get(0).getAddrType(), HostAddrType.ADDRTYPE_NETBIOS);
- //FIXME net bios name
- }
-}