Skip to content

Instantly share code, notes, and snippets.

View AnkurSen-github's full-sized avatar

Ankur Sen AnkurSen-github

  • Verifone
  • Bangalore
View GitHub Profile
@AnkurSen-github
AnkurSen-github / MultiplexOutputStream.java
Created September 17, 2021 08:06 — forked from zikani03/MultiplexOutputStream.java
Writing to multiple output streams in Java
import java.io.IOException;
import java.io.OutputStream;
/**
* <p>
* MultiplexOutputStream allows you to write to multiple output streams "at once".
* It allows you to use one outputstream writer to write to multiple outputstreams
* without repeating yourself.
* Based off <a href="https://github.com/creditdatamw/kapenta/blob/master/src/main/java/com/creditdatamw/labs/kapenta/io/MultiplexOutputStream.java">MultiplexOutputStream.java</a>
*/
@AnkurSen-github
AnkurSen-github / MimeTypes.java
Created August 17, 2021 10:21 — forked from markwhitaker/MimeTypes.java
Standard MIME type constants ready to use in a Java project. Now a library: see https://github.com/markwhitaker/MimeTypes.Java
public final class MimeTypes
{
public static final class Application
{
public static final String ATOM_XML = "application/atom+xml";
public static final String ATOMCAT_XML = "application/atomcat+xml";
public static final String ECMASCRIPT = "application/ecmascript";
public static final String JAVA_ARCHIVE = "application/java-archive";
public static final String JAVASCRIPT = "application/javascript";
public static final String JSON = "application/json";
@AnkurSen-github
AnkurSen-github / SslUtil.java
Created January 15, 2021 17:14 — forked from rohanag12/SslUtil.java
Create an SslSocketFactory using PEM encrypted certificate files
/**
* Utility class to read encrypted PEM files and generate a
* SSL Socket Factory based on the provided certificates.
* The original code is by Sharon Asher (link below). I have modified
* it to use a newer version of the BouncyCastle Library (v1.52)
*
* Reference - https://gist.github.com/sharonbn/4104301"
*/
import org.bouncycastle.cert.X509CertificateHolder;

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@AnkurSen-github
AnkurSen-github / SslUtil.java
Created December 20, 2020 18:44 — forked from sharonbn/SslUtil.java
SSL/TLS connection from Eclipse Paho Java client to mosquitto MQTT broker
import java.io.*;
import java.nio.file.*;
import java.security.*;
import java.security.cert.*;
import javax.net.ssl.*;
import org.bouncycastle.jce.provider.*;
import org.bouncycastle.openssl.*;
public class SslUtil