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

no.nav.security.token.support.jaxrs.JaxrsTokenValidationContextHolder Maven / Gradle / Ivy

There is a newer version: 5.0.13
Show newest version
package no.nav.security.token.support.jaxrs;

import no.nav.security.token.support.core.context.TokenValidationContext;
import no.nav.security.token.support.core.context.TokenValidationContextHolder;

public class JaxrsTokenValidationContextHolder implements TokenValidationContextHolder {

    private static final TokenValidationContextHolder JWT_BEARER_TOKEN_CONTEXT_HOLDER = new JaxrsTokenValidationContextHolder();

    private JaxrsTokenValidationContextHolder() {}

    public static TokenValidationContextHolder getHolder() {
        return JWT_BEARER_TOKEN_CONTEXT_HOLDER;
    }

    private static final ThreadLocal validationContextHolder = new ThreadLocal<>();

    @Override
    public TokenValidationContext getTokenValidationContext() {
        return validationContextHolder.get();
    }

    @Override
    public void setTokenValidationContext(TokenValidationContext tokenValidationContext) {
        if(validationContextHolder.get() != null && tokenValidationContext != null) {
            throw new IllegalStateException("Should not overwrite the TokenValidationContext");
        }
        validationContextHolder.set(tokenValidationContext);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy