示例#1
0
 public function exception()
 {
     if ($this->fails()) {
         $exception = $this->policy->getDefaultExceptionClass();
         throw new $exception($this->policy->getError());
     }
 }
 public function testRelationSaving()
 {
     $p = new Policy();
     $p->policy_number = '123';
     $a = new PolicyAsset();
     $a->value = '123.13';
     $p->PolicyAssets[] = $a;
     $p->save();
     $this->assertEqual($a->policy_number, '123');
 }
示例#3
0
 public function showWelcome()
 {
     if (Auth::getUser()->grp_id == 1) {
         //return View::make('layouts.admin');
         return Redirect::to('policy-content');
     } else {
         $policy = new Policy();
         $per_page = Config::get('nhc/site.policy_perpage');
         $user_policy = Policy::getPolicyByUserId();
         $all_policy = $policy->getAllPolicy($per_page);
         return View::make('welcome')->with('relate_policy', $user_policy)->with('paginator', $all_policy);
     }
 }
示例#4
0
 /**
  * [queryFrmAction show form query data by use ajax]
  * @return [type] [description]
  */
 public function queryFrmAction()
 {
     //$rs_data = QueryData::getDataType();//Get datatype only its exist in raw data
     // $user_id =  Auth::getUser()->id;
     // $role_obj = new RoleUser();
     // $role_id = $role_obj->getRoleById($user_id);
     // $role_policy_ojb = new RolePolicy();
     // $policy_id = $role_policy_ojb->getPolicyByRoleId($role_id->role_id);
     // var_dump($this->policy_id);exit;
     $data_privacy_obj = new DataPrivacy();
     $rs_data_privacy = $data_privacy_obj->getDataByPolicyId($this->policy_id);
     // var_dump($role_id->role_id);
     // var_dump($policy_id);
     // var_dump($rs_data_privacy);
     //exit;
     // $arr_dataid = DataPrivacy::getData();// Get datatype all privacy data is on and relate with policy assigned
     // $rs_data = Data::getDataInfo($arr_dataid);
     $all_agency = Agency::all();
     $relate_policy = Policy::getPolicyByUserId();
     //$relate_condition = QueryData::getCondtionType();
     $query_obj = new QueryData();
     $relate_condition = $query_obj->getCondtionTypeV2($this->policy_id);
     // var_dump($relate_condition);exit;
     return View::make('querydata.data')->with('all_data', $rs_data_privacy)->with('all_agency', $all_agency)->with('relate_policy', $relate_policy)->with('relate_condition', $relate_condition);
 }
示例#5
0
function logprint($conn)
{
    $policys = Policy::get_list($conn, "order by policy.order");
    foreach ($policys as $p) {
        echo "&nbsp;policy: order:" . $p->get_order() . " group:" . $p->get_group() . "<br>";
    }
}
示例#6
0
文件: Policy.php 项目: vberzsin/2014
 public static function getInstance()
 {
     if (null == self::$instance) {
         self::$instance = new Policy();
     }
     return self::$instance;
 }
示例#7
0
 public function showLoginfrm()
 {
     //print App::environment();exit;
     if (Auth::check()) {
         if (Auth::getUser()->grp_id == 1) {
             //return View::make('layouts.admin');
             return Redirect::to('policy-content');
         } else {
             $policy = new Policy();
             $per_page = Config::get('nhc/site.policy_perpage');
             //var_dump($policy->getAllPolicy($per_page)->toArray());exit;
             return View::make('welcome')->with('relate_policy', Policy::getPolicyByUserId())->with('paginator', $policy->getAllPolicy($per_page));
         }
     }
     return View::make('login');
 }
