Bladeren bron

ZOOKEEPER-446. some traces of the host auth scheme left (breed via mahadev)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@787395 13f79535-47bb-0310-9956-ffa450edef68
Mahadev Konar 16 jaren geleden
bovenliggende
commit
cbd8be4923

+ 2 - 0
CHANGES.txt

@@ -126,6 +126,8 @@ BUGFIXES:
 
   ZOOKEEPER-427. ZooKeeper server unexpectedly high CPU utilisation (Sergey Zhuravlev via breed)
 
+  ZOOKEEPER-446. some traces of the host auth scheme left (breed via mahadev)
+
 IMPROVEMENTS:
   ZOOKEEPER-308. improve the atomic broadcast performance 3x.
   (breed via mahadev)

+ 0 - 1
src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java

@@ -780,7 +780,6 @@ public class NIOServerCnxn implements Watcher, ServerCnxn {
         InetAddress addr = ((InetSocketAddress) sock.socket()
                 .getRemoteSocketAddress()).getAddress();
         authInfo.add(new Id("ip", addr.getHostAddress()));
-        authInfo.add(new Id("host", addr.getCanonicalHostName()));
         sk.interestOps(SelectionKey.OP_READ);
     }
 

+ 0 - 69
src/java/main/org/apache/zookeeper/server/auth/HostAuthenticationProvider.java

@@ -1,69 +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.zookeeper.server.auth;
-
-import org.apache.zookeeper.data.Id;
-import org.apache.zookeeper.server.ServerCnxn;
-import org.apache.zookeeper.KeeperException;
-
-public class HostAuthenticationProvider implements AuthenticationProvider {
-
-    public String getScheme() {
-        return "host";
-    }
-
-    public KeeperException.Code
-        handleAuthentication(ServerCnxn cnxn, byte[] authData)
-    {
-        String id = cnxn.getRemoteAddress().getAddress().getCanonicalHostName();
-        cnxn.getAuthInfo().add(new Id(getScheme(), id));
-        return KeeperException.Code.OK;
-    }
-
-    public boolean matches(String id, String aclExpr) {
-        // We just do suffix matching
-        String idParts[] = id.split("\\.");
-        String expParts[] = aclExpr.split("\\.");
-        int diff = idParts.length - expParts.length;
-        if (diff < 0) {
-            return false;
-        }
-        for (int i = 0; i < expParts.length; i++) {
-            if (idParts[i + diff].equals(expParts[i])) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    public boolean isAuthenticated() {
-        return false;
-    }
-
-    public boolean isValid(String id) {
-        String parts[] = id.split("\\.");
-        for (String part : parts) {
-            if (part.length() == 0) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-}

+ 0 - 2
src/java/main/org/apache/zookeeper/server/auth/ProviderRegistry.java

@@ -37,10 +37,8 @@ public class ProviderRegistry {
             if (initialized)
                 return;
             IPAuthenticationProvider ipp = new IPAuthenticationProvider();
-            HostAuthenticationProvider hostp = new HostAuthenticationProvider();
             DigestAuthenticationProvider digp = new DigestAuthenticationProvider();
             authenticationProviders.put(ipp.getScheme(), ipp);
-            authenticationProviders.put(hostp.getScheme(), hostp);
             authenticationProviders.put(digp.getScheme(), digp);
             Enumeration<Object> en = System.getProperties().keys();
             while (en.hasMoreElements()) {

+ 5 - 5
src/java/test/org/apache/zookeeper/test/ACLTest.java

@@ -80,13 +80,13 @@ public class ACLTest extends TestCase implements Watcher {
                     CreateMode.PERSISTENT);
         }
         assertTrue("size of the acl map ", (1 == zks.dataTree.longKeyMap.size()));
-        for (int j =100; j < 200; j++) {
+        for (int j = 100; j < 200; j++) {
             path = "/" + j;
             ACL acl = new ACL();
             acl.setPerms(0);
             Id id = new Id();
-            id.setId(j + "");
-            id.setScheme("host");
+            id.setId("1.1.1."+j);
+            id.setScheme("ip");
             acl.setId(id);
             ArrayList<ACL> list = new ArrayList<ACL>();
             list.add(acl);
@@ -119,8 +119,8 @@ public class ACLTest extends TestCase implements Watcher {
             ACL acl = new ACL();
             acl.setPerms(0);
             Id id = new Id();
-            id.setId(j + "");
-            id.setScheme("host");
+            id.setId("1.1.1."+j);
+            id.setScheme("ip");
             acl.setId(id);
             ArrayList<ACL> list = new ArrayList<ACL>();
             list.add(acl);