Skip to content

Instantly share code, notes, and snippets.

View davidmc24's full-sized avatar

David M. Carr davidmc24

  • Albany, NY, USA
  • 21:31 (UTC -04:00)
View GitHub Profile
@davidmc24
davidmc24 / AbstractWaffleRealm.java
Created December 21, 2012 12:40
Work in progress towards a Waffle Shiro realm
package waffle;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.CredentialsMatcher;
import org.apache.shiro.authc.credential.HashingPasswordService;
import org.apache.shiro.authc.credential.PasswordMatcher;
@davidmc24
davidmc24 / .gitignore
Last active December 10, 2015 15:28
Wrapper for HornetQBootstrapServer to allow running it as a Windows service using Java Service Wrapper. Conceptually based on a [forum post](https://community.jboss.org/thread/156466?start=15&tstart=0) by Syed Meerkasim Mustaffa.
build
.gradle
@davidmc24
davidmc24 / pom.xml
Created January 21, 2013 00:09
A sample POM for waffle-jna 1.5
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.dblock.waffle</groupId>
<artifactId>waffle-jna</artifactId>
<version>1.5</version>
<packaging>jar</packaging>
@davidmc24
davidmc24 / MyClientModule.java
Created August 26, 2013 19:55
Example Feign client with support for GZIP encoding of request bodies
package sample;
import dagger.Lazy;
import dagger.Module;
import dagger.Provides;
import feign.Client;
import feign.Request;
import feign.Request.Options;
import feign.Response;
@davidmc24
davidmc24 / BasicAuthenticationInterceptor.java
Created September 23, 2013 03:33
Quick and dirty version of a Basic auth interceptor for Feign
import dagger.Module;
import dagger.Provides;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.codehaus.groovy.runtime.EncodingGroovyMethods;
import java.nio.charset.StandardCharsets;
@Module(library = true)
public class BasicAuthenticationInterceptor implements RequestInterceptor {
@davidmc24
davidmc24 / test.patch
Last active December 27, 2015 17:48 — forked from devmop/Junit test
diff --git a/build.gradle b/build.gradle
index 3da4379..699c56d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -70,6 +70,7 @@ project(':feign-gson') {
compile project(':feign-core')
compile 'com.google.code.gson:gson:2.2.4'
testCompile 'org.testng:testng:6.8.5'
+ testCompile 'com.google.mockwebserver:mockwebserver:20130706'
}
@davidmc24
davidmc24 / init.gradle
Created November 8, 2013 14:32
Gradle init script snippet to remove mavenLocal from all builds
// Remove mavenLocal from all projects
// It makes builds less reproducible, and is error-prone.
// http://issues.gradle.org/browse/GRADLE-2034
projectsLoaded {
rootProject.allprojects { project ->
[buildscript.repositories, repositories].each { repoHandler ->
repoHandler.matching {it.name == "MavenLocal"}.all { repo ->
//project.logger.warn("Removing repo ${repo.name} from ${project.name}")
repoHandler.remove(repo)
}
import base.shiro.ShiroRole
import base.shiro.ShiroUser
import org.apache.shiro.cas.CasAuthenticationException
import org.apache.shiro.authc.AccountException
import org.apache.shiro.authc.SimpleAuthenticationInfo
import org.apache.shiro.util.StringUtils
import org.apache.shiro.util.CollectionUtils
import org.apache.shiro.subject.PrincipalCollection
import org.apache.shiro.subject.SimplePrincipalCollection
@davidmc24
davidmc24 / ConfigurationsSpec.groovy
Last active August 29, 2015 14:12
Example Config Reloading
/*
* Copyright 2015 the original author or authors.
*
* 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
@davidmc24
davidmc24 / BasicAuthHandler.groovy
Created January 14, 2015 18:06
Simple Ratpack BasicAuthHandler
package integration.pac4j
import chex.config.AuthConfig
import chex.util.HttpResponseCode
import com.unboundid.ldap.sdk.LDAPConnectionPool
import groovy.util.logging.Slf4j
import io.netty.handler.codec.http.HttpHeaderNames
import org.pac4j.core.profile.UserProfile
import org.pac4j.http.profile.HttpProfile
import ratpack.handling.Context