Skip to content

Instantly share code, notes, and snippets.

View erickdeoliveiraleal's full-sized avatar

Erick de Oliveira Leal erickdeoliveiraleal

  • Secretaria de Estado de Administração Penitenciária do Distrito Federal - SEAPE/DF
  • Brasília, Brasil
View GitHub Profile
package siapen.utilitarios;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import java.util.Arrays;
import java.util.Base64;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package siapen.utilitarios;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import java.util.Base64;
import java.util.Random;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
@erickdeoliveiraleal
erickdeoliveiraleal / test.java
Created July 9, 2018 19:04
omnifaces sendfile
// The code below should do the same as this
Faces.sendFile(JasperExportManager.exportReportToPdf(jasperPrint), nomeDownload + ".pdf", false);
/*ByteArrayOutputStream baos = new ByteArrayOutputStream();
JasperExportManager.exportReportToPdfStream(jasperPrint, baos);
ExternalContext ec = fc.getExternalContext();
ec.responseReset(); // Some JSF component library or some Filter might have set some headers in the buffer beforehand. We want to get rid of them, else it may collide.
ec.setResponseContentType("application/pdf"); // Check http://www.iana.org/assignments/media-types for all types. Use if necessary ExternalContext#getMimeType() for auto-detection based on filename.
ec.setResponseContentLength(baos.size()); // Set it with the file size. This header is optional. It will work if it's omitted, but the download progress will be unknown.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions">
@erickdeoliveiraleal
erickdeoliveiraleal / Feriados.java
Last active December 13, 2022 16:51
Lista de feriados brasileiros em Java. Cria lista com ano corrente anterior e proximo. Inclui dois feriados de Brasilia, Dia do evangelico e dia do servidor.
package siapen.utilitarios;
import java.text.ParseException;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class Feriados {
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core"
template="/WEB-INF/template.xhtml">
<ui:define name="title">Transferência de Internos</ui:define>
2017-06-09 19:10:14,303 SEVERE [org.firebirdsql.gds.impl.GDSFactory] (ServerService Thread Pool -- 63) Can't register plugin (skipping): org.firebirdsql.gds.impl.GDSFactoryPlugin: Provider org.firebirdsql.gds.impl.wire.WireGDSFactoryPlugin not a subtype: java.util.ServiceConfigurationError: org.firebirdsql.gds.impl.GDSFactoryPlugin: Provider org.firebirdsql.gds.impl.wire.WireGDSFactoryPlugin not a subtype
at java.util.ServiceLoader.fail(ServiceLoader.java:239)
at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at org.firebirdsql.gds.impl.GDSFactory.loadPluginsFromClassLoader(GDSFactory.java:123)
at org.firebirdsql.gds.impl.GDSFactory.<clinit>(GDSFactory.java:75)
at org.firebirdsql.jdbc.FBDriver.connect(FBDriver.java:110)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.cre
package siapen.generators;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.inject.Inject;
package siapen.jpa.interceptor;
import java.io.Serializable;
import java.util.Iterator;
import org.apache.commons.lang3.ObjectUtils;
import org.hibernate.CallbackException;
import org.hibernate.EmptyInterceptor;
import org.hibernate.type.Type;
<filter>
<filter-name>loginFilter</filter-name>
<filter-class>filtro.AuthFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>loginFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>