Created
April 16, 2020 22:17
-
-
Save virtualdogbert/35c97135a6a64ff6cb1362fc77a42c9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.security.enforcer | |
import com.security.Sprocket | |
import com.virtualdogbert.ast.* | |
import grails.gorm.transactions.Transactional | |
import grails.plugin.springsecurity.SpringSecurityService | |
@EnforcerTransactional | |
class EnforcerTestTService { | |
SpringSecurityService springSecurityService | |
@Transactional | |
Sprocket createSprocket() { | |
springSecurityService.currentUser | |
Sprocket sprocket = new Sprocket( | |
material: 'metal', | |
creator: springSecurityService.currentUser | |
) | |
sprocket.save() | |
} | |
@EnforceT({ isCreator(sprocket) }) | |
Sprocket updateSprocket(Sprocket sprocket) { | |
sprocket.material = 'plastic' | |
sprocket.save() | |
} | |
@EnforceTS({ isCreator(sprocket) }) | |
Sprocket updateSprocketCompileStatic(Sprocket sprocket) { | |
sprocket.material = 'plastic' | |
(Sprocket) sprocket.save() | |
} | |
@Enforce({ isCreator(sprocket) }) | |
Sprocket getSprocket(Sprocket sprocket) { | |
return sprocket | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment