This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String signXmlContent(String inputFile, String keyStoreFilePath, | |
String keyStorePassword, String keyStoreAlias) throws Exception { | |
KeyStore keyStore = KeyStore.getInstance("PKCS12"); | |
keyStore.load(new FileInputStream(keyStoreFilePath), keyStorePassword.toCharArray()); | |
DocumentBuilderFactory buildFactory = DocumentBuilderFactory.newInstance(); | |
buildFactory.setNamespaceAware(true); | |
Document document = buildFactory.newDocumentBuilder().parse(inputFile); | |
XMLSignatureFactory xmLSignatureFactory = XMLSignatureFactory.getInstance("DOM", | |
(Provider) Class.forName("org.jcp.xml.dsig.internal.dom.XMLDSigRI").newInstance()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String sha256(File input) throws IOException { | |
Digest sha256 = new Digest(); | |
sha256.update(Files.readAllBytes(input.toPath())); | |
StringBuilder buff = new StringBuilder(); | |
for (byte b : sha256.digest()) { | |
buff.append(String.format("%02x", b & 0xFF)); | |
} |
OlderNewer