Spring Webgate 的安全性
Spring Security with webgate
我正在开发 spring MVC application.I 正在使用 Webgate 实施 spring 安全性。我正在关注 this 文章。当我实现与博客中相同的方法时,出现以下错误。
java.lang.IllegalStateException: 未找到方法: 未找到可以接受类型 class org.springframework.security.web.firewall.RequestWrapper
的单个参数的构造函数
我的buildDetails(-)代码是这样的
public Object buildDetails(Object context)
{
System.out.println("HeaderAuthenticationDetails:buildDetails::: "+context);
Object result = super.buildDetails(context); //getting error in super class
List<GrantedAuthority> userGas = new ArrayList<GrantedAuthority>();
if (result instanceof MutableGrantedAuthoritiesContainer) {
Collection<String> userRoles = getUserRoles(context, allRoles);
userGas = (List<GrantedAuthority>) grantedAuthoritiesMapper.getGrantedAuthorities(userRoles);
((MutableGrantedAuthoritiesContainer) result).setGrantedAuthorities(userGas);
}
return result;
}
我可以通过如下修改 buildDetails(-) 来解决问题
public Object buildDetails(Object context)
{
List<GrantedAuthority> userGas = new ArrayList<GrantedAuthority>();
MutableGrantedAuthoritiesContainer container=new PreAuthenticatedGrantedAuthoritiesAuthenticationDetails(context);
Collection<String> userRoles = getUserRoles(context, allRoles);
userGas = (List<GrantedAuthority>) grantedAuthoritiesMapper.getGrantedAuthorities(userRoles);
container.setGrantedAuthorities(userGas);
return container;
}
并在我的 getUserRoles(-,-) 方法
中请求 header 中不存在任何角色时添加了一个 "anonymous" 角色
我正在开发 spring MVC application.I 正在使用 Webgate 实施 spring 安全性。我正在关注 this 文章。当我实现与博客中相同的方法时,出现以下错误。
java.lang.IllegalStateException: 未找到方法: 未找到可以接受类型 class org.springframework.security.web.firewall.RequestWrapper
的单个参数的构造函数我的buildDetails(-)代码是这样的
public Object buildDetails(Object context)
{
System.out.println("HeaderAuthenticationDetails:buildDetails::: "+context);
Object result = super.buildDetails(context); //getting error in super class
List<GrantedAuthority> userGas = new ArrayList<GrantedAuthority>();
if (result instanceof MutableGrantedAuthoritiesContainer) {
Collection<String> userRoles = getUserRoles(context, allRoles);
userGas = (List<GrantedAuthority>) grantedAuthoritiesMapper.getGrantedAuthorities(userRoles);
((MutableGrantedAuthoritiesContainer) result).setGrantedAuthorities(userGas);
}
return result;
}
我可以通过如下修改 buildDetails(-) 来解决问题
public Object buildDetails(Object context)
{
List<GrantedAuthority> userGas = new ArrayList<GrantedAuthority>();
MutableGrantedAuthoritiesContainer container=new PreAuthenticatedGrantedAuthoritiesAuthenticationDetails(context);
Collection<String> userRoles = getUserRoles(context, allRoles);
userGas = (List<GrantedAuthority>) grantedAuthoritiesMapper.getGrantedAuthorities(userRoles);
container.setGrantedAuthorities(userGas);
return container;
}
并在我的 getUserRoles(-,-) 方法
中请求 header 中不存在任何角色时添加了一个 "anonymous" 角色