spring - 在 Spring 和 Vaadin 中使用 ViewAccessControl

标签 spring spring-security spring-boot vaadin vaadin4spring

我目前正在尝试使用 vaadin.spring 的 ViewAccessControl 接口(interface),如 this 的最后一段所述。教程。

但是在实现 isAccessGranted 方法时出现以下错误:

org.springframework.beans.factory.BeanCreationException:创建名称为“frontPageView”的bean时出错:范围“vaadin-view”对于当前线程不活动;如果您打算从单例中引用该 bean,请考虑为此 bean 定义一个作用域代理;嵌套异常是java.lang.IllegalStateException:没有事件 View

FrontPageView 类的声明(我在 Enter 方法中做的唯一一件事就是添加一些 vaadin ui 元素):

@SpringView(name = FrontPageView.NAME)
public class FrontPageView extends DashboardDesign implements View, ViewAccessControl {

    @Override
    public void enter(ViewChangeEvent event) {

    }

}

以及我的 isAccessGranted 方法的实现:

@Override
public boolean isAccessGranted(UI ui, String beanName) {
        return SecurityContextHolder.getContext().getAuthentication().isAuthenticated();
}

附注这基本上与这个人一年前遇到的问题相同:How to create a secure view with Vaadin and SpringViewProvider

最佳答案

好吧,我现在明白了。如果其他人发现此问题,解决方案是使用 ViewInstanceAccessControl 接口(interface)而不是 ViewAccessControl iterface。这样一切都正常。

关于spring - 在 Spring 和 Vaadin 中使用 ViewAccessControl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36750415/

相关文章:

java - 在 Tomcat 中部署 Spring Boot war

Spring 禁用单个类方法的事务

java - Spring MVC : Could not resolve placeholder in string value

grails - 如何根据拒绝访问的原因使Grails的Spring Security Core呈现不同的页面

spring-boot - @MockBean 不熟悉 testNG

java - Spring Controller 针对 404 状态和 url 模式的异常处理

在服务器上部署后,java spring web 应用程序不起作用

java - 如何使用 spring-ws 客户端使用不同的 keystore 调用同一个 webservice

java - 在 user-service-ref 中使用 jdbc-user-service

java - Spring Security 3 - 总是返回错误 302