• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wmixvideo / nfe / #9665

31 Aug 2026 12:30PM UTC coverage: 51.298% (+0.3%) from 51.007%
#9665

push

web-flow
Implementação migração do Axis2 para Httpclient5 - Todos modulos documentos fiscais (#1184)

* Javadoc Warnings invalid input: '<' e '&' literais

* Javadoc Warnings invalid input: '<' e '&' literais

* Refatoração de chaves para suportar CNPJ alfanumérico (NT 2026.004)

* Normaliza char para maiusculo na chave

O cálculo do DV usa valores[i - 1] - '0'. Se a chave vier com letras minúsculas (o que é aceito por alguns validadores de CNPJ na base), o DV calculado muda (ex.: 'a' - '0' != 'A' - '0'), gerando falsos negativos/positivos. Normalize o caractere para maiúsculo antes de converter para o valor numérico.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Remove unused Javadoc references from stub classes
[Javadoc Warnings Tag @see: reference not found

* Implementa DFHttpClient e DFSoapEnvelope para migração do Axis2 para
httpclient5

* Add extra hardening against XXE in DFSoapEnvelope

* Clarify timeout mapping in DFHttpClient to maintain compatibility with
Axis2

* Add unit tests for DFHttpClient to validate SOAP request handling

* Add author annotations

* Alinhar o mapeamento de timeout no DFHttpClient

* Implementação migração do Axis2 para Httpclient5 - Envio Lote

* Migrate web services from Axis2 to HttpClient5 to nfe

* Add exception handling for HTTP client initialization in
WSDistribuicaoNFe

* Refactor web service methods to include specific exception handling for
IOException and DFSoapFaultException

* Add specific exception handling for IOException and DFSoapFaultException
in web service methods

* Implement Closeable interface for web service classes and add close
method to manage HTTP client connections

* Add unit tests for WSFacade to verify construction and closure behavior
after migration to HttpClient5

* Add connection management settings to DFHttpClient to mitigate
keep-alive issues

* Handle null HttpEntity in DFHttpClient response processing to prevent
NullPointerException

* E... (continued)

184 of 265 new or added lines in 21 files covered. (69.43%)

9 existing lines in 8 files now uncovered.

15291 of 29808 relevant lines covered (51.3%)

0.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/fincatto/documentofiscal/utils/DFSocketFactory.java
1
package com.fincatto.documentofiscal.utils;
2

3
import com.fincatto.documentofiscal.DFConfig;
4

5
import javax.net.ssl.KeyManager;
6
import javax.net.ssl.SSLContext;
7
import javax.net.ssl.TrustManager;
8
import javax.net.ssl.TrustManagerFactory;
9
import java.security.KeyManagementException;
10
import java.security.KeyStoreException;
11
import java.security.NoSuchAlgorithmException;
12
import java.security.UnrecoverableKeyException;
13

14
/**
15
 * Monta o {@link SSLContext} usado no mTLS com a SEFAZ a partir do certificado A1 (via
16
 * {@link DFKeyManager}) e da cadeia de certificados configurada.
17
 */
18
public class DFSocketFactory {
19

20
    public static final int TIMEOUT_PADRAO_EM_MILLIS = 60_000;
21
    public static final int SO_TIMEOUT_PADRAO_EM_MILLIS = 30_000;
22

23
    private final SSLContext sslContext;
24

25
    public DFSocketFactory(final DFConfig config) throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
×
26
        this.sslContext = this.createSSLContext(config);
×
27
    }
×
28

29
    /**
30
     * Expoe o {@link SSLContext} ja montado a partir do certificado A1 (via {@link DFKeyManager})
31
     * e da cadeia de certificados da SEFAZ, para que outros clientes HTTP (ex.: {@link DFHttpClient})
32
     * possam reaproveita-lo sem duplicar a leitura do KeyStore/TrustStore.
33
     *
34
     * @return o SSLContext usado para o mTLS com a SEFAZ.
35
     */
36
    public SSLContext getSslContext() {
NEW
37
        return this.sslContext;
×
38
    }
39

40
    private SSLContext createSSLContext(final DFConfig config) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException, UnrecoverableKeyException {
NEW
41
        if (config.getSSLProtocolos() == null || config.getSSLProtocolos().length == 0) {
×
NEW
42
            throw new IllegalStateException("Nenhum protocolo TLS configurado em getSSLProtocolos()");
×
43
        }
44
        final KeyManager[] keyManagers = this.createKeyManagers(config);
×
45
        final TrustManager[] trustManagers = this.createTrustManagers(config);
×
46
        // "TLS" negocia a melhor versao disponivel; a restricao as versoes de getSSLProtocolos()
47
        // e aplicada por conexao no DefaultClientTlsStrategy montado em DFHttpClient
NEW
48
        final SSLContext sslContext = SSLContext.getInstance("TLS");
×
49
        sslContext.init(keyManagers, trustManagers, null);
×
50
        return sslContext;
×
51
    }
52

53
    private KeyManager[] createKeyManagers(final DFConfig config) throws UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException{
54
        return new KeyManager[]{new com.fincatto.documentofiscal.utils.DFKeyManager(config)};
×
55
    }
56

57
    private TrustManager[] createTrustManagers(final DFConfig config) throws KeyStoreException, NoSuchAlgorithmException {
58
        final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
×
59
        trustManagerFactory.init(config.getCadeiaCertificadosKeyStore());
×
60
        return trustManagerFactory.getTrustManagers();
×
61
    }
62

63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc