Skip to content

Instantly share code, notes, and snippets.

View luiswolff's full-sized avatar

Luis-Manuel Wolff Heredia luiswolff

View GitHub Profile
@luiswolff
luiswolff / CallEuropeanHOS.java
Last active April 9, 2017 15:58
Using JPA to call a stored procedure and map the result to an intern domain model.
package de.luiswolff.test;
import javax.persistence.*;
import java.util.List;
/**
* This program uses the MySQL sample database "world" and a stored procedure from the MySQL-Tutorial
* <a href="https://dev.mysql.com/doc/connector-net/en/connector-net-tutorials-stored-procedures.html">
* Connector/Net 4.1.5 Working with Stored Procedures</a>.
*/
@luiswolff
luiswolff / CallEuropeanHOSWithSQLMapping.java
Last active April 9, 2017 16:04
Using JPA an Construtor-Result to call a stored procedure and map the result to an intern domain model
package de.luiswolff.test;
import javax.persistence.*;
import java.util.List;
/**
* This program uses the MySQL sample database "world" and a stored procedure from the MySQL-Tutorial
* <a href="https://dev.mysql.com/doc/connector-net/en/connector-net-tutorials-stored-procedures.html">
* Connector/Net 4.1.5 Working with Stored Procedures</a>.
*/
@luiswolff
luiswolff / AbstractHtmlServletMessageBodyWriter.java
Last active April 26, 2017 18:05
An action based MVC approach with Java EE 7 using JAX-RS and the Servlet/JSP-API.
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
@luiswolff
luiswolff / index.html
Created May 22, 2018 19:51
Create an icon with HTML and CSS
<html>
<head>
<title>Test CSS</title>
<link rel="stylesheet" href="style.css" >
</head>
<body>
<p>Test<span class="icon">!</span>
</body>
</html>
@luiswolff
luiswolff / MessageDESEncrypter.java
Created December 21, 2018 12:47
Example how to encrypt a message with a provided secret using the Data Encryption Standard algorithm. The message is writen to a given file. The provided secret is required to have exactly 8 characters.
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
import javax.crypto.CipherOutputStream;
import javax.crypto.NoSuchPaddingException;
@luiswolff
luiswolff / MessageDESDecrypter.java
Last active December 21, 2018 12:47
Example how to decrypt a protected message with a provided secret using the Data Encryption Standard algorithm. The messaged is readed from a provided file and the printed to the console. The provided secret is required to have exactly 8 characters.
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
@luiswolff
luiswolff / MessageSignGenerator.java
Created December 21, 2018 15:12
Example on how to sign file content using a randomly generated private Key. The Code takes a file as input and generates a signature and a public key, that can be used to verify, that the signature was create by the generated private key.
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.SecureRandom;
import java.security.Signature;
@luiswolff
luiswolff / MessageSignVerifier.java
Created December 21, 2018 15:14
Example on how to verify a data file using a provided signature and public key.
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.Signature;
import java.security.spec.X509EncodedKeySpec;
public class MessageSignVerifier {
package de.wolff.dsi;
public interface DynamicService {
String invoke();
}
@luiswolff
luiswolff / WSSecuritySigner.java
Created June 5, 2019 19:52
This gist shows how to sign a Soap-Message using Apache WSS4J.
package de.wolff.wsst;
import java.io.File;
import java.util.Properties;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
import org.apache.wss4j.common.crypto.Crypto;