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 / ConditionalOtpFormAuthenticator.java
Last active November 15, 2023 05:49
Keycloak Conditional OTP Step-by-Step
package org.keycloak.authentication.authenticators.browser;
import org.keycloak.authentication.AuthenticationFlowContext;
import org.keycloak.models.RoleModel;
import org.keycloak.models.UserModel;
import javax.ws.rs.core.MultivaluedMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
@thomasdarimont
thomasdarimont / keycloak_db_overview_4.0.0.CR1-SNAPSHOT.svg
Created January 7, 2018 22:47
Keycloak Database Overview 4.0.0.CR1-SNAPSHOT (06bb6f00e5)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thomasdarimont
thomasdarimont / App.java
Last active October 27, 2023 07:44
Secure REST API Example with Spring Security, Spring Session, Spring Boot
package demo;
import java.io.Serializable;
import java.security.Principal;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@thomasdarimont
thomasdarimont / JShellFetchDemo.java
Last active October 10, 2023 23:21
PoC for Fetch API like API for JShell
package demo;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Map;
public class JShellFetchDemo {
@thomasdarimont
thomasdarimont / LocalOnceDemo.java
Created September 23, 2021 09:36
Go's sync.Once with Java 17
package wb.java17;
import java.util.function.Supplier;
public class LocalOnceDemo {
public static void main(String[] args) {
System.out.println(answer());
System.out.println(answer());
}
@thomasdarimont
thomasdarimont / Dockerfile
Created April 8, 2022 10:58
Keycloak.X JGroups JDBC Ping
FROM quay.io/keycloak/keycloak:17.0.1 as builder
ENV KC_METRICS_ENABLED=true
ENV KC_FEATURES=preview
ENV KC_DB=postgres
ENV KC_HTTP_RELATIVE_PATH=/auth
# specify the custom cache config file here
ENV KC_CACHE_CONFIG_FILE=cache-ispn-jdbc-ping.xml
# copy the custom cache config file into the keycloak conf dir
@thomasdarimont
thomasdarimont / ExampleResource.java
Last active September 26, 2023 07:09
Example to reproduce RESTEASY-3384 with resteasy-reactive
package com.example;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
@Path("/hello")
public class ExampleResource {
@POST
public String greet() {
@thomasdarimont
thomasdarimont / minispa.html
Created September 20, 2023 10:23
Example SPA for Keycloak Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Acme Mini SPA</title>
<style>
body {
background-color: #eaeaea;
@thomasdarimont
thomasdarimont / App.java
Created January 5, 2017 17:00
Simple AuthN & AuthZ example with Spring Boot / Security / Session
package demo;
import java.io.Serializable;
import java.security.Principal;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@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;
/**