示例#8
0
 public function ckeckPolicyDuplicate($strlen_policy)
 {
     $pol = Policy::select(DB::raw(' count(*)'))->where(DB::raw("length(policy_content)"), '=', $strlen_policy)->get();
     $rs = $pol[0]['count'];
     if (isset($rs)) {
         return $rs >= 1 ? false : true;
     }
 }
 public static function generate($input)
 {
     $res = [];
     $plan = Plan::findOrFail($input['plan_id']);
     $voucher['expires_on'] = self::_makeExpiry($input['validity'], $input['validity_unit']);
     $voucher['created_at'] = time();
     $voucher['plan_name'] = $plan->name;
     $voucher['plan_type'] = $plan->plan_type;
     $voucher['sim_sessions'] = $plan->sim_sessions;
     $voucher['interim_updates'] = $plan->interim_updates;
     $voucher['price'] = $plan->price;
     $voucher['validity'] = $plan->validity;
     $voucher['validity_unit'] = $plan->validity_unit;
     $voucher['policy_type'] = $plan->policy_type;
     if ($plan->plan_type == 1) {
         //if limited
         $limit = $plan->limit->toArray();
         if ($plan->limit->aq_access == 1) {
             // $limit['aq_access'] = 1;
             $aq_policy = Policy::findOrFail($plan->limit->aq_policy);
             $limit['aq_policy'] = mikrotikRateLimit($aq_policy->toArray());
         }
         $voucher_limit = VoucherLimit::create($limit);
         $voucher['limit_id'] = $voucher_limit->id;
     }
     if ($plan->policy_type == 'Policy') {
         $policy = new VoucherPolicy(['bw_policy' => mikrotikRateLimit($plan->policy->toArray())]);
         $policy->save();
     } elseif ($plan->policy_type == 'PolicySchema') {
         $days = ['mo' => 'monday', 'tu' => 'tuesday', 'we' => 'wednesday', 'th' => 'thursday', 'fr' => 'friday', 'sa' => 'saturday', 'su' => 'sunday'];
         foreach ($days as $d => $day) {
             $tpl = $plan->policy->{$day}->toArray();
             $type = ['bw_policy', 'pr_policy', 'sec_policy'];
             foreach ($type as $t) {
                 if (!is_null($tpl[$t])) {
                     $policy = Policy::find($tpl[$t])->toArray();
                     $tpl[$t] = mikrotikRateLimit($policy);
                 }
             }
             $template = VoucherPolicySchemaTemplate::create($tpl);
             $schema[$d] = $template->id;
         }
         $policy = VoucherPolicySchema::create($schema);
     }
     $voucher['policy_id'] = $policy->id;
     for ($i = 0; $i < $input['count']; $i++) {
         $voucher['pin'] = self::generatePin();
         $voucher['expires_on'] = self::_makeExpiry($input['validity'], $input['validity_unit']);
         $v = new Voucher($voucher);
         if (!$v->save()) {
             return FALSE;
         }
         $res[] = $v->pin;
     }
     return $res;
 }
 public static function AssignPlan($user_id, $plan_id, $price = NULL)
 {
     DB::transaction(function () use($user_id, $plan_id, $price) {
         $oldPlan = APActivePlan::where('user_id', $user_id)->first();
         if (!is_null($oldPlan)) {
             self::updatePlanHistory($oldPlan);
         } else {
             $oldPlan = new ApActivePlan();
         }
         $plan = Plan::findOrFail($plan_id);
         $newPlan = ['user_id' => $user_id, 'plan_name' => $plan->name, 'plan_type' => $plan->plan_type, 'policy_type' => $plan->policy_type, 'sim_sessions' => $plan->sim_sessions, 'interim_updates' => $plan->interim_updates, 'aq_invocked' => 0, 'price' => $plan->price, 'time_balance' => NULL, 'data_balance' => NULL, 'assigned_on' => date("Y-m-d H:i:s"), 'validity' => $plan->validity, 'validity_unit' => $plan->validity_unit];
         if ($price != NULL) {
             $newPlan['price'] = $price;
         }
         if ($plan->plan_type == LIMITED) {
             $limit = $plan->limit;
             if ($limit->limit_type == TIME_LIMIT || $limit->limit_type == BOTH_LIMITS) {
                 $newPlan['time_balance'] = $limit->time_limit * constant($limit->time_unit);
             }
             if ($limit->limit_type == DATA_LIMIT || $limit->limit_type == BOTH_LIMITS) {
                 $newPlan['data_balance'] = $limit->data_limit * constant($limit->data_unit);
             }
             if ($limit->aq_access == ALLOWED) {
                 $aq_policy = Policy::findOrFail($limit->aq_policy);
                 $limit->aq_policy = mikrotikRateLimit($aq_policy->toArray());
             }
             $planLimit = APLimit::create($limit->toArray());
             $newPlan['limit_id'] = $planLimit->id;
         }
         if ($plan->policy_type == 'Policy') {
             $policy = APPolicy::create(['bw_policy' => mikrotikRateLimit($plan->policy->toArray())]);
         } elseif ($plan->policy_type == 'PolicySchema') {
             $days = ['mo' => 'monday', 'tu' => 'tuesday', 'we' => 'wednesday', 'th' => 'thursday', 'fr' => 'friday', 'sa' => 'saturday', 'su' => 'sunday'];
             foreach ($days as $d) {
                 $tpl = $plan->policy->{$day}->toArray();
                 $types = ['bw_policy', 'pr_policy', 'sec_policy'];
                 foreach ($types as $t) {
                     if (!is_null($tpl[$t])) {
                         $policy = Policy::find($tpl[$t])->toArray();
                         $tpl[$t] = mikrotikRateLimit($policy);
                     }
                 }
                 $template = APPolicySchemaTemplate::create($tpl);
                 $schema[$d] = $template->id;
             }
             $policy = APPolicySchema::create($schema);
         }
         $newPlan['policy_id'] = $policy->id;
         $oldPlan->fill($newPlan);
         $oldPlan->save();
         return TRUE;
     });
 }
