Skip to content

Instantly share code, notes, and snippets.

@sjohnr
sjohnr / ContinueFilterChainAuthenticationSuccessHandler.java
Created January 4, 2022 19:25
ContinueFilterChainAuthenticationSuccessHandler
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
@sjohnr
sjohnr / LICENSE
Created November 23, 2021 19:28
Apache 2.0 License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
@sjohnr
sjohnr / HomeController.java
Last active November 23, 2021 19:46
Siteminder Security Example
/*
* Copyright 2002-2021 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@sjohnr
sjohnr / AuthenticationManagerSupplier.java
Last active November 24, 2021 01:22
AuthenticationManagerSupplier
/*
* Copyright 2020-2021 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@sjohnr
sjohnr / SecurityConfiguration.kt
Last active October 20, 2021 20:06
StackOverflowException when adapter's AuthenticationManager gets published as a bean #10419
import org.springframework.context.annotation.Bean
import org.springframework.security.authentication.AnonymousAuthenticationProvider
import org.springframework.security.authentication.AuthenticationManager
import org.springframework.security.authentication.ProviderManager
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.web.servlet.invoke
import org.springframework.security.oauth2.jwt.JwtDecoder
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider
@sjohnr
sjohnr / AuthorizationConsent.java
Last active May 10, 2022 22:25
JpaOAuth2AuthorizationConsentService
/*
* Copyright 2020-2021 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@sjohnr
sjohnr / Client.java
Last active October 15, 2022 19:05
JpaRegisteredClientRepository
/*
* Copyright 2020-2021 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@sjohnr
sjohnr / DaoRegisteredClientRepository.java
Last active November 24, 2021 01:22
DaoRegisteredClientRepository for Spring Authorization Server
/*
* Copyright 2020-2021 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@sjohnr
sjohnr / .zshrc
Last active July 16, 2021 14:53
Export output of piped command to an environment variable
function exp() {
export $1=$(cat /dev/stdin)
}
@sjohnr
sjohnr / RingBuffer.kt
Created July 8, 2019 02:50
RingBuffer.kt
import java.util.AbstractQueue
/**
* RingBuffer implementation of the Queue interface, used to create a fixed-size
* collection. A ring buffer is a collection that is safe to add to, will not
* run out of space, and drops the oldest element when adding to a full buffer.
*/
class RingBuffer<E>(private val capacity: Int = 16) : AbstractQueue<E>() {
private var head = 0
override var size = 0