我剛剛開始使用Grails,並試圖配置spring-security-acl插件。我一直在關注official plugin tutorial,但是在試圖運行我的應用程序時,我無法超越Bootstrapping階段(使用Position
域級而不是Report
級,我的大部分問題都包含在應用程序的ACL部分中)如何在Spring-Security-Acl中創建ACL
我無法讓過去的問題是在Bootstrap.groovy
的grantPermissions()
功能每本教程的說明,通過功能開始了這樣的:
private void grantPermissions() {
def positions = []
100.times {
long id = it + 1
def position = new Position(title: "position$id").save()
positions << position
aclService.createAcl(
objectIdentityRetrievalStrategy.getObjectIdentity(position))
}
的IntelliJ警告我就aclService.createAcl
線,它「無法推斷這種檢查報告的類型不兼容。「確實如果我嘗試無論如何運行應用程序,它在該行與崩潰崩潰:
| Error 2013-03-09 09:35:24,207 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Cannot get property 'id' on null object
Message: Cannot get property 'id' on null object
Line | Method
->> 68 | doCall in BootStrap$_grantPermissions_closure4
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 63 | grantPermissions in BootStrap
| 29 | doCall . . . . . . . . . . . . . in BootStrap$_closure1
...
任何幫助將不勝感激!
附錄
在如此重要的情況下,我Position
域對象是這樣的:
class Position {
String title
Boolean draft
static constraints = {
}
}
我不認爲這個問題是有關聯的,但它是一個ACL與教程相關的偏差,所以爲了後代的緣故...我已經解決的第一個問題(我認爲)是在PositionService.groovy中,我在代碼塊中得到了IntelliJ中的錯誤:
def acl = aclUtilService.readAcl(position)
// Remove all permissions associated with this particular
// recipient (string equality to KISS)
acl.entries.eachWithIndex { entry, i ->
if (entry.sid.equals(position) &&
entry.permission.equals(permission)) {
acl.deleteAce i
}
}
看起來像這個問題無法找到通用acl
對象上的功能deleteAce
;我能夠通過指定類型MutableAcl
在
MutableAcl acl = aclUtilService.readAcl(position)
你使它看起來那麼容易......太感謝了! – 2013-03-09 16:02:55