示例#11
0
 public function evaluate(User $subject, Policy $policy)
 {
     $pass = true;
     foreach ($policy->getChecks() as $type => $value) {
         $propertyValue = $subject->getProperty($type);
         $valueType = gettype($propertyValue);
         // Ensure all of the things in our policy are true
         foreach ($value as $test) {
             $typeNs = __NAMESPACE__ . '\\Test\\Test' . ucwords(strtolower($valueType));
             if (class_exists($typeNs)) {
                 $testInstance = new $typeNs($test);
                 if ($testInstance->evaluate($propertyValue) === false) {
                     return false;
                 }
             } else {
                 throw new \InvalidArgumentException('Test type "' . $valueType . '" does not exist.');
             }
         }
     }
     return $pass;
 }
示例#12
0
 /**
  * Test the evaluation of all policies when no policy name is given
  */
 public function testAllPolicyEvaluateAllAny()
 {
     $set = PolicySet::instance()->add('policy1', Policy::instance()->hasUsername('ccornutt'));
     $user = (object) ['username' => 'ccornutt'];
     $subject = new Subject($user);
     $subject->setAuth(true);
     $context = new Context(['policies' => $set]);
     $gateway = new Gateway($subject, $context);
     // Evaluate the result of the policy above, true because they're:
     //  1. set correctly, 2. policy passes
     $result = $gateway->evaluate();
     $this->assertTrue($result);
 }
 public function postDelete($id)
 {
     try {
         if (!Policy::Destroy($id)) {
             throw new Exception("Bandwidth Policy deletion failed.");
         }
         $this->notifySuccess("Bandwidth Policy successfully deleted.");
     } catch (Exception $e) {
         $this->notifyError($e->getMessage());
         return Redirect::route('policies.index');
     }
     return Redirect::route('policies.index');
 }
示例#14
0
 public function actionProcess()
 {
     $model = new PolicyDetails();
     if (isset($_POST['PolicyDetails'])) {
         $policy = Policy::model()->findByPk($_POST['PolicyDetails']['policy']);
         $policy->policy_number = uniqid();
         $policy->amount_paid = $policy->policy_premium;
         $policy->is_purchased = 'p';
         $policy->policy_purchase_date = date("Y-m-d");
         $policy->policy_start_date = date("Y-m-d");
         $user = User::model()->findByPk(Yii::app()->user->id);
         $user->credit = $user->credit - $policy->policy_premium;
         $user->save();
         $policy->save();
         $model->attributes = $_POST['PolicyDetails'];
         if ($model->save()) {
             $this->redirect(array("success"));
         }
     }
 }
