You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by co...@apache.org on 2017/05/03 14:47:17 UTC

directory-kerby git commit: Fixing some typos + issues thrown up by FindBugs

Repository: directory-kerby
Updated Branches:
  refs/heads/trunk fd02601ec -> 00a1a16a2


Fixing some typos + issues thrown up by FindBugs


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

Branch: refs/heads/trunk
Commit: 00a1a16a25ed4619bd7a90f3bc625e96f2fb8773
Parents: fd02601
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Wed May 3 15:47:02 2017 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Wed May 3 15:47:02 2017 +0100

----------------------------------------------------------------------
 .../org/apache/kerby/xdr/type/XdrBoolean.java   | 10 +++---
 .../admin/server/kadmin/AdminServerHandler.java | 20 ++++++------
 .../kerby/kerberos/kerb/client/ClientUtil.java  |  4 +--
 .../kerb/type/ad/ADAuthenticationIndicator.java | 12 +++----
 .../tool/kinit/KinitToolWithConcurrence.java    |  4 +--
 .../kerby/kerberos/tool/token/TokenCache.java   | 34 ++++++--------------
 6 files changed, 34 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/00a1a16a/kerby-common/kerby-xdr/src/main/java/org/apache/kerby/xdr/type/XdrBoolean.java
----------------------------------------------------------------------
diff --git a/kerby-common/kerby-xdr/src/main/java/org/apache/kerby/xdr/type/XdrBoolean.java b/kerby-common/kerby-xdr/src/main/java/org/apache/kerby/xdr/type/XdrBoolean.java
index e8e092f..11d360b 100644
--- a/kerby-common/kerby-xdr/src/main/java/org/apache/kerby/xdr/type/XdrBoolean.java
+++ b/kerby-common/kerby-xdr/src/main/java/org/apache/kerby/xdr/type/XdrBoolean.java
@@ -6,16 +6,16 @@
  *  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. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.kerby.xdr.type;
 
