Groovy Documentation

org.grails.plugin.platform.security
[Groovy] Class SecurityImpl

java.lang.Object
  org.grails.plugin.platform.security.SecurityImpl
All Implemented Interfaces:
Security, org.springframework.context.ApplicationContextAware

class SecurityImpl

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


Property Summary
org.springframework.context.ApplicationContext applicationContext

java.lang.Object grailsSecurityBridge

java.lang.Object injectedMethods

java.lang.Object log

 
Constructor Summary
SecurityImpl()

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

Create a link to the specified security action

SecurityBridge getSecurityBridge(boolean throwIfNone = false)

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

void setApplicationContext(org.springframework.context.ApplicationContext context)

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

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Property Detail

applicationContext

org.springframework.context.ApplicationContext applicationContext


grailsSecurityBridge

java.lang.Object grailsSecurityBridge


injectedMethods

java.lang.Object injectedMethods


log

final java.lang.Object log


 
Constructor Detail

SecurityImpl

SecurityImpl()


 
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


getSecurityBridge

SecurityBridge getSecurityBridge(boolean throwIfNone = false)


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


setApplicationContext

void setApplicationContext(org.springframework.context.ApplicationContext context)


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