Skip to content

Instantly share code, notes, and snippets.

View malys's full-sized avatar

Malys malys

View GitHub Profile
@malys
malys / compare.groovy
Last active August 6, 2019 08:32
[Properties] Compare #properties
Properties props = new Properties();
props.load(new FileInputStream("D:\\Developpement\\archi\\idm\\rh-sso-theme-lyra\\src\\main\\resources\\theme\\lyra\\login\\messages\\messages_en.properties"))
// from now you have Properties object with your data.
// since properties extends Hashtable the task is done.
// if you still need keys in list, say
List<Object> keys = new ArrayList<Object>(props.keySet())
keys=keys.toSorted()
//println keys.join("\n")
@malys
malys / keycloak_aws_deployment.md
Last active April 18, 2019 11:21 — forked from pgchamberlin/keycloak_aws_deployment.md
Deploying Keycloak to AWS using a Ubuntu AMI

Deploying Keycloak to AWS Ligthsail

The objective of this guide is to deploy Keycloak to AWS in a minimally complex way for testing and discovery purposes. This means using the standalone build of Keycloak backed with Hibernate H2. The result is not a production ready system. It won't scale, it won't survive significant load, it can't be clustered.

Steps

  • Spin up and configure a Ubuntu
  • Install and configure Keycloak with an SSL cert

Spin up a Ubuntu and configure it

@malys
malys / templater.sh
Last active August 14, 2020 08:39
[Templater] Template engine in bash for Openshift #openshift #bash #template #kubernetes
#!/bin/bash
#set -x
#bash templater.sh < oc-template.tpl.yml | oc process -f - | oc create -f -
#bash templater.sh < oc-template.tpl.yml > oc-template.yml && oc process -f oc-template.yml | oc create -f -
while IFS= read -r line
do
end_offset=${#line}
IS_VAR=true
# Read variable in file
while [[ "${line:0:$end_offset}" =~ (.*)(\$\{([a-zA-Z_][a-zA-Z_0-9]*)\})(.*) ]] ; do
@malys
malys / SSLPoke.java
Last active April 25, 2019 06:58 — forked from 4ndrej/SSLPoke.java
Test of java SSL / keystore / cert setup. Check the commet #1 for howto.
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*/
public class SSLPoke {
public static void main(String[] args) {
@malys
malys / convertEnvToArgs.sh
Last active August 6, 2019 08:34
[Convert env to args] #args #env #bash
#!/bin/bash
# Convert PREFIX_XXX=YYY variable to --xxx=YYY
PREFIX=$1
DEFAULT=$DEFAULT_ARGS
RESULT=
if [ ${#PREFIX} -ge 2 ]; then
while IFS= read -r line
do
PRE_KEY=$(echo $line | cut -d'=' -f1)
KEY=$(echo $PRE_KEY |sed -e "s/$PREFIX/--/g; s/_/-/g; s/\(.*\)/\L\1/")
@malys
malys / server.py
Created August 6, 2019 08:39
[HTTP Debug] proxy,server #debug #python #nodeps
#!/usr/bin/python
import SimpleHTTPServer
import SocketServer
import logging
PORT = 8090
class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
@malys
malys / CountUppercase.java
Last active August 29, 2019 12:07
[Benchmark JVM] #java #graalvm #java11 #java8 #openJ9 #keycloak #keystore #bombardier
public class CountUppercase {
static final int ITERATIONS = Math.max(Integer.getInteger("iterations", 1), 1);
public static void main(String[] args) {
String sentence = String.join(" ", args);
for (int iter = 0; iter < ITERATIONS; iter++) {
if (ITERATIONS != 1) System.out.println("-- iteration " + (iter + 1) + " --");
long total = 0, start = System.currentTimeMillis(), last = start;
for (int i = 1; i < 10_000_000; i++) {
total += sentence.chars().filter(Character::isUpperCase).count();
if (i % 1_000_000 == 0) {
@malys
malys / ExportToCSV.js
Created August 9, 2019 09:55
[Table to CSV] #confluence #bookmarklet
//https://iamdav.in/2014/10/24/bookmarklet-creating-csv-html-table/
//http://js.do/blog/bookmarklets/
javascript:(function(){
function getJavaScript(url, success) {
var script = document.createElement('script');
script.src = url;
var head = document.getElementsByTagName('head')[0],
done = false;
script.onload = script.onreadystatechange = function(){
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
@malys
malys / keycloak-mutual-ssl.sh
Last active February 5, 2024 16:59 — forked from gyfoster/keycloak-wildfly-mutual-ssl.txt
[Keycloak X509 authentication] Instructions for enabling mutual SSL in Keycloak and WildFly #keycloak #TLS #mutual #x509
#!/bin/bash
# X509 Browser and Direct grant
# https://access.redhat.com/documentation/en-us/red_hat_single_sign-on/7.2/html/server_administration_guide/authentication
# https://github.com/keycloak/keycloak-documentation/blob/4.8.x/server_admin/topics/authentication/x509.adoc
#https://stackoverflow.com/questions/54258996/git-bash-string-parameter-with-at-start-is-being-expanded-to-a-file-path
unameOut="$(uname -s)"
case "${unameOut}" in
CYGWIN*) prefix="/";;
@malys
malys / authorizatio_code.sh
Last active August 4, 2020 10:13
[Probe for Keycloak integration] #keycloak #python #oauth2 #oidc #curl #bash
#!/bin/bash
#https://medium.com/@robert.broeckelmann/openid-connect-authorization-code-flow-with-red-hat-sso-d141dde4ed3f
#set -x
#Apache License 2.0
SERVER=
REALM=
CLIENT=
USER=
PW=