Skip to content

Instantly share code, notes, and snippets.

@serac
serac / ossl-ciphers-to-java.py
Created September 9, 2016 13:10
Convert OpenSSL TLS Cipher String to Java Cipher List
#!/usr/bin/env python
import sys
from os.path import basename
from subprocess import Popen, PIPE
"""Map of OpenSSL symmetric cipher names to cipher/block size tuples."""
CIPHERS={
'AES': ('AES', 128),
'AES128': ('AES', 128),
@serac
serac / CustomJpaTransactionManager.java
Created June 24, 2021 12:20
Custom Spring JPA transaction manager with support for rollback override
/*
* See LICENSE for licensing and NOTICE for copyright.
*/
package edu.vt.middleware.ed.support.spring.tx;
import java.lang.reflect.Field;
import java.util.concurrent.ConcurrentHashMap;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import edu.vt.middleware.core.annotation.Trivial;
@serac
serac / find-mixed-whitespace.sh
Created January 21, 2016 18:54
Bash script to find files with mixed whitespace (tabs and spaces)
#!/bin/bash
for F in $(find . -type f -print); do
TCOUNT=$(grep -ce '^\t' $F)
SCOUNT=$(grep -ce '^ ' $F)
if [[ $TCOUNT -gt 0 ]] && [[ $SCOUNT -gt 0 ]]; then
echo $F
fi
done
@serac
serac / Application.java
Last active March 25, 2021 16:32
Configuring RestTemplate for Client TLS in a Spring Boot Application
/*
* See LICENSE for licensing and NOTICE for copyright.
*/
package edu.vt.middleware.app;
import java.io.File;
import java.security.*;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
@serac
serac / cas-protocol-2.0.md
Created February 11, 2016 15:01
CAS Protocol 2.0 Specification

CAS Protocol

Author: Drew Mazurek Contributors: Susan Bramhall Howard Gilbert Andy Newman Andrew Petro Version: 1.0

Release Date: May 4, 2005

@serac
serac / Major.kt
Created May 23, 2019 19:20
JPA Many-to-Many Unidirectional Ordered List
/*
* See LICENSE for licensing and NOTICE for copyright.
*/
package edu.vt.middleware.ed.model.db
import javax.persistence.*
/**
* Models a Virginia Tech academic major from Banner.
*
@serac
serac / SanePGP-HOWTO.md
Last active January 29, 2019 20:59
Secure and Sane PGP for the Long Term

Secure and Sane PGP for the Long Term

Use the method described here if you would like most of the following benefits:

  1. Establish provenance of exactly one public key on the Internet over time (years typically).
  2. Use multiple keys daily without exposing the secret key corresponding to your published public key.
  3. Facilitate key creation and revocation.

While provenance isn't necessary for many folks, it's useful if not essential if you publish software artifacts

@serac
serac / gen-truststore.sh
Last active December 14, 2018 12:29
Generate a PKCS#12 trust store
#!/bin/bash
# Generates a PKCS#12 trust store from a directory of PEM-encoded certificates
# using the Java keytool utility.
if [ $# -lt 2 ]; then
echo "USAGE $(basename $0) path/to/certs/dir path/to/output.p12"
exit
fi
IN="${1%/}"
@serac
serac / idp-process-excerpt-failure.log
Last active September 20, 2018 11:55
Credential Resolver Logs
2018-09-17 11:51:19,659 DEBUG org.opensaml.saml.saml2.binding.decoding.impl.HTTPRedirectDeflateDecoder:99 1.2.3.4 Decoded RelayState: https://cloudforms02.systems.nis.dit.cas-1.opc.vt.edu/saml_login
2018-09-17 11:51:19,659 DEBUG org.opensaml.saml.saml2.binding.decoding.impl.HTTPRedirectDeflateDecoder:131 1.2.3.4 Base64 decoding and inflating SAML message
2018-09-17 11:51:19,660 DEBUG org.opensaml.saml.saml2.binding.decoding.impl.HTTPRedirectDeflateDecoder:114 1.2.3.4 Decoded SAML message
2018-09-17 11:51:19,661 DEBUG net.shibboleth.idp.profile.impl.WebFlowMessageHandlerAdaptor:174 1.2.3.4 Profile Action WebFlowMessageHandlerAdaptor: Invoking message handler of type 'org.opensaml.saml.common.binding.impl.CheckMessageVersionHandler' on INBOUND message context
2018-09-17 11:51:19,661 DEBUG net.shibboleth.idp.profile.impl.WebFlowMessageHandlerAdaptor:195 1.2.3.4 Profile Action WebFlowMessageHandlerAdaptor: Invoking message handler on message context containing a message of type 'org.opensaml.saml.saml2.core.impl.
@serac
serac / connect-redis-cli-to-ec.sh
Last active September 4, 2018 12:34
Connect Dockerized redis-cli to ElastiCache via AWS Bastion Host
#!/bin/bash
# Connects a docker image of redis-cli to an ElastiCache Redis instance
# by jumping through an AWS bastion host. Setup of the bastion host is
# an exercise left to the reader, but there are many detailed explanations
# of the AWS components and security controls.
#
# NOTE:
# 1. Script assumes OSX. Tweaking required for other platforms.
# 2. Clustered Redis not supported for practical reasons.
# Theoretically possible to establish tunnels to cluster discovery