gpt4 book ai didi

java - 无法解析 org.apache.poi.poifs.crypt.dsig.SignatureInfo 类?

转载 作者:行者123 更新时间:2023-12-01 12:16:34 25 4
gpt4 key购买 nike

我正在尝试在 Maven 项目中使用 POI OOXML 签署文档,如此处所述 https://poi.apache.org/apidocs/org/apache/poi/poifs/crypt/dsig/SignatureInfo.html

public boolean verify(InputStream inputStream) {

OPCPackage pkg = OPCPackage.open(inputStream);
SignatureConfig sic = new SignatureConfig();
sic.setOpcPackage(pkg);
SignatureInfo si = new SignatureInfo();
si.setSignatureConfig(sic);
boolean isValid = si.validate();
return isValid;
}

我的 POM 文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.me</groupId>
<artifactId>docx-signer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>docx-signer</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.10.1</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.51</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.51</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>org.apache.santuario</groupId>
<artifactId>xmlsec</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>

我无法解析此类org.apache.poi.poifs.crypt.dsig.SignatureInfo虽然它在文档中!!

有什么建议吗?

提前致谢。

最佳答案

问题就在这里:

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.10.1</version>
</dependency>

仅在 Apache POI 3.11 beta 3 中添加了对 OOXML 签名的支持。3.10.1 太旧了,不包含该支持

因此,您的 pom 依赖项需要是:

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11-beta3</version>
</dependency>

(或在新版本发布时更新)

关于java - 无法解析 org.apache.poi.poifs.crypt.dsig.SignatureInfo 类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26960729/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com