Skip to content

Instantly share code, notes, and snippets.

View idurucz's full-sized avatar

idurucz

  • United Kingdom
View GitHub Profile
@idurucz
idurucz / MyHttpsServer.java
Last active October 15, 2022 01:25
Java SSL HttpsServer with HttpHandler to send response to client (uses com.sun.net.httpserver.HttpsServer)
import java.io.*;
import java.net.InetSocketAddress;
import com.sun.net.httpserver.HttpsServer;
import java.security.KeyStore;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManagerFactory;
import com.sun.net.httpserver.*;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLParameters;
@idurucz
idurucz / SendFCMPushMessage.java
Last active December 30, 2018 18:14
Java Http POST to send JSON push notification
import java.io.IOException;
import java.io.OutputStreamWriter;
import javax.net.ssl.HttpsURLConnection;
import java.net.URL;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
public class SendFCMPushMessage {
public static void main(String[] args) throws IOException, JSONException {
URL url = new URL("https://fcm.googleapis.com/fcm/send");
@idurucz
idurucz / MyHttpServer.java
Created December 29, 2018 18:46
Java HttpServer with HttpHandler to send response to client (uses com.sun.net.httpserver)
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
public class MyHttpServer {
public static void main(String[] args) throws Exception {