示例#15
0
 /**
  * Process a transition.
  * `\Zhibaihe\State\MachineException` is thrown when:
  * 1. the machine is not initialized;
  * 2. no transition is defined at current state;
  * 3. the transition is illegal at current state.
  *
  * @param  string $transition  The transition to be processed
  * @param  array  $arguments   The arguments for the transition
  * @return void
  *
  * @throws \Zhibaihe\State\MachineException
  */
 public function process($transition, $arguments = [])
 {
     if (!$this->ready()) {
         throw new MachineException("Machine not initialized.");
     }
     if (!array_key_exists($this->state, $this->transitions)) {
         throw new MachineException("No transitions defined for state '{$this->state}'.");
     }
     $transitions = $this->transitions[$this->state];
     if (!array_key_exists($transition, $transitions)) {
         throw new MachineException("Transition '{$transition}' at state '{$this->state}' is invalid.");
     }
     $to = $transitions[$transition];
     if ($this->policy->denies($transition, $this->state, $to, $arguments)) {
         return false;
     }
     $this->triggerWalkers($transition, $this->state, $to, $arguments);
     $this->triggerListeners($transition, $this->state, $to, $arguments);
     $this->state = $to;
     return true;
 }
 public static function updateFreePlan($user_id)
 {
     $free_balance = Freebalance::where('user_id', $user_id)->first();
     if (!is_null($free_balance)) {
         return;
     }
     $free_balance = new Freebalance(['user_id' => $user_id]);
     $free_plan = FRINTERNET::select('plan_type', 'limit_type', 'time_limit', 'time_unit', 'data_limit', 'data_unit', 'validity', 'validity_unit', 'policy_id', 'limit_type', 'aq_access', 'aq_policy', 'sim_sessions', 'interim_updates', 'reset_every', 'reset_unit')->first();
     $new_balance = ['last_reset_on' => date('Y-m-d H:i:s'), 'expiration' => makeExpiry($free_plan->validity, $free_plan->validity_unit, 'd M Y H:i'), 'bw_policy' => mikrotikRateLimit(Policy::find($free_plan->policy_id)->toArray()), 'plan_type' => $free_plan->plan_type, 'limit_type' => $free_plan->limit_type, 'time_limit' => $free_plan->time_limit, 'time_unit' => $free_plan->time_unit, 'data_limit' => $free_plan->data_limit, 'data_unit' => $free_plan->data_unit, 'aq_access' => $free_plan->aq_access, 'sim_sessions' => $free_plan->sim_sessions, 'interim_updates' => $free_plan->interim_updates, 'reset_every' => $free_plan->reset_every, 'reset_unit' => $free_plan->reset_unit, 'aq_invocked' => 0, 'time_balance' => NULL, 'data_balance' => NULL];
     if ($free_plan->plan_type == LIMITED) {
         if ($free_plan->aq_access) {
             $new_balance['aq_policy'] = mikrotikRateLimit(Policy::find($free_plan->aq_policy)->toArray());
         }
         if ($free_plan->limit_type == TIME_LIMIT || $free_plan->limit_type == BOTH_LIMITS) {
             $new_balance['time_balance'] = $free_plan->time_limit * constant($free_plan->time_unit);
         }
         if ($free_plan->limit_type == DATA_LIMIT || $free_plan->limit_type == BOTH_LIMITS) {
             $new_balance['data_balance'] = $free_plan->data_limit * constant($free_plan->data_unit);
         }
     }
     $free_balance->fill($new_balance);
     $free_balance->save();
 }
