Checkstyle fixes

pull/91/head
Richard Körber 2020-08-02 17:06:08 +02:00
parent 85cc6261b6
commit 8c17ae730c
No known key found for this signature in database
GPG Key ID: AAB9FD19C78AA3E0
6 changed files with 13 additions and 16 deletions

View File

@ -167,9 +167,6 @@ public class Certificate extends AcmeResource {
Session session = login.getSession();
URL resUrl = session.resourceUrl(Resource.REVOKE_CERT);
if (resUrl == null) {
throw new AcmeException("Server does not allow certificate revocation");
}
try (Connection conn = session.connect()) {
JSONBuilder claims = new JSONBuilder();
@ -204,9 +201,6 @@ public class Certificate extends AcmeResource {
LOG.debug("revoke using the domain key pair");
URL resUrl = session.resourceUrl(Resource.REVOKE_CERT);
if (resUrl == null) {
throw new AcmeException("Server does not allow certificate revocation");
}
try (Connection conn = session.connect()) {
JSONBuilder claims = new JSONBuilder();

View File

@ -128,7 +128,7 @@ public class Challenge extends AcmeJsonResource {
}
String loc = json.get(KEY_URL).asString();
if (loc != null && !loc.equals(getLocation().toString())) {
if (!loc.equals(getLocation().toString())) {
throw new AcmeProtocolException("challenge has changed its location");
}

View File

@ -13,8 +13,9 @@
*/
package org.shredzone.acme4j.toolbox;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.net.IDN;
import java.net.URI;
@ -99,9 +100,9 @@ public final class AcmeUtils {
public static byte[] sha256hash(String z) {
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(z.getBytes("UTF-8"));
md.update(z.getBytes(UTF_8));
return md.digest();
} catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
} catch (NoSuchAlgorithmException ex) {
throw new AcmeProtocolException("Could not compute hash", ex);
}
}

View File

@ -13,6 +13,7 @@
*/
package org.shredzone.acme4j.toolbox;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.stream.Collectors.joining;
import static org.shredzone.acme4j.toolbox.AcmeUtils.parseTimestamp;
@ -27,7 +28,6 @@ import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.Instant;
import java.util.Collections;
@ -96,7 +96,7 @@ public final class JSON implements Serializable {
* @return {@link JSON} of the read content.
*/
public static JSON parse(InputStream in) throws IOException {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, "utf-8"))) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, UTF_8))) {
String json = reader.lines().map(String::trim).collect(joining());
return parse(json);
}
@ -347,7 +347,7 @@ public final class JSON implements Serializable {
required();
try {
byte[] raw = AcmeUtils.base64UrlDecode(val.toString());
return new JSON(path, JsonUtil.parseJson(new String(raw, StandardCharsets.UTF_8)));
return new JSON(path, JsonUtil.parseJson(new String(raw, UTF_8)));
} catch (IllegalArgumentException | JoseException ex) {
throw new AcmeProtocolException(path + ": expected an encoded object", ex);
}
@ -494,7 +494,7 @@ public final class JSON implements Serializable {
@Override
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof Value)) {
if (!(obj instanceof Value)) {
return false;
}
return Objects.equals(val, ((Value) obj).val);

View File

@ -13,6 +13,7 @@
*/
package org.shredzone.acme4j.toolbox;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Collections.unmodifiableList;
import static java.util.stream.Collectors.toList;
@ -319,7 +320,7 @@ public final class TestUtils {
final JsonWebKey jwk = JsonWebKey.Factory.newJwk(keyPair.getPublic());
Map<String, Object> params = new TreeMap<>(jwk.toParams(OutputControlLevel.PUBLIC_ONLY));
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(JsonUtil.toJson(params).getBytes("UTF-8"));
md.update(JsonUtil.toJson(params).getBytes(UTF_8));
byte[] thumbprint = md.digest();
System.out.println("N = " + params.get("n"));

View File

@ -13,6 +13,7 @@
*/
package org.shredzone.acme4j.util;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.joining;
import static org.shredzone.acme4j.toolbox.AcmeUtils.toAce;
@ -311,7 +312,7 @@ public class CSRBuilder {
* is closed after use.
*/
public void write(OutputStream out) throws IOException {
write(new OutputStreamWriter(out, "utf-8"));
write(new OutputStreamWriter(out, UTF_8));
}
@Override