class Tilia::DavAcl::Fs::HomeCollection

This collection contains a collection for every principal. It is similar to /home on many unix systems.

The per-user collections can only be accessed by the user who owns the collection.

Attributes

collection_name[RW]

Name of this collection.

@var string

storage_path[RW]

Path to where the users' files are actually stored.

@var string

Public Class Methods

new(principal_backend, storage_path, principal_prefix = 'principals') click to toggle source

Creates the home collection.

@param BackendInterface principal_backend @param string storage_path Where the actual files are stored. @param string principal_prefix list of principals to iterate.

# File lib/tilia/dav_acl/fs/home_collection.rb, line 33
def initialize(principal_backend, storage_path, principal_prefix = 'principals')
  @collection_name = 'home'
  super(principal_backend, principal_prefix)
  @storage_path = storage_path
end

Public Instance Methods

acl() click to toggle source

Returns a list of ACE's for this node.

Each ACE has the following properties:

* 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  currently the only supported privileges
* 'principal', a url to the principal who owns the node
* 'protected' (optional), indicating that this ACE is not allowed to
   be updated.

@return array

# File lib/tilia/dav_acl/fs/home_collection.rb, line 112
def acl
  [
    {
      'principal' => '{DAV:}authenticated',
      'privilege' => '{DAV:}read',
      'protected' => true
    }
  ]
end
acl=(_acl) click to toggle source

Updates the ACL

This method will receive a list of new ACE's as an array argument.

@param array acl @return void

# File lib/tilia/dav_acl/fs/home_collection.rb, line 128
def acl=(_acl)
  fail Dav::Exception::Forbidden, 'Setting ACL is not allowed here'
end
child_for_principal(principal_info) click to toggle source

Returns a principals' collection of files.

The passed array contains principal information, and is guaranteed to at least contain a uri item. Other properties may or may not be supplied by the authentication backend.

@param array principal_info @return void

# File lib/tilia/dav_acl/fs/home_collection.rb, line 56
def child_for_principal(principal_info)
  owner = principal_info['uri']
  acl = [
    {
      'privilege' => '{DAV:}read',
      'principal' => owner,
      'protected' => true
    },
    {
      'privilege' => '{DAV:}write',
      'principal' => owner,
      'protected' => true
    }
  ]

  principal_base_name = Uri.split(owner)[1]

  path = "#{@storage_path}/#{principal_base_name}"

  FileUtils.mkdir_p(path) unless ::File.directory?(path)

  Collection.new(
    path,
    acl,
    owner
  )
end
group() click to toggle source

Returns a group principal

This must be a url to a principal, or null if there's no owner

@return string|null

# File lib/tilia/dav_acl/fs/home_collection.rb, line 98
def group
  nil
end
name() click to toggle source

Returns the name of the node.

This is used to generate the url.

@return string

# File lib/tilia/dav_acl/fs/home_collection.rb, line 44
def name
  @collection_name
end
owner() click to toggle source

Returns the owner principal

This must be a url to a principal, or null if there's no owner

@return string|null

# File lib/tilia/dav_acl/fs/home_collection.rb, line 89
def owner
  nil
end
supported_privilege_set() click to toggle source

Returns the list of supported privileges for this node.

The returned data structure is a list of nested privileges. See Tilia::DavAcl::Plugin::getDefaultSupportedPrivilegeSet for a simple standard structure.

If null is returned from this method, the default privilege set is used, which is fine for most common usecases.

@return array|null

# File lib/tilia/dav_acl/fs/home_collection.rb, line 142
def supported_privilege_set
  nil
end