$enforcer = new Enforcer();
$decider = new Decider();
$enforcer->setDecider($decider);
// Create some Matches
//Action requested by the user
$match1 = new Match('StringEqual', 'property1', 'TestMatch1', $action);
//Action allowed by what policy states that group can do
$match2 = new Match('StringEqual', 'property1', 'TestMatch2', $actionRule);
// Create a Target container for our Matches
$target = new Target();
$target->addMatches(array($match1, $match2));
// Make a new Rule and add the Target to it
$rule1 = new Rule();
$rule1->setTarget($target)->setId('TestRule')->setEffect('Permit')->setDescription('Test to see if there is an attribute on the subject' . 'that exactly matches the word "test"')->setAlgorithm(new DenyOverrides());
// Make two new policies and add the Rule to it (with our Match)
$policy1 = new Policy();
$policy1->setAlgorithm('AllowOverrides')->setId('Policy1')->addRule($rule1);
$policy2 = new Policy();
$policy2->setAlgorithm('DenyOverrides')->setId('Policy2')->addRule($rule1);
// Create the subject with its own Attribute
$subject = new Subject();
$subject->addAttribute(new Attribute('property1', $actionRule));
// Link the Policies to the Resource
$resource = new Resource();
$resource->addPolicy($policy1)->addPolicy($policy2);
$environment = null;
$action = new Action();
$result = $enforcer->isAuthorized($subject, $resource, $action);
/**
 * The Subject does have a property that's equal to "test" on the "property1"
 * attribute, but the default Operation is to "fail closed". The other Match,
示例#18
0
        ossim_valid($id, OSS_HEX, 'illegal:' . _("Policy ID"));
        if (ossim_error()) {
            die(ossim_error());
        }
        Policy::update($conn, $id, $ctx, $priority, $active, $group, $order, $tzone, $b_month, $b_month_day, $b_week_day, $b_hour, $b_minute, $e_month, $e_month_day, $e_week_day, $e_hour, $e_minute, $descr, $source_ips, $source_host_groups, $dest_ips, $dest_host_groups, $source_nets, $source_net_groups, $dest_nets, $dest_net_groups, $portsrc, $portdst, $plug_groups, $sensors, $target, $taxonomy, $reputation, $event_conds, $idm, $correlate, $cross_correlate, $store, $rep, $qualify, $resend_alarms, $resend_events, $frw_conds, $sign, $sem, $sim);
        // Actions
        if (count($policy_action) > 0) {
            Policy_action::delete($conn, $id);
            foreach ($policy_action as $action_id) {
                Policy_action::insert($conn, $action_id, $id);
            }
        }
        break;
    case 'clone':
        $order = Policy::get_next_order($conn, $ctx, $group);
        $newid = Policy::insert($conn, $ctx, $priority, $active, $group, $order, $tzone, $b_month, $b_month_day, $b_week_day, $b_hour, $b_minute, $e_month, $e_month_day, $e_week_day, $e_hour, $e_minute, $descr, $source_ips, $source_host_groups, $dest_ips, $dest_host_groups, $source_nets, $source_net_groups, $dest_nets, $dest_net_groups, $portsrc, $portdst, $plug_groups, $sensors, $target, $taxonomy, $reputation, $event_conds, $idm, $correlate, $cross_correlate, $store, $rep, $qualify, $resend_alarms, $resend_events, $frw_conds, $sign, $sem, $sim);
        // Actions
        if (!empty($newid) && count($policy_action) > 0) {
            foreach ($policy_action as $action_id) {
                Policy_action::insert($conn, $action_id, $newid);
            }
        }
        break;
    default:
        die(_('Wrong option chosen'));
}
$db->close();
?>
    <p> <?php 
echo _("Policy successfully inserted");
?>
示例#19
0
 public static function getRelatedFromPolicy(Policy $policy)
 {
     $ret = array();
     $authm = new AuthManager();
     $apim = new ApiManager();
     $allAuths = $authm->getAllAuths(true);
     $relatedAuthIds = array();
     $relatedAuths = array();
     $authPropsArr = array();
     $allApis = $apim->getAllApis(true);
     $relatedApiIds = array();
     $relatedApis = array();
     $apiPropsArr = array();
     foreach ($allAuths as $auth) {
         /**
          * @var $auth Auth
          */
         foreach ($policy->getAuthIds() as $authBucket) {
             if ($authBucket->getAuthIds() && in_array($auth->getId(), $authBucket->getAuthIds())) {
                 $relatedAuths[] = $auth;
             }
         }
     }
     foreach ($relatedAuths as $auth) {
         $props = $auth->getProperties();
         if (!empty($props)) {
             $authPropsArr[$auth->getId()] = array_keys($props);
         }
     }
     $relatedApiIds = $policy->getApiIds();
     foreach ($allApis as $api) {
         /**
          * @var $api Api
          */
         if (in_array($api->getId(), $relatedApiIds)) {
             $relatedApis[] = $api;
         }
     }
     foreach ($relatedApis as $api) {
         $props = $api->getProperties();
         if (!empty($props)) {
             if ($api->getDisplayName()) {
                 $apiPropsArr[$api->getDisplayName()] = array_keys($props);
             } else {
                 $apiPropsArr[$api->getId()] = array_keys($props);
             }
         }
     }
     if (!empty($authPropsArr)) {
         $ret["auth"] = $authPropsArr;
     }
     if (!empty($apiPropsArr)) {
         $ret["api"] = $apiPropsArr;
     }
     return json_encode($ret);
 }
