Skip to content

Commit

Permalink
Move away of deprecated bouncycastle API
Browse files Browse the repository at this point in the history
  • Loading branch information
akurtakov committed May 26, 2024
1 parent 54b04e0 commit 61408d3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2022 Eclipse contributors and others.
* Copyright (c) 2022, 2024 Eclipse contributors and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -267,16 +267,14 @@ private void init(String... userIDs) throws PGPException, IOException {
}

var publicKeyOut = new ByteArrayOutputStream();
try (var targetStream = new ArmoredOutputStream(publicKeyOut)) {
targetStream.setHeader("Version", null);
try (var targetStream = ArmoredOutputStream.builder().setVersion(null).build(publicKeyOut)) {
publicKeyRings.stream().map(it -> toHex(it.getPublicKey().getFingerprint()))
.forEach(it -> targetStream.addHeader("Key", it));
new PGPPublicKeyRingCollection(publicKeyRings).encode(targetStream);
}

var secretKeyOut = new ByteArrayOutputStream();
try (var targetStream = new ArmoredOutputStream(secretKeyOut)) {
targetStream.setHeader("Version", null);
try (var targetStream = ArmoredOutputStream.builder().setVersion(null).build(secretKeyOut)) {
new PGPSecretKeyRingCollection(secretKeyRings).encode(targetStream);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2022 Eclipse contributors and others.
* Copyright (c) 2022, 2024 Eclipse contributors and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -77,8 +77,7 @@ public Collection<PGPPublicKey> getKeys(long id) {

public String toArmoredString() throws IOException {
var out = new ByteArrayOutputStream();
try (var armoredOut = new ArmoredOutputStream(out)) {
armoredOut.setHeader("Version", null);
try (var armoredOut = ArmoredOutputStream.builder().setVersion(null).build(out)) {
for (var key : keys.values()) {
key.encode(armoredOut);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2022 Eclipse contributors and others.
* Copyright (c) 2022, 2024 Eclipse contributors and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -70,8 +70,7 @@ public void add(String... signatures) {

public String toArmoredString() throws IOException {
var out = new ByteArrayOutputStream();
try (var armoredOut = new ArmoredOutputStream(out)) {
armoredOut.setHeader("Version", null);
try (var armoredOut = ArmoredOutputStream.builder().setVersion(null).build(out)) {
for (var signatures : signatures.values()) {
signatures.encode(armoredOut);
}
Expand Down

0 comments on commit 61408d3

Please sign in to comment.