Skip to content

Instantly share code, notes, and snippets.

View ToastShaman's full-sized avatar

Kevin Denver ToastShaman

View GitHub Profile
@ToastShaman
ToastShaman / cert.sh
Last active August 29, 2015 14:00
Run dropwizard with the SPDY module
#!/bin/bash
keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 360 -keysize 2048
@ToastShaman
ToastShaman / PasswordUtils.java
Last active February 23, 2021 11:13
A utility class for hashing passwords using PBKDF2 with BouncyCastle.
package com.zuhlke.lsapi;
import org.bouncycastle.crypto.PBEParametersGenerator;
import org.bouncycastle.crypto.digests.SHA3Digest;
import org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.prng.DigestRandomGenerator;
import java.util.Base64;
@ToastShaman
ToastShaman / ServiceExceptionTest.java
Last active July 4, 2018 17:43
Nested Hamcrest Matcher
@Test
public void shouldCheckWhetherWeHaveAnUsernameAlreadyInUseErrorCode() {
ServiceException e = new ServiceException("ERR500|532323");
assertThat(e, hasErrorCode(usernameAlreadyInUse()));
}
@ToastShaman
ToastShaman / SftpServiceTest.java
Created November 13, 2013 18:40
Using an embedded Apache MINA SSHD server in a unit test to verify that your code is able to upload a file through SFTP. This unit tests uses JSch as the client to speak to an embedded Apache MINA sftp server and verifies that the upload of a text file was successful.
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;