示例#20
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Policy $value A Policy object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Policy $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
示例#21
0
$conn = $db->connect();
$policy_list = Policy::get_list($conn);
foreach ($policy_list as $policy) {
    $id_group = $policy->get_group();
    $id = $policy->get_id();
    $rs = $conn->Execute("SELECT name FROM policy_group WHERE group_id={$id_group}");
    if ($rs->fields["name"] == "") {
        $conn->Execute("UPDATE policy SET policy.group=0 WHERE id={$id}");
    }
}
//
$neworder = 1;
$policy_groups = Policy::get_policy_groups($conn);
foreach ($policy_groups as $group) {
    $policy_list = Policy::get_list($conn, "WHERE policy.group=" . $group->get_group_id() . " ORDER BY policy.priority");
    foreach ($policy_list as $policy) {
        $id = $policy->get_id();
        $conn->Execute("UPDATE policy SET policy.order={$neworder} WHERE id={$id}");
        $neworder++;
    }
}
$reorderpolicygrps = Policy::get_policy_groups($conn, "ORDER BY order");
$neworder = 1000;
foreach ($reorderpolicygrps as $policy) {
    if (intval($policy->get_group_id()) != 0) {
        $conn->Execute("UPDATE policy_group SET policy_group.order={$neworder} WHERE group_id=" . $policy->get_group_id());
        $neworder++;
    }
}
$db->close($conn);
header("Location: /ossim/policy/policy.php?hmenu=Policy&smenu=Policy");
示例#22
0
<?php

