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 / java-keytool-sign-certificate.cmd
Last active June 5, 2019 19:57
This gist show how to create a self signed certificate (bob) and use it to sign a other (alice). So a application only requires to know the public key of bob in order to trust alice, too. The Java Keytool is used.
rem # create a new self signed certificate insite the keystore bob.jks. This will act as issuer for the other certificate
rem # It is importent to add the extention BasicConstraints Certificate Authority (bc:c)
rem # Otherwise tools like the JVM will not accept other certificates issued by this
keytool -genkey -alias bob -keyalg RSA -keypass changeit -storepass changeit -keystore bob.jks -dname CN=bob -ext bc:c
rem # create a other self siged certificate for with we will create a Certificate Sign Request (CSR)
keytool -genkey -alias alice -keyalg RSA -keypass changeit -storepass changeit -keystore alice.jks -dname CN=alice
@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;
@luiswolff
luiswolff / WSSecurityVerifier.java
Created June 5, 2019 19:54
This gist shows how to verify a signed Soap-Message using Apache WSS4J
package de.wolff.wsst;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Properties;
import java.util.regex.Pattern;
// For more information see: https://stackoverflow.com/questions/2897619/using-html5-javascript-to-generate-and-save-a-file
var pom = document.createElement('a');
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent('hello world!'));
pom.setAttribute('download', 'test.txt');
if (document.createEvent) {
var event = document.createEvent('MouseEvents');
event.initEvent('click', true, true);
pom.dispatchEvent(event);
}
@echo off
rem install angular cli if not already done
npm install -g @angular/cli
rem create workspace with routing module and not interaction
ng new webapp --routing --defaults
rem enter workspace
cd webapp