@@ -88,7 +88,7 @@ public class XdrBoolean extends XdrSimple<Boolean> {
         } else if (Arrays.equals(bytes, FALSE_BYTE)) {
             setValue(false);
         } else {
-            throw new IOException("Fail to decode boolean type: " + bytes.toString());
+            throw new IOException("Fail to decode boolean type: " + Arrays.toString(bytes));
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/00a1a16a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/kadmin/AdminServerHandler.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/kadmin/AdminServerHandler.java b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/kadmin/AdminServerHandler.java
index 1f1197f..775a4f9 100644
--- a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/kadmin/AdminServerHandler.java
+++ b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/kadmin/AdminServerHandler.java
@@ -14,7 +14,7 @@
  *  "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. 
+ *  under the License.
  *
  */
 package org.apache.kerby.kerberos.kerb.admin.server.kadmin;
@@ -95,7 +95,7 @@ public class AdminServerHandler {
                 responseMessage = handleGetprincsReq(localKadmin, fieldInfos);
                 break;
             default:
-                throw new KrbException("AdminMessageType error, can not handle it.");
+                throw new KrbException("AdminMessageType error, can not handle the type: " + type);
         }
         return responseMessage;
 
@@ -112,7 +112,7 @@ public class AdminServerHandler {
             try {
                 localKadmin.addPrincipal(temp[0]);
             } catch (KrbException e) {
-                String error = "principal already exist!";
+                String error = "The principal already exists!";
                 LOG.error(error);
                 System.err.println(error);
                 ByteBuffer response = infoPackageTool(error, "addPrincipal");
@@ -126,14 +126,14 @@ public class AdminServerHandler {
             try {
                 localKadmin.addPrincipal(temp[0], password);
             } catch (KrbException e) {
-                String error = "principal already exist.\n"
+                String error = " The principal already exists.\n"
                         + "Choose update password instead of add principal";
                 LOG.error(error);
                 ByteBuffer response = infoPackageTool(error, "addPrincipal");
                 return response;
             }
         }
-        String message = "add principal of " + principal;
+        String message = "Add principal:" + principal;
         System.out.println(message);
         LOG.info(message);
         ByteBuffer responseMessage = infoPackageTool(message, "addPrincipal");
@@ -147,12 +147,12 @@ public class AdminServerHandler {
         try {
             localKadmin.deletePrincipal(temp[0]);
         } catch (KrbException e) {
-            String error = "no such principal exist!";
+            String error = "No such principal exists!";
             LOG.error(error);
             ByteBuffer response = infoPackageTool(error, "deletePrincipal");
             return response;
         }
-        String message = "delete principal of " + principal;
+        String message = "Delete principal of " + principal;
         System.out.println(message);
         LOG.info(message);
         ByteBuffer responseMessage = infoPackageTool(message, "deletePrincipal");
@@ -166,14 +166,14 @@ public class AdminServerHandler {
         try {
             localKadmin.renamePrincipal(oldPrincipalName[0], newPrincipalName[0]);
         } catch (KrbException e) {
-            String error = "the old principal name does not exist, or the new principal name"
+            String error = "The old principal name does not exist, or the new principal name"
                     + " already exists, rename failed.";
             System.err.println(error);
             ByteBuffer response = infoPackageTool(error, "renamePrincipal");
             return response;
         }
 
-        String message = "rename " + oldPrincipalName[0] + " to " + newPrincipalName[0];
+        String message = "Rename " + oldPrincipalName[0] + " to " + newPrincipalName[0];
         System.out.println(message);
         LOG.info(message);
         ByteBuffer responseMessage = infoPackageTool(message, "renamePrincipal");
@@ -193,7 +193,7 @@ public class AdminServerHandler {
             ByteBuffer responseMessage = infoPackageTool(listToString(princsList), "getPrincs");
             return responseMessage;
         } catch (KrbException e) {
-            String error = "principal do not exist.";
+            String error = "The principal does not exist.";
             LOG.error(error + e);
             ByteBuffer responseError = infoPackageTool(error, "getPrincs");
             return responseError;

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/00a1a16a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/ClientUtil.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/ClientUtil.java b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/ClientUtil.java
index f3dbc44..004675c 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/ClientUtil.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/ClientUtil.java
@@ -212,8 +212,8 @@ public final class ClientUtil {
                 }
             }
 
-            if (kdcList == null) {
-                LOG.info("Cannot get kdc for realm " + realm);
+            if (kdcList.isEmpty()) {
+                LOG.error("Cannot get kdc for realm " + realm);
             }
         } else {
             throw new KrbException("Can't get the realm");

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/00a1a16a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/ADAuthenticationIndicator.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/ADAuthenticationIndicator.java b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/ADAuthenticationIndicator.java
index f76b4e2..5dbcace 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/ADAuthenticationIndicator.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/ad/ADAuthenticationIndicator.java
@@ -6,16 +6,16 @@
  *  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. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.kerby.kerberos.kerb.type.ad;
 
@@ -28,14 +28,14 @@ import org.apache.kerby.kerberos.kerb.type.KrbSequenceOfType;
 
 /**
  * Contributed to the Apache Kerby Project by: Prodentity - Corrales, NM
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache DirectoryProject</a>
  */
 public class ADAuthenticationIndicator extends AuthorizationDataEntry {
 
     private AuthIndicator myAuthIndicator;
 
-    private class AuthIndicator extends KrbSequenceOfType<Asn1Utf8String> {
+    private static class AuthIndicator extends KrbSequenceOfType<Asn1Utf8String> {
     }
 
     public ADAuthenticationIndicator() {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/00a1a16a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/KinitToolWithConcurrence.java
----------------------------------------------------------------------
diff --git a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/KinitToolWithConcurrence.java b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/KinitToolWithConcurrence.java
index 7d33e1a..a63da76 100644
--- a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/KinitToolWithConcurrence.java
+++ b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/KinitToolWithConcurrence.java
@@ -242,7 +242,7 @@ public class KinitToolWithConcurrence {
             for (int j = 0; j < threadNumbers; j++) {
                 temp += reList[j * INTERVAL];
             }
-            float res = (now - startTime) / 1000;
+            float res = (now - startTime) / (float) 1000;
 
             double totalDelay = 0.0;
             int cutThreads = 0;
@@ -318,4 +318,4 @@ public class KinitToolWithConcurrence {
         return results;
     }
 
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/00a1a16a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenCache.java
----------------------------------------------------------------------
diff --git a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenCache.java b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenCache.java
index 64b9acd..d80c4b2 100644
--- a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenCache.java
+++ b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenCache.java
@@ -6,16 +6,16 @@
  *  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. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.kerby.kerberos.tool.token;
 
@@ -53,30 +53,14 @@ public class TokenCache {
             }
         }
 
-        String token = null;
-        BufferedReader reader = null;
-        try {
-            reader = new BufferedReader(
-                new InputStreamReader(Files.newInputStream(cacheFile.toPath()), StandardCharsets.UTF_8));
+        try (BufferedReader reader = new BufferedReader(
+                new InputStreamReader(Files.newInputStream(cacheFile.toPath()), StandardCharsets.UTF_8))) {
+
+            return reader.readLine();
         } catch (IOException e) {
             LOG.error("Can't find the cache file. " + e);
+            return null;
         }
-        String line = null;
-        try {
-            line = reader.readLine();
-        } catch (IOException e) {
-            LOG.error("I/O error occurs. " + e);
-        }
-        try {
-            reader.close();
-        } catch (IOException e) {
-            LOG.warn("Fail to close reader. " + e);
-        }
-        if (line != null) {
-            token = line;
-        }
-
-        return token;
     }
 
     public static void writeToken(String token) throws KrbException {