All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy