Skip to content

Instantly share code, notes, and snippets.

View thomasdarimont's full-sized avatar
🏠
Working from home

Thomas Darimont thomasdarimont

🏠
Working from home
View GitHub Profile
@thomasdarimont
thomasdarimont / MainMethodFinder.java
Last active September 8, 2023 22:28
Small tool to find classes with executable main methods in a given JDK.
import jdk.internal.org.objectweb.asm.*;
import java.io.*;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.Consumer;
/**
@thomasdarimont
thomasdarimont / readme.md
Last active July 6, 2023 12:33
Kind with local registry

Create locale registry

create-podman-registry.sh

#!/bin/sh
reg_name='kind-registry'
reg_port='5000'
running="$(podman inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)"
if [ "${running}" != 'true' ]; then
@thomasdarimont
thomasdarimont / readme.md
Created July 6, 2023 11:25
Keycloak Nightly with Podman
podman run -it \
  -p 8080:8080 \
  -p 8443:8443 \
  -p 8787:8787 \
  -e KEYCLOAK_ADMIN=admin \
  -e KEYCLOAK_ADMIN_PASSWORD=admin \
  -e DEBUG=true \
  -e DEBUG_PORT='0.0.0.0:8787' \
 quay.io/keycloak/keycloak:nightly \
@thomasdarimont
thomasdarimont / MainMethodFinder.java
Last active May 23, 2023 21:22
Main Method finder to discovery main methods in JDK jars or jmods
package wb.java21;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassVisitor;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.org.objectweb.asm.Opcodes;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
@thomasdarimont
thomasdarimont / CustomReferenceTokenEncoder.java
Last active May 3, 2023 19:48
PoC for encoding ReferenceTokens with expirationDate and signature
package demo;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
@thomasdarimont
thomasdarimont / docker-compose.yml
Created April 19, 2023 18:01
Oracle Docker-Compose
services:
oracle-db:
image: container-registry.oracle.com/database/free
environment:
ORACLE_PWD: training
ports:
- "1521:1521"
volumes:
- ./data:/opt/oracle/oradata:z
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
public class Main {
// --add-opens=java.base/sun.nio.fs=ALL-UNNAMED
public static void main(String[] args) throws Exception {
@thomasdarimont
thomasdarimont / BuildToolProvider.java
Last active March 21, 2023 14:51
Java Build Tool PoC
package demo.tools.build;
import com.google.auto.service.AutoService;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
package demo;
public class InstanceOnceDemo {
public static void main(String[] args) {
var c1 = new MyClass(2);
System.out.println(c1.calc());
System.out.println(c1.calc());
package org.acme;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.container.ResourceContext;
import javax.ws.rs.core.Context;
@Path("/resource")
public class DemoResource {