通过 SecurityContextHolder 可以得知,SecurityContextHolderStrategy 接口用来定义存储策略方法
public interface SecurityContextHolderStrategy {
void clearContext();
SecurityContext getContext();
void setContext(SecurityContext context);
SecurityContext createEmptyContext();
}
接口中一共定义了四个方法:
-
clearContext
:该方法用来清除存储的 SecurityContext对象。 -
getContext
:该方法用来获取存储的 SecurityContext 对象。 -
setContext
:该方法用来设置存储的 SecurityContext 对象。 -
create Empty Context
:该方法则用来创建一个空的 SecurityContext 对象。
从上面可以看出每一个实现类对应一种策略的实现。