directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject [2/4] directory-kerby git commit: DIRKRB-474 Moved KrbFlags to asn1 module as Asn1Flags since it's also desired by X509 and CMS
Date Wed, 25 Nov 2015 02:50:00 GMT
DIRKRB-474 Moved KrbFlags to asn1 module as Asn1Flags since it's also desired by X509 and CMS


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/57d63f2d
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/57d63f2d
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/57d63f2d

Branch: refs/heads/pkinit-support
Commit: 57d63f2d6626310cea771bed194f6e6e5e9adc76
Parents: 1fbaebc
Author: Kai Zheng <kai.zheng@intel.com>
Authored: Wed Nov 25 10:36:16 2015 +0800
Committer: Kai Zheng <kai.zheng@intel.com>
Committed: Wed Nov 25 10:36:16 2015 +0800

----------------------------------------------------------------------
 .../apache/kerby/asn1/type/Asn1EnumType.java    |  24 +++
 .../org/apache/kerby/asn1/type/Asn1Flags.java   | 130 ++++++++++++++++
 .../org/apache/kerby/asn1/TestAsn1Flags.java    | 153 ++++++++++++++++++
 .../identitybackend/LdapIdentityBackend.java    |   2 +-
 .../org/apache/kerby/KrbIdentitySerializer.java |   2 +-
 .../kerby/kerberos/kerb/auth/AuthContext.java   |   8 +-
 .../kerby/kerberos/kerb/preauth/PaFlag.java     |  10 +-
 .../kerby/kerberos/kerb/preauth/PaFlags.java    |   4 +-
 .../kerberos/kerb/codec/TestAsReqCodec.java     |   8 +-
 .../kerberos/kerb/codec/TestTgsReqCodec.java    |   8 +-
 .../kerby/kerberos/kerb/KrbErrorCode.java       |  10 +-
 .../kerberos/kerb/spec/KrbAppSequenceType.java  |   5 +-
 .../kerby/kerberos/kerb/spec/KrbEnum.java       |  24 ---
 .../kerberos/kerb/spec/KrbSequenceType.java     |   5 +-
 .../kerb/spec/ad/AuthorizationDataEntry.java    |   2 +-
 .../kerb/spec/ad/AuthorizationType.java         |  10 +-
 .../kerby/kerberos/kerb/spec/ap/ApOption.java   |  10 +-
 .../kerby/kerberos/kerb/spec/ap/ApOptions.java  |   4 +-
 .../kerby/kerberos/kerb/spec/base/CheckSum.java |   2 +-
 .../kerberos/kerb/spec/base/CheckSumType.java   |  10 +-
 .../kerberos/kerb/spec/base/EncryptedData.java  |   2 +-
 .../kerberos/kerb/spec/base/EncryptionKey.java  |   2 +-
 .../kerberos/kerb/spec/base/EncryptionType.java |  10 +-
 .../kerberos/kerb/spec/base/HostAddrType.java   |  10 +-
 .../kerberos/kerb/spec/base/HostAddress.java    |   2 +-
 .../kerby/kerberos/kerb/spec/base/KeyUsage.java |  10 +-
 .../kerby/kerberos/kerb/spec/base/KrbFlags.java | 124 ---------------
 .../kerberos/kerb/spec/base/KrbMessage.java     |   4 +-
 .../kerberos/kerb/spec/base/KrbMessageType.java |  10 +-
 .../kerby/kerberos/kerb/spec/base/KrbToken.java |   2 +-
 .../kerberos/kerb/spec/base/LastReqEntry.java   |   2 +-
 .../kerberos/kerb/spec/base/LastReqType.java    |  10 +-
 .../kerby/kerberos/kerb/spec/base/NameType.java |  10 +-
 .../kerberos/kerb/spec/base/PrincipalName.java  |   2 +-
 .../kerby/kerberos/kerb/spec/base/SamType.java  |   8 +-
 .../kerberos/kerb/spec/base/TokenFormat.java    |  10 +-
 .../kerb/spec/base/TransitedEncodingType.java   |  10 +-
 .../kerberos/kerb/spec/fast/ArmorType.java      |  10 +-
 .../kerberos/kerb/spec/fast/FastOption.java     |  10 +-
 .../kerberos/kerb/spec/fast/FastOptions.java    |   4 +-
 .../kerberos/kerb/spec/fast/KrbFastArmor.java   |   2 +-
 .../kerberos/kerb/spec/fast/PaAuthnEntry.java   |   2 +-
 .../kerby/kerberos/kerb/spec/kdc/KdcOption.java |  10 +-
 .../kerberos/kerb/spec/kdc/KdcOptions.java      |   4 +-
 .../kerberos/kerb/spec/kdc/KdcReqBody.java      |   2 +-
 .../kerb/spec/pa/PaAuthenticationSetElem.java   |   2 +-
 .../kerberos/kerb/spec/pa/PaDataEntry.java      |   2 +-
 .../kerby/kerberos/kerb/spec/pa/PaDataType.java |  10 +-
 .../kerberos/kerb/spec/pa/token/TokenFlag.java  |  10 +-
 .../kerberos/kerb/spec/pa/token/TokenFlags.java |   6 +-
 .../kerberos/kerb/spec/ticket/TicketFlag.java   |  10 +-
 .../kerberos/kerb/spec/ticket/TicketFlags.java  |   6 +-
 .../kerberos/kerb/spec/base/KrbFlagsTest.java   | 155 -------------------
 .../kerberos/kerb/crypto/CheckSumHandler.java   |   4 +-
 .../kerberos/kerb/crypto/EncryptionHandler.java |   6 +-
 .../kerb/identity/backend/BackendTest.java      |   4 +-
 .../kerb/ccache/CredCacheOutputStream.java      |  10 +-
 .../kerby/kerberos/kerb/ccache/Credential.java  |   2 +-
 .../kerb/keytab/KeytabOutputStream.java         |   4 +-
 59 files changed, 470 insertions(+), 464 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1EnumType.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1EnumType.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1EnumType.java
