Skip to content

Commit f36a6e7

Browse files
committed
Replace functions that will not be available in JDK11
1 parent 44e452e commit f36a6e7

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/main/java/com/faforever/api/deployment/GitHubController.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.faforever.api.config.FafApiProperties;
44
import lombok.SneakyThrows;
55
import lombok.extern.slf4j.Slf4j;
6+
import org.apache.commons.codec.DecoderException;
7+
import org.apache.commons.codec.binary.Hex;
68
import org.kohsuke.github.GHEventPayload;
79
import org.kohsuke.github.GHEventPayload.Deployment;
810
import org.kohsuke.github.GHEventPayload.Push;
@@ -16,7 +18,7 @@
1618
import org.springframework.web.bind.annotation.RestController;
1719

1820
import javax.crypto.spec.SecretKeySpec;
19-
import javax.xml.bind.DatatypeConverter;
21+
import java.io.IOException;
2022
import java.io.StringReader;
2123
import java.nio.charset.StandardCharsets;
2224

@@ -55,18 +57,16 @@ public void onPush(@RequestBody String body,
5557
}
5658
}
5759

58-
@SneakyThrows
59-
private <T extends GHEventPayload> T parseEvent(@RequestBody String body, Class<T> type) {
60+
private <T extends GHEventPayload> T parseEvent(@RequestBody String body, Class<T> type) throws IOException {
6061
return gitHub.parseEventPayload(new StringReader(body), type);
6162
}
6263

63-
@SneakyThrows
64-
private void verifyRequest(String payload, String signature) {
64+
private void verifyRequest(String payload, String signature) throws DecoderException {
6565
String secret = apiProperties.getGitHub().getWebhookSecret();
6666
MacSigner macSigner = new MacSigner(HMAC_SHA1, new SecretKeySpec(secret.getBytes(StandardCharsets.US_ASCII), HMAC_SHA1));
6767

6868
byte[] content = payload.getBytes(StandardCharsets.US_ASCII);
6969
// Signature starts with "sha1="
70-
macSigner.verify(content, DatatypeConverter.parseHexBinary(signature.substring(5)));
70+
macSigner.verify(content, Hex.decodeHex(signature.substring(5)));
7171
}
7272
}

0 commit comments

Comments
 (0)