forked from mvnpm/mvnpm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now using org.pgpainless for signing
Signed-off-by: Phillip Kruger <phillip.kruger@gmail.com>
- Loading branch information
1 parent
184705e
commit 7b1db5b
Showing
8 changed files
with
164 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package io.mvnpm.file; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Optional; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.event.Observes; | ||
|
||
import org.bouncycastle.openpgp.PGPSecretKeyRing; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
import org.pgpainless.PGPainless; | ||
|
||
import io.quarkus.runtime.StartupEvent; | ||
|
||
/** | ||
* Holds the key for signing the files | ||
* | ||
* @author Phillip Kruger (phillip.kruger@gmail.com) | ||
*/ | ||
@ApplicationScoped | ||
public class KeyHolder { | ||
|
||
private PGPSecretKeyRing secretKeyRing = null; | ||
|
||
@ConfigProperty(name = "mvnpm.asckey.path") | ||
Optional<String> asckeyPath; | ||
|
||
void onStart(@Observes StartupEvent ev) { | ||
if (asckeyPath.isPresent()) { | ||
try { | ||
Path keyFilePath = Paths.get(asckeyPath.get()); | ||
byte[] keyBytes = Files.readAllBytes(keyFilePath); | ||
this.secretKeyRing = PGPainless.readKeyRing().secretKeyRing(keyBytes); | ||
} catch (IOException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
} | ||
} | ||
|
||
public PGPSecretKeyRing getSecretKeyRing() { | ||
return this.secretKeyRing; | ||
} | ||
|
||
public boolean hasSecretKeyRing() { | ||
return this.secretKeyRing != null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.