-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PgpSignatureProcessorFactory class and Bc implementation
- Loading branch information
1 parent
787fda7
commit 77d1ef0
Showing
3 changed files
with
86 additions
and
4 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
rpm/src/main/java/org/eclipse/packager/rpm/signature/BcPgpSignatureProcessorFactory.java
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,46 @@ | ||
/* | ||
* Copyright (c) 2024 Paul Schaub | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
package org.eclipse.packager.rpm.signature; | ||
|
||
import org.bouncycastle.openpgp.PGPPrivateKey; | ||
|
||
/** | ||
* Implementation of the {@link PgpSignatureProcessorFactory} that uses Bouncy Castle directly for signing. | ||
*/ | ||
public class BcPgpSignatureProcessorFactory extends PgpSignatureProcessorFactory { | ||
|
||
private final PGPPrivateKey privateKey; | ||
private final int hashAlgorithm; | ||
|
||
/** | ||
* Create a new factory. | ||
* | ||
* @param privateKey private signing key | ||
* @param hashAlgorithm OpenPgp hash algorithm ID of the digest algorithm used for signing | ||
*/ | ||
public BcPgpSignatureProcessorFactory(PGPPrivateKey privateKey, int hashAlgorithm) { | ||
this.privateKey = privateKey; | ||
this.hashAlgorithm = hashAlgorithm; | ||
} | ||
|
||
@Override | ||
public SignatureProcessor createHeaderSignatureProcessor() { | ||
return new RsaHeaderSignatureProcessor(privateKey, hashAlgorithm); | ||
} | ||
|
||
@Override | ||
public SignatureProcessor createSignatureProcessor() { | ||
return new RsaSignatureProcessor(privateKey, hashAlgorithm); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
rpm/src/main/java/org/eclipse/packager/rpm/signature/PgpSignatureProcessorFactory.java
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,36 @@ | ||
/* | ||
* Copyright (c) 2024 Paul Schaub | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
package org.eclipse.packager.rpm.signature; | ||
|
||
/** | ||
* Factory for creating OpenPGP signing-related {@link SignatureProcessor} instances. | ||
* By default, packager will use {@link BcPgpSignatureProcessorFactory}. | ||
* TODO: Use Dependency Injection to allow for dynamic replacing of the factory instance. | ||
*/ | ||
public abstract class PgpSignatureProcessorFactory { | ||
|
||
/** | ||
* Create a {@link SignatureProcessor} for signing the header. | ||
* | ||
* @return header signature processor | ||
*/ | ||
public abstract SignatureProcessor createHeaderSignatureProcessor(); | ||
|
||
/** | ||
* Create a {@link SignatureProcessor} for signing both header and data. | ||
* | ||
* @return signature processor | ||
*/ | ||
public abstract SignatureProcessor createSignatureProcessor(); | ||
} |
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