/**
 * ownCloud - Persona plugin
 * 
 * @author Victor Dubiniuk
 * @copyright 2012-2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 * 
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\User_persona;

\OCP\User::checkAdminUser();
$policy = intval(@$_POST['policy']);
Policy::setSystemPolicy($policy);
示例#23
0
    $log_dst = $order_dst . " (" . $policy_dst->get_id() . ")";
}
if ($group_src == $group_dst) {
    // same group => swap
    Policy::swap_simple_orders($conn, $policy_src, $policy_dst);
} else {
    // different group => especial swap
    if ($order_src < $order_dst) {
        // Only change group (do not change order value)
        if ($order_src == $order_dst - 1) {
            Policy::change_group($conn, $policy_src->get_id(), $group_dst);
        } else {
            for ($i = $order_src; $i < $order_dst - 1; $i++) {
                Policy::swap_orders($conn, $i, $i + 1, $group_dst, $ctx, "src");
            }
        }
    } else {
        if ($order_src == $order_dst) {
            Policy::change_group($conn, $policy_src->get_id(), $group_dst);
        }
        for ($i = $order_src; $i > $order_dst; $i--) {
            Policy::swap_orders($conn, $i - 1, $i, $group_dst, $ctx, "dst");
        }
    }
}
$infolog = array($order_src . " (" . $policy_src->get_id() . ")", $log_dst);
Log_action::log(98, $infolog);
Web_indicator::set_on("Reload_policies");
// ReloadPolicy key deprecated, now using Reload_policies always
//Web_indicator::set_on("ReloadPolicy");
$db->close();
示例#24
0
    if (!strcasecmp($target_any, "any")) {
        array_push($target, "any");
    }
    /* actions / responses */
    $responses = array();
    $actions = POST('actions');
    if ($actions) {
        foreach ($actions as $action_id) {
            ossim_valid($action_id, OSS_DIGIT, 'illegal:' . _("Action ID"));
            $responses[] = $action_id;
        }
    }
    if ($order == 0) {
        $order = Policy::get_next_order($conn, $group);
    }
    $newid = Policy::insert($conn, $priority, $active, $group, $order, $begin_hour, $end_hour, $begin_day, $end_day, $descr, $source_ips, $source_host_groups, $dest_ips, $dest_host_groups, $source_nets, $source_net_groups, $dest_nets, $dest_net_groups, $ports, $plug_groups, $sensors, $target, $correlate, $cross_correlate, $store, $qualify, $resend_alarms, $resend_events, $sign, $sem, $sim);
    // Response/Actions
    if (count($responses) > 0) {
        foreach ($responses as $action_id) {
            Policy_action::insert($conn, $action_id, $newid);
        }
        Response::insert($conn, "policy {$newid}", $source_nets, $source_ips, $dest_nets, $dest_ips, $sensors, $ports, $ports, $plug_ids, $responses);
    }
    ?>
    <p> <?php 
    echo gettext("Policy succesfully inserted");
    ?>
 </p>
    <script>document.location.href="policy.php"</script>
<?php 
    $db->close($conn);
示例#25
0
<?php

/**
 * ownCloud - Persona plugin
 * 
 * @author Victor Dubiniuk
 * @copyright 2012-2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 * 
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\User_persona;

\OCP\User::checkAdminUser();
\OCP\Util::addScript(App::APP_ID, 'settings');
$tmpl = new \OCP\Template(App::APP_ID, 'settings');
$tmpl->assign('allPolicies', Policy::getAllPolicies());
$tmpl->assign('currentPolicy', Policy::getSystemPolicy());
return $tmpl->fetchPage();
示例#26
0
$filter = get_filters_names($conn);
$policy_list = Policy::get_list($conn, "AND ctx=UNHEX('{$ctx}') {$where} ORDER BY policy.{$order}");
if ($policy_list[0]) {
    $total = $policy_list[0]->get_foundrows();
    if ($total == 0) {
        $total = count($policy_list);
    }
} else {
    $total = 0;
}
$engine = is_ctx_engine($conn, $ctx) ? 'engine' : 'ctx';
$xml .= "<rows>\n";
$xml .= "<page>{$page}</page>\n";
$xml .= "<total>{$total}</total>\n";
if ($total > 0) {
    list($conds_list, $pol_conds) = Policy::get_conditions_hash($conn, $ctx);
}
foreach ($policy_list as $policy) {
    $id = $policy->get_id();
    $order = $policy->get_order();
    $xml .= "<row id='{$id}' col_order='{$order}' col_type='{$engine}'>";
    $tabla = "<img src='../pixmaps/tables/cross.png' border='0'/>";
    $active = !$policy->get_active() ? $tabla : str_replace("cross", "tick", $tabla);
    $xml .= "<cell><![CDATA[" . $active . "]]></cell>";
    $xml .= "<cell><![CDATA[" . $order . "]]></cell>";
    $pname = $policy->get_descr();
    $pname = empty($pname) ? _("Unknown") : "<a href='newpolicyform.php?ctx={$ctx}&id={$id}'>{$pname}</a>";
    /*Checking if the policy has a conflict */
    $md5 = $pol_conds[$id];
    $collisions = $conds_list[$md5];
    if (count($collisions) > 1) {
 public function getEditTemplate($id)
 {
     try {
         $template = SchemaTemplate::findOrFail($id);
         $times = Config::get('times', NULL);
         $policies = Policy::lists('name', 'id');
         return View::make('admin.schematemplates.add-edit', ['template' => $template, 'times' => $times, 'policies' => $policies]);
     } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
         App::abort(404);
     }
 }
