Skip to content

Commit a76451c

Browse files
author
zhuxiangyi
committed
deal the checkstyle
1 parent 467c68d commit a76451c

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/authorize/ServiceAuthorizationManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ public void authorize(UserGroupInformation user,
126126
}
127127
if (addr != null) {
128128
String hostAddress = addr.getHostAddress();
129-
if (hosts.length != 2 || !hosts[0].includes(hostAddress, user.getUserName()) ||
129+
if (hosts.length != 2 ||
130+
!hosts[0].includes(hostAddress, user.getUserName()) ||
130131
hosts[1].includes(hostAddress, user.getUserName())) {
131132
AUDITLOG.warn(AUTHZ_FAILED_FOR + " for protocol=" + protocol
132133
+ " from host = " + hostAddress);

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/MachineList.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,6 @@ public boolean includes(String ipAddress, String user) {
178178
if (ipAddress == null) {
179179
throw new IllegalArgumentException("ipAddress is null.");
180180
}
181-
if (all) {
182-
return true;
183-
}
184181
// iterate through the ip ranges for inclusion
185182
if (node != null) {
186183
String binaryIp = ipToBinaryNumber(ipAddress);
@@ -250,10 +247,10 @@ public Collection<String> getCollection() {
250247
return entries;
251248
}
252249

253-
private class TrieTree {
250+
final private static class TrieTree {
254251
private Node root;
255252

256-
final private class Node {
253+
final private static class Node {
257254
private boolean netRange;
258255
private HashSet<String> userSet;
259256
private Node[] children;
@@ -317,7 +314,7 @@ private boolean search(String binaryIP, String user) {
317314
* @param ipAddress A ip.
318315
* @return A binary mask.
319316
*/
320-
public static String ipToBinaryNumber(String ipAddress) {
317+
private static String ipToBinaryNumber(String ipAddress) {
321318
String[] octetArray = ipAddress.split("\\.");
322319
StringBuilder binaryNumber = new StringBuilder();
323320
for (String str : octetArray) {
@@ -335,7 +332,7 @@ public static String ipToBinaryNumber(String ipAddress) {
335332
return binaryNumber.toString();
336333
}
337334

338-
public String subtractBinaryNumber(String s, int size) {
335+
private String subtractBinaryNumber(String s, int size) {
339336
return s.substring(0, size);
340337
}
341338

@@ -345,7 +342,7 @@ public String subtractBinaryNumber(String s, int size) {
345342
* @param ip A ip
346343
* @return if the given string is a Ipv4 false otherwise.
347344
*/
348-
public static boolean isValidIPv4(String ip) {
345+
private static boolean isValidIPv4(String ip) {
349346
if (ip.length() < 7) {
350347
return false;
351348
}
@@ -367,7 +364,7 @@ public static boolean isValidIPv4(String ip) {
367364
return true;
368365
}
369366

370-
public static boolean isValidIPv4Segment(String token) {
367+
private static boolean isValidIPv4Segment(String token) {
371368
if (token.startsWith("0") && token.length() > 1) {
372369
return false;
373370
}

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/authorize/TestServiceAuthorization.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public void testDefaultBlockedMachineList() throws UnknownHostException {
381381
// TestProtocol1 can be accessed from "1.2.3.4" because it uses default block list
382382
try {
383383
serviceAuthorizationManager.authorize(drwho,
384-
TestProtocol1.class, conf, InetAddress.getByName("192.168.1.1"));
384+
TestProtocol1.class, conf, InetAddress.getByName("192.168.1.1"));
385385
} catch (AuthorizationException e) {
386386
fail();
387387
}

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestMachineList.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ public class TestMachineList {
4343
"10.222.0.0/16,10.119.103.110,10.119.103.112,10.119.103.114,10.241.23.0/24";
4444
private static String HOST_LIST = "host1,host4";
4545
private static String HOSTNAME_IP_USER_CIDR_LIST =
46-
"host1:user1|user2,10.222.0.0/16:user1|user2,10.119.103.110:*,10.119.103.111";
46+
"host1:user1|user2,10.222.0.0/16:user1|" +
47+
"user2,10.119.103.110:*,10.119.103.111";
4748
private static String HOSTNAME_IP_CIDR_LIST =
48-
"host1,10.222.0.0/16,10.119.103.110,10.119.103.112,10.119.103.114,10.241.23.0/24,host4,";
49+
"host1,10.222.0.0/16,10.119.103.110," +
50+
"10.119.103.112,10.119.103.114,10.241.23.0/24,host4,";
4951

5052
class TestAddressFactory extends MachineList.InetAddressFactory {
5153
private Map<String, InetAddress> cache = new HashMap<>();
@@ -222,7 +224,8 @@ public void testIpWithUser() throws UnknownHostException {
222224
TestAddressFactory addressFactory = new TestAddressFactory();
223225
addressFactory.put("192.168.1.2", "host1");
224226
//create MachineList with a list of of ip ranges specified in CIDR format
225-
MachineList ml = new MachineList(HOSTNAME_IP_USER_CIDR_LIST, addressFactory);
227+
MachineList ml =
228+
new MachineList(HOSTNAME_IP_USER_CIDR_LIST, addressFactory);
226229
// test IPHost
227230
assertTrue(ml.includes("192.168.1.2", "user1"));
228231
assertFalse(ml.includes("192.168.1.2", "user3"));

0 commit comments

Comments
 (0)