Class

de.ceow.security.acl

Acl

Related Doc: package acl

Permalink

case class Acl(roles: List[Role], user: Identity) extends AllowLike with Product with Serializable

Acl Component using roles and identities to check if a resource/privilege is allowed for the current defined identity.

Usage: new Acl(List[de.ceow.security.acl.Role](role1, role2), user) This identity and it's containing roles will be used for allowed checks

How it works: the roleRegistry is used to store all defined roles and to map the identity-roles to a role object. The identity itself will store only integer values as bits (1,2,4,8 ...) which maps to the role identifier.

Example: Role1.id=1, Role2.id=2 ... Role4.id=8 Identity:roles = 11 means List(Role1, Role2, Role8)

While adding a identity, the mapping will check if there is a role defined, generates a new unique GenericRole which inherits from all mapped Roles.

Resource: Resources have to be objects / case classes. It's more used like a type

Privilege: Privileges are also just types as resources are

Assert: An assert is a class with an apply method which receive "Option[AclObject]" as it's first parameter and the current acl object as it's second argument. The return value is always a boolean. This type or assertion can be used to decide on "AclObject" if the resource/privilege is allowed or not.

Example: Lets say you have a site which have a company profile and related employees (Identities). Companies and Employees are in relation and you want to allow some employees to change things on your company profile page. So some employees will have a flag (canEditCompany). Your assert can now receive the company entity and you can check if the user is related to the company and is allowed to edit.

Roles: A role defines the rule definition???? and the resources, privileges and asserts. You can reduce it to just resources when you want to allow every privilege in this resource (helpful for admins).

Mapping example: val rules = Map( Resource -> Map() <- allowed all privileges Resource2 -> Map( Privilege1 -> Seq(), <- no assertions Privilege2 -> Seq((value: Option[AclObject], acl: Acl) => true|false) ) )

Let's see some implementations

Examples: Acl.isAllowed(Resource, Privilege) Acl.isAllowed(Resource, Privilege, Some(Foo))

Linear Supertypes
Serializable, Serializable, Product, Equals, AllowLike, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Acl
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AllowLike
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Acl(roles: List[Role], user: Identity)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def allowed(role: Role, resource: Resource, privilege: Privilege, objectToCheck: Option[AclObject]): Boolean

    Permalink

    internal, recursive check method.

    internal, recursive check method. 1. check if a resource is allowed including all privileges 2. check if a resource is allowed for given privilege 3. check all inheritance roles by using recursion

    Attributes
    protected
  5. def allows(v: AclObject)(implicit acl: Acl): AllowObject

    Permalink

    allows for acl object

    allows for acl object

    v

    AclObject

    acl

    the acl instance

  6. def allows(p: Privilege)(implicit acl: Acl): AllowResource

    Permalink

    allow like for privilege to check for

    allow like for privilege to check for

    p

    the privilege

    acl

    the acl instance

    Definition Classes
    AclAllowLike
  7. def allows(r: Resource)(implicit acl: Acl): AllowPrivilege

    Permalink

    allow like for acl instance to check for resource

    allow like for acl instance to check for resource

    r

    the resource

    acl

    the acl instance

    Definition Classes
    AclAllowLike
  8. def applyRules(roles: List[Role]): Map[String, Seq[Assert]]

    Permalink

    apply the rule definition from a role to a easy understandable format for the acl to check against

    apply the rule definition from a role to a easy understandable format for the acl to check against

    Attributes
    protected
  9. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  10. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. def createHash(role: Role, r: Resource, p: Privilege): String

    Permalink

    creates a hash value by give role, resource and privilege RoleName/ResourceName/PrivilegeName RoleName/ResourceName/\* for allowing all privileges in this resource

    creates a hash value by give role, resource and privilege RoleName/ResourceName/PrivilegeName RoleName/ResourceName/\* for allowing all privileges in this resource

    Attributes
    protected
  12. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. def generateGenericRole(user: Identity): Role

    Permalink

    create the custom role for the current user

    create the custom role for the current user

    Attributes
    protected
  15. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  16. def isAllowed(r: Resource, p: Privilege, o: Option[AclObject] = None): Boolean

    Permalink

    check methods if a resource and a privilege is allowed by itself or with object

  17. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  18. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  19. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. def observerEntity: Identity

    Permalink

    the observer (Identity)

  22. lazy val observerRole: Role

    Permalink

    the role of the observer itself

  23. lazy val roleRegistry: List[Role]

    Permalink

    available roles

  24. val roles: List[Role]

    Permalink
  25. lazy val rules: Map[String, Seq[Assert]]

    Permalink

    rule definitions

  26. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  27. val user: Identity

    Permalink
  28. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AllowLike

Inherited from AnyRef

Inherited from Any

Ungrouped