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 / Base64-Encode.cmd
Last active April 9, 2021 13:12
A CMD-File, thats convert a given File to a Base64-Code and write that to an other file. The File that should be encoded is submitted as command line parameter. So you can use the drap and drop function of Windows. The output file will be the same as the input but with the string ".base64" as suffix.
@echo off
powershell -command "$bytes = [System.IO.File]::ReadAllBytes('%1'); [Convert]::ToBase64String($bytes) | Out-File -FilePath '%1.base64' -Encoding ASCII -NoNewline"
@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 / 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 / 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();
}