directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject [1/2] directory-kerby git commit: DIRKRB-199. Support both blocking and event based network transport
Date Sun, 29 Mar 2015 14:19:33 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master bf116de47 -> ff0200f8b


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/impl/event/KrbClientEventType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/impl/event/KrbClientEventType.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/impl/event/KrbClientEventType.java
new file mode 100644
index 0000000..8f0e981
--- /dev/null
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/impl/event/KrbClientEventType.java
@@ -0,0 +1,29 @@
+/**
+ *  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.client.impl.event;
+
+import org.apache.kerby.event.EventType;
+
+public enum KrbClientEventType implements EventType {
+    TGT_INTENT,
+    TGT_RESULT,
+    TKT_INTENT,
+    TKT_RESULT
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/AbstractPreauthPlugin.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/AbstractPreauthPlugin.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/AbstractPreauthPlugin.java
index a9988a1..bdc8ccf 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/AbstractPreauthPlugin.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/AbstractPreauthPlugin.java
@@ -20,7 +20,7 @@
 package org.apache.kerby.kerberos.kerb.client.preauth;
 
 import org.apache.kerby.kerberos.kerb.client.KrbContext;
-import org.apache.kerby.kerberos.kerb.client.KOptions;
+import org.apache.kerby.KOptions;
 import org.apache.kerby.kerberos.kerb.client.request.KdcRequest;
 import org.apache.kerby.kerberos.kerb.preauth.PaFlag;
 import org.apache.kerby.kerberos.kerb.preauth.PaFlags;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/KrbPreauth.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/KrbPreauth.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/KrbPreauth.java
index 52a638f..23bb7d8 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/KrbPreauth.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/KrbPreauth.java
@@ -20,7 +20,7 @@
 package org.apache.kerby.kerberos.kerb.client.preauth;
 
 import org.apache.kerby.kerberos.kerb.client.KrbContext;
-import org.apache.kerby.kerberos.kerb.client.KOptions;
+import org.apache.kerby.KOptions;
 import org.apache.kerby.kerberos.kerb.client.request.KdcRequest;
 import org.apache.kerby.kerberos.kerb.preauth.PaFlags;
 import org.apache.kerby.kerberos.kerb.preauth.PluginRequestContext;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/PreauthHandle.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/PreauthHandle.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/PreauthHandle.java
index 6813ee6..b822dc7 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/PreauthHandle.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/PreauthHandle.java
@@ -19,7 +19,7 @@
  */
 package org.apache.kerby.kerberos.kerb.client.preauth;
 
-import org.apache.kerby.kerberos.kerb.client.KOptions;
+import org.apache.kerby.KOptions;
 import org.apache.kerby.kerberos.kerb.client.request.KdcRequest;
 import org.apache.kerby.kerberos.kerb.preauth.PaFlags;
 import org.apache.kerby.kerberos.kerb.preauth.PluginRequestContext;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/PreauthHandler.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/PreauthHandler.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/PreauthHandler.java
index de67884..30599d6 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/PreauthHandler.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/PreauthHandler.java
@@ -20,7 +20,7 @@
 package org.apache.kerby.kerberos.kerb.client.preauth;
 
 import org.apache.kerby.kerberos.kerb.client.KrbContext;
-import org.apache.kerby.kerberos.kerb.client.KOptions;
+import org.apache.kerby.KOptions;
 import org.apache.kerby.kerberos.kerb.client.preauth.builtin.EncTsPreauth;
 import org.apache.kerby.kerberos.kerb.client.preauth.builtin.TgtPreauth;
 import org.apache.kerby.kerberos.kerb.client.preauth.pkinit.PkinitPreauth;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/pkinit/PkinitPreauth.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/pkinit/PkinitPreauth.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/pkinit/PkinitPreauth.java
index 21c7208..c616131 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/pkinit/PkinitPreauth.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/pkinit/PkinitPreauth.java
@@ -21,7 +21,7 @@ package org.apache.kerby.kerberos.kerb.client.preauth.pkinit;
 
 import org.apache.kerby.kerberos.kerb.client.KrbContext;
 import org.apache.kerby.kerberos.kerb.client.KrbOption;
