CONNECTSignatureProcessor extends SignatureProcessor { void inlineSignatureAttachments(SoapMessage soapMsg, Element signatureElem) throws WSSecurityException { Collection<Attachment> attachments = soapMsg.getAttachments(); try { inlineDigestValueIncludes(signatureElem, attachments); inlineSignatureValueIncludes(signatureElem, attachments); } catch (IOException ioe) { throw new WSSecurityException(ErrorCode.FAILURE, ioe, "Failed to inline attachments to signature."); } }  @Override List<WSSecurityEngineResult> handleToken(Element signatureElem, RequestData data, WSDocInfo wsDocInfo);  }
@Test public void inlineIncludesWithPrefixRefId() throws ParserConfigurationException, WSSecurityException { SoapMessage msg = mock(SoapMessage.class); Collection<Attachment> attachmentList = new ArrayList<>(); attachmentList.add(createMockAttachment(DIG_REF_ID, DIG_BINARY_DATA)); attachmentList.add(createMockAttachment(SIG_REF_ID, SIG_BINARY_DATA)); when(msg.getAttachments()).thenReturn(attachmentList); Element signatureElem = createSignatureElementWithIncludes("cid:" + DIG_REF_ID, "cid:" + SIG_REF_ID); CONNECTSignatureProcessor processor = new CONNECTSignatureProcessor(); processor.inlineSignatureAttachments(msg, signatureElem); assertDigitalValueIsInline(signatureElem, DIG_BASE64_DATA); assertSignatureValueIsInline(signatureElem, SIG_BASE64_DATA); }
@Test public void noIncludes() throws ParserConfigurationException, WSSecurityException { SoapMessage msg = mock(SoapMessage.class); Element signatureElem = createSignatureElement(DIG_BASE64_DATA, SIG_BASE64_DATA); CONNECTSignatureProcessor processor = new CONNECTSignatureProcessor(); processor.inlineSignatureAttachments(msg, signatureElem); assertDigitalValueIsInline(signatureElem, DIG_BASE64_DATA); assertSignatureValueIsInline(signatureElem, SIG_BASE64_DATA); }