Skip to content

Instantly share code, notes, and snippets.

@moomdate
Created September 11, 2024 07:51
Show Gist options
  • Save moomdate/e50cf2bd374b5f3077545abab87525cc to your computer and use it in GitHub Desktop.
Save moomdate/e50cf2bd374b5f3077545abab87525cc to your computer and use it in GitHub Desktop.
@SneakyThrows
public XadesSigner createXadesSigner(X509Certificate x509Certificate) {
final String PROVIDER_NAME = "LunaProvider";
KeyStoreKeyingDataProvider.SigningCertSelector signingCertSelector = availableCertificates -> x509Certificate;
KeyStoreKeyingDataProvider.KeyStorePasswordProvider password = () -> tokenProperties.getPwd().toCharArray();
KeyingDataProvider kp = new PKCS11KeyStoreKeyingDataProvider(tokenProperties.driverUse, PROVIDER_NAME, Integer.parseInt(tokenProperties.getSlot()), signingCertSelector, password, null, false);
XadesSigningProfile p = new XadesBesSigningProfile(kp).withAlgorithmsProviderEx(new XMLProcess.MyAlgorithmsProviderEx());
return p.newSigner();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment