Code

Fixed add/remove of policies.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 7 May 2008 06:44:17 +0000 (06:44 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 7 May 2008 06:44:17 +0000 (06:44 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10797 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/heimdal/admin/systems/services/kerberos/class_goKrbServer.inc
gosa-plugins/heimdal/admin/systems/services/kerberos/class_krb5_policy.inc

index 9478b9c0bd003ec50dc402a427e62592698ba542..707b80f55484a713ea5be299e1834f4d11d7e9a1 100644 (file)
@@ -301,33 +301,36 @@ class goKrbServer extends goService{
     foreach($this->policies as $policy){
       switch($policy['STATUS']){
         case "REMOVED" : $actions['del'] [] = $policy;break; 
-        case "ADDED"   : $actions['add'] [] = $policy;break; 
-        case "EDITED"  : $actions['edit'][] = $policy;break; 
+        case "ADDED"   : 
+        case "EDITED"  : $actions['add_edit'] [] = $policy;break; 
       }
     }
 
     $o = new gosaSupportDaemon();
+    $policies = $o->krb5_list_policies($this->macAddress);
+
     /* Send remove policy event  
      */
     foreach($actions['del'] as $policy){
+      if(!in_array($policy['NAME'],$policies)) continue;
       if(!$o->krb5_del_policy($this->macAddress,$policy['NAME'])){
         msg_dialog::display(_("Service infrastructure"),msgPool::siError($o->get_error()),ERROR_DIALOG);
       }
     }
     
-    /* Send add new policy event
-     */
-    foreach($actions['add'] as $policy){
-      if(!$o->krb5_add_policy($this->macAddress,$policy['NAME'],$policy['DATA'])){
-        msg_dialog::display(_("Service infrastructure"),msgPool::siError($o->get_error()),ERROR_DIALOG);
-      }
-    }
-    
-    /* Send update policy event
+    /* Send add new/edit policy event
      */
-    foreach($actions['edit'] as $policy){
-      if(!$o->krb5_set_policy($this->macAddress,$policy['NAME'],$policy['DATA'])){
-        msg_dialog::display(_("Service infrastructure"),msgPool::siError($o->get_error()),ERROR_DIALOG);
+    foreach($actions['add_edit'] as $policy){
+      if(in_array($policy['NAME'],$policies)){
+        if(!$o->krb5_set_policy($this->macAddress,$policy['NAME'],$policy['DATA'])){
+          msg_dialog::display(_("Service infrastructure"),msgPool::siError($o->get_error()),ERROR_DIALOG);
+        }
+      }else{
+        unset($policy['DATA']['MASK']);
+        unset($policy['DATA']['POLICY_REFCNT']);
+        if(!$o->krb5_add_policy($this->macAddress,$policy['NAME'],$policy['DATA'])){
+          msg_dialog::display(_("Service infrastructure"),msgPool::siError($o->get_error()),ERROR_DIALOG);
+        }
       }
     }
   }
index 7dac3ac5f6763e9e0e29b208fbd96acbba7612d1..24df262030525a79aa00c01102c2d0eb372bf7be 100644 (file)
@@ -21,9 +21,13 @@ class krb5_policy extends plugin
       $this->name = $entry['NAME'];
       $this->data = $entry['DATA'];
     }else{
-      foreach($this->attributes as $attr){
-        $this->data[$attr] = 0;
-      }
+      $this->data['MASK']           = 0;
+      $this->data['POLICY_REFCNT']  = 0;
+      $this->data['PW_HISTORY_NUM'] = 5;
+      $this->data['PW_MAX_LIFE']    = 604800;
+      $this->data['PW_MIN_CLASSES'] = 3;
+      $this->data['PW_MIN_LENGTH']  = 6;
+      $this->data['PW_MIN_LIFE']    = 36000;
     }
     $this->init_name = $this->name;
        }
@@ -58,12 +62,40 @@ class krb5_policy extends plugin
   
   public function check()
   {
-    $messages = array();
+    $message = array();
     $names = $this->parent->getPolicyNames();
     if($this->name != $this->init_name && in_array($this->name,$names)){
-      $messages[] = msgPool::duplicated(_("Name"));
+      $message[] = msgPool::duplicated(_("Name"));
+    }
+    if(empty($this->name)){
+      $message[] = msgPool::required(_("Name"));
+    }
+  
+    if(!preg_match("/^[a-z0-9\@\.\-_]*$/i",$this->name)){
+      $message[] = msgPool::invalid(_("Name"),$this->name,"/[a-z0-9]/i");
+    }
+
+    /* Check password history */
+    if(!is_numeric($this->data['PW_HISTORY_NUM'])){
+      $message[] = msgPool::invalid(_("Password history"));
+    }elseif($this->data['PW_HISTORY_NUM'] <= 0){
+      $message[] = msgPool::toosmall(_("Password history"));
+    }
+
+    /* Check password  */
+    if(!is_numeric($this->data['PW_MIN_LENGTH'])){
+      $message[] = msgPool::invalid(_("Password minimum length"));
+    }elseif($this->data['PW_MIN_LENGTH'] <= 0){
+      $message[] = msgPool::toosmall(_("Password minimum length"));
+    }
+
+    /* Check password history */
+    if(!is_numeric($this->data['PW_MIN_LENGTH'])){
+      $message[] = msgPool::invalid(_("Password minimum length"));
+    }elseif($this->data['PW_MIN_LENGTH'] <= 0){
+      $message[] = msgPool::toosmall(_("Password minimum length"));
     }
-    return($messages);
+    return($message);
   }