Skip to content

Instantly share code, notes, and snippets.

View kwart's full-sized avatar

Josef Cacek kwart

View GitHub Profile
@kwart
kwart / SanCheckingLoginModule.java
Created May 13, 2022 13:59
Sample Hazelcast login module that checks SAN information in TLS client certificate.
package com.hazelcast.security.loginimpl;
import java.io.IOException;
import java.security.cert.Certificate;
import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
import java.util.Collection;
import java.util.List;
import javax.security.auth.callback.Callback;
#!/bin/bash
# define Hazelcast configuration in YAML file (TCP discovery used, REST API enabled)
cat <<EOT >hazelcast.yaml
hazelcast:
network:
join:
multicast:
enabled: false
tcp-ip:
@kwart
kwart / shotTheScreen.sh
Last active September 23, 2019 19:40
LInux - take the screenshot every 30 seconds
#!/bin/bash
while scrot '/tmp/scr-%Y%m%d-%H%M%S.png' -q 20; do
sleep 30
done
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v UserAuthentication /t REG_DWORD /d 0 /f
@kwart
kwart / github-team.py
Last active October 17, 2018 09:06 — forked from krusynth/github-team.py
Python script to add all GitHub repositories to an organization team - permission is set to push. You'll need a settings.py file with your organization name and API key. Based off of my GitHub stats script (requirements.txt here): https://github.com/krues8dr/project-migration
#!/usr/bin/python
# Exports a CSV of repo names, readme files, and the license of the project.
from __future__ import print_function
import requests
import json
import settings
from urlparse import urlparse, parse_qs
import sys
@kwart
kwart / ConfigureMemberLoginModule.java
Created February 9, 2018 16:39
Create Hazelcast configuration with custom login module
LoginModuleConfig loginModuleConfig = new LoginModuleConfig();
loginModuleConfig.setClassName(CustomVerifyingLoginModule.class.getName());
loginModuleConfig.setUsage(LoginModuleUsage.REQUIRED);
Properties properties = new Properties();
properties.setProperty("allowed-hosts", "192.168.2.*,server-x.my-company.example")
loginModuleConfig.setProperties(properties);
config.getSecurityConfig().setEnabled(true).addMemberLoginModuleConfig(loginModuleConfig);
@kwart
kwart / VerifyRemoteAddressInterceptor.java
Created February 9, 2018 09:27
Validating remote address in Hazelcast. We don't have information if the other side is member or client yet.
/*
// Usage:
Config config = new Config();
SocketInterceptorConfig socketInterceptorConfig = new SocketInterceptorConfig();
VerifyRemoteAddressInterceptor interceptor = new
VerifyRemoteAddressInterceptor();
socketInterceptorConfig.setImplementation(interceptor).setEnabled(true);
config.getNetworkConfig().setSocketInterceptorConfig(socketInterceptorConfig);
Hazelcast.newHazelcastInstance(config);
*/
@kwart
kwart / limit-time.sh
Last active January 28, 2018 17:12
Dialog based script which shuts down the machine after given amount of time.
if timeoutMin=$(zenity --entry --text "Shutdown in (min)" --entry-text "30" --title "Shutdown?"); then
sudo shutdown -P ${timeoutMin}
fi
/*
* Copyright (c) 2008-2017, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@kwart
kwart / standalone-EXTERNAL-DR19.xml
Created May 26, 2017 19:04
Wildfly - EXTERNAL SASL mechanism configured in Elytron
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:5.0">
<extensions>
<extension module="org.jboss.as.clustering.infinispan"/>
<extension module="org.jboss.as.connector"/>
<extension module="org.jboss.as.deployment-scanner"/>
<extension module="org.jboss.as.ee"/>
<extension module="org.jboss.as.ejb3"/>