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/11/29 01:02:15 UTC

[04/10] directory-kerby git commit: Renamed spec package to type for Kerberos types defined in kerb-core module to be consistent with ASN1/X509/CMS

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/HostAddrType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/HostAddrType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/HostAddrType.java
new file mode 100644
index 0000000..b148bf6
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/HostAddrType.java
@@ -0,0 +1,100 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.type.Asn1EnumType;
+
+public enum HostAddrType implements Asn1EnumType {
+    /**
+     * Constant for the "null" host address type.
+     */
+    NULL(0),
+
+    /**
+     * Constant for the "Internet" host address type.
+     */
+    ADDRTYPE_INET(2),
+
+    /**
+     * Constant for the "Arpanet" host address type.
+     */
+    ADDRTYPE_IMPLINK(3),
+
+    /**
+     * Constant for the "CHAOS" host address type.
+     */
+    ADDRTYPE_CHAOS(5),
+
+    /**
+     * Constant for the "XEROX Network Services" host address type.
+     */
+    ADDRTYPE_XNS(6),
+
+    /**
+     * Constant for the "OSI" host address type.
+     */
+    ADDRTYPE_OSI(7),
+
+    /**
+     * Constant for the "DECnet" host address type.
+     */
+    ADDRTYPE_DECNET(12),
+
+    /**
+     * Constant for the "AppleTalk" host address type.
+     */
+    ADDRTYPE_APPLETALK(16),
+
+    /**
+     * Constant for the "NetBios" host address type.
+     *
+     * Not in RFC
+     */
+    ADDRTYPE_NETBIOS(20),
+
+    /**
+     * Constant for the "Internet Protocol V6" host address type.
+     */
+    ADDRTYPE_INET6(24);
+
+
+    private final int value;
+
+    private HostAddrType(int value) {
+        this.value = value;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    public static HostAddrType fromValue(Integer value) {
+        if (value != null) {
+            for (Asn1EnumType e : values()) {
+                if (e.getValue() == value.intValue()) {
+                    return (HostAddrType) e;
+                }
+            }
+        }
+
+        return NULL;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/HostAddress.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/HostAddress.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/HostAddress.java
new file mode 100644
index 0000000..948bcc4
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/HostAddress.java
@@ -0,0 +1,110 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1Integer;
+import org.apache.kerby.asn1.type.Asn1OctetString;
+import org.apache.kerby.asn1.ExplicitField;
+import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
+
+import java.net.InetAddress;
+import java.util.Arrays;
+
+/*
+HostAddress     ::= SEQUENCE  {
+        addr-type       [0] Int32,
+        address         [1] OCTET STRING
+}
+ */
+public class HostAddress extends KrbSequenceType {
+    private static final int ADDR_TYPE = 0;
+    private static final int ADDRESS = 1;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+            new ExplicitField(ADDR_TYPE, 0, Asn1Integer.class),
+            new ExplicitField(ADDRESS, 1, Asn1OctetString.class)
+    };
+
+    public HostAddress() {
+        super(fieldInfos);
+    }
+
+    public HostAddress(InetAddress inetAddress) {
+        this();
+
+        setAddrType(HostAddrType.ADDRTYPE_INET);
+        setAddress(inetAddress.getAddress());
+    }
+
+    public HostAddrType getAddrType() {
+        Integer value = getFieldAsInteger(ADDR_TYPE);
+        return HostAddrType.fromValue(value);
+    }
+
+    public void setAddrType(HostAddrType addrType) {
+        setField(ADDR_TYPE, addrType);
+    }
+
+    public byte[] getAddress() {
+        return getFieldAsOctets(ADDRESS);
+    }
+
+    public void setAddress(byte[] address) {
+        setFieldAsOctets(ADDRESS, address);
+    }
+
+    public boolean equalsWith(InetAddress address) {
+        if (address == null) {
+            return false;
+        }
+        HostAddress that = new HostAddress(address);
+        return that.equals(this);
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (other == null) {
+            return false;
+        }
+        if (other == this) {
+            return true;
+        } else if (!(other instanceof HostAddress)) {
+            return false;
+        }
+
+        HostAddress that = (HostAddress) other;
+        if (getAddrType() == that.getAddrType()
+                && Arrays.equals(getAddress(), that.getAddress())) {
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getAddrType().getValue();
+        if (getAddress() != null) {
+            result = 31 * result + Arrays.hashCode(getAddress());
+        }
+
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/HostAddresses.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/HostAddresses.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/HostAddresses.java
new file mode 100644
index 0000000..21edb15
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/HostAddresses.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.kerberos.kerb.type.base;
+
+import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
+
+import java.net.InetAddress;
+
+/**
+ -- NOTE: HostAddresses is always used as an OPTIONAL field and
+ -- should not be empty.
+ HostAddresses   -- NOTE: subtly different from rfc1510,
+ -- but has a value mapping and encodes the same
+ ::= SEQUENCE OF HostAddress
+ */
+public class HostAddresses extends KrbSequenceOfType<HostAddress> {
+
+    public boolean contains(InetAddress address) {
+        for (HostAddress hostAddress : getElements()) {
+            if (hostAddress.equalsWith(address)) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KeyUsage.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KeyUsage.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KeyUsage.java
new file mode 100644
index 0000000..055977c
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KeyUsage.java
@@ -0,0 +1,129 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.type.Asn1EnumType;
+
+/**
+ * From krb5.hin
+ */
+public enum KeyUsage implements Asn1EnumType {
+    UNKNOWN(-1),
+    NONE(0),
+    //AS-REQ PA-ENC-TIMESTAMP padata timestamp, encrypted with the client key
+    AS_REQ_PA_ENC_TS(1),
+    //AS-REP Ticket and TGS-REP Ticket (includes TGS session key or application session key),
+    //encrypted with the service key (Section 5.3)
+    KDC_REP_TICKET(2),
+    //AS-REP encrypted part (includes TGS session key or application session key),
+    //encrypted with the client key (Section 5.4.2)
+    AS_REP_ENCPART(3),
+    //TGS-REQ KDC-REQ-BODY AuthorizationData,
+    //encrypted with the TGS session key (Section 5.4.1)
+    TGS_REQ_AD_SESSKEY(4),
+    //TGS-REQ KDC-REQ-BODY AuthorizationData,
+    //encrypted with the TGS authenticator subkey (Section 5.4.1)
+    TGS_REQ_AD_SUBKEY(5),
+    //TGS-REQ PA-TGS-REQ padata AP-REQ Authenticator cksum,
+    //keyed with the TGS session key (Section 5.5.1)
+    TGS_REQ_AUTH_CKSUM(6),
+    //TGS-REQ PA-TGS-REQ padata AP-REQ Authenticator (includes TGS authenticator subkey),
+    //encrypted with the TGS session key (Section 5.5.1)
+    TGS_REQ_AUTH(7),
+    //TGS-REP encrypted part (includes application session key),
+    //encrypted with the TGS session key (Section 5.4.2)
+    TGS_REP_ENCPART_SESSKEY(8),
+    //TGS-REP encrypted part (includes application session key),
+    //encrypted with the TGS authenticator subkey (Section 5.4.2)
+    TGS_REP_ENCPART_SUBKEY(9),
+    //AP-REQ Authenticator cksum, keyed with the application session key (Section 5.5.1)
+    AP_REQ_AUTH_CKSUM(10),
+    //AP-REQ Authenticator (includes application authenticator subkey),
+    //encrypted with the application session key (Section 5.5.1)
+    AP_REQ_AUTH(11),
+    //AP-REP encrypted part (includes application session subkey),
+    //encrypted with the application session key (Section 5.5.2)
+    AP_REP_ENCPART(12),
+    //KRB-PRIV encrypted part, encrypted with a key chosen by the application (Section 5.7.1)
+    KRB_PRIV_ENCPART(13),
+    KRB_CRED_ENCPART(14),
+    KRB_SAFE_CKSUM(15),
+    APP_DATA_ENCRYPT(16),
+    APP_DATA_CKSUM(17),
+    KRB_ERROR_CKSUM(18),
+    AD_KDCISSUED_CKSUM(19),
+    AD_MTE(20),
+    AD_ITE(21),
+    GSS_TOK_MIC(22),
+    GSS_TOK_WRAP_INTEG(23),
+    GSS_TOK_WRAP_PRIV(24),
+    //Defined in Integrating SAM Mechanisms with Kerberos draft
+    PA_SAM_CHALLENGE_CKSUM(25),
+    //Note conflict with @ref PA_S4U_X509_USER_REQUEST
+    PA_SAM_CHALLENGE_TRACKID(26),
+    //Note conflict with @ref PA_S4U_X509_USER_REPLY
+    PA_SAM_RESPONSE(27),
+    //Defined in [MS-SFU]
+    //Note conflict with @ref PA_SAM_CHALLENGE_TRACKID
+    PA_S4U_X509_USER_REQUEST(26),
+    //Note conflict with @ref PA_SAM_RESPONSE
+    PA_S4U_X509_USER_REPLY(27),
+    //unused
+    PA_REFERRAL(26),
+    AD_SIGNEDPATH(-21),
+    IAKERB_FINISHED(42),
+    PA_PKINIT_KX(44),
+    PA_OTP_REQUEST(45),  //See RFC 6560 section 4.2
+    //define in preauth-framework
+    FAST_REQ_CHKSUM(50),
+    FAST_ENC(51),
+    FAST_REP(52),
+    FAST_FINISHED(53),
+    ENC_CHALLENGE_CLIENT(54),
+    ENC_CHALLENGE_KDC(55),
+    AS_REQ(56),
+    //PA-TOKEN padata,encrypted with the client key
+    PA_TOKEN(57);
+
+    private int value;
+
+    private KeyUsage(int value) {
+        this.value = value;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public static KeyUsage fromValue(Integer value) {
+        if (value != null) {
+            for (Asn1EnumType e : values()) {
+                if (e.getValue() == value) {
+                    return (KeyUsage) e;
+                }
+            }
+        }
+        return UNKNOWN;
+    }
+
+    public static final boolean isValid(int usage) {
+        return usage > -1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbError.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbError.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbError.java
new file mode 100644
index 0000000..73b3e01
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbError.java
@@ -0,0 +1,167 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1Integer;
+import org.apache.kerby.asn1.type.Asn1OctetString;
+import org.apache.kerby.asn1.ExplicitField;
+import org.apache.kerby.kerberos.kerb.KrbErrorCode;
+import org.apache.kerby.kerberos.kerb.type.KerberosString;
+import org.apache.kerby.kerberos.kerb.type.KerberosTime;
+
+/**
+ KRB-ERROR       ::= [APPLICATION 30] SEQUENCE {
+     pvno            [0] INTEGER (5),
+     msg-type        [1] INTEGER (30),
+     ctime           [2] KerberosTime OPTIONAL,
+     cusec           [3] Microseconds OPTIONAL,
+     stime           [4] KerberosTime,
+     susec           [5] Microseconds,
+     error-code      [6] Int32,
+     crealm          [7] Realm OPTIONAL,
+     cname           [8] PrincipalName OPTIONAL,
+     realm           [9] Realm -- service realm --,
+     sname           [10] PrincipalName -- service name --,
+     e-text          [11] KerberosString OPTIONAL,
+     e-data          [12] OCTET STRING OPTIONAL
+ }
+ */
+public class KrbError extends KrbMessage {
+    private static final int CTIME = 2;
+    private static final int CUSEC = 3;
+    private static final int STIME = 4;
+    private static final int SUSEC = 5;
+    private static final int ERROR_CODE = 6;
+    private static final int CREALM = 7;
+    private static final int CNAME = 8;
+    private static final int REALM = 9;
+    private static final int SNAME = 10;
+    private static final int ETEXT = 11;
+    private static final int EDATA = 12;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+            new ExplicitField(PVNO, Asn1Integer.class),
+            new ExplicitField(MSG_TYPE, Asn1Integer.class),
+            new ExplicitField(CTIME, KerberosTime.class),
+            new ExplicitField(CUSEC, Asn1Integer.class),
+            new ExplicitField(STIME, KerberosTime.class),
+            new ExplicitField(SUSEC, Asn1Integer.class),
+            new ExplicitField(ERROR_CODE, Asn1Integer.class),
+            new ExplicitField(CREALM, KerberosString.class),
+            new ExplicitField(CNAME, PrincipalName.class),
+            new ExplicitField(REALM, KerberosString.class),
+            new ExplicitField(SNAME, PrincipalName.class),
+            new ExplicitField(ETEXT, KerberosString.class),
+            new ExplicitField(EDATA, Asn1OctetString.class)
+    };
+
+    public KrbError() {
+        super(KrbMessageType.KRB_ERROR, fieldInfos);
+    }
+
+    public KerberosTime getCtime() {
+        return getFieldAs(CTIME, KerberosTime.class);
+    }
+
+    public void setCtime(KerberosTime ctime) {
+        setFieldAs(CTIME, ctime);
+    }
+
+    public int getCusec() {
+        return getFieldAsInt(CUSEC);
+    }
+
+    public void setCusec(int cusec) {
+        setFieldAsInt(CUSEC, cusec);
+    }
+
+    public KerberosTime getStime() {
+        return getFieldAs(STIME, KerberosTime.class);
+    }
+
+    public void setStime(KerberosTime stime) {
+        setFieldAs(STIME, stime);
+    }
+
+    public int getSusec() {
+        return getFieldAsInt(SUSEC);
+    }
+
+    public void setSusec(int susec) {
+        setFieldAsInt(SUSEC, susec);
+    }
+
+    public KrbErrorCode getErrorCode() {
+        return KrbErrorCode.fromValue(getFieldAsInt(ERROR_CODE));
+    }
+
+    public void setErrorCode(KrbErrorCode errorCode) {
+        setField(ERROR_CODE, errorCode);
+    }
+
+    public String getCrealm() {
+        return getFieldAsString(CREALM);
+    }
+
+    public void setCrealm(String realm) {
+        setFieldAs(CREALM, new KerberosString(realm));
+    }
+
+    public PrincipalName getCname() {
+        return getFieldAs(CNAME, PrincipalName.class);
+    }
+
+    public void setCname(PrincipalName sname) {
+        setFieldAs(CNAME, sname);
+    }
+
+    public PrincipalName getSname() {
+        return getFieldAs(SNAME, PrincipalName.class);
+    }
+
+    public void setSname(PrincipalName sname) {
+        setFieldAs(SNAME, sname);
+    }
+
+    public String getRealm() {
+        return getFieldAsString(REALM);
+    }
+
+    public void setRealm(String realm) {
+        setFieldAs(REALM, new KerberosString(realm));
+    }
+
+    public String getEtext() {
+        return getFieldAsString(ETEXT);
+    }
+
+    public void setEtext(String realm) {
+        setFieldAs(ETEXT, new KerberosString(realm));
+    }
+
+    public byte[] getEdata() {
+        return getFieldAsOctetBytes(EDATA);
+    }
+
+    public void setEdata(byte[] edata) {
+        setFieldAsOctetBytes(EDATA, edata);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbMessage.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbMessage.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbMessage.java
new file mode 100644
index 0000000..ffcccfb
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbMessage.java
@@ -0,0 +1,54 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.Asn1FieldInfo;
+import org.apache.kerby.kerberos.kerb.KrbConstant;
+import org.apache.kerby.kerberos.kerb.type.KrbAppSequenceType;
+
+public abstract class KrbMessage extends KrbAppSequenceType {
+    protected static final int PVNO = 0;
+    protected static final int MSG_TYPE = 1;
+
+    private final int pvno = KrbConstant.KRB_V5;
+
+    public KrbMessage(KrbMessageType msgType, Asn1FieldInfo[] fieldInfos) {
+        super(msgType.getValue(), fieldInfos);
+        setPvno(pvno);
+        setMsgType(msgType);
+    }
+
+    public int getPvno() {
+        return pvno;
+    }
+
+    protected void setPvno(int pvno) {
+        setFieldAsInt(0, pvno);
+    }
+
+    public KrbMessageType getMsgType() {
+        Integer value = getFieldAsInteger(MSG_TYPE);
+        return KrbMessageType.fromValue(value);
+    }
+
+    public void setMsgType(KrbMessageType msgType) {
+        setFieldAsInt(MSG_TYPE, msgType.getValue());
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbMessageType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbMessageType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbMessageType.java
new file mode 100644
index 0000000..d483838
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbMessageType.java
@@ -0,0 +1,59 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.type.Asn1EnumType;
+
+public enum KrbMessageType implements Asn1EnumType {
+    NONE(-1),
+    AS_REQ(10),
+    AS_REP(11),
+    TGS_REQ(12),
+    TGS_REP(13),
+    AP_REQ(14),
+    AP_REP(15),
+    KRB_SAFE(20),
+    KRB_PRIV(21),
+    KRB_CRED(22),
+    KRB_ERROR(30);
+
+    private int value;
+
+    private KrbMessageType(int value) {
+        this.value = value;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    public static KrbMessageType fromValue(Integer value) {
+        if (value != null) {
+            for (Asn1EnumType e : values()) {
+                if (e.getValue() == value.intValue()) {
+                    return (KrbMessageType) e;
+                }
+            }
+        }
+
+        return NONE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbToken.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbToken.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbToken.java
new file mode 100644
index 0000000..f5910ca
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/KrbToken.java
@@ -0,0 +1,335 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1Integer;
+import org.apache.kerby.asn1.type.Asn1OctetString;
+import org.apache.kerby.asn1.ExplicitField;
+import org.apache.kerby.kerberos.kerb.KrbConstant;
+import org.apache.kerby.kerberos.kerb.KrbException;
+import org.apache.kerby.kerberos.kerb.KrbRuntime;
+import org.apache.kerby.kerberos.kerb.provider.TokenDecoder;
+import org.apache.kerby.kerberos.kerb.provider.TokenEncoder;
+import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * KRB-TOKEN_VALUE ::= SEQUENCE {
+ * token-format [0] INTEGER,
+ * token-value  [1] OCTET STRING,
+ * }
+ */
+public class KrbToken extends KrbSequenceType implements AuthToken {
+    private static TokenEncoder tokenEncoder;
+    private static TokenDecoder tokenDecoder;
+
+    private static final int TOKEN_FORMAT = 0;
+    private static final int TOKEN_VALUE = 1;
+
+    private AuthToken innerToken = null;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[]{
+            new ExplicitField(TOKEN_FORMAT, 0, Asn1Integer.class),
+            new ExplicitField(TOKEN_VALUE, 1, Asn1OctetString.class)
+    };
+
+
+    /**
+     * Default constructor.
+     */
+    public KrbToken() {
+        super(fieldInfos);
+    }
+
+    /**
+     * Construct with prepared authToken and token format.
+     *
+     * @param authToken The authToken
+     * @param format    The token format
+     */
+    public KrbToken(AuthToken authToken, TokenFormat format) {
+        this();
+
+        this.innerToken = authToken;
+        setTokenType();
+        setTokenFormat(format);
+        try {
+            setTokenValue(getTokenEncoder().encodeAsBytes(innerToken));
+        } catch (KrbException e) {
+            throw new RuntimeException("Failed to encode AuthToken", e);
+        }
+    }
+
+    /**
+     * Get AuthToken.
+     *
+     * @return The inner token.
+     */
+    public AuthToken getAuthToken() {
+        return innerToken;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void decode(ByteBuffer content) throws IOException {
+        super.decode(content);
+        this.innerToken = getTokenDecoder().decodeFromBytes(getTokenValue());
+        setTokenType();
+    }
+
+    /**
+     * Set token type.
+     */
+    public void setTokenType() {
+        List<String> audiences = this.innerToken.getAudiences();
+        if (audiences.size() == 1 && audiences.get(0).startsWith(KrbConstant.TGS_PRINCIPAL)) {
+            isIdToken(true);
+        } else {
+            isAcToken(true);
+        }
+    }
+
+    /**
+     * Get token encoder.
+     * @return The token encoder
+     */
+    private static TokenEncoder getTokenEncoder() {
+        if (tokenEncoder == null) {
+            tokenEncoder = KrbRuntime.getTokenProvider().createTokenEncoder();
+        }
+        return tokenEncoder;
+    }
+
+    /**
+     * Get token decoder.
+     * @return The token decoder
+     */
+    private static TokenDecoder getTokenDecoder() {
+        if (tokenDecoder == null) {
+            tokenDecoder = KrbRuntime.getTokenProvider().createTokenDecoder();
+        }
+        return tokenDecoder;
+    }
+
+    /**
+     * Get token format.
+     * @return The token format
+     */
+    public TokenFormat getTokenFormat() {
+        Integer value = getFieldAsInteger(TOKEN_FORMAT);
+        return TokenFormat.fromValue(value);
+    }
+
+    /**
+     * Set token format.
+     * @param tokenFormat The token format
+     */
+    public void setTokenFormat(TokenFormat tokenFormat) {
+        setFieldAsInt(TOKEN_FORMAT, tokenFormat.getValue());
+    }
+
+    /**
+     * Get token value.
+     * @return The token value
+     */
+    public byte[] getTokenValue() {
+        return getFieldAsOctets(TOKEN_VALUE);
+    }
+
+    /**
+     * Set token value.
+     * @param tokenValue The token value
+     */
+    public void setTokenValue(byte[] tokenValue) {
+        setFieldAsOctets(TOKEN_VALUE, tokenValue);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getSubject() {
+        return innerToken.getSubject();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setSubject(String sub) {
+        innerToken.setSubject(sub);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getIssuer() {
+        return innerToken.getIssuer();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setIssuer(String issuer) {
+        innerToken.setIssuer(issuer);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<String> getAudiences() {
+        return innerToken.getAudiences();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setAudiences(List<String> audiences) {
+        innerToken.setAudiences(audiences);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isIdToken() {
+        return innerToken.isIdToken();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void isIdToken(boolean isIdToken) {
+        innerToken.isIdToken(isIdToken);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isAcToken() {
+        return innerToken.isAcToken();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void isAcToken(boolean isAcToken) {
+        innerToken.isAcToken(isAcToken);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isBearerToken() {
+        return innerToken.isBearerToken();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isHolderOfKeyToken() {
+        return innerToken.isHolderOfKeyToken();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Date getExpiredTime() {
+        return innerToken.getExpiredTime();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setExpirationTime(Date exp) {
+        innerToken.setExpirationTime(exp);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Date getNotBeforeTime() {
+        return innerToken.getNotBeforeTime();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setNotBeforeTime(Date nbt) {
+        innerToken.setNotBeforeTime(nbt);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Date getIssueTime() {
+        return innerToken.getIssueTime();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setIssueTime(Date iat) {
+        innerToken.setIssueTime(iat);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Map<String, Object> getAttributes() {
+        return innerToken.getAttributes();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addAttribute(String name, Object value) {
+        innerToken.addAttribute(name, value);
+    }
+
+    public void setInnerToken(AuthToken authToken) {
+        this.innerToken = authToken;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/LastReq.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/LastReq.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/LastReq.java
new file mode 100644
index 0000000..d7e3623
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/LastReq.java
@@ -0,0 +1,32 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
+
+/**
+ LastReq         ::=     SEQUENCE OF SEQUENCE {
+ lr-type         [0] Int32,
+ lr-value        [1] KerberosTime
+ }
+ */
+public class LastReq extends KrbSequenceOfType<LastReqEntry> {
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/LastReqEntry.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/LastReqEntry.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/LastReqEntry.java
new file mode 100644
index 0000000..4b1fff4
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/LastReqEntry.java
@@ -0,0 +1,63 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1Integer;
+import org.apache.kerby.asn1.ExplicitField;
+import org.apache.kerby.kerberos.kerb.type.KerberosTime;
+import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
+
+/**
+ LastReq         ::=     SEQUENCE OF SEQUENCE {
+ lr-type         [0] Int32,
+ lr-value        [1] KerberosTime
+ }
+ */
+public class LastReqEntry extends KrbSequenceType {
+    private static final int LR_TYPE = 0;
+    private static final int LR_VALUE = 1;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+            new ExplicitField(LR_TYPE, 0, Asn1Integer.class),
+            new ExplicitField(LR_VALUE, 1, KerberosTime.class)
+    };
+
+    public LastReqEntry() {
+        super(fieldInfos);
+    }
+
+    public LastReqType getLrType() {
+        Integer value = getFieldAsInteger(LR_TYPE);
+        return LastReqType.fromValue(value);
+    }
+
+    public void setLrType(LastReqType lrType) {
+        setFieldAsInt(LR_TYPE, lrType.getValue());
+    }
+
+    public KerberosTime getLrValue() {
+        return getFieldAs(LR_VALUE, KerberosTime.class);
+    }
+
+    public void setLrValue(KerberosTime lrValue) {
+        setFieldAs(LR_VALUE, lrValue);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/LastReqType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/LastReqType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/LastReqType.java
new file mode 100644
index 0000000..0353750
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/LastReqType.java
@@ -0,0 +1,62 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.type.Asn1EnumType;
+
+public enum LastReqType implements Asn1EnumType {
+    NONE(0),
+    ALL_LAST_TGT(1),
+    THE_LAST_TGT(-1),
+    ALL_LAST_INITIAL(2),
+    THE_LAST_INITIAL(-2),
+    ALL_LAST_TGT_ISSUED(3),
+    THE_LAST_TGT_ISSUED(-3),
+    ALL_LAST_RENEWAL(4),
+    THE_LAST_RENEWAL(-4),
+    ALL_LAST_REQ(5),
+    THE_LAST_REQ(-5),
+    ALL_PW_EXPTIME(6),
+    THE_PW_EXPTIME(-6),
+    ALL_ACCT_EXPTIME(7),
+    THE_ACCT_EXPTIME(-7);
+
+    private int value;
+
+    private LastReqType(int value) {
+        this.value = value;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    public static LastReqType fromValue(Integer value) {
+        if (value != null) {
+            for (Asn1EnumType e : values()) {
+                if (e.getValue() == value) {
+                    return (LastReqType) e;
+                }
+            }
+        }
+        return NONE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/MethodData.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/MethodData.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/MethodData.java
new file mode 100644
index 0000000..454b340
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/MethodData.java
@@ -0,0 +1,30 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
+import org.apache.kerby.kerberos.kerb.type.pa.PaDataEntry;
+
+/**
+ METHOD-DATA     ::= SEQUENCE OF PA-DATA
+ */
+public class MethodData extends KrbSequenceOfType<PaDataEntry> {
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/NameType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/NameType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/NameType.java
new file mode 100644
index 0000000..d85b786
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/NameType.java
@@ -0,0 +1,54 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.type.Asn1EnumType;
+
+public enum NameType implements Asn1EnumType {
+    NT_UNKNOWN(0),
+    NT_PRINCIPAL(1),
+    NT_SRV_INST(2),
+    NT_SRV_HST(3),
+    NT_SRV_XHST(4),
+    NT_UID(5);
+    
+    private int value;
+
+    private NameType(int value) {
+        this.value = value;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    public static NameType fromValue(Integer value) {
+        if (value != null) {
+            for (Asn1EnumType e : values()) {
+                if (e.getValue() == value.intValue()) {
+                    return (NameType) e;
+                }
+            }
+        }
+
+        return NT_UNKNOWN;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/PrincipalName.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/PrincipalName.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/PrincipalName.java
new file mode 100644
index 0000000..1c94adc
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/PrincipalName.java
@@ -0,0 +1,202 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1Integer;
+import org.apache.kerby.asn1.ExplicitField;
+import org.apache.kerby.kerberos.kerb.type.KerberosStrings;
+import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ PrincipalName   ::= SEQUENCE {
+ name-type       [0] Int32,
+ name-string     [1] SEQUENCE OF KerberosString
+ }
+ */
+public class PrincipalName extends KrbSequenceType {
+    private static final int NAME_TYPE = 0;
+    private static final int NAME_STRING = 1;
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+            new ExplicitField(NAME_TYPE, Asn1Integer.class),
+            new ExplicitField(NAME_STRING, KerberosStrings.class)
+    };
+    private String realm;
+
+    public PrincipalName() {
+        super(fieldInfos);
+    }
+
+    public PrincipalName(String nameString) {
+        this();
+        setNameType(NameType.NT_PRINCIPAL);
+        fromNameString(nameString);
+    }
+
+    public PrincipalName(String nameString, NameType type) {
+        this();
+        fromNameString(nameString);
+        setNameType(type);
+    }
+
+    public PrincipalName(List<String> nameStrings, NameType type) {
+        this();
+        setNameStrings(nameStrings);
+        setNameType(type);
+    }
+
+    public static String extractRealm(String principal) {
+        int pos = principal.indexOf('@');
+
+        if (pos > 0) {
+            return principal.substring(pos + 1);
+        }
+
+        throw new IllegalArgumentException("Not a valid principal, missing realm name");
+    }
+
+    public static String extractName(String principal) {
+        int pos = principal.indexOf('@');
+
+        if (pos < 0) {
+            return principal;
+        }
+
+        return principal.substring(0, pos);
+    }
+
+    public static String makeSalt(PrincipalName principalName) {
+        StringBuilder salt = new StringBuilder();
+        if (principalName.getRealm() != null) {
+            salt.append(principalName.getRealm().toString());
+        }
+        List<String> nameStrings = principalName.getNameStrings();
+        for (String ns : nameStrings) {
+            salt.append(ns);
+        }
+        return salt.toString();
+    }
+
+    public NameType getNameType() {
+        Integer value = getFieldAsInteger(NAME_TYPE);
+        return NameType.fromValue(value);
+    }
+
+    public void setNameType(NameType nameType) {
+        setFieldAsInt(NAME_TYPE, nameType.getValue());
+    }
+
+    public List<String> getNameStrings() {
+        KerberosStrings krbStrings = getFieldAs(NAME_STRING, KerberosStrings.class);
+        if (krbStrings != null) {
+            return krbStrings.getAsStrings();
+        }
+        return Collections.emptyList();
+    }
+
+    public void setNameStrings(List<String> nameStrings) {
+        setFieldAs(NAME_STRING, new KerberosStrings(nameStrings));
+    }
+
+    public String getRealm() {
+        return this.realm;
+    }
+
+    public void setRealm(String realm) {
+        this.realm = realm;
+    }
+
+    public String getName() {
+        return makeSingleName();
+    }
+
+    private String makeSingleName() {
+        List<String> names = getNameStrings();
+        StringBuilder sb = new StringBuilder();
+        boolean isFirst = true;
+        for (String name : names) {
+            sb.append(name);
+            if (isFirst && names.size() > 1) {
+                sb.append('/');
+            }
+            isFirst = false;
+        }
+
+        String realm = getRealm();
+        if (realm != null && !realm.isEmpty()) {
+            sb.append('@');
+            sb.append(realm);
+        }
+
+        return sb.toString();
+    }
+
+    @Override
+    public String toString() {
+        return getName();
+    }
+
+    @Override
+    public int hashCode() {
+        return getName().hashCode();
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (other == null) {
+            return false;
+        } else if (this == other) {
+            return true;
+        } else if (!(other instanceof PrincipalName)) {
+            return false;
+        }
+
+        PrincipalName otherPrincipal = (PrincipalName) other;
+        if (getNameType() != ((PrincipalName) other).getNameType()) {
+            return false;
+        }
+
+        return getName().equals(otherPrincipal.getName());
+    }
+
+    private void fromNameString(String nameString) {
+        if (nameString == null) {
+            return;
+        }
+        String tmpRealm = null;
+        List<String> nameStrings;
+        int pos = nameString.indexOf('@');
+        String nameParts = nameString;
+        if (pos != -1) {
+            nameParts = nameString.substring(0, pos);
+            tmpRealm = nameString.substring(pos + 1);
+        }
+        String[] parts = nameParts.split("\\/");
+        nameStrings = Arrays.asList(parts);
+
+        setNameStrings(nameStrings);
+        setRealm(tmpRealm);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/Realm.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/Realm.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/Realm.java
new file mode 100644
index 0000000..76306f3
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/Realm.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.kerberos.kerb.type.base;
+
+import org.apache.kerby.kerberos.kerb.type.KerberosString;
+
+/**
+ * Realm           ::= KerberosString
+ */
+public class Realm extends KerberosString {
+    public Realm() {
+    }
+
+    public Realm(String value) {
+        super(value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/SamType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/SamType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/SamType.java
new file mode 100644
index 0000000..faa6e18
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/SamType.java
@@ -0,0 +1,65 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.type.Asn1EnumType;
+
+public enum SamType implements Asn1EnumType {
+    SAM_NONE(0),
+    /** safe SAM type enum for Enigma Logic */
+    SAM_TYPE_ENIGMA(1), // Enigma Logic"
+
+    /** safe SAM type enum for Digital Pathways */
+    SAM_TYPE_DIGI_PATH(2), // Digital Pathways
+
+    /** safe SAM type enum for S/key where KDC has key 0 */
+    SAM_TYPE_SKEY_K0(3), // S/key where KDC has key 0
+
+    /** safe SAM type enum for Traditional S/Key */
+    SAM_TYPE_SKEY(4), // Traditional S/Key
+
+    /** safe SAM type enum for Security Dynamics */
+    SAM_TYPE_SECURID(5), // Security Dynamics
+
+    /** safe SAM type enum for CRYPTOCard */
+    SAM_TYPE_CRYPTOCARD(6); // CRYPTOCard
+
+    private int value;
+
+    private SamType(int value) {
+        this.value = value;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    public static SamType fromValue(Integer value) {
+        if (value != null) {
+            for (SamType st : SamType.values()) {
+                if (value == st.getValue()) {
+                    return st;
+                }
+            }
+        }
+        return SAM_NONE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/TokenFormat.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/TokenFormat.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/TokenFormat.java
new file mode 100644
index 0000000..15781b7
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/TokenFormat.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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.type.Asn1EnumType;
+
+public enum TokenFormat implements Asn1EnumType {
+    NONE                (0),
+    JWT                 (1);
+
+    private final int value;
+
+    private TokenFormat(int value) {
+        this.value = value;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    public static TokenFormat fromValue(Integer value) {
+        if (value != null) {
+            for (Asn1EnumType e : values()) {
+                if (e.getValue() == value.intValue()) {
+                    return (TokenFormat) e;
+                }
+            }
+        }
+
+        return NONE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/TransitedEncoding.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/TransitedEncoding.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/TransitedEncoding.java
new file mode 100644
index 0000000..3b38ff9
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/TransitedEncoding.java
@@ -0,0 +1,63 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1Integer;
+import org.apache.kerby.asn1.type.Asn1OctetString;
+import org.apache.kerby.asn1.ExplicitField;
+import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
+
+/**
+ TransitedEncoding       ::= SEQUENCE {
+ tr-type         [0] Int32 -- must be registered --,
+ contents        [1] OCTET STRING
+ }
+ */
+public class TransitedEncoding extends KrbSequenceType {
+    private static final int TR_TYPE = 0;
+    private static final int CONTENTS = 1;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+            new ExplicitField(TR_TYPE, 0, Asn1Integer.class),
+            new ExplicitField(CONTENTS, 1, Asn1OctetString.class)
+    };
+
+    public TransitedEncoding() {
+        super(fieldInfos);
+    }
+
+    public TransitedEncodingType getTrType() {
+        Integer value = getFieldAsInteger(TR_TYPE);
+        return TransitedEncodingType.fromValue(value);
+    }
+
+    public void setTrType(TransitedEncodingType trType) {
+        setField(TR_TYPE, trType);
+    }
+
+    public byte[] getContents() {
+        return getFieldAsOctets(CONTENTS);
+    }
+
+    public void setContents(byte[] contents) {
+        setFieldAsOctets(CONTENTS, contents);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/TransitedEncodingType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/TransitedEncodingType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/TransitedEncodingType.java
new file mode 100644
index 0000000..744b643
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/base/TransitedEncodingType.java
@@ -0,0 +1,51 @@
+/**
+ *  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.kerberos.kerb.type.base;
+
+import org.apache.kerby.asn1.type.Asn1EnumType;
+
+public enum TransitedEncodingType implements Asn1EnumType {
+    UNKNOWN(-1),
+    NULL(0),
+    DOMAIN_X500_COMPRESS(1);
+
+    private final int value;
+
+    private TransitedEncodingType(int value) {
+        this.value = value;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    public static TransitedEncodingType fromValue(Integer value) {
+        if (value != null) {
+            for (Asn1EnumType e : values()) {
+                if (e.getValue() == value.intValue()) {
+                    return (TransitedEncodingType) e;
+                }
+            }
+        }
+
+        return NULL;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/ArmorType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/ArmorType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/ArmorType.java
new file mode 100644
index 0000000..3331088
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/ArmorType.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.kerberos.kerb.type.fast;
+
+import org.apache.kerby.asn1.type.Asn1EnumType;
+
+public enum ArmorType implements Asn1EnumType {
+    NONE                (0),
+    ARMOR_AP_REQUEST              (1);
+
+    private final int value;
+
+    private ArmorType(int value) {
+        this.value = value;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    public static ArmorType fromValue(Integer value) {
+        if (value != null) {
+            for (Asn1EnumType e : values()) {
+                if (e.getValue() == value.intValue()) {
+                    return (ArmorType) e;
+                }
+            }
+        }
+
+        return NONE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/FastOption.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/FastOption.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/FastOption.java
new file mode 100644
index 0000000..dc46d83
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/FastOption.java
@@ -0,0 +1,51 @@
+/**
+ *  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.kerberos.kerb.type.fast;
+
+import org.apache.kerby.asn1.type.Asn1EnumType;
+
+public enum FastOption implements Asn1EnumType {
+    NONE(-1),
+    RESERVED(0),
+    HIDE_CLIENT_NAMES(1),
+
+    KDC_FOLLOW_REFERRALS(16);
+
+    private final int value;
+
+    private FastOption(int value) {
+        this.value = value;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    public static FastOption fromValue(int value) {
+        for (Asn1EnumType e : values()) {
+            if (e.getValue() == value) {
+                return (FastOption) e;
+            }
+        }
+
+        return NONE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/FastOptions.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/FastOptions.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/FastOptions.java
new file mode 100644
index 0000000..21bc2c4
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/FastOptions.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.kerberos.kerb.type.fast;
+
+import org.apache.kerby.asn1.type.Asn1Flags;
+
+public class FastOptions extends Asn1Flags {
+
+    public FastOptions() {
+        this(0);
+    }
+
+    public FastOptions(int value) {
+        setFlags(value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmor.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmor.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmor.java
new file mode 100644
index 0000000..0cde5f6
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmor.java
@@ -0,0 +1,65 @@
+/**
+ *  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.kerberos.kerb.type.fast;
+
+import org.apache.kerby.asn1.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1Integer;
+import org.apache.kerby.asn1.type.Asn1OctetString;
+import org.apache.kerby.asn1.ExplicitField;
+import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
+
+/**
+ KrbFastArmor ::= SEQUENCE {
+     armor-type   [0] Int32,
+     -- Type of the armor.
+     armor-value  [1] OCTET STRING,
+     -- Value of the armor.
+ }
+ */
+public class KrbFastArmor extends KrbSequenceType {
+    private static final int ARMOR_TYPE = 0;
+    private static final int ARMOR_VALUE = 1;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+            new ExplicitField(ARMOR_TYPE, Asn1Integer.class),
+            new ExplicitField(ARMOR_VALUE, Asn1OctetString.class)
+    };
+
+    public KrbFastArmor() {
+        super(fieldInfos);
+    }
+
+    public ArmorType getArmorType() {
+        Integer value = getFieldAsInteger(ARMOR_TYPE);
+        return ArmorType.fromValue(value);
+    }
+
+    public void setArmorType(ArmorType armorType) {
+        setFieldAsInt(ARMOR_TYPE, armorType.getValue());
+    }
+
+    public byte[] getArmorValue() {
+        return getFieldAsOctets(ARMOR_VALUE);
+    }
+
+    public void setArmorValue(byte[] armorValue) {
+        setFieldAsOctets(ARMOR_VALUE, armorValue);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmoredRep.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmoredRep.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmoredRep.java
new file mode 100644
index 0000000..0615a30
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmoredRep.java
@@ -0,0 +1,53 @@
+/**
+ *  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.kerberos.kerb.type.fast;
+
+import org.apache.kerby.asn1.Asn1FieldInfo;
+import org.apache.kerby.asn1.ExplicitField;
+import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
+import org.apache.kerby.kerberos.kerb.type.base.EncryptedData;
+
+/**
+ KrbFastArmoredRep ::= SEQUENCE {
+    enc-fast-rep      [0] EncryptedData, -- KrbFastResponse --
+    -- The encryption key is the armor key in the request, and
+    -- the key usage number is KEY_USAGE_FAST_REP.
+ }
+ */
+public class KrbFastArmoredRep extends KrbSequenceType {
+    private static final int ENC_FAST_REP = 0;
+
+    //private
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+            new ExplicitField(ENC_FAST_REP, EncryptedData.class)
+    };
+
+    public KrbFastArmoredRep() {
+        super(fieldInfos);
+    }
+
+    public EncryptedData getEncFastRep() {
+        return getFieldAs(ENC_FAST_REP, EncryptedData.class);
+    }
+
+    public void setEncFastRep(EncryptedData encFastRep) {
+        setFieldAs(ENC_FAST_REP, encFastRep);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmoredReq.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmoredReq.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmoredReq.java
new file mode 100644
index 0000000..aaa0d24
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastArmoredReq.java
@@ -0,0 +1,96 @@
+/**
+ *  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.kerberos.kerb.type.fast;
+
+import org.apache.kerby.asn1.Asn1FieldInfo;
+import org.apache.kerby.asn1.ExplicitField;
+import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
+import org.apache.kerby.kerberos.kerb.type.base.CheckSum;
+import org.apache.kerby.kerberos.kerb.type.base.EncryptedData;
+
+/**
+ KrbFastArmoredReq ::= SEQUENCE {
+     armor        [0] KrbFastArmor OPTIONAL,
+     -- Contains the armor that identifies the armor key.
+     -- MUST be present in AS-REQ.
+     req-checksum [1] Checksum,
+     -- For AS, contains the checksum performed over the type
+     -- KDC-REQ-BODY for the req-body field of the KDC-REQ
+     -- structure;
+     -- For TGS, contains the checksum performed over the type
+     -- AP-REQ in the PA-TGS-REQ padata.
+     -- The checksum key is the armor key, the checksum
+     -- type is the required checksum type for the enctype of
+     -- the armor key, and the key usage number is
+     -- KEY_USAGE_FAST_REQ_CHKSUM.
+     enc-fast-req [2] EncryptedData, -- KrbFastReq --
+     -- The encryption key is the armor key, and the key usage
+     -- number is KEY_USAGE_FAST_ENC.
+ }
+ */
+public class KrbFastArmoredReq extends KrbSequenceType {
+    private static final int ARMOR = 0;
+    private static final int REQ_CHECKSUM = 1;
+    private static final int ENC_FAST_REQ = 2;
+
+    private KrbFastReq fastReq;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+            new ExplicitField(ARMOR, KrbFastArmor.class),
+            new ExplicitField(REQ_CHECKSUM, CheckSum.class),
+            new ExplicitField(ENC_FAST_REQ, EncryptedData.class),
+    };
+
+    public KrbFastArmoredReq() {
+        super(fieldInfos);
+    }
+
+    public KrbFastArmor getArmor() {
+        return getFieldAs(ARMOR, KrbFastArmor.class);
+    }
+
+    public void setArmor(KrbFastArmor armor) {
+        setFieldAs(ARMOR, armor);
+    }
+
+    public CheckSum getReqChecksum() {
+        return getFieldAs(REQ_CHECKSUM, CheckSum.class);
+    }
+
+    public void setReqChecksum(CheckSum checkSum) {
+        setFieldAs(REQ_CHECKSUM, checkSum);
+    }
+
+    public KrbFastReq getFastReq() {
+        return fastReq;
+    }
+
+    public void setFastReq(KrbFastReq fastReq) {
+        this.fastReq = fastReq;
+    }
+
+    public EncryptedData getEncryptedFastReq() {
+        return getFieldAs(ENC_FAST_REQ, EncryptedData.class);
+    }
+
+    public void setEncryptedFastReq(EncryptedData encFastReq) {
+        setFieldAs(ENC_FAST_REQ, encFastReq);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastFinished.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastFinished.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastFinished.java
new file mode 100644
index 0000000..2944471
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastFinished.java
@@ -0,0 +1,83 @@
+/**
+ *  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.kerberos.kerb.type.fast;
+
+import org.apache.kerby.asn1.Asn1FieldInfo;
+import org.apache.kerby.asn1.ExplicitField;
+import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
+import org.apache.kerby.kerberos.kerb.type.base.CheckSum;
+import org.apache.kerby.kerberos.kerb.type.base.EncryptedData;
+import org.apache.kerby.kerberos.kerb.type.pa.PaData;
+
+/**
+ KrbFastFinished ::= SEQUENCE {
+     timestamp       [0] KerberosTime,
+     usec            [1] Microseconds,
+     -- timestamp and usec represent the time on the KDC when
+     -- the reply was generated.
+     crealm          [2] Realm,
+     cname           [3] PrincipalName,
+     -- Contains the client realm and the client name.
+     ticket-checksum [4] Checksum,
+     -- checksum of the ticket in the KDC-REP using the armor
+     -- and the key usage is KEY_USAGE_FAST_FINISH.
+     -- The checksum type is the required checksum type
+     -- of the armor key.
+ }
+ */
+public class KrbFastFinished extends KrbSequenceType {
+    private static final int FAST_OPTIONS = 0;
+    private static final int PADATA = 1;
+    private static final int REQ_BODY = 2;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+            new ExplicitField(FAST_OPTIONS, KrbFastArmor.class),
+            new ExplicitField(PADATA, PaData.class),
+            new ExplicitField(REQ_BODY, EncryptedData.class),
+    };
+
+    public KrbFastFinished() {
+        super(fieldInfos);
+    }
+
+    public KrbFastArmor getArmor() {
+        return getFieldAs(FAST_OPTIONS, KrbFastArmor.class);
+    }
+
+    public void setArmor(KrbFastArmor armor) {
+        setFieldAs(FAST_OPTIONS, armor);
+    }
+
+    public CheckSum getReqChecksum() {
+        return getFieldAs(PADATA, CheckSum.class);
+    }
+
+    public void setReqChecksum(CheckSum checkSum) {
+        setFieldAs(PADATA, checkSum);
+    }
+
+    public EncryptedData getEncFastReq() {
+        return getFieldAs(REQ_BODY, EncryptedData.class);
+    }
+
+    public void setEncFastReq(EncryptedData encFastReq) {
+        setFieldAs(REQ_BODY, encFastReq);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastReq.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastReq.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastReq.java
new file mode 100644
index 0000000..0f7da88
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastReq.java
@@ -0,0 +1,79 @@
+/**
+ *  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.kerberos.kerb.type.fast;
+
+import org.apache.kerby.asn1.Asn1FieldInfo;
+import org.apache.kerby.asn1.ExplicitField;
+import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
+import org.apache.kerby.kerberos.kerb.type.kdc.KdcReqBody;
+import org.apache.kerby.kerberos.kerb.type.pa.PaData;
+
+/**
+ KrbFastReq ::= SEQUENCE {
+     fast-options [0] FastOptions,
+     -- Additional options.
+     padata       [1] SEQUENCE OF PA-DATA,
+     -- padata typed holes.
+     req-body     [2] KDC-REQ-BODY,
+     -- Contains the KDC request body as defined in Section
+     -- 5.4.1 of [RFC4120].
+     -- This req-body field is preferred over the outer field
+     -- in the KDC request.
+ }
+ */
+public class KrbFastReq extends KrbSequenceType {
+    private static final int FAST_OPTIONS = 0;
+    private static final int PADATA = 1;
+    private static final int REQ_BODY = 2;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+            new ExplicitField(FAST_OPTIONS, FastOptions.class),
+            new ExplicitField(PADATA, PaData.class),
+            new ExplicitField(REQ_BODY, KdcReqBody.class),
+    };
+
+    public KrbFastReq() {
+        super(fieldInfos);
+    }
+
+    public FastOptions getFastOptions() {
+        return getFieldAs(FAST_OPTIONS, FastOptions.class);
+    }
+
+    public void setFastOptions(FastOptions fastOptions) {
+        setFieldAs(FAST_OPTIONS, fastOptions);
+    }
+
+    public PaData getPaData() {
+        return getFieldAs(PADATA, PaData.class);
+    }
+
+    public void setPaData(PaData paData) {
+        setFieldAs(PADATA, paData);
+    }
+
+    public KdcReqBody getKdcReqBody() {
+        return getFieldAs(REQ_BODY, KdcReqBody.class);
+    }
+
+    public void setKdcReqBody(KdcReqBody kdcReqBody) {
+        setFieldAs(REQ_BODY, kdcReqBody);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8483322e/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastResponse.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastResponse.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastResponse.java
new file mode 100644
index 0000000..cd06c42
--- /dev/null
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/fast/KrbFastResponse.java
@@ -0,0 +1,91 @@
+/**
+ *  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.kerberos.kerb.type.fast;
+
+import org.apache.kerby.asn1.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1Integer;
+import org.apache.kerby.asn1.ExplicitField;
+import org.apache.kerby.kerberos.kerb.type.KrbSequenceType;
+import org.apache.kerby.kerberos.kerb.type.base.EncryptionKey;
+import org.apache.kerby.kerberos.kerb.type.pa.PaData;
+
+/**
+ KrbFastResponse ::= SEQUENCE {
+     padata         [0] SEQUENCE OF PA-DATA,
+     -- padata typed holes.
+     strengthen-key [1] EncryptionKey OPTIONAL,
+     -- This, if present, strengthens the reply key for AS and
+     -- TGS. MUST be present for TGS.
+     -- MUST be absent in KRB-ERROR.
+     finished       [2] KrbFastFinished OPTIONAL,
+     -- Present in AS or TGS reply; absent otherwise.
+     nonce          [3] UInt32,
+     -- Nonce from the client request.
+ }
+ */
+public class KrbFastResponse extends KrbSequenceType {
+    private static final int PADATA = 0;
+    private static final int STRENGTHEN_KEY = 1;
+    private static final int FINISHED = 2;
+    private static final int NONCE = 3;
+
+    static Asn1FieldInfo[] fieldInfos = new Asn1FieldInfo[] {
+            new ExplicitField(PADATA, PaData.class),
+            new ExplicitField(STRENGTHEN_KEY, EncryptionKey.class),
+            new ExplicitField(FINISHED, KrbFastFinished.class),
+            new ExplicitField(NONCE, Asn1Integer.class)
+    };
+
+    public KrbFastResponse() {
+        super(fieldInfos);
+    }
+
+    public PaData getPaData() {
+        return getFieldAs(PADATA, PaData.class);
+    }
+
+    public void setPaData(PaData paData) {
+        setFieldAs(PADATA, paData);
+    }
+
+    public EncryptionKey getStrengthenKey() {
+        return getFieldAs(STRENGTHEN_KEY, EncryptionKey.class);
+    }
+
+    public void setStrengthenKey(EncryptionKey strengthenKey) {
+        setFieldAs(STRENGTHEN_KEY, strengthenKey);
+    }
+
+    public KrbFastFinished getFastFinished() {
+        return getFieldAs(FINISHED, KrbFastFinished.class);
+    }
+
+    public void setFastFinished(KrbFastFinished fastFinished) {
+        setFieldAs(FINISHED, fastFinished);
+    }
+
+    public int getNonce() {
+        return getFieldAsInt(NONCE);
+    }
+
+    public void setNonce(int nonce) {
+        setFieldAsInt(NONCE, nonce);
+    }
+}