feat: implement in-memory log buffer, add ICP-Brasil seal assets, and improve SDK parameter handling
This commit is contained in:
+48
@@ -0,0 +1,48 @@
|
||||
package br.com.cybercore.signer.core.log;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Buffer circular thread-safe em memória para armazenar eventos reais de log da aplicação,
|
||||
* permitindo auditoria visual em tempo real pela interface gráfica desktop.
|
||||
*/
|
||||
public final class AppLogBuffer {
|
||||
|
||||
private static final int MAX_ENTRIES = 1000;
|
||||
private static final Deque<String> BUFFER = new ArrayDeque<>(MAX_ENTRIES);
|
||||
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
|
||||
static {
|
||||
appendSystemMessage("CyberCore Signer iniciado. Aguardando eventos criptográficos e conexões locais...");
|
||||
}
|
||||
|
||||
private AppLogBuffer() {
|
||||
}
|
||||
|
||||
public static synchronized void append(String logLine) {
|
||||
if (logLine == null || logLine.isBlank()) return;
|
||||
if (BUFFER.size() >= MAX_ENTRIES) {
|
||||
BUFFER.pollFirst();
|
||||
}
|
||||
BUFFER.addLast(logLine.trim());
|
||||
}
|
||||
|
||||
public static synchronized void appendSystemMessage(String msg) {
|
||||
String timestamp = LocalDateTime.now().format(FORMATTER);
|
||||
append("[" + timestamp + "] [INFO] " + msg);
|
||||
}
|
||||
|
||||
public static synchronized List<String> getLogs() {
|
||||
return new ArrayList<>(BUFFER);
|
||||
}
|
||||
|
||||
public static synchronized void clear() {
|
||||
BUFFER.clear();
|
||||
appendSystemMessage("Histórico de logs limpo pelo usuário.");
|
||||
}
|
||||
}
|
||||
+34
-26
@@ -112,8 +112,10 @@ public final class PdfSealRenderer {
|
||||
String headerText = resolveHeaderText(theme);
|
||||
String footerText = resolveFooterText(theme, null);
|
||||
|
||||
Color footerColor = new Color(100, 116, 139); // Cinza corporativo neutro e sóbrio (#64748b)
|
||||
|
||||
if (hasIdentity && hasDate) {
|
||||
// Layout com 5 linhas: Cabeçalho, Nome, Identificação (CPF/Matrícula), Data, Rodapé
|
||||
// Layout com 5 linhas: Cabeçalho, Nome, Identificação (CPF/CNPJ/Matrícula), Data, Rodapé
|
||||
g2d.setColor(primaryColor);
|
||||
g2d.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 9));
|
||||
g2d.drawString(headerText, textX, 16);
|
||||
@@ -127,9 +129,8 @@ public final class PdfSealRenderer {
|
||||
|
||||
g2d.drawString("Data: " + data.signingDate(), textX, 60);
|
||||
|
||||
g2d.setColor(secondaryColor);
|
||||
g2d.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 8));
|
||||
g2d.drawString(footerText, textX, 73);
|
||||
g2d.setColor(footerColor);
|
||||
drawFittedText(g2d, footerText, textX, 73, textWidthAvailable, 7.8f);
|
||||
|
||||
} else if (hasIdentity || hasDate) {
|
||||
// Layout com 4 linhas: Cabeçalho, Nome, (Identificação ou Data), Rodapé
|
||||
@@ -145,9 +146,8 @@ public final class PdfSealRenderer {
|
||||
String singleLineInfo = hasIdentity ? identityLine : ("Data: " + data.signingDate());
|
||||
drawFittedText(g2d, singleLineInfo, textX, 53, textWidthAvailable, 10.0f);
|
||||
|
||||
g2d.setColor(secondaryColor);
|
||||
g2d.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 8));
|
||||
g2d.drawString(footerText, textX, 71);
|
||||
g2d.setColor(footerColor);
|
||||
drawFittedText(g2d, footerText, textX, 71, textWidthAvailable, 7.8f);
|
||||
|
||||
} else {
|
||||
// Layout com 3 linhas: Cabeçalho, Nome em Destaque Máximo, Rodapé
|
||||
@@ -158,9 +158,8 @@ public final class PdfSealRenderer {
|
||||
g2d.setColor(textColor);
|
||||
drawFullSignerName(g2d, fullName, textX, 44, textWidthAvailable, 14.5f);
|
||||
|
||||
g2d.setColor(secondaryColor);
|
||||
g2d.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 9));
|
||||
g2d.drawString(footerText, textX, 68);
|
||||
g2d.setColor(footerColor);
|
||||
drawFittedText(g2d, footerText, textX, 68, textWidthAvailable, 8.0f);
|
||||
}
|
||||
|
||||
} finally {
|
||||
@@ -250,19 +249,28 @@ public final class PdfSealRenderer {
|
||||
* Formata os dados de documento (CPF/CNPJ) de acordo com o modo de exibição configurado.
|
||||
*/
|
||||
private static String formatSignerDoc(PdfSealData data) {
|
||||
CpfDisplayMode mode = data.cpfDisplayMode() != null ? data.cpfDisplayMode() : CpfDisplayMode.FULL;
|
||||
String rawDoc = data.identifier() != null ? data.identifier() : "";
|
||||
String rawDoc = data.identifier() != null ? data.identifier().trim() : "";
|
||||
if (rawDoc.isBlank()) return "";
|
||||
|
||||
if (mode == CpfDisplayMode.NONE) {
|
||||
// Se for CPF, oculta. Se for CNPJ, pode manter ou formatar.
|
||||
if (rawDoc.toUpperCase().contains("CPF")) {
|
||||
return "";
|
||||
String digits = rawDoc.replaceAll("\\D", "");
|
||||
|
||||
// Pessoa Jurídica (14 dígitos): Rótulo CNPJ, SEMPRE completo, sem mascaramento
|
||||
if (digits.length() == 14 || rawDoc.toUpperCase().contains("CNPJ")) {
|
||||
if (digits.length() == 14) {
|
||||
return "CNPJ: " + String.format("%s.%s.%s/%s-%s",
|
||||
digits.substring(0, 2), digits.substring(2, 5), digits.substring(5, 8),
|
||||
digits.substring(8, 12), digits.substring(12, 14));
|
||||
}
|
||||
return rawDoc;
|
||||
return rawDoc.toUpperCase().startsWith("CNPJ") ? rawDoc : "CNPJ: " + rawDoc;
|
||||
}
|
||||
|
||||
if (rawDoc.toUpperCase().contains("CPF")) {
|
||||
String digits = rawDoc.replaceAll("\\D", "");
|
||||
// Pessoa Física (11 dígitos): Rótulo CPF, respeitando CpfDisplayMode
|
||||
CpfDisplayMode mode = data.cpfDisplayMode() != null ? data.cpfDisplayMode() : CpfDisplayMode.FULL;
|
||||
if (mode == CpfDisplayMode.NONE) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (digits.length() == 11) {
|
||||
String formatted = mode.formatCpf(digits);
|
||||
return formatted.isBlank() ? "" : "CPF: " + formatted;
|
||||
}
|
||||
@@ -378,10 +386,10 @@ public final class PdfSealRenderer {
|
||||
return theme.customHeader().toUpperCase();
|
||||
}
|
||||
return switch (theme.id().toLowerCase()) {
|
||||
case "cybercore-modern" -> "CYBERCORE SIGNER • AUTENTICAÇÃO DIGITAL";
|
||||
case "cybercore-modern" -> "DOCUMENTO ASSINADO DIGITALMENTE";
|
||||
case "minimal-clean" -> "DOCUMENTO ASSINADO DIGITALMENTE";
|
||||
case "gov-br" -> "GOV.BR • CONFORMIDADE MP Nº 2.200-2/2001";
|
||||
default -> "ASSINADO DIGITALMENTE • ICP-BRASIL";
|
||||
case "gov-br" -> "DOCUMENTO ASSINADO DIGITALMENTE";
|
||||
default -> "DOCUMENTO ASSINADO DIGITALMENTE";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -393,10 +401,10 @@ public final class PdfSealRenderer {
|
||||
return "Hash Criptográfico: " + hash;
|
||||
}
|
||||
return switch (theme.id().toLowerCase()) {
|
||||
case "cybercore-modern" -> "Autenticidade assegurada por chave criptográfica local";
|
||||
case "minimal-clean" -> "Assinatura qualificada padrão ICP-Brasil";
|
||||
case "gov-br" -> "Validade jurídica plena conforme MP nº 2.200-2/2001";
|
||||
default -> "Conformidade ICP-Brasil e validade jurídica plena";
|
||||
case "cybercore-modern" -> "Verifique a autenticidade em https://validar.iti.gov.br";
|
||||
case "minimal-clean" -> "Verifique a autenticidade em https://validar.iti.gov.br";
|
||||
case "gov-br" -> "Verifique a autenticidade em https://validar.iti.gov.br";
|
||||
default -> "Verifique a autenticidade em https://validar.iti.gov.br";
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+13
-107
@@ -35,10 +35,10 @@ public final class PdfSealThemeRegistry {
|
||||
}
|
||||
|
||||
private static void registerBuiltInThemes() {
|
||||
// 1. Tema ICP-Brasil Institucional
|
||||
// Único Selo Padrão Embutido do Sistema: ICP-Brasil Institucional Oficial
|
||||
registerTheme(new PdfSealTheme(
|
||||
"icp-brasil",
|
||||
"ICP-Brasil Institucional",
|
||||
DEFAULT_THEME_ID,
|
||||
"ICP-Brasil Institucional (Padrão)",
|
||||
"Estilo oficial corporativo com escudo de segurança vetorial e dados completos do titular",
|
||||
320,
|
||||
82,
|
||||
@@ -51,7 +51,7 @@ public final class PdfSealThemeRegistry {
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 82" width="320" height="82">
|
||||
<rect x="1" y="1" width="318" height="80" rx="6" fill="${THEME_BG}" stroke="${THEME_BORDER}" stroke-width="1.5"/>
|
||||
<rect x="1" y="1" width="6" height="80" rx="3" fill="${THEME_PRIMARY}"/>
|
||||
<!-- Escudo Criptográfico Vetorial -->
|
||||
<!-- Escudo Criptográfico Vetorial ICP-Brasil -->
|
||||
<g transform="translate(14, 18)">
|
||||
<path d="M18 2 L32 7 V18 C32 28 25 36 18 39 C11 36 4 28 4 18 V7 Z" fill="${THEME_PRIMARY}" opacity="0.12"/>
|
||||
<path d="M18 2 L32 7 V18 C32 28 25 36 18 39 C11 36 4 28 4 18 V7 Z" fill="none" stroke="${THEME_PRIMARY}" stroke-width="2"/>
|
||||
@@ -65,104 +65,7 @@ public final class PdfSealThemeRegistry {
|
||||
<text x="56" y="32" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="12" font-weight="bold" fill="${THEME_TEXT}">${SIGNER_NAME}</text>
|
||||
<text x="56" y="46" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="8.5" fill="#475569">Doc: ${SIGNER_DOC} • AC: ${CERT_ISSUER}</text>
|
||||
<text x="56" y="59" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="8.5" fill="#475569">Data/Hora: ${SIGNING_DATE}</text>
|
||||
<text x="56" y="72" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="7.5" fill="${THEME_SECONDARY}">Verificação criptográfica válida e com fé pública</text>
|
||||
</svg>
|
||||
"""
|
||||
));
|
||||
|
||||
// 2. Tema CyberCore Moderno
|
||||
registerTheme(new PdfSealTheme(
|
||||
"cybercore-modern",
|
||||
"CyberCore Moderno",
|
||||
"Identidade tecnológica com cristal vetorial CyberCore e visual ciano/esmeralda",
|
||||
320,
|
||||
82,
|
||||
"#0284c7",
|
||||
"#10b981",
|
||||
"#ffffff",
|
||||
"#38bdf8",
|
||||
"#0f172a",
|
||||
"""
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 82" width="320" height="82">
|
||||
<rect x="1" y="1" width="318" height="80" rx="8" fill="${THEME_BG}" stroke="${THEME_BORDER}" stroke-width="1.5"/>
|
||||
<rect x="1" y="1" width="5" height="80" rx="2.5" fill="${THEME_SECONDARY}"/>
|
||||
<!-- Cristal CyberCore Vetorial -->
|
||||
<g transform="translate(14, 20)">
|
||||
<polygon points="18,2 32,10 32,28 18,36 4,28 4,10" fill="${THEME_PRIMARY}" opacity="0.15"/>
|
||||
<polygon points="18,2 32,10 32,28 18,36 4,28 4,10" fill="none" stroke="${THEME_PRIMARY}" stroke-width="1.8"/>
|
||||
<line x1="18" y1="2" x2="18" y2="36" stroke="${THEME_SECONDARY}" stroke-width="1.2"/>
|
||||
<line x1="4" y1="19" x2="32" y2="19" stroke="${THEME_PRIMARY}" stroke-width="1.2"/>
|
||||
</g>
|
||||
<!-- Dados da Assinatura -->
|
||||
<text x="56" y="17" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="8.5" font-weight="bold" fill="${THEME_PRIMARY}">CYBERCORE SIGNER • ASSINATURA ELETRÔNICA</text>
|
||||
<text x="56" y="32" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="12" font-weight="bold" fill="${THEME_TEXT}">${SIGNER_NAME}</text>
|
||||
<text x="56" y="46" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="8.5" fill="#475569">${SIGNER_DOC} • ${CERT_ISSUER}</text>
|
||||
<text x="56" y="59" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="8.5" fill="#475569">Autenticado em: ${SIGNING_DATE}</text>
|
||||
<text x="56" y="72" font-family="monospace" font-size="7.5" fill="${THEME_SECONDARY}">Hash: ${HASH_SUMMARY}</text>
|
||||
</svg>
|
||||
"""
|
||||
));
|
||||
|
||||
// 3. Tema Minimalista Clássico
|
||||
registerTheme(new PdfSealTheme(
|
||||
"minimal-clean",
|
||||
"Minimalista Clássico",
|
||||
"Design monocromático sóbrio em tons de grafite, ideal para contratos e certidões",
|
||||
300,
|
||||
76,
|
||||
"#334155",
|
||||
"#64748b",
|
||||
"#fafafa",
|
||||
"#cbd5e1",
|
||||
"#1e293b",
|
||||
"""
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 76" width="300" height="76">
|
||||
<rect x="1" y="1" width="298" height="74" rx="4" fill="${THEME_BG}" stroke="${THEME_BORDER}" stroke-width="1"/>
|
||||
<!-- Ícone de Carimbo Notarial -->
|
||||
<g transform="translate(12, 18)">
|
||||
<circle cx="18" cy="18" r="16" fill="none" stroke="${THEME_PRIMARY}" stroke-width="1.5"/>
|
||||
<circle cx="18" cy="18" r="13" fill="none" stroke="${THEME_PRIMARY}" stroke-width="0.8" stroke-dasharray="2,2"/>
|
||||
<path d="M12 18 L16 22 L24 14" fill="none" stroke="${THEME_PRIMARY}" stroke-width="2"/>
|
||||
</g>
|
||||
<!-- Dados da Assinatura -->
|
||||
<text x="52" y="17" font-family="Georgia, serif" font-size="9" font-weight="bold" fill="${THEME_PRIMARY}">Assinado Digitalmente</text>
|
||||
<text x="52" y="32" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" font-size="11.5" font-weight="bold" fill="${THEME_TEXT}">${SIGNER_NAME}</text>
|
||||
<text x="52" y="46" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" font-size="8" fill="#475569">${SIGNER_DOC} • ${CERT_ISSUER}</text>
|
||||
<text x="52" y="58" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" font-size="8" fill="#475569">${SIGNING_DATE}</text>
|
||||
<text x="52" y="69" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" font-size="7.5" fill="#64748b">Conforme MP 2.200-2/2001 e ICP-Brasil</text>
|
||||
</svg>
|
||||
"""
|
||||
));
|
||||
|
||||
// 4. Tema Governamental (Gov.br / ITI)
|
||||
registerTheme(new PdfSealTheme(
|
||||
"gov-br",
|
||||
"Governamental (Padrão Gov.br / ITI)",
|
||||
"Faixa verde e ouro com declaração expressa de validade pela MP nº 2.200-2/2001",
|
||||
320,
|
||||
82,
|
||||
"#047857",
|
||||
"#eab308",
|
||||
"#ffffff",
|
||||
"#a7f3d0",
|
||||
"#064e3b",
|
||||
"""
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 82" width="320" height="82">
|
||||
<rect x="1" y="1" width="318" height="80" rx="4" fill="${THEME_BG}" stroke="${THEME_BORDER}" stroke-width="1.5"/>
|
||||
<rect x="1" y="1" width="6" height="80" rx="2" fill="${THEME_PRIMARY}"/>
|
||||
<rect x="7" y="1" width="3" height="80" fill="${THEME_SECONDARY}"/>
|
||||
<!-- Brasão Estilizado -->
|
||||
<g transform="translate(16, 20)">
|
||||
<circle cx="17" cy="18" r="15" fill="${THEME_PRIMARY}" opacity="0.1"/>
|
||||
<circle cx="17" cy="18" r="15" fill="none" stroke="${THEME_PRIMARY}" stroke-width="1.5"/>
|
||||
<path d="M17 6 L20 14 L28 14 L22 19 L24 27 L17 22 L10 27 L12 19 L6 14 L14 14 Z" fill="${THEME_SECONDARY}"/>
|
||||
</g>
|
||||
<!-- Dados da Assinatura -->
|
||||
<text x="56" y="17" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="8.5" font-weight="bold" fill="${THEME_PRIMARY}">GOV.BR • DOCUMENTO ASSINADO DIGITALMENTE</text>
|
||||
<text x="56" y="32" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="12" font-weight="bold" fill="${THEME_TEXT}">${SIGNER_NAME}</text>
|
||||
<text x="56" y="46" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="8.5" fill="#065f46">Doc: ${SIGNER_DOC} • AC: ${CERT_ISSUER}</text>
|
||||
<text x="56" y="59" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="8.5" fill="#475569">Data/Hora: ${SIGNING_DATE}</text>
|
||||
<text x="56" y="72" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="7.5" fill="#047857">Verifique a autenticidade da assinatura eletrônica em https://validar.iti.gov.br</text>
|
||||
<text x="56" y="72" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" font-size="7.5" fill="#64748b">Verifique a autenticidade em https://validar.iti.gov.br</text>
|
||||
</svg>
|
||||
"""
|
||||
));
|
||||
@@ -205,10 +108,9 @@ public final class PdfSealThemeRegistry {
|
||||
if (themeId == null) return false;
|
||||
String idLower = themeId.toLowerCase();
|
||||
|
||||
// Protege temas padrão
|
||||
if (idLower.equals("icp-brasil") || idLower.equals("cybercore-modern") ||
|
||||
idLower.equals("minimal-clean") || idLower.equals("gov-br")) {
|
||||
throw new IllegalArgumentException("Não é permitido excluir os temas de selo pré-instalados do sistema.");
|
||||
// Protege o tema padrão
|
||||
if (idLower.equals(DEFAULT_THEME_ID)) {
|
||||
throw new IllegalArgumentException("Não é permitido excluir o selo padrão pré-instalado do sistema.");
|
||||
}
|
||||
|
||||
boolean deleted = STORAGE.deleteSeal(idLower);
|
||||
@@ -218,7 +120,11 @@ public final class PdfSealThemeRegistry {
|
||||
|
||||
public static Optional<PdfSealTheme> findById(String id) {
|
||||
if (id == null) return Optional.empty();
|
||||
return Optional.ofNullable(THEMES.get(id.toLowerCase()));
|
||||
PdfSealTheme theme = THEMES.get(id.toLowerCase());
|
||||
if (theme == null && ("cybercore-modern".equalsIgnoreCase(id) || "minimal-clean".equalsIgnoreCase(id) || "gov-br".equalsIgnoreCase(id))) {
|
||||
return Optional.of(getDefaultTheme());
|
||||
}
|
||||
return Optional.ofNullable(theme);
|
||||
}
|
||||
|
||||
public static Optional<PdfSealTheme> getTheme(String id) {
|
||||
|
||||
+58
-18
@@ -595,6 +595,9 @@ public class CcspServer {
|
||||
sealTheme = PdfSealThemeRegistry.getDefaultTheme();
|
||||
}
|
||||
|
||||
logger.info("[CCSP REQ] Selo visual configurado: '{}' (custom={}, hasLogo={}, header='{}')",
|
||||
sealTheme.name(), sealTheme.isCustom(), sealTheme.customLogoBase64() != null, sealTheme.customHeader());
|
||||
|
||||
PdfSealPosition position = PdfSealPosition.BOTTOM_RIGHT;
|
||||
if (request.x() != null && request.y() != null) {
|
||||
position = PdfSealPosition.CUSTOM;
|
||||
@@ -916,34 +919,71 @@ public class CcspServer {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getMapString(Map<String, Object> map, String defaultVal, String... keys) {
|
||||
if (map == null) return defaultVal;
|
||||
for (String k : keys) {
|
||||
Object v = map.get(k);
|
||||
if (v != null && !v.toString().isBlank()) {
|
||||
return v.toString().trim();
|
||||
}
|
||||
}
|
||||
return defaultVal;
|
||||
}
|
||||
|
||||
private static int getMapInt(Map<String, Object> map, int defaultVal, String... keys) {
|
||||
if (map == null) return defaultVal;
|
||||
for (String k : keys) {
|
||||
Object v = map.get(k);
|
||||
if (v instanceof Number n) {
|
||||
return n.intValue();
|
||||
} else if (v != null) {
|
||||
try {
|
||||
return Integer.parseInt(v.toString().trim());
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
return defaultVal;
|
||||
}
|
||||
|
||||
private PdfSealTheme parseCustomSealTheme(Map<String, Object> map) {
|
||||
if (map == null || map.isEmpty()) {
|
||||
return PdfSealThemeRegistry.getDefaultTheme();
|
||||
}
|
||||
String id = "custom-" + UUID.randomUUID().toString().substring(0, 8);
|
||||
String name = (String) map.getOrDefault("name", "Selo Personalizado");
|
||||
String description = (String) map.getOrDefault("description", "Selo customizado via aplicação web");
|
||||
int width = map.containsKey("width") ? ((Number) map.get("width")).intValue() : 320;
|
||||
int height = map.containsKey("height") ? ((Number) map.get("height")).intValue() : 82;
|
||||
String primaryColor = (String) map.getOrDefault("primaryColor", "#0d47a1");
|
||||
String secondaryColor = (String) map.getOrDefault("secondaryColor", "#0284c7");
|
||||
String backgroundColor = (String) map.getOrDefault("backgroundColor", "#ffffff");
|
||||
String borderColor = (String) map.getOrDefault("borderColor", "#cbd5e1");
|
||||
String textColor = (String) map.getOrDefault("textColor", "#0f172a");
|
||||
String customHeader = (String) map.get("customHeader");
|
||||
String customFooter = (String) map.get("customFooter");
|
||||
String iconStyle = (String) map.getOrDefault("iconStyle", "shield");
|
||||
String customLogoBase64 = (String) map.get("customLogoBase64");
|
||||
String customFieldLabel = (String) map.get("customFieldLabel");
|
||||
String customFieldValue = (String) map.get("customFieldValue");
|
||||
String name = getMapString(map, "Selo Personalizado", "name", "theme_name", "title");
|
||||
String description = getMapString(map, "Selo customizado via aplicação web", "description", "desc");
|
||||
int width = getMapInt(map, 320, "width", "w");
|
||||
int height = getMapInt(map, 82, "height", "h");
|
||||
String primaryColor = getMapString(map, "#0d47a1", "primaryColor", "primary_color");
|
||||
String secondaryColor = getMapString(map, "#0284c7", "secondaryColor", "secondary_color");
|
||||
String backgroundColor = getMapString(map, "#ffffff", "backgroundColor", "background_color");
|
||||
String borderColor = getMapString(map, "#cbd5e1", "borderColor", "border_color");
|
||||
String textColor = getMapString(map, "#0f172a", "textColor", "text_color");
|
||||
String customHeader = getMapString(map, null, "customHeader", "custom_header", "title");
|
||||
String customFooter = getMapString(map, null, "customFooter", "custom_footer");
|
||||
String iconStyle = getMapString(map, "shield", "iconStyle", "icon_style");
|
||||
String customLogoBase64 = getMapString(map, null, "customLogoBase64", "custom_logo_base64", "logo", "logoBase64");
|
||||
String customFieldLabel = getMapString(map, null, "customFieldLabel", "custom_field_label");
|
||||
String customFieldValue = getMapString(map, null, "customFieldValue", "custom_field_value");
|
||||
|
||||
CpfDisplayMode cpfMode = CpfDisplayMode.FULL;
|
||||
if (map.containsKey("defaultCpfMode") && map.get("defaultCpfMode") != null) {
|
||||
String rawCpfMode = getMapString(map, null, "defaultCpfMode", "default_cpf_mode", "cpfMode", "cpf_mode");
|
||||
if (rawCpfMode != null) {
|
||||
try {
|
||||
cpfMode = CpfDisplayMode.valueOf(map.get("defaultCpfMode").toString().toUpperCase());
|
||||
cpfMode = CpfDisplayMode.valueOf(rawCpfMode.toUpperCase());
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
boolean includeDateTime = !map.containsKey("defaultIncludeDateTime") || Boolean.TRUE.equals(map.get("defaultIncludeDateTime"));
|
||||
|
||||
boolean includeDateTime = true;
|
||||
Object dtObj = map.containsKey("defaultIncludeDateTime") ? map.get("defaultIncludeDateTime")
|
||||
: (map.containsKey("default_include_date_time") ? map.get("default_include_date_time")
|
||||
: (map.containsKey("includeDateTime") ? map.get("includeDateTime")
|
||||
: map.get("include_date_time")));
|
||||
if (dtObj instanceof Boolean b) {
|
||||
includeDateTime = b;
|
||||
} else if (dtObj != null) {
|
||||
includeDateTime = Boolean.parseBoolean(dtObj.toString());
|
||||
}
|
||||
|
||||
return new PdfSealTheme(
|
||||
id, name, description, width, height,
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 54" width="36" height="54">
|
||||
<!-- Escudo Criptográfico Vetorial ICP-Brasil -->
|
||||
<path d="M18 4 L32 9 V24 C32 37 25 46 18 50 C11 46 4 37 4 24 V9 Z" fill="#0d47a1" opacity="0.14"/>
|
||||
<path d="M18 4 L32 9 V24 C32 37 25 46 18 50 C11 46 4 37 4 24 V9 Z" fill="none" stroke="#0d47a1" stroke-width="2.2" stroke-linejoin="round"/>
|
||||
|
||||
<!-- Corpo do Cadeado de Segurança -->
|
||||
<rect x="11" y="24" width="14" height="12" rx="2.5" fill="#0284c7"/>
|
||||
|
||||
<!-- Arco Superior do Cadeado -->
|
||||
<path d="M13.5 24 V19 C13.5 16.5 15.5 14.5 18 14.5 C20.5 14.5 22.5 16.5 22.5 19 V24" fill="none" stroke="#0284c7" stroke-width="2.2" stroke-linecap="round"/>
|
||||
|
||||
<!-- Orifício da Chave -->
|
||||
<circle cx="18" cy="29" r="1.6" fill="#ffffff"/>
|
||||
<path d="M17.3 29.5 L18.7 29.5 L19.2 33 L16.8 33 Z" fill="#ffffff"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 858 B |
Reference in New Issue
Block a user