com.infilos.auth.profile.context.ThreadLocalProfileContext Maven / Gradle / Ivy
The newest version!
package com.infilos.auth.profile.context;
import com.infilos.auth.profile.ProfileContext;
import com.infilos.auth.core.TokenProfile;
import org.springframework.util.Assert;
public final class ThreadLocalProfileContext implements ProfileContext {
private static final ThreadLocal contextHolder = new ThreadLocal<>();
@Override
public void clearProfile() {
contextHolder.remove();
}
@Override
public TokenProfile getProfile() {
return contextHolder.get();
}
@Override
public void setProfile(TokenProfile profile) {
Assert.notNull(profile, "Only non-null TokenProfile instances are permitted");
contextHolder.set(profile);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy