1
# Copyright 2011 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Interfaces for pillar and artifact access policies."""
11
'IAccessPolicyArtifact',
12
'IAccessPolicyArtifactSource',
14
'IAccessPolicySource',
17
from lazr.enum import (
21
from zope.interface import (
27
class AccessPolicyType(DBEnumeratedType):
28
"""Access policy type."""
30
PRIVATE = DBItem(1, """
33
This policy covers general private information.
36
SECURITY = DBItem(2, """
39
This policy covers information relating to confidential security
44
class IAccessPolicy(Interface):
46
pillar = Attribute("Pillar")
47
type = Attribute("Type")
50
class IAccessPolicyArtifact(Interface):
52
concrete_artifact = Attribute("Concrete artifact")
53
policy = Attribute("Access policy")
56
class IAccessPolicyGrant(Interface):
58
grantee = Attribute("Grantee")
59
grantor = Attribute("Grantor")
60
date_created = Attribute("Date created")
61
policy = Attribute("Access policy")
62
abstract_artifact = Attribute("Abstract artifact")
64
concrete_artifact = Attribute("Concrete artifact")
67
class IAccessPolicySource(Interface):
69
def create(pillar, display_name):
70
"""Create an `IAccessPolicy` for the pillar with the given name."""
73
"""Return the `IAccessPolicy` with the given ID."""
75
def getByPillarAndType(pillar, type):
76
"""Return the pillar's `IAccessPolicy` with the given type."""
78
def findByPillar(pillar):
79
"""Return a ResultSet of all `IAccessPolicy`s for the pillar."""
82
class IAccessPolicyArtifactSource(Interface):
84
def ensure(concrete_artifact):
85
"""Return the `IAccessPolicyArtifact` for a concrete artifact.
87
Creates the abstract artifact if it doesn't already exist.
90
def get(concrete_artifact):
91
"""Return the `IAccessPolicyArtifact` for an artifact, if it exists.
93
Use ensure() if you want to create one if it doesn't yet exist.
96
def delete(concrete_artifact):
97
"""Delete the `IAccessPolicyArtifact` for a concrete artifact.
99
Also removes any AccessPolicyGrants for the artifact.
103
class IAccessPolicyGrantSource(Interface):
105
def grant(grantee, grantor, object):
106
"""Create an `IAccessPolicyGrant`.
108
:param grantee: the `IPerson` to hold the access.
109
:param grantor: the `IPerson` that grants the access.
110
:param object: the `IAccessPolicy` or `IAccessPolicyArtifact` to
115
"""Return the `IAccessPolicyGrant` with the given ID."""
117
def findByPolicy(policy):
118
"""Return all `IAccessPolicyGrant` objects for the policy."""