<?xml version="1.0"?>

<!--Policy in the EPAL language For the Sharing With Partners Privacy Systems Example.-->

<epal-policy default-ruling="deny" 
 version="1.2" xmlns="http://www.research.ibm.com/privacy/epal" 
 xmlns:xs="http://www.w3.org/2001/XMLSchema" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:schemaLocation="http://www.research.ibm.com/privacy/epal epal.xsd 
 http://www.w3.org/2001/XMLSchema xs-dummy.xsd ">
  <policy-information id="SWP-Policy">
    <short-description language="en">Policy that enforces the rules of a Sharing With Partners Privacy System.  It accomplishes this
        by using the Direct Time Limited Permissions vocabulary and just ignoring the time attributes.</short-description>

    <issuer>
      <name>Penn Security Lab</name>
      <organization>University of Pennsylvania</organization>
      <e-mail>mjmay@seas.upenn.edu</e-mail>
      <address>200 South 33rd Street, Philadelphia, PA 19104</address>
      <country>USA</country>
    </issuer>

    <location>http://securitylab.cis.upenn.edu/pdrm</location>
    <version-info end-date="2005-07-26T12:00:00"
       last-modified="2004-08-11T13:19:00" 
       start-date="2004-07-26T12:19:00" test="true"/>
  </policy-information>

  <epal-vocabulary-ref id="DTLP-Vocab" location="http://securitylab.cis.upenn.edu/pdrm/"/>

  <!--Conditions for the privacy system-->
  <condition id="HasDirPermission">
    <short-description language="en">Checks that the requesting principal has direct permission set</short-description>

    <!--Permission is set to direct permission-->
    <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
       <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
           <attribute-reference container-refid="PrincipalPermissions" attribute-refid="Sigma"/>
       </function> 
       <attribute-value simpleType="http://www.w3.org/2001/XMLSchema#string">dir</attribute-value>
    </predicate>
   </condition>

   <condition id="HasIndirPermission">
      <short-description language="en">Checks that the requesting principal has indirect permission set</short-description>
   
    <!--Permission is set to indirect permission-->
    <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
       <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
           <attribute-reference container-refid="PrincipalPermissions" attribute-refid="Sigma"/>
       </function> 
       <attribute-value simpleType="http://www.w3.org/2001/XMLSchema#string">indir</attribute-value>
    </predicate>
   </condition>      

    <!--If the event is a Transfer event:  If we are in case 1, where the receiver has direct permission
        (a) The receiver must have direct permission
        (b) The object being transfered must be about the subject of the direct permission
        (c) The name of the receiver must match the name of the permission-->
   <condition id="PublishSubscribeEventCondition">
      <short-description language="en">The conditions that must be true particularly for a publish subscribe event</short-description>

      <!--AND-ing all the conditions below together-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#and">

      <!--Checking that the receiver has direct permission.  This is done again because the PrincipalPermissions
         check in the normal direct permissions check is ambiguous about whose permission is being checked.-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
         <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
             <attribute-reference container-reference="TransferPermissions" attribute-refid="SubscriberSigma"/>
         </function>
         <attribute-value simpleType="http://www.w3.org/2001/XMLSchema#string">dir</attribute-value>
      </predicate>

      <!--Checking the name of the subject in the permission against the name of the subject of the item being transfered-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="PublishSubscribeEvent" attribute-refid="Subject"/>
          </function> 
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="TransferPermissions" attribute-refid="Subject"/>
          </function>
      </predicate>

      <!--Checking the name of the receiver in the permission against the name of the receiver in the permission-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="PublishSubscribeEvent" attribute-refid="Subscriber"/>
          </function> 
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="TransferPermissions" attribute-refid="Subscriber"/>
          </function>
      </predicate>

      </predicate>
   </condition>

    <!--If the event is a Transfer event:  If we are in case 2, where the receiver has indirect permission and the publisher has direct permission
        (a) The publisher must have direct permission
        (b) The subscriber must have indirect permission
        (c) The object being transfered must be about the subject of the direct permission
        (d) The name of the receiver must match the name of the permission
        (e) The name of the publisher must match the name of the permission-->
   <condition id="PublishSubscribeIndirectEventCondition">
      <short-description language="en">The conditions that must be true particularly for a publish subscribe event when the
         subscriber has only indirect permission</short-description>

      <!--AND-ing all the conditions below together-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#and">

      <!--Checking that the publisher has direct permission.  This is done again because the PrincipalPermissions
         check in the normal direct permissions check is ambiguous about whose permission is being checked.-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
         <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
             <attribute-reference container-reference="TransferPermissions" attribute-refid="PublisherSigma"/>
         </function>
         <attribute-value simpleType="http://www.w3.org/2001/XMLSchema#string">dir</attribute-value>
      </predicate>

      <!--Checking that the subscriber has indirect permission.-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
         <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
             <attribute-reference container-reference="TransferPermissions" attribute-refid="SubscriberSigma"/>
         </function>
         <attribute-value simpleType="http://www.w3.org/2001/XMLSchema#string">indir</attribute-value>
      </predicate>

      <!--Checking the name of the subject in the permission against the name of the subject of the item being transfered-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="PublishSubscribeEvent" attribute-refid="Subject"/>
          </function> 
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="TransferPermissions" attribute-refid="Subject"/>
          </function>
      </predicate>

      <!--Checking the name of the subscriber in the permission against the name of the receiver in the permission-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="PublishSubscribeEvent" attribute-refid="Subscriber"/>
          </function> 
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="TransferPermissions" attribute-refid="Subscriber"/>
          </function>
      </predicate>

      <!--Checking the name of the publisher in the permission against the name of the receiver in the permission-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="PublishSubscribeEvent" attribute-refid="Publisher"/>
          </function> 
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="TransferPermissions" attribute-refid="Publisher"/>
          </function>
      </predicate>

      </predicate>
   </condition>


   <!--If the event is a Action event:
       (Direct and Indirect Permissions will be handled using the AllowedIndirAction and HasDirPermission and HasIndirPermission conditions)
       (a) The name of the subject must match the name of the permission
       (b) The name of the actor must match the name of the permission-->
   <condition id="ActionEventCondition">
     <short-description language="en">The conditions that need to be checked for an Action event to proceed</short-description>

      <!--AND-ing all the conditions below together-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#and">

      <!--Checking the name of the subject in the permission against the name of the subject of the action-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="ActionEvent" attribute-refid="Subject"/>
          </function> 
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="PrincipalPermissions" attribute-refid="Subject"/>
          </function>
      </predicate>

      <!--Checking the name of the owner in the permission against the name of the actor in the permission-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="ActionEvent" attribute-refid="Actor"/>
          </function> 
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="PrincipalPermissions" attribute-refid="Owner"/>
          </function>
      </predicate>

      </predicate>
   </condition>

   <!--Checking that the action is in the set A_indir-->
   <condition id="AllowedIndirAction">
      <short-description language="en">Checks that the action proposed in an Action Event is part of the set A_indir</short-description>

      <predicate refid="http://www.research.ibm.com/privacy/epal#string-at-least-one-value-equal">
          <attribute-reference container-refid="ActionEvent" attribute-refid="Action"/>
          <attribute-reference container-refid="A_indir" attribute-refid="ActionID"/>
      </predicate>
   </condition>
 
   <!--If the event is a Creation event:
       (a) The creator must have direct permission
       (b) The name of the subject must match the name of the permission
       (c) The name of the creator must match the name of the permission-->
   <condition id="CreationEventCondition">
     <short-description language="en">Conditions necessary for the execution of a Creation event</short-description>

      <!--AND-ing all the conditions below together-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#and">

      <!--Checking the name of the subject in the permission against the name of the subject of the action-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="CreationEvent" attribute-refid="Subject"/>
          </function> 
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="PrincipalPermissions" attribute-refid="Subject"/>
          </function>
      </predicate>

      <!--Checking the name of the owner in the permission against the name of the creator in the permission-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="CreationEvent" attribute-refid="Creator"/>
          </function> 
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="PrincipalPermissions" attribute-refid="Owner"/>
          </function>
      </predicate>

      </predicate>
   </condition>

   <!--Check if the actor in a set policy event is the subject herself-->
       (a) The establisher must be the subject of the permissions-->
   <condition id="SetterIsSubjectCondition">
      <short-description language="en">Checks if the one setting policy in a Set Policy Event is the subject</short-description>

      <!--Checking the name of the establisher in the permission against the name of the subject of the set policy action-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="SetPolicyEvent" attribute-refid="Setter"/>
          </function> 
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="SetPolicyEvent" attribute-refid="Subject"/>
          </function>
      </predicate>
   </condition>

  <!--If the event is a Set Policy Event and the setter is not the subject:
      (a) The setter must have direct permission
      (b) The recipient must be a partner of the setter
      (c) The recipient must receive only indirect permission
      (d) The name of the subject must match the name in the permission
      (e) The name of the setter must match the name in the permission
      (f) The name of the recipient must match the name in the permission-->
  <condition id="OusiderSetPolicyEventCondition">
     <short-description language="en">Checks two conditions on the set policy event for the case where an outsider is setting policy for the subject</short-description>

     <!--AND-ing the all the conditions below together-->
     <predicate refid="http://www.research.ibm.com/privacy/epal#and">

      <!--Checking that the setter has direct permission.  This is done again because the PrincipalPermissions
         check in the normal direct permissions check is ambiguous about whose permission is being checked.-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
         <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
             <attribute-reference container-reference="SetPolicyPermissions" attribute-refid="SetterSigma"/>
         </function>
         <attribute-value simpleType="http://www.w3.org/2001/XMLSchema#string">dir</attribute-value>
      </predicate>

      <!--Checking that the subscriber is a partner of the setter-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-at-least-one-value-equal">
         <attribute-reference container-reference="SetPolicyEvent" attribute-refid="Recipient"/>
         <attribute-reference container-reference="Partners" attribute-refid="Name"/>         
      </predicate>

      <!--Checking that the recipient is getting only indirect permission-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
         <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
             <attribute-reference container-reference="SetPolicyEvent" attribute-refid="Sigma"/>
         </function>
         <attribute-value simpleType="http://www.w3.org/2001/XMLSchema#string">indir</attribute-value>
      </predicate>      

      <!--Checking the name of the subject in the permission against the name of the subject of the item being transfered-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="SetPolicyEvent" attribute-refid="Subject"/>
          </function> 
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="SetPolicyPermissions" attribute-refid="Subject"/>
          </function>
      </predicate>

      <!--Checking the name of the setter in the permission against the name of the receiver in the permission-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="SetPolicyEvent" attribute-refid="Setter"/>
          </function> 
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="SetPolicyPermissions" attribute-refid="Setter"/>
          </function>
      </predicate>

      <!--Checking the name of the recipient in the permission against the name of the receiver in the permission-->
      <predicate refid="http://www.research.ibm.com/privacy/epal#string-equal">
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="SetPolicyEvent" attribute-refid="Recipient"/>
          </function> 
          <function refid="http://www.research.ibm.com/privacy/epal#string-bag-to-value">
              <attribute-reference container-refid="SetPolicyPermissions" attribute-refid="Recipient"/>
          </function>
      </predicate>

      </predicate>
  </condition>

  <!--Rules for the sharing with partners example-->

  <!--Publish/Subscribe event rules-->
  <rule id="PublishSubscribeDirectRule" ruling="allow">
      <short-description language="en">Allows transfer of data provided that the receiver
        has direct permission and that the other conditions in the Publish/Subscribe event
        are met</short-description>

      <user-category refid="AnyUser"/>
      <data-category refid="AnyCategory"/>
      <purpose refid="AnyPurpose"/>
      <action refid="PublishSubscribe"/>
      <condition refid="PublishSubscribeEventCondition"/>
      <condition refid="HasDirPermission"/>
  </rule>

  <rule id="PublishSubscribeIndirectRule" ruling="allow">
      <short-description language="en">Allows transfer of data provided that the receiver
        has indirect permission, the publisher has direct permission, and that the other
        conditions in the Publish/Subscribe event are met</short-description>

      <user-category refid="AnyUser"/>
      <data-category refid="AnyCategory"/>
      <purpose refid="AnyPurpose"/>
      <action refid="PublishSubscribe"/>
      <condition refid="PublishSubscribeIndirectEventCondition"/>
      <condition refid="HasIndirPermission"/>
  </rule>

  <!--Action event rules-->
  <rule id="ActionRule" ruling="allow">
      <short-description language="en">Allows all actions from one principal on a subject provided
         that the actor has direct permission to do so and that the other conditions in the
         Action event are met</short-description>

      <user-category refid="AnyUser"/>
      <data-category refid="AnyCategory"/>
      <purpose refid="AnyPurpose"/>
      <action refid="Action"/>
      <condition refid="ActionEventCondition"/>
      <condition refid="HasDirPermission"/>
  </rule>

  <rule id="ActionPartnerRule" ruling="allow">
      <short-description language="en">Allows restricted actions from one principal on a subject provided
         that the actor has indirect permission to do so, the action is in the allowed set of actions by partners,
         and that the other conditions in the Action event are met</short-description>

      <user-category refid="AnyUser"/>
      <data-category refid="AnyCategory"/>
      <purpose refid="AnyPurpose"/>
      <action refid="Action"/>
      <condition refid="ActionEventCondition"/>
      <condition refid="HasIndirPermission"/>
      <condition refid="AllowedIndirAction"/>
  </rule>

  <!--Creation event rule-->
  <rule id="CreationRule" ruling="allow">
      <short-description language="en">Allows creation of data about a subject provided that the 
         creator has direct permission and that the other conditions in the Publish/Subscribe
         event are met</short-description>

      <user-category refid="AnyUser"/>
      <data-category refid="AnyCategory"/>
      <purpose refid="AnyPurpose"/>
      <action refid="Creation"/>
      <condition refid="CreationEventCondition"/>
      <condition refid="HasDirPermission"/>
  </rule>

  <!--Set Policy event rule-->
  <rule id="SubjectSetPolicyRule" ruling="allow">
      <short-description language="en">Allows a subject to grant direct permission to anybody.  No one else may grant this right.</short-description>

      <user-category refid="AnyUser"/>
      <data-category refid="AnyCategory"/>
      <purpose refid="AnyPurpose"/>
      <action refid="SetPolicy"/>
      <condition refid="SetterIsSubjectCondition"/>
  </rule>

  <rule id="SetPolicyRule" ruling="allow">
      <short-description language="en">Allows a principal with direct permission to grant indirect permission to partners.</short-description>

      <user-category refid="AnyUser"/>
      <data-category refid="AnyCategory"/>
      <purpose refid="AnyPurpose"/>
      <action refid="SetPolicy"/>
      <condition refid="OutsiderSetPolicyEventCondition"/>
      <condition refid="HasDirPermission"/>
  </rule>

</epal-policy><!--  LocalWords:  AnyUser AnyCategory AnyPurpose www refid EPAL
 -->
<!--  LocalWords:  PublishSubscribeEvent PublishSubscribeEventCondition xmlns
 -->
<!--  LocalWords:  HasDirPermission http schemaLocation simpleType epal ibm
 -->
<!--  LocalWords:  TransferPermissions SubscriberSigma XMLSchema
 -->
<!--  LocalWords:  HasIndirPermission PublishSubscribeIndirectEventCondition
 -->
