sonarlint changes
This commit is contained in:
parent
39d938c4e1
commit
bf6a68e864
@ -46,7 +46,8 @@ import org.xbill.DNS.utils.base64;
|
||||
*/
|
||||
public class BINDKeyUtils {
|
||||
|
||||
private BINDKeyUtils() { }
|
||||
private BINDKeyUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the BIND9 key file base name (i.e., without the ".key" or
|
||||
@ -60,18 +61,18 @@ public class BINDKeyUtils {
|
||||
/** Reads in the DNSKEYRecord from the public key file */
|
||||
private static DNSKEYRecord loadPublicKeyFile(File publicKeyFile)
|
||||
throws IOException {
|
||||
Master m = new Master(publicKeyFile.getAbsolutePath(), null, 600);
|
||||
try (Master m = new Master(publicKeyFile.getAbsolutePath(), null, 600)) {
|
||||
Record r;
|
||||
DNSKEYRecord result = null;
|
||||
|
||||
Record r;
|
||||
DNSKEYRecord result = null;
|
||||
|
||||
while ((r = m.nextRecord()) != null) {
|
||||
if (r.getType() == Type.DNSKEY) {
|
||||
result = (DNSKEYRecord) r;
|
||||
while ((r = m.nextRecord()) != null) {
|
||||
if (r.getType() == Type.DNSKEY) {
|
||||
result = (DNSKEYRecord) r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads in the private key verbatim from the private key file */
|
||||
@ -272,7 +273,7 @@ public class BINDKeyUtils {
|
||||
try {
|
||||
DnsKeyConverter conv = new DnsKeyConverter();
|
||||
return conv.parsePrivateKeyString(privateKeyString);
|
||||
} catch (IOException|NoSuchAlgorithmException e) {
|
||||
} catch (IOException | NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class TypeMap {
|
||||
private Set<Integer> typeSet;
|
||||
|
||||
public TypeMap() {
|
||||
this.typeSet = new HashSet<Integer>();
|
||||
this.typeSet = new HashSet<>();
|
||||
}
|
||||
|
||||
/** Add the given type to the typemap. */
|
||||
@ -78,20 +78,20 @@ public class TypeMap {
|
||||
TypeMap typemap = new TypeMap();
|
||||
|
||||
int page;
|
||||
int byte_length;
|
||||
int byteLength;
|
||||
|
||||
while (m < map.length) {
|
||||
page = map[m++];
|
||||
byte_length = map[m++];
|
||||
byteLength = map[m++];
|
||||
|
||||
for (int i = 0; i < byte_length; i++) {
|
||||
for (int i = 0; i < byteLength; i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
if ((map[m + i] & (1 << (7 - j))) != 0) {
|
||||
if (((map[m + i] & 0xFF) & (1 << (7 - j))) != 0) {
|
||||
typemap.set((page << 8) + (i * 8) + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
m += byte_length;
|
||||
m += byteLength;
|
||||
}
|
||||
|
||||
return typemap;
|
||||
@ -115,7 +115,7 @@ public class TypeMap {
|
||||
int[] types = getTypes();
|
||||
Arrays.sort(types);
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (i > 0)
|
||||
@ -129,16 +129,16 @@ public class TypeMap {
|
||||
protected static void mapToWire(DNSOutput out, int[] types, int base, int start, int end) {
|
||||
// calculate the length of this map by looking at the largest
|
||||
// typecode in this section.
|
||||
int max_type = types[end - 1] & 0xFF;
|
||||
int map_length = (max_type / 8) + 1;
|
||||
int maxType = types[end - 1] & 0xFF;
|
||||
int mapLength = (maxType / 8) + 1;
|
||||
|
||||
// write the map "header" -- the base and the length of the map.
|
||||
out.writeU8(base & 0xFF);
|
||||
out.writeU8(map_length & 0xFF);
|
||||
out.writeU8(mapLength & 0xFF);
|
||||
|
||||
// allocate a temporary scratch space for caculating the actual
|
||||
// bitmap.
|
||||
byte[] map = new byte[map_length];
|
||||
byte[] map = new byte[mapLength];
|
||||
|
||||
// for each type in our sub-array, set its corresponding bit in the map.
|
||||
for (int i = start; i < end; i++) {
|
||||
@ -179,7 +179,7 @@ public class TypeMap {
|
||||
}
|
||||
|
||||
public int[] getTypes() {
|
||||
Integer[] a = (Integer[]) typeSet.toArray(integerArray);
|
||||
Integer[] a = typeSet.toArray(integerArray);
|
||||
|
||||
int[] res = new int[a.length];
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
@ -189,8 +189,8 @@ public class TypeMap {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static int[] fromWireToTypes(byte[] wire_fmt) {
|
||||
return TypeMap.fromBytes(wire_fmt).getTypes();
|
||||
public static int[] fromWireToTypes(byte[] wireFmt) {
|
||||
return TypeMap.fromBytes(wireFmt).getTypes();
|
||||
}
|
||||
|
||||
public static byte[] fromTypesToWire(int[] types) {
|
||||
|
@ -39,6 +39,10 @@ import org.xbill.DNS.Type;
|
||||
*/
|
||||
|
||||
public class ZoneUtils {
|
||||
|
||||
private ZoneUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a zone file.
|
||||
*
|
||||
@ -53,19 +57,10 @@ public class ZoneUtils {
|
||||
* if something goes wrong reading the zone file.
|
||||
*/
|
||||
public static List<Record> readZoneFile(String zonefile, Name origin) throws IOException {
|
||||
ArrayList<Record> records = new ArrayList<Record>();
|
||||
Master m;
|
||||
try {
|
||||
if (zonefile.equals("-")) {
|
||||
m = new Master(System.in);
|
||||
} else {
|
||||
m = new Master(zonefile, origin);
|
||||
}
|
||||
|
||||
ArrayList<Record> records = new ArrayList<>();
|
||||
try (Master m = zonefile.equals("-") ? new Master(System.in) : new Master(zonefile, origin)) {
|
||||
Record r = null;
|
||||
|
||||
while ((r = m.nextRecord()) != null) {
|
||||
|
||||
records.add(r);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@ -120,7 +115,7 @@ public class ZoneUtils {
|
||||
}
|
||||
|
||||
public static List<Record> findRRs(List<Record> records, Name name, int type) {
|
||||
List<Record> res = new ArrayList<Record>();
|
||||
List<Record> res = new ArrayList<>();
|
||||
for (Record r : records) {
|
||||
if (r.getName().equals(name) && r.getType() == type) {
|
||||
res.add(r);
|
||||
|
Loading…
Reference in New Issue
Block a user