示例#28
0
 /**
  * @depends testRemovePolicies
  */
 public function testDeleteAllPolicies()
 {
     $nerd = User::getByUsername('billy');
     $salesStaff = Group::getByName('Sales Staff');
     $this->assertEquals(null, $nerd->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $this->assertEquals(null, $salesStaff->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $this->assertEquals(null, $nerd->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $this->assertEquals(null, $salesStaff->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $nerd->setPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS, 30);
     $this->assertTrue($nerd->save());
     $this->assertEquals(30, $nerd->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $this->assertEquals(null, $salesStaff->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $salesStaff->setPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS, 10);
     $this->assertTrue($salesStaff->save());
     $this->assertEquals(30, $nerd->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $this->assertEquals(10, $salesStaff->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     Policy::removeAllForPermitable($nerd);
     PoliciesCache::forgetAll();
     unset($nerd);
     unset($salesStaff);
     RedBeanModel::forgetAll();
     $nerd = User::getByUsername('billy');
     $salesStaff = Group::getByName('Sales Staff');
     $this->assertEquals(null, $nerd->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $this->assertEquals(10, $salesStaff->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     Policy::deleteAll();
     PoliciesCache::forgetAll();
     unset($nerd);
     unset($salesStaff);
     RedBeanModel::forgetAll();
     $nerd = User::getByUsername('billy');
     $salesStaff = Group::getByName('Sales Staff');
     $this->assertEquals(null, $nerd->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
     $this->assertEquals(null, $salesStaff->getActualPolicy('UsersModule', UsersModule::POLICY_PASSWORD_EXPIRY_DAYS));
 }
示例#29
0
    $date_type = 1;
    //Assets Filters
    $ports_source[] = "ANY";
    $ports_destiny[] = "ANY";
    $targets['00000000000000000000000000000000'] = "ANY";
    $sensors['00000000000000000000000000000000'] = "ANY";
    $plugingroups[] = '00000000000000000000000000000000';
}
if ($utz == "0" || $utz == "") {
    $utz = 'UTC';
}
if (preg_match("/Localtime/", $utz)) {
    $utz = trim(`head -1 /etc/timezone`);
}
if ($insert != "") {
    if ($policies = Policy::get_list($conn, " AND id=UNHEX('{$insert}')")) {
        $order = $policies[0]->get_order();
        $group = $policies[0]->get_group();
        if (GET('insertafter') != "") {
            $order++;
        }
        // insert after
    }
}
if (!$open_source) {
    $def_server = Server::get_deafault_server($conn);
    if (!empty($def_server)) {
        $def_server = str_replace('-', '', $def_server);
    }
    $server_h = Server::get_my_hierarchy($conn, $def_server);
}
示例#30
0
文件: index.php 项目: vberzsin/2014
         return;
     }
     // evals roles of current user
     $model['role'] = $roleUtils->getRoleById($id);
     if (false == $model['role']) {
         $session->addError(L::__('No such role.'));
         $app->response->redirect(Settings::baseRef . '/admin/edit-userrole/all', 303);
         return;
     }
     // permissions of user
     $model['permissions'] = $roleUtils->getPermissionsById($id);
     if (false == $model['permissions']) {
         $model['permissions'] = [];
     }
     // difference (of all policies and currently used policies)
     $model['diff_permissions'] = Policy::getInstance()->getDiffPermissions($model['permissions']);
     // role id
     $model['rid'] = $id;
     // renders view
     $app->render('admin-userrole.php', $model);
     return;
     break;
 case 'edit-user':
     // checks policy
     if (false == $user->can(Policy::EDIT_USER)) {
         $session->addError(L::__('Policy does not fit.'));
         $session->setRedirectURL(Settings::baseRef . '/admin/' . $method . '/' . $id);
         $app->response->redirect(Settings::baseRef . '/login', 303);
         return;
     }
     // sets up utils