Skip to content

Instantly share code, notes, and snippets.

@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
public HttpSessionStrategy httpSessionStrategy() {
return new HeaderHttpSessionStrategy();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
@RestController
@RequestMapping("/api")
public class Controller {
@RequestMapping(value = "/resource", method = RequestMethod.GET)
public Map<String, String> getResource() {
Map<String, String> resource = new HashMap<String, String>();
resource.put("resource", "here is some resource");
return resource;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers(HttpMethod.OPTIONS, "/api/resource").permitAll()
.anyRequest().authenticated()
.and()
.requestCache()
.requestCache(new NullRequestCache())
.and()
public class LogInterceptor extends TurboFilter {
@Override
public FilterReply decide(Marker marker, Logger logger, Level level, String s, Object[] objects, Throwable throwable) {
boolean logChanged = false;
if (objects != null) {
for (int i = 0; i < objects.length; i++) {
if (objects[i] instanceof String) {
String str = (String) objects[i];
<configuration>
<turboFilter class="filters.LogInterceptor" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%-4relative [%thread] %-5level %logger - %msg%n
</pattern>
</encoder>
</appender>
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
public HttpSessionStrategy httpSessionStrategy() {
return new HeaderHttpSessionStrategy();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
[
{
"timestamp":1503137711145,
"info":{
"method":"GET",
"path":"/actuator",
"headers":{
"request":{
"host":"localhost:8080",
"connection":"keep-alive",
@Component
public class RequestTraceFilter extends WebRequestTraceFilter {
private final String[] excludedEndpoints = new String[]{"/css/**", "/js/**", "/trace"};
RequestTraceFilter(TraceRepository repository, TraceProperties properties) {
super(repository, properties);
}
@Override
@Repository
public class CustomTraceRepository extends InMemoryTraceRepository {
private static final Logger log = LoggerFactory.getLogger(CustomTraceRepository.class);
public CustomTraceRepository() {
super.setCapacity(200);
}
@Override
import kotlinx.coroutines.experimental.TimeoutCancellationException
import kotlinx.coroutines.experimental.async
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.experimental.withTimeout
import kotlin.system.measureTimeMillis
// lightweight replacement for spring retry
suspend fun <T> retry(maxRetryCount: Int = 5, timeout: Long = 3000, block: suspend (retryCount: Int) -> T): T {
for (i in 1..maxRetryCount) {