This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<persistence xmlns="http://java.sun.com/xml/ns/persistence" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" | |
version="2.0"> | |
<persistence-unit name="default"> | |
<properties> | |
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" /> | |
<property name="javax.persistence.jdbc.url" value="jdbc:h2:~/faces-motors" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@WebServlet(urlPatterns="/carrega-imagem") | |
public class ImagemServlet extends HttpServlet{ | |
private static final long serialVersionUID = -4433688269834762430L; | |
@Override | |
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | |
String id = req.getParameter("auto_id"); | |
Automovel automovel = JpaUtil.getEntityManager().find(Automovel.class, Long.valueOf(id)); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier(){ | |
@Override | |
public boolean verify(String arg0, SSLSession arg1) { | |
return true; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String clientTruststorePath = Main.class.getResource("/META-INF/client.truststore").getPath(); | |
System.setProperty("javax.net.ssl.trustStore", clientTruststorePath); | |
System.setProperty("javax.net.ssl.trustStorePassword", "a1234b"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#geração da chave e armazenamento no keystore | |
keytool -genkey -alias certificado_servidor -keyalg RSA -validity 1000 -keystore server.keystore | |
#extração da chave que estava no keystore para um arquivo separado | |
keytool -export -alias certificado_servidor -keystore server.keystore -file server.cer | |
#criação de um truststore do cliente contendo a chave do servidor | |
keytool -import -alias certificado_servidor -keystore client.truststore -file server.cer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Credentials credentials = new UsernamePasswordCredentials("xico", "xico123"); | |
HttpClient httpClient = new HttpClient(); | |
httpClient.getState().setCredentials(AuthScope.ANY, credentials); | |
httpClient.getParams().setAuthenticationPreemptive(true); | |
ClientExecutor clientExecutor = new ApacheHttpClientExecutor(httpClient); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- no web.xml --> | |
<security-constraint> | |
<display-name>require valid user</display-name> | |
<web-resource-collection> | |
<web-resource-name>internal application</web-resource-name> | |
<!-- secure only admin pages--> | |
<url-pattern>/*</url-pattern> | |
</web-resource-collection> | |
<auth-constraint> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InscricaoController { | |
//... | |
def inscricaoSimples = { | |
def inscricaoInstance = new Inscricao(params) | |
/*if(inscricaoInstance.validate() & inscricaoInstance.participante.validate(['nome', 'email'])){ | |
inscricao.save(validate: false) | |
}*/ | |
if(inscricaoInstance.inscricaoSimples()){ |