2012-08-13 67 views
1

我已經有了使用vaadin和spring安全核心插件的grails,但是不能把三者結合起來。如果我轉到一個使用@Secured的頁面,它的工作原理與之相同。但是如果我把@Secured放在我的vaadin應用程序類中,它什麼都不會做。我期望做的是保護整個vaadin應用程序,然後在該應用程序中爲某些更高權限角色保護一些內容。我在這裏做錯了什麼?如果任何人都能指引我走向正確的方向,那就太棒了。謝謝!Grails,Vaadin和Spring Security Plugin在一起

回答

0

您是否嘗試過在Config.groovy中設置URL映射?

@ Secured註解將用於grails控制器類。

1

查看this post - 他將要保護的方法放入Grails服務類中,註釋工作正常,並從vaadin應用程序調用服務方法。

(要知道,靠依賴注入在vaadin應用不推薦,看的getBean(字符串beanName)的getBean(類beanType)在plugin docs

0

您需要使用Grails服務到您的Vaadin應用程序。 使用Vaadin插件,聲明你的服務在您的用戶界面或任何Vaadin組件,例如:

import com.vaadin.grails.Grails 
import com.company.app.SecurityService 

class <YourComponent> extends CustomComponent implements View { 

def securityService = Grails.get(SecurityService) 
... 
<use securityService in your component's methods> 

} 

在名爲「securityService」你的Grails服務,絲springSecurityService,並使用彈簧安全的Grails插件提供的註釋或任何東西。此外,感謝Grails goodn ess,服務已經是事務性的。

@Transactional 
class SecurityService { 

    def springSecurityService 

    def signOut() { 
     SCH.context.authentication = null 
    } 

    boolean isSignedIn() { 
     return springSecurityService.isLoggedIn() 
    } 

    User getCurrentUser() { 
     return springSecurityService.currentUser 
    } 

......或任何安全問題。

相關問題