Skip to content

Commit 00d1e2e

Browse files
committed
Merge branch 'fb-DSS-2643-compile-pkcs11cryptotoken-against-cesecore' into 'main'
DSS-2643: Compile PKCS11CryptoToken against CESeCore instead of KFC for now. See merge request signserver/signserver!237
2 parents b431e91 + c704a50 commit 00d1e2e

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

signserver/modules/SignServer-Server/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
<groupId>log4j</groupId>
2424
<artifactId>log4j</artifactId>
2525
</exclusion>
26+
<!-- DSS-2643: Workaround for PKCS11CryptoToken available in x509-common-util conflicing with the one from cesecore-common -->
27+
<exclusion>
28+
<groupId>org.ejbca.cesecore</groupId>
29+
<artifactId>x509-common-util</artifactId>
30+
</exclusion>
2631
</exclusions>
2732
</dependency>
2833
<dependency>

signserver/modules/SignServer-Server/src/main/java/org/signserver/server/cryptotokens/PKCS11CryptoToken.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
import org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil;
5151
import org.bouncycastle.operator.OperatorCreationException;
5252
import org.cesecore.certificates.util.AlgorithmTools;
53-
import com.keyfactor.util.keys.token.CryptoTokenAuthenticationFailedException;
54-
import com.keyfactor.util.keys.token.pkcs11.Pkcs11SlotLabelType;
55-
import com.keyfactor.util.keys.token.pkcs11.NoSuchSlotException;
53+
import org.cesecore.keys.token.CryptoTokenAuthenticationFailedException;
54+
import org.cesecore.keys.token.p11.Pkcs11SlotLabelType;
55+
import org.cesecore.keys.token.p11.exception.NoSuchSlotException;
5656
import org.cesecore.util.query.QueryCriteria;
5757
import org.signserver.common.CryptoTokenAuthenticationFailureException;
5858
import org.signserver.common.CryptoTokenInitializationFailureException;
@@ -291,7 +291,7 @@ public void init(int workerId, Properties props, org.signserver.server.IServices
291291
// don't initialize keystore delegator when not auto-activated
292292
}
293293

294-
} catch (com.keyfactor.util.keys.token.CryptoTokenOfflineException | NumberFormatException ex) {
294+
} catch (org.cesecore.keys.token.CryptoTokenOfflineException | NumberFormatException ex) {
295295
LOG.error("Init failed", ex);
296296
throw new CryptoTokenInitializationFailureException(ex.getMessage());
297297
} catch (NoSuchSlotException ex) {
@@ -326,7 +326,7 @@ public int getCryptoTokenStatus(IServices services) {
326326
}
327327
}
328328
}
329-
} catch (com.keyfactor.util.keys.token.CryptoTokenOfflineException | NoSuchAlgorithmException | NoSuchProviderException | InvalidKeyException | SignatureException | ProviderException | OperatorCreationException | IOException ex) {
329+
} catch (org.cesecore.keys.token.CryptoTokenOfflineException | NoSuchAlgorithmException | NoSuchProviderException | InvalidKeyException | SignatureException | ProviderException | OperatorCreationException | IOException ex) {
330330
LOG.error("Error testing activation", ex);
331331
}
332332
}
@@ -339,7 +339,7 @@ public void activate(String authenticationcode, IServices services) throws Crypt
339339
try {
340340
delegate.activate(authenticationcode.toCharArray());
341341
keystoreDelegator = new JavaKeyStoreDelegator(delegate.getActivatedKeyStore());
342-
} catch (com.keyfactor.util.keys.token.CryptoTokenOfflineException ex) {
342+
} catch (org.cesecore.keys.token.CryptoTokenOfflineException ex) {
343343
LOG.error("Activate failed", ex);
344344
throw new CryptoTokenOfflineException(ex);
345345
} catch (CryptoTokenAuthenticationFailedException ex) {
@@ -368,7 +368,7 @@ public boolean deactivate(IServices services) throws CryptoTokenOfflineException
368368
private PrivateKey getPrivateKey(String alias) throws CryptoTokenOfflineException {
369369
try {
370370
return delegate.getPrivateKey(alias);
371-
} catch (com.keyfactor.util.keys.token.CryptoTokenOfflineException ex) {
371+
} catch (org.cesecore.keys.token.CryptoTokenOfflineException ex) {
372372
throw new CryptoTokenOfflineException(ex);
373373
}
374374
}
@@ -402,7 +402,7 @@ public ICertReqData genCertificateRequest(ISignerCertReqInfo info,
402402
}
403403
try {
404404
return CryptoTokenHelper.genCertificateRequest(info, delegate.getPrivateKey(alias), getProvider(ICryptoTokenV4.PROVIDERUSAGE_SIGN), delegate.getPublicKey(alias), explicitEccParameters);
405-
} catch (com.keyfactor.util.keys.token.CryptoTokenOfflineException e) {
405+
} catch (org.cesecore.keys.token.CryptoTokenOfflineException e) {
406406
LOG.error("Certificate request error: " + e.getMessage(), e);
407407
throw new CryptoTokenOfflineException(e);
408408
} catch (IllegalArgumentException ex) {
@@ -482,7 +482,7 @@ private void generateKeyPair(String keyAlgorithm, String keySpec, String alias,
482482
final KeyStore ks = delegate.getActivatedKeyStore();
483483
CryptoTokenHelper.regenerateCertIfWanted(alias, authCode, params, keystoreDelegator, ks.getProvider().getName());
484484
}
485-
} catch (InvalidAlgorithmParameterException | com.keyfactor.util.keys.token.CryptoTokenOfflineException | CertificateException | IOException | KeyStoreException | NoSuchAlgorithmException | UnrecoverableKeyException | OperatorCreationException ex) {
485+
} catch (InvalidAlgorithmParameterException | org.cesecore.keys.token.CryptoTokenOfflineException | CertificateException | IOException | KeyStoreException | NoSuchAlgorithmException | UnrecoverableKeyException | OperatorCreationException ex) {
486486
LOG.error(ex, ex);
487487
throw new CryptoTokenOfflineException(ex);
488488
}
@@ -533,7 +533,7 @@ private void generateSecretKey(String keyAlgorithm, String keySpec, String alias
533533
}
534534
try {
535535
delegate.generateKey(keyAlgorithm, Integer.valueOf(keySpec), alias);
536-
} catch (IllegalArgumentException | NoSuchAlgorithmException | NoSuchProviderException | KeyStoreException | com.keyfactor.util.keys.token.CryptoTokenOfflineException ex) {
536+
} catch (IllegalArgumentException | NoSuchAlgorithmException | NoSuchProviderException | KeyStoreException | org.cesecore.keys.token.CryptoTokenOfflineException ex) {
537537
LOG.error(ex, ex);
538538
throw new CryptoTokenOfflineException(ex);
539539
}
@@ -639,7 +639,7 @@ public KeyStorePKCS11CryptoToken() throws InstantiationException {
639639
public KeyStore getActivatedKeyStore() throws CryptoTokenOfflineException {
640640
try {
641641
return getKeyStore().getKeyStore(); // TODO: Consider if we should instead use the CachingKeystoreWrapper
642-
} catch (com.keyfactor.util.keys.token.CryptoTokenOfflineException ex) {
642+
} catch (org.cesecore.keys.token.CryptoTokenOfflineException ex) {
643643
throw new CryptoTokenOfflineException(ex);
644644
}
645645
}

0 commit comments

Comments
 (0)