Using the SignerServices Object

The following sample code shows how to create a signature using the SignerServices object:
gateway92
The following sample code shows how to create a signature using the
SignerServices
object:
public CustomAssertionStatus checkRequest(final CustomPolicyContext customPolicyContext) { String keyId = ...; String hashAlgorithm = ...; InputStream dataToSign = ...; ServiceFinder serviceFinder = (ServiceFinder) customPolicyContext.getContext().get("serviceFinder"); SignerServices signerServices= serviceFinder.lookupService(SignerServices.class); Signer signer = signerServices.createSigner(keyId); try { byte[] signature = signer.createSignature(hashAlgorithm, dataToSign); } catch (NoSuchAlgorithmException e) { // process error. } catch (InvalidKeyException e) { // process error. } catch (SignatureException e) { // process error. } catch (IOException e) { // process error. } }