new file mode 100644
index 0000000..42eabc6
--- /dev/null
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1EnumType.java
@@ -0,0 +1,24 @@
+/**
+ *  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.asn1.type;
+
+public interface Asn1EnumType {
+    int getIntValue();
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Flags.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Flags.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Flags.java
new file mode 100644
index 0000000..a9b57f2
--- /dev/null
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Flags.java
@@ -0,0 +1,130 @@
+/**
+ *  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.asn1.type;
+
+import java.io.IOException;
+
+/**
+ KrbFlags   ::= BIT STRING (SIZE (32..MAX))
+ -- minimum number of bits shall be sent,
+ -- but no fewer than 32
+ */
+public class Asn1Flags extends Asn1BitString {
+    private static final int MAX_SIZE = 32;
+    private static final int MASK;
+
+    static {
+        int maskBuilder = 0;
+        for (int i = 0; i < MAX_SIZE; i++) {
+          maskBuilder = maskBuilder << 1;
+          maskBuilder |= 0x00000001;
+        }
+        MASK = maskBuilder;
+    }
+
+    private int flags;
+
+    public Asn1Flags() {
+        this(0);
+    }
+
+    public Asn1Flags(int value) {
+        super();
+        setFlags(value);
+    }
+
+    public void setFlags(int flags) {
+        this.flags = flags;
+        flags2Value();
+    }
+
+    @Override
+    public void setValue(byte[] value) {
+        super.setValue(value);
+        value2Flags();
+    }
+
+    public int getFlags() {
+        return flags;
+    }
+
+    public boolean isFlagSet(int flag) {
+        return (flags & flag) != 0;
+    }
+
+    public void setFlag(int flag)  {
+        setFlags(flags | flag);
+    }
+
+    public void clearFlag(int flag) {
+        setFlags(flags & (MASK ^ flag));
+    }
+
+    public void clear() {
+        setFlags(0);
+    }
+
+    public boolean isFlagSet(Asn1EnumType flag) {
+        return isFlagSet(flag.getIntValue());
+    }
+
+    public void setFlag(Asn1EnumType flag) {
+        setFlag(flag.getIntValue());
+    }
+
+    public void setFlag(Asn1EnumType flag, boolean isSet)  {
+        if (isSet) {
+            setFlag(flag.getIntValue());
+        } else {
+            clearFlag(flag.getIntValue());
+        }
+    }
+
+    public void clearFlag(Asn1EnumType flag) {
+        clearFlag(flag.getIntValue());
+    }
+
+    private void flags2Value() {
+        byte[] bytes = new byte[4];
+        bytes[0] = (byte) (flags >> 24);
+        bytes[1] = (byte) ((flags >> 16) & 0xFF);
+        bytes[2] = (byte) ((flags >> 8) & 0xFF);
+        bytes[3] = (byte) (flags & 0xFF);
+
+        setValue(bytes);
+    }
+
+    private void value2Flags() {
+        byte[] valueBytes = getValue();
+        flags = ((valueBytes[0] & 0xFF) << 24) | ((valueBytes[1] & 0xFF) << 16)
+            | ((valueBytes[2] & 0xFF) << 8) | (0xFF & valueBytes[3]);
+    }
+
+    @Override
+    protected void toValue() throws IOException {
+        super.toValue();
+
+        if (getPadding() != 0 || getValue().length != 4) {
+            throw new IOException("Bad bitstring decoded as invalid krb flags");
+        }
+
+        value2Flags();
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Flags.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Flags.java b/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Flags.java
new file mode 100644
index 0000000..e866831
--- /dev/null
+++ b/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Flags.java
@@ -0,0 +1,153 @@
+/**
+ *  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.asn1;
+
+import org.apache.kerby.asn1.type.Asn1EnumType;
+import org.apache.kerby.asn1.type.Asn1Flags;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+public class TestAsn1Flags {
+  
+  public static final int FLAG_0 = 0b00000000000000000000000000000001;
+  public static final int FLAG_1 = 0b00000000000000000000000000000010;
+  public static final int FLAG_2 = 0x00000004;
+  public static final int FLAG_3 = 0x00000008;
+  public static final int FLAG_4 = 16;
+  public static final int FLAG_5 = 32;
+  
+  public enum TestEnum implements Asn1EnumType {
+    FLAG_0(0x00000001),
+    FLAG_1(0x00000002),
+    FLAG_2(0x00000004),
+    FLAG_3(0x00000008),
+    FLAG_4(0x00000010),
+    FLAG_5(0x00000020);
+    
+    private int value;
+    
+    private TestEnum(int value) {
+      this.value = value;
+    }
+
+    @Override
+    public int getIntValue() {
+      return value;
+    }
+  }
+  
+  @Rule
+  public ExpectedException thrown = ExpectedException.none();
+  
+  private Asn1Flags flags;
+  
+  @Before
+  public void setUp() {
+    flags = new Asn1Flags(FLAG_5 | FLAG_3 | FLAG_1);
+  }
+
+  @Test
+  public void testToValue() throws IOException {
+    byte[] value = {(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF};
+    flags.setValue(value);
+    assertEquals(0b11011110101011011011111011101111, flags.getFlags());
+  }
+
+  @Test
+  public void testFlags() {
+    flags = new Asn1Flags();
+    assertEquals(0b00000000000000000000000000000000, flags.getFlags());
+  }
+
+  @Test
+  public void testFlagsInt() {
+    flags = new Asn1Flags(FLAG_4 | FLAG_2 | FLAG_0);
+    assertEquals(0b00000000000000000000000000010101, flags.getFlags());
+  }
+
+  @Test
+  public void testSetFlags() {
+    flags.setFlags(FLAG_4 | FLAG_2 | FLAG_0);
+    assertEquals(0b00000000000000000000000000010101, flags.getFlags());
+  }
+
+  @Test
+  public void testGetFlags() {
+    assertEquals(0b00000000000000000000000000101010, flags.getFlags());
+  }
+
+  @Test
+  public void testIsFlagSetInt() {
+    assertTrue(flags.isFlagSet(FLAG_5));
+    assertFalse(flags.isFlagSet(FLAG_4));
+  }
+
+  @Test
+  public void testSetFlagInt() {
+    flags.setFlag(FLAG_4);
+    assertEquals(0b00000000000000000000000000111010, flags.getFlags());
+  }
+
+  @Test
+  public void testClearFlagInt() {
+    flags.clearFlag(FLAG_3);
+    assertEquals(0b00000000000000000000000000100010, flags.getFlags());
+  }
+
+  @Test
+  public void testClear() {
+    flags.clear();
+    assertEquals(0b00000000000000000000000000000000, flags.getFlags());
+  }
+
+  @Test
+  public void testIsFlagSetEnum() {
+    assertTrue(flags.isFlagSet(TestEnum.FLAG_5));
+    assertFalse(flags.isFlagSet(TestEnum.FLAG_4));
+  }
+
+  @Test
+  public void testSetFlagEnum() {
+    flags.setFlag(TestEnum.FLAG_4);
+    assertEquals(0b00000000000000000000000000111010, flags.getFlags());
+  }
+
+  @Test
+  public void testSetFlagEnumBoolean() {
+    flags.setFlag(TestEnum.FLAG_4, true);
+    assertEquals(0b00000000000000000000000000111010, flags.getFlags());
+    flags.setFlag(TestEnum.FLAG_4, false);
+    assertEquals(0b00000000000000000000000000101010, flags.getFlags());
+  }
+
+  @Test
+  public void testClearFlagEnum() {
+    flags.clearFlag(TestEnum.FLAG_3);
+    assertEquals(0b00000000000000000000000000100010, flags.getFlags());
+  }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-backend/ldap-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/LdapIdentityBackend.java
----------------------------------------------------------------------
diff --git a/kerby-backend/ldap-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/LdapIdentityBackend.java b/kerby-backend/ldap-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/LdapIdentityBackend.java
index 3c9c39e..993f63e 100644
--- a/kerby-backend/ldap-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/LdapIdentityBackend.java
+++ b/kerby-backend/ldap-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/LdapIdentityBackend.java
@@ -162,7 +162,7 @@ public class LdapIdentityBackend extends AbstractIdentityBackend {
             this.kvnos = new String[keymap.size()];
             int i = 0;
             for (Map.Entry<EncryptionType, EncryptionKey> entryKey : keymap.entrySet()) {
-                etypes[i] = entryKey.getKey().getValue() + "";
+                etypes[i] = entryKey.getKey().getIntValue() + "";
                 keys[i] = entryKey.getValue().encode();
                 kvnos[i] = entryKey.getValue().getKvno() + "";
                 i++;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-backend/mavibot-backend/src/main/java/org/apache/kerby/KrbIdentitySerializer.java
----------------------------------------------------------------------
diff --git a/kerby-backend/mavibot-backend/src/main/java/org/apache/kerby/KrbIdentitySerializer.java b/kerby-backend/mavibot-backend/src/main/java/org/apache/kerby/KrbIdentitySerializer.java
index 22766ec..61fef87 100644
--- a/kerby-backend/mavibot-backend/src/main/java/org/apache/kerby/KrbIdentitySerializer.java
+++ b/kerby-backend/mavibot-backend/src/main/java/org/apache/kerby/KrbIdentitySerializer.java
@@ -85,7 +85,7 @@ public class KrbIdentitySerializer implements ElementSerializer<KrbIdentity> {
             out.write(IntSerializer.serialize(keys.size()));
             
             for (EncryptionKey ek : keys.values()) {
-                int type = ek.getKeyType().getValue();
+                int type = ek.getKeyType().getIntValue();
                 out.write(IntSerializer.serialize(type));
                 byte[] data = ek.getKeyData();
                 out.write(IntSerializer.serialize(data.length));

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/auth/AuthContext.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/auth/AuthContext.java b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/auth/AuthContext.java
index f759f42..5b1c2cd 100644
--- a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/auth/AuthContext.java
+++ b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/auth/AuthContext.java
@@ -19,11 +19,11 @@
  */
 package org.apache.kerby.kerberos.kerb.auth;
 
+import org.apache.kerby.asn1.type.Asn1Flags;
 import org.apache.kerby.kerberos.kerb.spec.ap.Authenticator;
 import org.apache.kerby.kerberos.kerb.spec.base.EncryptionKey;
 import org.apache.kerby.kerberos.kerb.spec.base.EncryptionType;
 import org.apache.kerby.kerberos.kerb.spec.base.HostAddress;
-import org.apache.kerby.kerberos.kerb.spec.base.KrbFlags;
 
 import java.util.List;
 
@@ -31,7 +31,7 @@ import java.util.List;
  * Auth context shared by KDC and client for relevant information during auth.
  */
 public class AuthContext {
-    private KrbFlags flags;
+    private Asn1Flags flags;
     private HostAddress remoteAddress;
     private int remotePort;
     private HostAddress localAddress;
@@ -45,11 +45,11 @@ public class AuthContext {
     private EncryptionType negotiatedEncType;
     private Authenticator authenticator;
 
-    public KrbFlags getFlags() {
+    public Asn1Flags getFlags() {
         return flags;
     }
 
-    public void setFlags(KrbFlags flags) {
+    public void setFlags(Asn1Flags flags) {
         this.flags = flags;
     }
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/PaFlag.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/PaFlag.java b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/PaFlag.java
index 1b68c2a..99fd33e 100644
--- a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/PaFlag.java
+++ b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/PaFlag.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.preauth;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum PaFlag implements KrbEnum {
+public enum PaFlag implements Asn1EnumType {
     NONE(-1),
     PA_REAL(0x01),
     PA_INFO(0x02);
@@ -33,13 +33,13 @@ public enum PaFlag implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static PaFlag fromValue(int value) {
-        for (KrbEnum e : values()) {
-            if (e.getValue() == value) {
+        for (Asn1EnumType e : values()) {
+            if (e.getIntValue() == value) {
                 return (PaFlag) e;
             }
         }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/PaFlags.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/PaFlags.java b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/PaFlags.java
index 0546f57..d643d20 100644
--- a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/PaFlags.java
+++ b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/preauth/PaFlags.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.preauth;
 
-import org.apache.kerby.kerberos.kerb.spec.base.KrbFlags;
+import org.apache.kerby.asn1.type.Asn1Flags;
 
-public class PaFlags extends KrbFlags {
+public class PaFlags extends Asn1Flags {
 
     public PaFlags() {
         this(0);

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsReqCodec.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsReqCodec.java b/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsReqCodec.java
index 21317a9..94b9c16 100644
--- a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsReqCodec.java
+++ b/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestAsReqCodec.java
@@ -90,12 +90,12 @@ public class TestAsReqCodec {
 
         List<EncryptionType> types = body.getEtypes();
         assertThat(types).hasSize(7);
-        assertThat(types.get(0).getValue()).isEqualTo(0x0017);
+        assertThat(types.get(0).getIntValue()).isEqualTo(0x0017);
         //assertThat(types.get(1).getValue()).isEqualTo(0xff7b);//FIXME
         //assertThat(types.get(2).getValue()).isEqualTo(0x0080);//FIXME
-        assertThat(types.get(3).getValue()).isEqualTo(0x0003);
-        assertThat(types.get(4).getValue()).isEqualTo(0x0001);
-        assertThat(types.get(5).getValue()).isEqualTo(0x0018);
+        assertThat(types.get(3).getIntValue()).isEqualTo(0x0003);
+        assertThat(types.get(4).getIntValue()).isEqualTo(0x0001);
+        assertThat(types.get(5).getIntValue()).isEqualTo(0x0018);
         //assertThat(types.get(6).getValue()).isEqualTo(0xff79);//FIXME
 
         List<HostAddress> hostAddress = body.getAddresses().getElements();

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsReqCodec.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsReqCodec.java b/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsReqCodec.java
index de75355..5fabbce 100644
--- a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsReqCodec.java
+++ b/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/TestTgsReqCodec.java
@@ -81,12 +81,12 @@ public class TestTgsReqCodec {
 
         List<EncryptionType> eTypes = body.getEtypes();
         assertThat(eTypes).hasSize(7);
-        assertThat(eTypes.get(0).getValue()).isEqualTo(0x0017);
+        assertThat(eTypes.get(0).getIntValue()).isEqualTo(0x0017);
         //assertThat(eTypes.get(1).getValue()).isEqualTo(-133);//FIXME
         //assertThat(eTypes.get(2).getValue()).isEqualTo(-128);//FIXME
-        assertThat(eTypes.get(3).getValue()).isEqualTo(0x0003);
-        assertThat(eTypes.get(4).getValue()).isEqualTo(0x0001);
-        assertThat(eTypes.get(5).getValue()).isEqualTo(0x0018);
+        assertThat(eTypes.get(3).getIntValue()).isEqualTo(0x0003);
+        assertThat(eTypes.get(4).getIntValue()).isEqualTo(0x0001);
+        assertThat(eTypes.get(5).getIntValue()).isEqualTo(0x0018);
         //assertThat(eTypes.get(6).getValue()).isEqualTo(-135);//FIXME
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbErrorCode.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbErrorCode.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbErrorCode.java
index 43a0b07..ef0a3d1 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbErrorCode.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbErrorCode.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum KrbErrorCode implements KrbEnum {
+public enum KrbErrorCode implements Asn1EnumType {
     KDC_ERR_NONE(0, "No error"),
     KDC_ERR_NAME_EXP(1, "Client's entry in database has expired"),
     KDC_ERR_SERVICE_EXP(2, "Server's entry in database has expired"),
@@ -108,8 +108,8 @@ public enum KrbErrorCode implements KrbEnum {
 
     public static KrbErrorCode fromValue(Integer value) {
         if (value != null) {
-            for (KrbEnum e : values()) {
-                if (e.getValue() == value.intValue()) {
+            for (Asn1EnumType e : values()) {
+                if (e.getIntValue() == value.intValue()) {
                     return (KrbErrorCode) e;
                 }
             }
@@ -118,7 +118,7 @@ public enum KrbErrorCode implements KrbEnum {
         return KRB_ERR_GENERIC;
     }
 
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbAppSequenceType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbAppSequenceType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbAppSequenceType.java
index 2e72cbb..05e87f1 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbAppSequenceType.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbAppSequenceType.java
@@ -20,6 +20,7 @@
 package org.apache.kerby.kerberos.kerb.spec;
 
 import org.apache.kerby.asn1.type.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 import org.apache.kerby.asn1.type.TaggingSequence;
 
 /**
@@ -50,7 +51,7 @@ public abstract class KrbAppSequenceType extends TaggingSequence {
         setFieldAs(index, new KerberosTime(value));
     }
 
-    protected void setField(int index, KrbEnum krbEnum) {
-        setFieldAsInt(index, krbEnum.getValue());
+    protected void setField(int index, Asn1EnumType krbEnum) {
+        setFieldAsInt(index, krbEnum.getIntValue());
     }
 }

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

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbSequenceType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbSequenceType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbSequenceType.java
index d0d9d52..388de92 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbSequenceType.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbSequenceType.java
@@ -21,6 +21,7 @@ package org.apache.kerby.kerberos.kerb.spec;
 
 import org.apache.kerby.asn1.type.Asn1FieldInfo;
 import org.apache.kerby.asn1.type.Asn1SequenceType;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
 public abstract class KrbSequenceType extends Asn1SequenceType {
 
@@ -48,7 +49,7 @@ public abstract class KrbSequenceType extends Asn1SequenceType {
         setFieldAs(index, new KerberosTime(value));
     }
 
-    protected void setField(int index, KrbEnum value) {
-        setFieldAsInt(index, value.getValue());
+    protected void setField(int index, Asn1EnumType value) {
+        setFieldAsInt(index, value.getIntValue());
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ad/AuthorizationDataEntry.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ad/AuthorizationDataEntry.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ad/AuthorizationDataEntry.java
index 07b04d7..113c9c4 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ad/AuthorizationDataEntry.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ad/AuthorizationDataEntry.java
@@ -49,7 +49,7 @@ public class AuthorizationDataEntry extends KrbSequenceType {
     }
 
     public void setAuthzType(AuthorizationType authzType) {
-        setFieldAsInt(AD_TYPE, authzType.getValue());
+        setFieldAsInt(AD_TYPE, authzType.getIntValue());
     }
 
     public byte[] getAuthzData() {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ad/AuthorizationType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ad/AuthorizationType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ad/AuthorizationType.java
index f2efe74..aecc138 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ad/AuthorizationType.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ad/AuthorizationType.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.ad;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum AuthorizationType implements KrbEnum {
+public enum AuthorizationType implements Asn1EnumType {
     /**
      * Constant for the "null" authorization type.
      */
@@ -125,14 +125,14 @@ public enum AuthorizationType implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static AuthorizationType fromValue(Integer value) {
         if (value != null) {
-            for (KrbEnum e : values()) {
-                if (e.getValue() == value.intValue()) {
+            for (Asn1EnumType e : values()) {
+                if (e.getIntValue() == value.intValue()) {
                     return (AuthorizationType) e;
                 }
             }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ap/ApOption.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ap/ApOption.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ap/ApOption.java
index 4cd9e40..4faf643 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ap/ApOption.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ap/ApOption.java
@@ -19,7 +19,7 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.ap;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
 /**
  APOptions       ::= KrbFlags
@@ -27,7 +27,7 @@ import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
  -- use-session-key(1),
  -- mutual-required(2)
  */
-public enum ApOption implements KrbEnum {
+public enum ApOption implements Asn1EnumType {
     NONE(-1),
     RESERVED(0x80000000),
     USE_SESSION_KEY(0x40000000),
@@ -42,13 +42,13 @@ public enum ApOption implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static ApOption fromValue(int value) {
-        for (KrbEnum e : values()) {
-            if (e.getValue() == value) {
+        for (Asn1EnumType e : values()) {
+            if (e.getIntValue() == value) {
                 return (ApOption) e;
             }
         }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ap/ApOptions.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ap/ApOptions.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ap/ApOptions.java
index 1864a25..a8518d2 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ap/ApOptions.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ap/ApOptions.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.ap;
 
-import org.apache.kerby.kerberos.kerb.spec.base.KrbFlags;
+import org.apache.kerby.asn1.type.Asn1Flags;
 
-public class ApOptions extends KrbFlags {
+public class ApOptions extends Asn1Flags {
 
     public ApOptions() {
         this(0);

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/CheckSum.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/CheckSum.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/CheckSum.java
index b0ec6b8..d40fa81 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/CheckSum.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/CheckSum.java
@@ -62,7 +62,7 @@ public class CheckSum extends KrbSequenceType {
     }
 
     public void setCksumtype(CheckSumType cksumtype) {
-        setFieldAsInt(CKSUM_TYPE, cksumtype.getValue());
+        setFieldAsInt(CKSUM_TYPE, cksumtype.getIntValue());
     }
 
     public byte[] getChecksum() {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/CheckSumType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/CheckSumType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/CheckSumType.java
index 9ca0a65..a4c7498 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/CheckSumType.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/CheckSumType.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.base;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum CheckSumType implements KrbEnum {
+public enum CheckSumType implements Asn1EnumType {
     NONE(0, "none", "None checksum type"),
 
     CRC32(0x0001, "crc32", "CRC-32"),
@@ -80,8 +80,8 @@ public enum CheckSumType implements KrbEnum {
 
     public static CheckSumType fromValue(Integer value) {
         if (value != null) {
-            for (KrbEnum e : values()) {
-                if (e.getValue() == value) {
+            for (Asn1EnumType e : values()) {
+                if (e.getIntValue() == value) {
                     return (CheckSumType) e;
                 }
             }
@@ -101,7 +101,7 @@ public enum CheckSumType implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptedData.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptedData.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptedData.java
index 2092560..8e4dca7 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptedData.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptedData.java
@@ -54,7 +54,7 @@ public class EncryptedData extends KrbSequenceType {
     }
 
     public void setEType(EncryptionType eType) {
-        setFieldAsInt(ETYPE, eType.getValue());
+        setFieldAsInt(ETYPE, eType.getIntValue());
     }
 
     public int getKvno() {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptionKey.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptionKey.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptionKey.java
index 4f00a46..b15160a 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptionKey.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptionKey.java
@@ -72,7 +72,7 @@ public class EncryptionKey extends KrbSequenceType {
     }
 
     public void setKeyType(EncryptionType keyType) {
-        setFieldAsInt(KEY_TYPE, keyType.getValue());
+        setFieldAsInt(KEY_TYPE, keyType.getIntValue());
     }
 
     public byte[] getKeyData() {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptionType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptionType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptionType.java
index fda305b..f173c09 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptionType.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/EncryptionType.java
@@ -19,12 +19,12 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.base;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
 /**
  * According to krb5.hin
  */
-public enum EncryptionType implements KrbEnum {
+public enum EncryptionType implements Asn1EnumType {
 
     NONE(0, "none", "None encryption type"),
 
@@ -96,7 +96,7 @@ public enum EncryptionType implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
@@ -118,8 +118,8 @@ public enum EncryptionType implements KrbEnum {
 
     public static EncryptionType fromValue(Integer value) {
         if (value != null) {
-            for (KrbEnum e : values()) {
-                if (e.getValue() == value) {
+            for (Asn1EnumType e : values()) {
+                if (e.getIntValue() == value) {
                     return (EncryptionType) e;
                 }
             }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/HostAddrType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/HostAddrType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/HostAddrType.java
index db7ced3..1b8b616 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/HostAddrType.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/HostAddrType.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.base;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum HostAddrType implements KrbEnum {
+public enum HostAddrType implements Asn1EnumType {
     /**
      * Constant for the "null" host address type.
      */
@@ -82,14 +82,14 @@ public enum HostAddrType implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static HostAddrType fromValue(Integer value) {
         if (value != null) {
-            for (KrbEnum e : values()) {
-                if (e.getValue() == value.intValue()) {
+            for (Asn1EnumType e : values()) {
+                if (e.getIntValue() == value.intValue()) {
                     return (HostAddrType) e;
                 }
             }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/HostAddress.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/HostAddress.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/HostAddress.java
index 2c2a1b8..2fd33d4 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/HostAddress.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/HostAddress.java
@@ -99,7 +99,7 @@ public class HostAddress extends KrbSequenceType {
 
     @Override
     public int hashCode() {
-        int result = getAddrType().getValue();
+        int result = getAddrType().getIntValue();
         if (getAddress() != null) {
             result = 31 * result + Arrays.hashCode(getAddress());
         }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KeyUsage.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KeyUsage.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KeyUsage.java
index c1b07bc..2cdb10b 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KeyUsage.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KeyUsage.java
@@ -19,12 +19,12 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.base;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
 /**
  * From krb5.hin
  */
-public enum KeyUsage implements KrbEnum {
+public enum KeyUsage implements Asn1EnumType {
     UNKNOWN(-1),
     NONE(0),
     //AS-REQ PA-ENC-TIMESTAMP padata timestamp, encrypted with the client key
@@ -108,14 +108,14 @@ public enum KeyUsage implements KrbEnum {
         this.value = value;
     }
 
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static KeyUsage fromValue(Integer value) {
         if (value != null) {
-            for (KrbEnum e : values()) {
-                if (e.getValue() == value) {
+            for (Asn1EnumType e : values()) {
+                if (e.getIntValue() == value) {
                     return (KeyUsage) e;
                 }
             }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbFlags.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbFlags.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbFlags.java
deleted file mode 100644
index 4dfd807..0000000
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbFlags.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *  
- *    http://www.apache.org/licenses/LICENSE-2.0
- *  
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *  
- */
-package org.apache.kerby.kerberos.kerb.spec.base;
-
-import org.apache.kerby.asn1.type.Asn1BitString;
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
-
-import java.io.IOException;
-
-/**
- KrbFlags   ::= BIT STRING (SIZE (32..MAX))
- -- minimum number of bits shall be sent,
- -- but no fewer than 32
- */
-public class KrbFlags extends Asn1BitString {
-    private static final int MAX_SIZE = 32;
-    private static final int MASK;
-
-    static {
-        int maskBuilder = 0;
-        for (int i = 0; i < MAX_SIZE; i++) {
-          maskBuilder = maskBuilder << 1;
-          maskBuilder |= 0x00000001;
-        }
-        MASK = maskBuilder;
-    }
-
-    private int flags;
-
-    public KrbFlags() {
-        this(0);
-    }
-
-    public KrbFlags(int value) {
-        super();
-        setFlags(value);
-    }
-
-    public void setFlags(int flags) {
-        this.flags = flags;
-        flags2Value();
-    }
-
-    public int getFlags() {
-        return flags;
-    }
-
-    public boolean isFlagSet(int flag) {
-        return (flags & flag) != 0;
-    }
-
-    public void setFlag(int flag)  {
-        setFlags(flags | flag);
-    }
-
-    public void clearFlag(int flag) {
-        setFlags(flags & (MASK ^ flag));
-    }
-
-    public void clear() {
-        setFlags(0);
-    }
-
-    public boolean isFlagSet(KrbEnum flag) {
-        return isFlagSet(flag.getValue());
-    }
-
-    public void setFlag(KrbEnum flag) {
-        setFlag(flag.getValue());
-    }
-
-    public void setFlag(KrbEnum flag, boolean isSet)  {
-        if (isSet) {
-            setFlag(flag.getValue());
-        } else {
-            clearFlag(flag.getValue());
-        }
-    }
-
-    public void clearFlag(KrbEnum flag) {
-        clearFlag(flag.getValue());
-    }
-
-    private void flags2Value() {
-        byte[] bytes = new byte[4];
-        bytes[0] = (byte) (flags >> 24);
-        bytes[1] = (byte) ((flags >> 16) & 0xFF);
-        bytes[2] = (byte) ((flags >> 8) & 0xFF);
-        bytes[3] = (byte) (flags & 0xFF);
-
-        setValue(bytes);
-    }
-
-    @Override
-    protected void toValue() throws IOException {
-
-        super.toValue();
-
-        if (getPadding() != 0 || getValue().length != 4) {
-            throw new IOException("Bad bitstring decoded as invalid krb flags");
-        }
-
-        byte[] valueBytes = getValue();
-        flags = ((valueBytes[0] & 0xFF) << 24) | ((valueBytes[1] & 0xFF) << 16)
-                | ((valueBytes[2] & 0xFF) << 8) | (0xFF & valueBytes[3]);
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbMessage.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbMessage.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbMessage.java
index 0b1297c..904a919 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbMessage.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbMessage.java
@@ -30,7 +30,7 @@ public abstract class KrbMessage extends KrbAppSequenceType {
     private final int pvno = KrbConstant.KRB_V5;
 
     public KrbMessage(KrbMessageType msgType, Asn1FieldInfo[] fieldInfos) {
-        super(msgType.getValue(), fieldInfos);
+        super(msgType.getIntValue(), fieldInfos);
         setPvno(pvno);
         setMsgType(msgType);
     }
@@ -49,6 +49,6 @@ public abstract class KrbMessage extends KrbAppSequenceType {
     }
 
     public void setMsgType(KrbMessageType msgType) {
-        setFieldAsInt(MSG_TYPE, msgType.getValue());
+        setFieldAsInt(MSG_TYPE, msgType.getIntValue());
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbMessageType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbMessageType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbMessageType.java
index 5f99266..32d22cb 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbMessageType.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbMessageType.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.base;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum KrbMessageType implements KrbEnum {
+public enum KrbMessageType implements Asn1EnumType {
     NONE(-1),
     AS_REQ(10),
     AS_REP(11),
@@ -41,14 +41,14 @@ public enum KrbMessageType implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static KrbMessageType fromValue(Integer value) {
         if (value != null) {
-            for (KrbEnum e : values()) {
-                if (e.getValue() == value.intValue()) {
+            for (Asn1EnumType e : values()) {
+                if (e.getIntValue() == value.intValue()) {
                     return (KrbMessageType) e;
                 }
             }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbToken.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbToken.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbToken.java
index c40b7bb..970692e 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbToken.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/KrbToken.java
@@ -149,7 +149,7 @@ public class KrbToken extends KrbSequenceType implements AuthToken {
      * @param tokenFormat The token format
      */
     public void setTokenFormat(TokenFormat tokenFormat) {
-        setFieldAsInt(TOKEN_FORMAT, tokenFormat.getValue());
+        setFieldAsInt(TOKEN_FORMAT, tokenFormat.getIntValue());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/LastReqEntry.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/LastReqEntry.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/LastReqEntry.java
index c2553d8..f6e4d16 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/LastReqEntry.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/LastReqEntry.java
@@ -49,7 +49,7 @@ public class LastReqEntry extends KrbSequenceType {
     }
 
     public void setLrType(LastReqType lrType) {
-        setFieldAsInt(LR_TYPE, lrType.getValue());
+        setFieldAsInt(LR_TYPE, lrType.getIntValue());
     }
 
     public KerberosTime getLrValue() {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/LastReqType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/LastReqType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/LastReqType.java
index ee9a7fe..5064de0 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/LastReqType.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/LastReqType.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.base;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum LastReqType implements KrbEnum {
+public enum LastReqType implements Asn1EnumType {
     NONE(0),
     ALL_LAST_TGT(1),
     THE_LAST_TGT(-1),
@@ -45,14 +45,14 @@ public enum LastReqType implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static LastReqType fromValue(Integer value) {
         if (value != null) {
-            for (KrbEnum e : values()) {
-                if (e.getValue() == value) {
+            for (Asn1EnumType e : values()) {
+                if (e.getIntValue() == value) {
                     return (LastReqType) e;
                 }
             }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/NameType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/NameType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/NameType.java
index 9672883..8f61bc3 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/NameType.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/NameType.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.base;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum NameType implements KrbEnum {
+public enum NameType implements Asn1EnumType {
     NT_UNKNOWN(0),
     NT_PRINCIPAL(1),
     NT_SRV_INST(2),
@@ -36,14 +36,14 @@ public enum NameType implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static NameType fromValue(Integer value) {
         if (value != null) {
-            for (KrbEnum e : values()) {
-                if (e.getValue() == value.intValue()) {
+            for (Asn1EnumType e : values()) {
+                if (e.getIntValue() == value.intValue()) {
                     return (NameType) e;
                 }
             }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/PrincipalName.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/PrincipalName.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/PrincipalName.java
index 4bf6e0f..496e36d 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/PrincipalName.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/PrincipalName.java
@@ -103,7 +103,7 @@ public class PrincipalName extends KrbSequenceType {
     }
 
     public void setNameType(NameType nameType) {
-        setFieldAsInt(NAME_TYPE, nameType.getValue());
+        setFieldAsInt(NAME_TYPE, nameType.getIntValue());
     }
 
     public List<String> getNameStrings() {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/SamType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/SamType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/SamType.java
index 5b948a7..7461672 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/SamType.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/SamType.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.base;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum SamType implements KrbEnum {
+public enum SamType implements Asn1EnumType {
     SAM_NONE(0),
     /** safe SAM type enum for Enigma Logic */
     SAM_TYPE_ENIGMA(1), // Enigma Logic"
@@ -48,14 +48,14 @@ public enum SamType implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static SamType fromValue(Integer value) {
         if (value != null) {
             for (SamType st : SamType.values()) {
-                if (value == st.getValue()) {
+                if (value == st.getIntValue()) {
                     return st;
                 }
             }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/TokenFormat.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/TokenFormat.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/TokenFormat.java
index 872067d..de9aad8 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/TokenFormat.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/TokenFormat.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.base;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum TokenFormat implements KrbEnum {
+public enum TokenFormat implements Asn1EnumType {
     NONE                (0),
     JWT                 (1);
 
@@ -32,14 +32,14 @@ public enum TokenFormat implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static TokenFormat fromValue(Integer value) {
         if (value != null) {
-            for (KrbEnum e : values()) {
-                if (e.getValue() == value.intValue()) {
+            for (Asn1EnumType e : values()) {
+                if (e.getIntValue() == value.intValue()) {
                     return (TokenFormat) e;
                 }
             }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/TransitedEncodingType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/TransitedEncodingType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/TransitedEncodingType.java
index ca1e83b..83de2bc 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/TransitedEncodingType.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/base/TransitedEncodingType.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.base;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum TransitedEncodingType implements KrbEnum {
+public enum TransitedEncodingType implements Asn1EnumType {
     UNKNOWN(-1),
     NULL(0),
     DOMAIN_X500_COMPRESS(1);
@@ -33,14 +33,14 @@ public enum TransitedEncodingType implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static TransitedEncodingType fromValue(Integer value) {
         if (value != null) {
-            for (KrbEnum e : values()) {
-                if (e.getValue() == value.intValue()) {
+            for (Asn1EnumType e : values()) {
+                if (e.getIntValue() == value.intValue()) {
                     return (TransitedEncodingType) e;
                 }
             }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/ArmorType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/ArmorType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/ArmorType.java
index 1bd0589..05d5f0e 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/ArmorType.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/ArmorType.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.fast;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum ArmorType implements KrbEnum {
+public enum ArmorType implements Asn1EnumType {
     NONE                (0),
     ARMOR_AP_REQUEST              (1);
 
@@ -32,14 +32,14 @@ public enum ArmorType implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static ArmorType fromValue(Integer value) {
         if (value != null) {
-            for (KrbEnum e : values()) {
-                if (e.getValue() == value.intValue()) {
+            for (Asn1EnumType e : values()) {
+                if (e.getIntValue() == value.intValue()) {
                     return (ArmorType) e;
                 }
             }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/FastOption.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/FastOption.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/FastOption.java
index 5819d7c..39bfbbb 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/FastOption.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/FastOption.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.fast;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum FastOption implements KrbEnum {
+public enum FastOption implements Asn1EnumType {
     NONE(-1),
     RESERVED(0),
     HIDE_CLIENT_NAMES(1),
@@ -35,13 +35,13 @@ public enum FastOption implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static FastOption fromValue(int value) {
-        for (KrbEnum e : values()) {
-            if (e.getValue() == value) {
+        for (Asn1EnumType e : values()) {
+            if (e.getIntValue() == value) {
                 return (FastOption) e;
             }
         }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/FastOptions.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/FastOptions.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/FastOptions.java
index 90cdbdb..994f195 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/FastOptions.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/FastOptions.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.fast;
 
-import org.apache.kerby.kerberos.kerb.spec.base.KrbFlags;
+import org.apache.kerby.asn1.type.Asn1Flags;
 
-public class FastOptions extends KrbFlags {
+public class FastOptions extends Asn1Flags {
 
     public FastOptions() {
         this(0);

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/KrbFastArmor.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/KrbFastArmor.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/KrbFastArmor.java
index 71227ba..4b7d04d 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/KrbFastArmor.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/KrbFastArmor.java
@@ -51,7 +51,7 @@ public class KrbFastArmor extends KrbSequenceType {
     }
 
     public void setArmorType(ArmorType armorType) {
-        setFieldAsInt(ARMOR_TYPE, armorType.getValue());
+        setFieldAsInt(ARMOR_TYPE, armorType.getIntValue());
     }
 
     public byte[] getArmorValue() {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/PaAuthnEntry.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/PaAuthnEntry.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/PaAuthnEntry.java
index 34f60fa..da15051 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/PaAuthnEntry.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/fast/PaAuthnEntry.java
@@ -59,7 +59,7 @@ public class PaAuthnEntry extends KrbSequenceType {
     }
 
     public void setPaType(PaDataType paDataType) {
-        setFieldAsInt(PA_TYPE, paDataType.getValue());
+        setFieldAsInt(PA_TYPE, paDataType.getIntValue());
     }
 
     public byte[] getPaHint() {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcOption.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcOption.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcOption.java
index 36e289e..57633b5 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcOption.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcOption.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.kdc;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum KdcOption implements KrbEnum {
+public enum KdcOption implements Asn1EnumType {
     NONE(-1),
     //RESERVED(0x80000000),
     FORWARDABLE(0x40000000),
@@ -63,13 +63,13 @@ public enum KdcOption implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static KdcOption fromValue(int value) {
-        for (KrbEnum e : values()) {
-            if (e.getValue() == value) {
+        for (Asn1EnumType e : values()) {
+            if (e.getIntValue() == value) {
                 return (KdcOption) e;
             }
         }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcOptions.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcOptions.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcOptions.java
index dbb60fd..299b6d0 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcOptions.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcOptions.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.kdc;
 
-import org.apache.kerby.kerberos.kerb.spec.base.KrbFlags;
+import org.apache.kerby.asn1.type.Asn1Flags;
 
-public class KdcOptions extends KrbFlags {
+public class KdcOptions extends Asn1Flags {
 
     public KdcOptions() {
         this(0);

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcReqBody.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcReqBody.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcReqBody.java
index a9b3c48..081b0a0 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcReqBody.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/kdc/KdcReqBody.java
@@ -141,7 +141,7 @@ public class KdcReqBody extends KrbSequenceType {
     public void setEtypes(List<EncryptionType> etypes) {
         List<Integer> values = new ArrayList<Integer>();
         for (EncryptionType etype: etypes) {
-            values.add(etype.getValue());
+            values.add(etype.getIntValue());
         }
         KrbIntegers value = new KrbIntegers(values);
         setFieldAs(ETYPE, value);

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaAuthenticationSetElem.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaAuthenticationSetElem.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaAuthenticationSetElem.java
index 48fbef9..62f90b5 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaAuthenticationSetElem.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaAuthenticationSetElem.java
@@ -53,7 +53,7 @@ public class PaAuthenticationSetElem extends KrbSequenceType {
     }
 
     public void setPaType(PaDataType paDataType) {
-        setFieldAsInt(PA_TYPE, paDataType.getValue());
+        setFieldAsInt(PA_TYPE, paDataType.getIntValue());
     }
 
     public byte[] getPaHint() {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaDataEntry.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaDataEntry.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaDataEntry.java
index 901eb06..f9a9170 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaDataEntry.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaDataEntry.java
@@ -56,7 +56,7 @@ public class PaDataEntry extends KrbSequenceType {
     }
 
     public void setPaDataType(PaDataType paDataType) {
-        setFieldAsInt(PADATA_TYPE, paDataType.getValue());
+        setFieldAsInt(PADATA_TYPE, paDataType.getIntValue());
     }
 
     public byte[] getPaDataValue() {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaDataType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaDataType.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaDataType.java
index 7938277..a29540b 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaDataType.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/PaDataType.java
@@ -19,12 +19,12 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.pa;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
 /**
  * From krb5.h
  */
-public enum PaDataType implements KrbEnum {
+public enum PaDataType implements Asn1EnumType {
     NONE                (0),
     TGS_REQ              (1),
     AP_REQ              (1),
@@ -74,14 +74,14 @@ public enum PaDataType implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static PaDataType fromValue(Integer value) {
         if (value != null) {
-            for (KrbEnum e : values()) {
-                if (e.getValue() == value.intValue()) {
+            for (Asn1EnumType e : values()) {
+                if (e.getIntValue() == value.intValue()) {
                     return (PaDataType) e;
                 }
             }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/token/TokenFlag.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/token/TokenFlag.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/token/TokenFlag.java
index 75f06f6..ea3fac7 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/token/TokenFlag.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/token/TokenFlag.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.pa.token;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum TokenFlag implements KrbEnum {
+public enum TokenFlag implements Asn1EnumType {
     NONE(-1),
     ID_TOKEN_REQUIRED(0x40000000),
     AC_TOKEN_REQUIRED(0x20000000),
@@ -35,13 +35,13 @@ public enum TokenFlag implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static TokenFlag fromValue(int value) {
-        for (KrbEnum e : values()) {
-            if (e.getValue() == value) {
+        for (Asn1EnumType e : values()) {
+            if (e.getIntValue() == value) {
                 return (TokenFlag) e;
             }
         }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/token/TokenFlags.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/token/TokenFlags.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/token/TokenFlags.java
index e5ffe43..ec34811 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/token/TokenFlags.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/pa/token/TokenFlags.java
@@ -19,11 +19,11 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.pa.token;
 
-import org.apache.kerby.kerberos.kerb.spec.base.KrbFlags;
+import org.apache.kerby.asn1.type.Asn1Flags;
 
 import static org.apache.kerby.kerberos.kerb.spec.ticket.TicketFlag.INVALID;
 
-public class TokenFlags extends KrbFlags {
+public class TokenFlags extends Asn1Flags {
 
     public TokenFlags() {
         this(0);
@@ -34,6 +34,6 @@ public class TokenFlags extends KrbFlags {
     }
 
     public boolean isInvalid() {
-        return isFlagSet(INVALID.getValue());
+        return isFlagSet(INVALID.getIntValue());
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ticket/TicketFlag.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ticket/TicketFlag.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ticket/TicketFlag.java
index a5ea6ca..56ac780 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ticket/TicketFlag.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ticket/TicketFlag.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.ticket;
 
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
+import org.apache.kerby.asn1.type.Asn1EnumType;
 
-public enum TicketFlag implements KrbEnum {
+public enum TicketFlag implements Asn1EnumType {
     NONE(-1),
     FORWARDABLE(0x40000000),
     FORWARDED(0x20000000),
@@ -46,13 +46,13 @@ public enum TicketFlag implements KrbEnum {
     }
 
     @Override
-    public int getValue() {
+    public int getIntValue() {
         return value;
     }
 
     public static TicketFlag fromValue(int value) {
-        for (KrbEnum e : values()) {
-            if (e.getValue() == value) {
+        for (Asn1EnumType e : values()) {
+            if (e.getIntValue() == value) {
                 return (TicketFlag) e;
             }
         }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ticket/TicketFlags.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ticket/TicketFlags.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ticket/TicketFlags.java
index f2031c9..240af65 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ticket/TicketFlags.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/ticket/TicketFlags.java
@@ -19,11 +19,11 @@
  */
 package org.apache.kerby.kerberos.kerb.spec.ticket;
 
-import org.apache.kerby.kerberos.kerb.spec.base.KrbFlags;
+import org.apache.kerby.asn1.type.Asn1Flags;
 
 import static org.apache.kerby.kerberos.kerb.spec.ticket.TicketFlag.INVALID;
 
-public class TicketFlags extends KrbFlags {
+public class TicketFlags extends Asn1Flags {
 
     public TicketFlags() {
         this(0);
@@ -34,6 +34,6 @@ public class TicketFlags extends KrbFlags {
     }
 
     public boolean isInvalid() {
-        return isFlagSet(INVALID.getValue());
+        return isFlagSet(INVALID.getIntValue());
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/spec/base/KrbFlagsTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/spec/base/KrbFlagsTest.java b/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/spec/base/KrbFlagsTest.java
deleted file mode 100644
index 69e52ec..0000000
--- a/kerby-kerb/kerb-core/src/test/java/org/apache/kerby/kerberos/kerb/spec/base/KrbFlagsTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- *
- */
-package org.apache.kerby.kerberos.kerb.spec.base;
-
-import org.apache.kerby.kerberos.kerb.spec.KrbEnum;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import java.io.IOException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class KrbFlagsTest {
-  
-  public static final int FLAG_0 = 0b00000000000000000000000000000001;
-  public static final int FLAG_1 = 0b00000000000000000000000000000010;
-  public static final int FLAG_2 = 0x00000004;
-  public static final int FLAG_3 = 0x00000008;
-  public static final int FLAG_4 = 16;
-  public static final int FLAG_5 = 32;
-  
-  public enum TestEnum implements KrbEnum {
-    FLAG_0(0x00000001),
-    FLAG_1(0x00000002),
-    FLAG_2(0x00000004),
-    FLAG_3(0x00000008),
-    FLAG_4(0x00000010),
-    FLAG_5(0x00000020);
-    
-    private int value;
-    
-    private TestEnum(int value) {
-      this.value = value;
-    }
-
-    @Override
-    public int getValue() {
-      return value;
-    }
-    
-  }
-  
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-  
-  private KrbFlags krbFlags;
-  
-  @Before
-  public void setUp() {
-    krbFlags = new KrbFlags(FLAG_5 | FLAG_3 | FLAG_1);
-  }
-
-  @Test
-  public void testToValue() throws IOException {
-    byte[] value = {(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF};
-    krbFlags.setValue(value);
-    krbFlags.toValue();
-    assertEquals(0b11011110101011011011111011101111, krbFlags.getFlags());
-  }
-
-  @Test
-  public void testKrbFlags() {
-    krbFlags = new KrbFlags();
-    assertEquals(0b00000000000000000000000000000000, krbFlags.getFlags());
-  }
-
-  @Test
-  public void testKrbFlagsInt() {
-    krbFlags = new KrbFlags(FLAG_4 | FLAG_2 | FLAG_0);
-    assertEquals(0b00000000000000000000000000010101, krbFlags.getFlags());
-  }
-
-  @Test
-  public void testSetFlags() {
-    krbFlags.setFlags(FLAG_4 | FLAG_2 | FLAG_0);
-    assertEquals(0b00000000000000000000000000010101, krbFlags.getFlags());
-  }
-
-  @Test
-  public void testGetFlags() {
-    assertEquals(0b00000000000000000000000000101010, krbFlags.getFlags());
-  }
-
-  @Test
-  public void testIsFlagSetInt() {
-    assertTrue(krbFlags.isFlagSet(FLAG_5));
-    assertFalse(krbFlags.isFlagSet(FLAG_4));
-  }
-
-  @Test
-  public void testSetFlagInt() {
-    krbFlags.setFlag(FLAG_4);
-    assertEquals(0b00000000000000000000000000111010, krbFlags.getFlags());
-  }
-
-  @Test
-  public void testClearFlagInt() {
-    krbFlags.clearFlag(FLAG_3);
-    assertEquals(0b00000000000000000000000000100010, krbFlags.getFlags());
-  }
-
-  @Test
-  public void testClear() {
-    krbFlags.clear();
-    assertEquals(0b00000000000000000000000000000000, krbFlags.getFlags());
-  }
-
-  @Test
-  public void testIsFlagSetKrbEnum() {
-    assertTrue(krbFlags.isFlagSet(TestEnum.FLAG_5));
-    assertFalse(krbFlags.isFlagSet(TestEnum.FLAG_4));
-  }
-
-  @Test
-  public void testSetFlagKrbEnum() {
-    krbFlags.setFlag(TestEnum.FLAG_4);
-    assertEquals(0b00000000000000000000000000111010, krbFlags.getFlags());
-  }
-
-  @Test
-  public void testSetFlagKrbEnumBoolean() {
-    krbFlags.setFlag(TestEnum.FLAG_4, true);
-    assertEquals(0b00000000000000000000000000111010, krbFlags.getFlags());
-    krbFlags.setFlag(TestEnum.FLAG_4, false);
-    assertEquals(0b00000000000000000000000000101010, krbFlags.getFlags());
-  }
-
-  @Test
-  public void testClearFlagKrbEnum() {
-    krbFlags.clearFlag(TestEnum.FLAG_3);
-    assertEquals(0b00000000000000000000000000100010, krbFlags.getFlags());
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/57d63f2d/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/CheckSumHandler.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/CheckSumHandler.java b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/CheckSumHandler.java
index 5fb7d42..b2b30b4 100644
--- a/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/CheckSumHandler.java
+++ b/kerby-kerb/kerb-crypto/src/main/java/org/apache/kerby/kerberos/kerb/crypto/CheckSumHandler.java
@@ -157,7 +157,7 @@ public class CheckSumHandler {
     public static CheckSum checksumWithKey(CheckSumType checkSumType,
                            byte[] bytes, byte[] key, KeyUsage usage) throws KrbException {
         CheckSumTypeHandler handler = getCheckSumHandler(checkSumType);
-        byte[] checksumBytes = handler.checksumWithKey(bytes, key, usage.getValue());
+        byte[] checksumBytes = handler.checksumWithKey(bytes, key, usage.getIntValue());
         CheckSum checkSum = new CheckSum();
         checkSum.setCksumtype(checkSumType);
         checkSum.setChecksum(checksumBytes);
@@ -169,6 +169,6 @@ public class CheckSumHandler {
         CheckSumType checkSumType = checkSum.getCksumtype();
         CheckSumTypeHandler handler = getCheckSumHandler(checkSumType);
         return handler.verifyWithKey(bytes, key,
-                usage.getValue(), checkSum.getChecksum());
+                usage.getIntValue(), checkSum.getChecksum());
     }
 }


Mime
View raw message