我正在研究 Spring Security 的不同类实现。我知道我们将Authentication对象设置为SecurityContext ThreadLocal 对象,如下所示:
UsernamePasswordAuthenticationToken upat = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
upat.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
SecurityContextHolder.getContext().setAuthentication(upat);
Run Code Online (Sandbox Code Playgroud)
因此,基本上每个线程都有一个单独的 SecurityContext ThreadLocal 对象副本,它保存该线程的 Authentication 对象。到这里就好了。我也在我的 SecurityConfiguration 中将 SessionCreationPolicy 设置为 Stateless。以下是安全配置:
@Override
protected void configure(HttpSecurity http) throws Exception
{
final CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOriginPattern("*");
config.addAllowedHeader("*");
config.addAllowedMethod("*");
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
final CorsConfigurer<HttpSecurity> cors = http.csrf().disable().cors().configurationSource(source);
final ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry exp =
cors.and().authorizeRequests();
exp.antMatchers("/getJWTToken/**").permitAll()
.antMatchers("/actuator/**").permitAll()
.antMatchers("/rest/**").authenticated();
exp.and().exceptionHandling()
.authenticationEntryPoint(authEntryPoint())
.and().sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
;
// Add a filter to validate …Run Code Online (Sandbox Code Playgroud) Spring Security 的基础知识是什么,即 Spring 如何在内部设置安全性。为 Spring Security 提供开箱即用的所有 bean 有哪些?
最近我犯了一个错误,即我的 oracle 数据库中的所有表都被删除(从 SQL Developer 工具运行 drop 命令)在我不知道我在错误的数据库中删除表的所有事务序列中。每次删除一组表时,我都会提交操作。到时候,我意识到我已经删除了错误数据库中的表,我来不及回滚,因为它只回滚了最后一个操作。我也在网上搜索,发现SavePoints是解决方案,但我没有配置savepoints。我在 2 天前备份了所有表,因此,我从那里运行脚本并在过去 2 天内进行了丢失的更改。有没有其他方法可以让我的数据库状态恢复。不过,我已经习惯于在执行此类操作时创建保存点。但是,我仍然很困惑。
database-administration rollback oracle11g savepoints oracle-sqldeveloper
我浏览了许多帖子,但似乎都回答了接口的静态方法存储在哪里。但是,接口可以具有抽象、静态和默认方法。我知道静态和抽象方法。但是,我无法在内存中找到与默认方法存储相关的任何内容。
我可能错了,但我认为默认方法将存储在静态堆空间中,就像实例方法与类一起存储一样。但是,除此之外,考虑到实现类不会覆盖接口中默认方法的实现并且没有菱形问题,如果默认方法也被分配给堆栈帧,我也很困惑。
我参考了以下链接:
java ×3
spring ×2
spring-boot ×2
java-8 ×1
jvm ×1
oracle11g ×1
rollback ×1
savepoints ×1
spring-mvc ×1