com.codingapi.springboot.security.gateway.TokenContext Maven / Gradle / Ivy
package com.codingapi.springboot.security.gateway;
import org.springframework.security.core.context.SecurityContextHolder;
public class TokenContext {
private static final ThreadLocal threadLocal = new ThreadLocal<>();
private TokenContext() {
}
public static Token current() {
return (Token) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
}
public static void pushExtra(String extra){
threadLocal.set(extra);
}
public static String getExtra(){
return threadLocal.get();
}
}