Groovy Documentation

org.grails.plugin.platform.security
[Groovy] Interface Security


interface Security

Bean for registering and accessing security information A security-provider plugin must be installed


Method Summary
java.util.Map createLink(java.lang.String action)

Create a link to the specified security action

java.lang.String getUserIdentity()

Get user id string i.e.

java.lang.Object getUserInfo()

Get user info object i.e. email address, other stuff defined by the security implementation

boolean hasProvider()

java.lang.Object ifUserHasRole(java.lang.Object role, groovy.lang.Closure code)

java.lang.Object ifUserIsAllowed(java.lang.Object object, java.lang.Object action, groovy.lang.Closure code)

Can the current user access this object to perform the named action?

java.lang.Object requirePermission(java.lang.Object object, java.lang.Object action, groovy.lang.Closure code)

Run the closure if userIsAllowed returns true for the object and action otherwise throw exception

boolean userExists(java.lang.Object identity)

Determine whether a user with the given id already exists or not

boolean userHasAllRoles(java.lang.Object roleOrRoles)

Test if the user has all the listed roles

boolean userHasAnyRole(java.lang.Object roleOrRoles)

Test if the user has any of the listed roles

boolean userIsAllowed(java.lang.Object object, java.lang.Object action)

Can the current user access this object to perform the named action?

java.lang.Object withUser(java.lang.Object identity, groovy.lang.Closure code)

Execute the closure pretending to be the user id specified

 

Method Detail

createLink

java.util.Map createLink(java.lang.String action)
Create a link to the specified security action
Parameters:
action - One of "login", "logout", "signup"
Returns:
Must return a Map of arguments to pass to g:link to create the link


getUserIdentity

java.lang.String getUserIdentity()
Get user id string i.e. "marcpalmer" of the currently logged in user, from whatever underlying security API is in force


getUserInfo

java.lang.Object getUserInfo()
Get user info object i.e. email address, other stuff defined by the security implementation
Returns:
An object of completely unknown type. Only for use if you know the security provider


hasProvider

boolean hasProvider()


ifUserHasRole

java.lang.Object ifUserHasRole(java.lang.Object role, groovy.lang.Closure code)


ifUserIsAllowed

java.lang.Object ifUserIsAllowed(java.lang.Object object, java.lang.Object action, groovy.lang.Closure code)
Can the current user access this object to perform the named action?
Parameters:
object - The object, typically domain but we don't care what
action - Some application-defined action string i.e. "view" or "edit"


requirePermission

java.lang.Object requirePermission(java.lang.Object object, java.lang.Object action, groovy.lang.Closure code)
Run the closure if userIsAllowed returns true for the object and action otherwise throw exception
throws:
NotPermittedException
Returns:
the return value of the closure


userExists

boolean userExists(java.lang.Object identity)
Determine whether a user with the given id already exists or not


userHasAllRoles

boolean userHasAllRoles(java.lang.Object roleOrRoles)
Test if the user has all the listed roles
Parameters:
roleOrRoles - A list of roles or a single role
Returns:
true if the user has all of the roles


userHasAnyRole

boolean userHasAnyRole(java.lang.Object roleOrRoles)
Test if the user has any of the listed roles
Parameters:
roleOrRoles - A list of roles or a single role
Returns:
true if the user has any of the roles


userIsAllowed

boolean userIsAllowed(java.lang.Object object, java.lang.Object action)
Can the current user access this object to perform the named action?
Parameters:
object - The object, typically domain but we don't care what
action - Some application-defined action string i.e. "view" or "edit"


withUser

java.lang.Object withUser(java.lang.Object identity, groovy.lang.Closure code)
Execute the closure pretending to be the user id specified


 

Groovy Documentation