-import org.apache.kerby.kerberos.kerb.client.KOptions;
+import org.apache.kerby.KOptions;
 import org.apache.kerby.kerberos.kerb.client.preauth.AbstractPreauthPlugin;
 import org.apache.kerby.kerberos.kerb.preauth.PluginRequestContext;
 import org.apache.kerby.kerberos.kerb.client.request.KdcRequest;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/token/TokenPreauth.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/token/TokenPreauth.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/token/TokenPreauth.java
index fbab3ee..23269c6 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/token/TokenPreauth.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/preauth/token/TokenPreauth.java
@@ -21,7 +21,7 @@ package org.apache.kerby.kerberos.kerb.client.preauth.token;
 
 import org.apache.kerby.kerberos.kerb.client.KrbContext;
 import org.apache.kerby.kerberos.kerb.client.KrbOption;
-import org.apache.kerby.kerberos.kerb.client.KOptions;
+import org.apache.kerby.KOptions;
 import org.apache.kerby.kerberos.kerb.client.preauth.AbstractPreauthPlugin;
 import org.apache.kerby.kerberos.kerb.preauth.PluginRequestContext;
 import org.apache.kerby.kerberos.kerb.client.request.KdcRequest;
@@ -75,7 +75,7 @@ public class TokenPreauth extends AbstractPreauthPlugin {
                                   PluginRequestContext requestContext,
                                   KOptions options) {
 
-        tokenContext.usingIdToken = options.getBooleanOption(KrbOption.TOKEN_USING_IDTOKEN);
+        tokenContext.usingIdToken = options.getBooleanOption(KrbOption.USE_TOKEN);
         if (tokenContext.usingIdToken) {
             if (options.contains(KrbOption.TOKEN_USER_ID_TOKEN)) {
                 tokenContext.token =

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/ArmoredAsRequest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/ArmoredAsRequest.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/ArmoredAsRequest.java
index 6d19bf6..5c45479 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/ArmoredAsRequest.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/ArmoredAsRequest.java
@@ -21,7 +21,7 @@ package org.apache.kerby.kerberos.kerb.client.request;
 
 import org.apache.kerby.kerberos.kerb.KrbException;
 import org.apache.kerby.kerberos.kerb.ccache.CredentialCache;
-import org.apache.kerby.kerberos.kerb.client.KOptions;
+import org.apache.kerby.KOptions;
 import org.apache.kerby.kerberos.kerb.client.KrbContext;
 import org.apache.kerby.kerberos.kerb.client.KrbOption;
 import org.apache.kerby.kerberos.kerb.crypto.fast.FastUtil;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithCert.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithCert.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithCert.java
index 9b3d8fb..ef2808f 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithCert.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithCert.java
@@ -21,7 +21,7 @@ package org.apache.kerby.kerberos.kerb.client.request;
 
 import org.apache.kerby.kerberos.kerb.client.KrbContext;
 import org.apache.kerby.kerberos.kerb.client.KrbOption;
-import org.apache.kerby.kerberos.kerb.client.KOptions;
+import org.apache.kerby.KOptions;
 import org.apache.kerby.kerberos.kerb.KrbException;
 import org.apache.kerby.kerberos.kerb.spec.pa.PaDataType;
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithKeytab.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithKeytab.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithKeytab.java
index 5fa6799..3cde244 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithKeytab.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithKeytab.java
@@ -19,8 +19,8 @@
  */
 package org.apache.kerby.kerberos.kerb.client.request;
 
+import org.apache.kerby.KOptions;
 import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.kerberos.kerb.client.KOptions;
 import org.apache.kerby.kerberos.kerb.client.KrbContext;
 import org.apache.kerby.kerberos.kerb.client.KrbOption;
 import org.apache.kerby.kerberos.kerb.keytab.Keytab;
@@ -31,9 +31,6 @@ import java.io.File;
 import java.io.IOException;
 
 public class AsRequestWithKeytab extends AsRequest{
-    private static final String DEFAULT_KEY_LOCATION = "/etc/krb5.keytab";
-    private static final String DEFAULT_CLIENT_KEY_LOCATION = "/usr/local/var/krb5/user/0/client.keytab";
-
 
     public AsRequestWithKeytab(KrbContext context) {
         super(context);
@@ -45,12 +42,8 @@ public class AsRequestWithKeytab extends AsRequest{
         File keytabFile = null;
         KOptions kOptions = getKrbOptions();
 
-        if (kOptions.contains(KrbOption.USE_DFT_KEYTAB)) {
-            keytabFile = new File(DEFAULT_CLIENT_KEY_LOCATION);
-        } else if (kOptions.contains(KrbOption.USER_KEYTAB_FILE)) {
-            keytabFile = new File(kOptions.getStringOption(KrbOption.USER_KEYTAB_FILE));
-        } else {
-            keytabFile = new File(DEFAULT_KEY_LOCATION);
+        if (kOptions.contains(KrbOption.KEYTAB_FILE)) {
+            keytabFile = kOptions.getFileOption(KrbOption.KEYTAB_FILE);
         }
 
         Keytab keytab = null;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithToken.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithToken.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithToken.java
index 95e6021..0d08415 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithToken.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/AsRequestWithToken.java
@@ -20,7 +20,7 @@
 package org.apache.kerby.kerberos.kerb.client.request;
 
 import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.kerberos.kerb.client.KOptions;
+import org.apache.kerby.KOptions;
 import org.apache.kerby.kerberos.kerb.client.KrbContext;
 import org.apache.kerby.kerberos.kerb.client.KrbOption;
 import org.apache.kerby.kerberos.kerb.spec.pa.PaDataType;
@@ -46,7 +46,7 @@ public class AsRequestWithToken extends ArmoredAsRequest {
         KOptions results = super.getPreauthOptions();
         KOptions krbOptions = getKrbOptions();
 
-        results.add(krbOptions.getOption(KrbOption.TOKEN_USING_IDTOKEN));
+        results.add(krbOptions.getOption(KrbOption.USE_TOKEN));
         results.add(krbOptions.getOption(KrbOption.TOKEN_USER_ID_TOKEN));
         //results.add(krbOptions.getOption(KrbOption.TOKEN_USER_AC_TOKEN));
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/KdcRequest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/KdcRequest.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/KdcRequest.java
index d4c2a4e..1a5570d 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/KdcRequest.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/KdcRequest.java
@@ -19,13 +19,13 @@
  */
 package org.apache.kerby.kerberos.kerb.client.request;
 
+import org.apache.kerby.KOptions;
+import org.apache.kerby.kerberos.kerb.KrbException;
 import org.apache.kerby.kerberos.kerb.client.KrbContext;
-import org.apache.kerby.kerberos.kerb.client.KOptions;
 import org.apache.kerby.kerberos.kerb.client.preauth.KrbFastContext;
 import org.apache.kerby.kerberos.kerb.client.preauth.PreauthContext;
 import org.apache.kerby.kerberos.kerb.client.preauth.PreauthHandler;
 import org.apache.kerby.kerberos.kerb.crypto.EncryptionHandler;
-import org.apache.kerby.kerberos.kerb.KrbException;
 import org.apache.kerby.kerberos.kerb.spec.KerberosTime;
 import org.apache.kerby.kerberos.kerb.spec.base.*;
 import org.apache.kerby.kerberos.kerb.spec.kdc.KdcOptions;
@@ -33,7 +33,7 @@ import org.apache.kerby.kerberos.kerb.spec.kdc.KdcRep;
 import org.apache.kerby.kerberos.kerb.spec.kdc.KdcReq;
 import org.apache.kerby.kerberos.kerb.spec.kdc.KdcReqBody;
 import org.apache.kerby.kerberos.kerb.spec.pa.PaDataType;
-import org.apache.kerby.transport.Transport;
+import org.apache.kerby.kerberos.kerb.transport.KrbTransport;
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
@@ -47,7 +47,7 @@ import java.util.Map;
  */
 public abstract class KdcRequest {
     private KrbContext context;
-    private Transport transport;
+    private KrbTransport transport;
 
     private KOptions krbOptions;
     private PrincipalName serverPrincipal;
@@ -75,11 +75,11 @@ public abstract class KdcRequest {
         this.fastContext = new KrbFastContext();
     }
 
-    public void setTransport(Transport transport) {
+    public void setTransport(KrbTransport transport) {
         this.transport = transport;
     }
 
-    public Transport getTransport() {
+    public KrbTransport getTransport() {
         return this.transport;
     }
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/TgsRequest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/TgsRequest.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/TgsRequest.java
index e0ca3ed..4a4b6e0 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/TgsRequest.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/TgsRequest.java
@@ -39,6 +39,10 @@ public class TgsRequest extends KdcRequest {
     private TgtTicket tgt;
     private ApReq apReq;
 
+    public TgsRequest(KrbContext context) {
+        super(context);
+    }
+
     public TgsRequest(KrbContext context, TgtTicket tgtTicket) {
         super(context);
         this.tgt = tgtTicket;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/TgsRequestWithToken.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/TgsRequestWithToken.java
b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/TgsRequestWithToken.java
new file mode 100644
index 0000000..a167718
--- /dev/null
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/request/TgsRequestWithToken.java
@@ -0,0 +1,36 @@
+/**
+ *  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.client.request;
+
+import org.apache.kerby.kerberos.kerb.client.KrbContext;
+import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+
+/**
+ * Tgs request with an Access Token.
+ */
+public class TgsRequestWithToken extends TgsRequest {
+
+    public TgsRequestWithToken(KrbContext context) {
+        super(context);
+
+        // TODO: Access Token specific.
+        throw new NotImplementedException();
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/common/KrbUtil.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/common/KrbUtil.java
b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/common/KrbUtil.java
index 45020e0..ad461ba 100644
--- a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/common/KrbUtil.java
+++ b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/common/KrbUtil.java
@@ -21,6 +21,7 @@ package org.apache.kerby.kerberos.kerb.common;
 
 import org.apache.kerby.kerberos.kerb.KrbCodec;
 import org.apache.kerby.kerberos.kerb.spec.base.KrbMessage;
+import org.apache.kerby.kerberos.kerb.transport.KrbTransport;
 import org.apache.kerby.transport.Transport;
 
 import java.io.IOException;
@@ -28,7 +29,8 @@ import java.nio.ByteBuffer;
 
 public class KrbUtil {
 
-    public static void sendMessage(KrbMessage message, Transport transport) {
+    public static void sendMessage(KrbMessage message,
+                                   KrbTransport transport) throws IOException {
         int bodyLen = message.encodingLength();
         ByteBuffer buffer = ByteBuffer.allocate(bodyLen + 4);
         buffer.putInt(bodyLen);
@@ -37,7 +39,29 @@ public class KrbUtil {
         transport.sendMessage(buffer);
     }
 
-    public static KrbMessage decodeMessage(ByteBuffer message) throws IOException {
+    /**
+     * To be cleaned up
+     * @param message
+     * @param transport
+     * @throws IOException
+     */
+    public static void sendMessageOld(KrbMessage message,
+                                   Transport transport) throws IOException {
+        int bodyLen = message.encodingLength();
+        ByteBuffer buffer = ByteBuffer.allocate(bodyLen + 4);
+        buffer.putInt(bodyLen);
+        message.encode(buffer);
+        buffer.flip();
+        transport.sendMessage(buffer);
+    }
+
+    /**
+     * To be cleaned.
+     * @param message
+     * @return
+     * @throws IOException
+     */
+    public static KrbMessage decodeMessageOld(ByteBuffer message) throws IOException {
         int bodyLen = message.getInt();
         assert (message.remaining() >= bodyLen);
 
@@ -46,4 +70,10 @@ public class KrbUtil {
         return krbMessage;
     }
 
+    public static KrbMessage decodeMessage(ByteBuffer message) throws IOException {
+        KrbMessage krbMessage = KrbCodec.decodeMessage(message);
+
+        return krbMessage;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/transport/AbstractKrbTransport.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/transport/AbstractKrbTransport.java
b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/transport/AbstractKrbTransport.java
new file mode 100644
index 0000000..b7577cf
--- /dev/null
+++ b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/transport/AbstractKrbTransport.java
@@ -0,0 +1,38 @@
+/**
+ *  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.transport;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * Abstract Krb transport.
+ */
+public abstract class AbstractKrbTransport implements KrbTransport {
+    private Object attachment;
+
+    public void setAttachment(Object attachment) {
+        this.attachment = attachment;
+    }
+
+    public Object getAttachment() {
+        return attachment;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/transport/KrbTransport.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/transport/KrbTransport.java
b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/transport/KrbTransport.java
new file mode 100644
index 0000000..432bda8
--- /dev/null
+++ b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/transport/KrbTransport.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.transport;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * Krb client transport.
+ */
+public interface KrbTransport {
+
+    /**
+     * Send out a Kerberos message to remote peer.
+     * @param message
+     */
+    public void sendMessage(ByteBuffer message) throws IOException;
+
+    /**
+     * Receive a Kerberos message from remote.
+     * @return
+     */
+    public ByteBuffer receiveMessage() throws IOException;
+
+    /**
+     * Set an attachment.
+     * @param attachment
+     */
+    public void setAttachment(Object attachment);
+
+    /**
+     * Get the attachment set before.
+     * @return attachment
+     */
+    public Object getAttachment();
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/KdcTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/KdcTest.java
b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/KdcTest.java
index 3a3d22d..17d4357 100644
--- a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/KdcTest.java
+++ b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/KdcTest.java
@@ -51,10 +51,10 @@ public abstract class KdcTest extends KdcTestBase {
 
         // With good password
         try {
-            tgt = krbClnt.requestTgtTicket(clientPrincipal, password, null);
+            tgt = krbClnt.requestTgtWithPassword(clientPrincipal, password);
             assertThat(tgt).isNotNull();
 
-            tkt = krbClnt.requestServiceTicket(tgt, serverPrincipal, null);
+            tkt = krbClnt.requestServiceTicketWithTgt(tgt, serverPrincipal);
             assertThat(tkt).isNotNull();
         } catch (Exception e) {
             System.out.println("Exception occurred with good password");
@@ -64,23 +64,22 @@ public abstract class KdcTest extends KdcTestBase {
 
         // With bad password
         try {
-            tgt = krbClnt.requestTgtTicket(clientPrincipal, "badpassword", null);
+            tgt = krbClnt.requestTgtWithPassword(clientPrincipal, "badpassword");
         } catch (Exception e) {
             System.out.println("Exception occurred with bad password");
         }
 
-        // TODO: With good password again. This will fail, to be investigated.
-        /*
+        // With good password again
         try {
-            tgt = krbClnt.requestTgtTicket(clientPrincipal, password, null);
+            tgt = krbClnt.requestTgtWithPassword(clientPrincipal, password);
             assertThat(tgt).isNotNull();
 
-            tkt = krbClnt.requestServiceTicket(tgt, serverPrincipal, null);
+            tkt = krbClnt.requestServiceTicketWithTgt(tgt, serverPrincipal);
             assertThat(tkt).isNotNull();
         } catch (Exception e) {
             System.out.println("Exception occurred with good password again");
             e.printStackTrace();
             Assert.fail();
-        }*/
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcHandler.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcHandler.java
b/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcHandler.java
index 8c730fd..7a0a3d7 100644
--- a/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcHandler.java
+++ b/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcHandler.java
@@ -99,7 +99,7 @@ public class KdcHandler extends MessageHandler {
         ByteBuffer message = event.getMessage();
         Transport transport = event.getTransport();
 
-        KrbMessage krbRequest = KrbUtil.decodeMessage(message);
+        KrbMessage krbRequest = KrbUtil.decodeMessageOld(message);
         KdcRequest kdcRequest = null;
 
         KrbMessageType messageType = krbRequest.getMsgType();
@@ -128,7 +128,7 @@ public class KdcHandler extends MessageHandler {
             kdcRequest.process();
 
             KrbMessage krbResponse = kdcRequest.getReply();
-            KrbUtil.sendMessage(krbResponse, transport);
+            KrbUtil.sendMessageOld(krbResponse, transport);
         } catch (Exception e) {
             //TODO: log the error
             System.out.println("Error occured while processing request:"

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/ToolUtil.java
----------------------------------------------------------------------
diff --git a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/ToolUtil.java
b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/ToolUtil.java
index bce6117..45d9c65 100644
--- a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/ToolUtil.java
+++ b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/ToolUtil.java
@@ -19,10 +19,10 @@
  */
 package org.apache.kerby.kerberos.tool;
 
-import org.apache.kerby.kerberos.kerb.client.KOption;
-import org.apache.kerby.kerberos.kerb.client.KOptionType;
+import org.apache.kerby.KOption;
+import org.apache.kerby.KOptionType;
 import org.apache.kerby.kerberos.kerb.client.KrbOption;
-import org.apache.kerby.kerberos.kerb.client.KOptions;
+import org.apache.kerby.KOptions;
 
 import java.io.File;
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/Kinit.java
----------------------------------------------------------------------
diff --git a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/Kinit.java
b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/Kinit.java
index 740bb90..7c16c98 100644
--- a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/Kinit.java
+++ b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/Kinit.java
@@ -19,11 +19,11 @@
  */
 package org.apache.kerby.kerberos.tool.kinit;
 
+import org.apache.kerby.KOptionType;
+import org.apache.kerby.KOptions;
 import org.apache.kerby.kerberos.kerb.KrbException;
 import org.apache.kerby.kerberos.kerb.ccache.Credential;
 import org.apache.kerby.kerberos.kerb.ccache.CredentialCache;
-import org.apache.kerby.kerberos.kerb.client.KOptionType;
-import org.apache.kerby.kerberos.kerb.client.KOptions;
 import org.apache.kerby.kerberos.kerb.client.KrbClient;
 import org.apache.kerby.kerberos.kerb.client.KrbOption;
 import org.apache.kerby.kerberos.kerb.spec.ticket.TgtTicket;
@@ -101,25 +101,25 @@ public class Kinit {
         return password;
     }
 
-    private static void requestTicket(String principal, KOptions krbOptions) throws KrbException,
IOException {
-        KrbClient krbClient = getClient();
-        TgtTicket tgt;
-
-        if (krbOptions.contains(KrbOption.USE_KEYTAB)) {
-            tgt = krbClient.requestTgtTicket(principal, krbOptions);
-        } else {
+    private static void requestTicket(String principal,
+                                      KOptions ktOptions) throws Exception {
+        ktOptions.add(KinitOption.CLIENT_PRINCIPAL, principal);
+        if (! ktOptions.contains(KinitOption.USE_KEYTAB)) {
             String password = getPassword(principal);
-            tgt = krbClient.requestTgtTicket(principal, password,
-                    krbOptions);
+            ktOptions.add(KinitOption.USER_PASSWD, password);
         }
 
-        writeTgtToCache(tgt, principal, krbOptions);
+        KrbClient krbClient = getClient();
+        TgtTicket tgt = krbClient.requestTgtWithOptions(
+                ToolUtil.convertOptions(ktOptions));
+
+        writeTgtToCache(tgt, principal, ktOptions);
     }
 
     /**
      * Init the client.
      */
-    private static KrbClient getClient() {
+    private static KrbClient getClient() throws KrbException {
         KrbClient krbClient = new KrbClient();
         krbClient.init();
         return krbClient;
@@ -128,8 +128,8 @@ public class Kinit {
     /**
      * Write tgt into credentials cache.
      */
-    private static void writeTgtToCache(TgtTicket tgt, String principal, KOptions kinitOptions)
-            throws IOException {
+    private static void writeTgtToCache(
+            TgtTicket tgt, String principal, KOptions kinitOptions) throws IOException {
         Credential credential = new Credential(tgt);
         CredentialCache cCache = new CredentialCache();
         cCache.addCredential(credential);
@@ -189,7 +189,7 @@ public class Kinit {
             printUsage("No principal is specified");
         }
 
-        Kinit.requestTicket(principal, ToolUtil.convertOptions(ktOptions));
+        Kinit.requestTicket(principal, ktOptions);
         System.exit(0);
     }
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/KinitOption.java
----------------------------------------------------------------------
diff --git a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/KinitOption.java
b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/KinitOption.java
index cade8a8..bce997b 100644
--- a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/KinitOption.java
+++ b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/KinitOption.java
@@ -19,11 +19,12 @@
  */
 package org.apache.kerby.kerberos.tool.kinit;
 
-import org.apache.kerby.kerberos.kerb.client.KOption;
-import org.apache.kerby.kerberos.kerb.client.KOptionType;
+import org.apache.kerby.KOption;
+import org.apache.kerby.KOptionType;
 
 public enum KinitOption implements KOption {
     NONE("NONE"),
+    CLIENT_PRINCIPAL("client-principal", "Client principal", KOptionType.STR),
     LIFE_TIME("-l", "lifetime", KOptionType.INT),
     START_TIME("-s", "start time", KOptionType.INT),
     RENEWABLE_LIFE("-r", "renewable lifetime", KOptionType.INT),
@@ -38,6 +39,7 @@ public enum KinitOption implements KOption {
     RENEW("-R", "renew"),
     CANONICALIZE("-C", "canonicalize"),
     AS_ENTERPRISE_PN("-E", "client is enterprise principal name"),
+    USER_PASSWD("user-passwd", "User plain password"),
     USE_KEYTAB("-k", "use keytab"),
     USE_DFT_KEYTAB("-i", "use default client keytab (with -k)"),
     USER_KEYTAB_FILE("-t", "filename of keytab to use", KOptionType.STR),

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/lib/kerby-util/src/main/java/org/apache/kerby/KOption.java
----------------------------------------------------------------------
diff --git a/lib/kerby-util/src/main/java/org/apache/kerby/KOption.java b/lib/kerby-util/src/main/java/org/apache/kerby/KOption.java
new file mode 100644
index 0000000..52f185d
--- /dev/null
+++ b/lib/kerby-util/src/main/java/org/apache/kerby/KOption.java
@@ -0,0 +1,41 @@
+/**
+ *  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;
+
+public interface KOption {
+
+    public void setType(KOptionType type);
+
+    public KOptionType getType();
+
+    public String getOptionName();
+
+    public void setName(String name);
+
+    public String getName();
+
+    public void setDescription(String description);
+
+    public String getDescription();
+
+    public void setValue(Object value);
+
+    public Object getValue();
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/lib/kerby-util/src/main/java/org/apache/kerby/KOptionType.java
----------------------------------------------------------------------
diff --git a/lib/kerby-util/src/main/java/org/apache/kerby/KOptionType.java b/lib/kerby-util/src/main/java/org/apache/kerby/KOptionType.java
new file mode 100644
index 0000000..e985131
--- /dev/null
+++ b/lib/kerby-util/src/main/java/org/apache/kerby/KOptionType.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;
+
+/**
+ * Option type.
+ */
+public enum KOptionType {
+    NONE,
+    NOV, // no value, a control flag
+    STR, // string value
+    INT, // integer value
+    BOOL, // boolean value
+    FILE, // file path value
+    DIR, // dir path value
+    OBJ  // arbitrary object
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/ff0200f8/lib/kerby-util/src/main/java/org/apache/kerby/KOptions.java
----------------------------------------------------------------------
diff --git a/lib/kerby-util/src/main/java/org/apache/kerby/KOptions.java b/lib/kerby-util/src/main/java/org/apache/kerby/KOptions.java
new file mode 100644
index 0000000..d124582
--- /dev/null
+++ b/lib/kerby-util/src/main/java/org/apache/kerby/KOptions.java
@@ -0,0 +1,122 @@
+/**
+ *  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;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A KOption container.
+ */
+public class KOptions {
+
+    private final Map<KOption, KOption> options =
+            new HashMap<KOption, KOption>();
+
+    public void add(KOption option) {
+        if (option != null) {
+            options.put(option, option);
+        }
+    }
+
+    public void add(KOption option, Object optionValue) {
+        if (option != null) {
+            option.setValue(optionValue);
+            add(option);
+        }
+    }
+
+    public boolean contains(KOption option) {
+        return options.containsKey(option);
+    }
+
+    public List<KOption> getOptions() {
+        return new ArrayList<>(options.keySet());
+    }
+
+    public KOption getOption(KOption option) {
+        if (! options.containsKey(option)) {
+            return null;
+        }
+
+        return options.get(option);
+    }
+
+    public Object getOptionValue(KOption option) {
+        if (! contains(option)) {
+            return null;
+        }
+        return options.get(option).getValue();
+    }
+
+    public String getStringOption(KOption option) {
+        Object value = getOptionValue(option);
+        if (value instanceof String) {
+            return (String) value;
+        }
+        return null;
+    }
+
+    public Boolean getBooleanOption(KOption option) {
+        Object value = getOptionValue(option);
+        if (value instanceof String) {
+            String strVal = (String) value;
+            if (strVal.equalsIgnoreCase("true") ||
+                strVal.equalsIgnoreCase("yes") ||
+                strVal.equals("1")) {
+                return true;
+            }
+        } else if (value instanceof Boolean) {
+            return (Boolean) value;
+        }
+
+        return null;
+    }
+
+    public int getIntegerOption(KOption option) {
+        Object value = getOptionValue(option);
+        if (value instanceof String) {
+            String strVal = (String) value;
+            return Integer.valueOf(strVal);
+        } else if (value instanceof Integer) {
+            return (Integer) value;
+        }
+        return -1;
+    }
+
+    public File getFileOption(KOption option) {
+        Object value = getOptionValue(option);
+        if (value instanceof File) {
+            return (File) value;
+        }
+        return null;
+    }
+
+    public File getDirOption(KOption option) {
+        Object value = getOptionValue(option);
+        if (value instanceof File) {
+            return (File) value;
+        }
+        return null;
+    }
+}


Mime
View raw message