다음 코드는 document.xml에 content.xml을 가져오고 document.xml 루트 요소에 서명하는 코드입니다. 같은 서명 생성Xades4J 서명의 서명 요소에서 namespace를 제거하는 방법은 무엇입니까?
try {
KeyingDataProvider kp = new FileSystemKeyStoreKeyingDataProvider(
"pkcs12",
"C:\\workspace\\tests\\my\\LG.pfx",
new FirstCertificateSelector(),
new DirectPasswordProvider("mykeypass"),
new DirectPasswordProvider("mykeypass"),
true);
XadesSigningProfile p = new XadesBesSigningProfile(kp);
XadesSigner signer = p.newSigner();
javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
javax.xml.parsers.DocumentBuilder builder = null;
builder = factory.newDocumentBuilder();
Document doc1 = builder.parse(new File("C:\\workspace\\tests\\document.xml"));
Document doc2 = builder.parse(new File("C:\\workspace\\tests\\content.xml"));
Node contentElement = doc2.getDocumentElement();
Node parentElement = doc1.getDocumentElement();
Node adoptedContentElement = doc1.adoptNode(contentElement);
parentElement.appendChild(adoptedContentElement);
Node nodeToSign = doc1.getDocumentElement().getFirstChild();
Node nodeToAttachSignature = doc1.getDocumentElement();
IndividualDataObjsTimeStampProperty dataObjsTimeStamp = new IndividualDataObjsTimeStampProperty();
AllDataObjsCommitmentTypeProperty globalCommitment = AllDataObjsCommitmentTypeProperty.proofOfApproval();
CommitmentTypeProperty commitment = CommitmentTypeProperty.proofOfCreation();
DataObjectDesc obj = new EnvelopedXmlObject(nodeToSign, "text/xml", null);
SignedDataObjects dataObjs = new SignedDataObjects(obj).withCommitmentType(globalCommitment);
signer.sign(dataObjs, nodeToAttachSignature);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Result output = new StreamResult(new File("C:\\workspace\\tests\\signedDocument.xml"));
Source input = new DOMSource(doc1);
transformer.transform(input, output);
} catch (KeyStoreException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (XadesProfileResolutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerFactoryConfigurationError e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XAdES4jException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
:
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="xmldsig-26102a68-cfea-43fd-a40e-9682ae7da4a1">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
질문은을 - 어떻게 서명 요소에서 네임 스페이스 ds:
를 제거하려면?