[bug-66475] SignatureConfig: remove ThreadLocals and deprecated code associated with them

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1907579 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2023-02-11 11:51:13 +00:00
parent dc91cdbaaa
commit 28a26d9cb2
2 changed files with 4 additions and 115 deletions

View File

@ -125,12 +125,6 @@ public class SignatureConfig {
Office2010SignatureFacet::new
);
private final ThreadLocal<OPCPackage> opcPackage = new ThreadLocal<>();
private final ThreadLocal<XMLSignatureFactory> signatureFactory = new ThreadLocal<>();
private final ThreadLocal<KeyInfoFactory> keyInfoFactory = new ThreadLocal<>();
private final ThreadLocal<Provider> provider = new ThreadLocal<>();
private List<SignatureFacet> signatureFacets = new ArrayList<>();
private HashAlgorithm digestAlgo = HashAlgorithm.sha256;
private Date executionTime = new Date();
@ -324,28 +318,6 @@ public class SignatureConfig {
this.digestAlgo = digestAlgo;
}
/**
* @return the opc package to be used by this thread, stored as thread-local
*
* @deprecated in POI 5.0.0 - use {@link SignatureInfo#setOpcPackage(OPCPackage)} instead
*/
@Deprecated
@Removal(version = "5.0.0")
public OPCPackage getOpcPackage() {
return opcPackage.get();
}
/**
* @param opcPackage the opc package to be handled by this thread, stored as thread-local
*
* @deprecated in POI 5.0.0 - use {@link SignatureInfo#setOpcPackage(OPCPackage)} instead
*/
@Deprecated
@Removal(version = "5.0.0")
public void setOpcPackage(OPCPackage opcPackage) {
this.opcPackage.set(opcPackage);
}
/**
* @return the private key
*/
@ -1011,74 +983,6 @@ public class SignatureConfig {
}
}
/**
* @param signatureFactory the xml signature factory, saved as thread-local
*
* @deprecated in POI 5.0.0 - use {@link SignatureInfo#setSignatureFactory(XMLSignatureFactory)}
*/
@Deprecated
@Removal(version = "5.0.0")
public void setSignatureFactory(XMLSignatureFactory signatureFactory) {
this.signatureFactory.set(signatureFactory);
}
/**
* @return the xml signature factory (thread-local)
*
* @deprecated in POI 5.0.0 - will be handled by SignatureInfo internally
*/
@Deprecated
@Removal(version = "5.0.0")
public XMLSignatureFactory getSignatureFactory() {
return signatureFactory.get();
}
/**
* @param keyInfoFactory the key factory, saved as thread-local
*
* @deprecated in POI 5.0.0 - use {@link SignatureInfo#setKeyInfoFactory(KeyInfoFactory)}
*/
@Deprecated
@Removal(version = "5.0.0")
public void setKeyInfoFactory(KeyInfoFactory keyInfoFactory) {
this.keyInfoFactory.set(keyInfoFactory);
}
/**
* @return the key factory (thread-local)
*
* @deprecated in POI 5.0.0 - will be handled by SignatureInfo internally
*/
@Deprecated
@Removal(version = "5.0.0")
public KeyInfoFactory getKeyInfoFactory() {
return keyInfoFactory.get();
}
/**
* Helper method to set provider
* @param provider the provider
* @deprecated in POI 5.0.0 - use {@link SignatureInfo#setProvider(Provider)}
*/
@Internal
@Deprecated
@Removal(version = "5.0.0")
public void setProvider(Provider provider) {
this.provider.set(provider);
}
/**
* @return the cached provider or null if not set before
*
* @deprecated in POI 5.0.0 - will be handled by SignatureInfo internally
*/
@Deprecated
@Removal(version = "5.0.0")
public Provider getProvider() {
return provider.get();
}
/**
* Determine the possible classes for XMLSEC.
* The order is

View File

@ -626,32 +626,17 @@ public class SignatureInfo {
*/
@SuppressWarnings("deprecation")
protected void initXmlProvider() {
if (opcPackage == null) {
opcPackage = signatureConfig.getOpcPackage();
}
if (provider == null) {
provider = signatureConfig.getProvider();
if (provider == null) {
provider = XmlProviderInitSingleton.getInstance().findProvider();
}
provider = XmlProviderInitSingleton.getInstance().findProvider();
}
if (signatureFactory == null) {
signatureFactory = signatureConfig.getSignatureFactory();
if (signatureFactory == null) {
signatureFactory = XMLSignatureFactory.getInstance("DOM", provider);
}
signatureFactory = XMLSignatureFactory.getInstance("DOM", provider);
}
if (keyInfoFactory == null) {
keyInfoFactory = signatureConfig.getKeyInfoFactory();
if (keyInfoFactory == null) {
keyInfoFactory = KeyInfoFactory.getInstance("DOM", provider);
}
keyInfoFactory = KeyInfoFactory.getInstance("DOM", provider);
}
if (uriDereferencer == null) {
uriDereferencer = signatureConfig.getUriDereferencer();
if (uriDereferencer == null) {
uriDereferencer = new OOXMLURIDereferencer();
}
uriDereferencer = new OOXMLURIDereferencer();
}
if (uriDereferencer instanceof OOXMLURIDereferencer) {
((OOXMLURIDereferencer)uriDereferencer).setSignatureInfo(this);