Code

Updated dak import
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 16 Jun 2008 09:39:19 +0000 (09:39 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 16 Jun 2008 09:39:19 +0000 (09:39 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11337 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_gosaSupportDaemon.inc

index 797d56f4804d5685e41dd35389950dcd74dce637..478eee9c7a9770f4f13fadc4209f8c8d122037b2 100644 (file)
@@ -1872,6 +1872,46 @@ class gosaSupportDaemon
       return(array());
     }
   }
+
+
+  /*! \brief  Imports the given key into the specified keyring (Servers mac address)
+      @param  String  The servers mac address 
+      @param  String  The gpg key.
+      @return Boolean TRUE on success else FALSE 
+   */
+  public function DAK_import_key($server,$key)  
+  {
+    /* Ensure that we send the event to a valid mac address 
+     */
+    if(!is_string($server) || !tests::is_mac($server)){
+      trigger_error("No valid mac address given '".$server."'.");
+      return;
+    }
+
+    /* Check if there is some cleanup required before importing the key.
+        There may be some Header lines like:
+        -----BEGIN PGP PUBLIC KEY BLOCK-----   Version: GnuPG v1.4.6 (GNU/Linux)
+     */
+    if(preg_match("/".normalizePreg("BEGIN PGP PUBLIC KEY BLOCK")."/",$key)){
+
+      /* Remove header */
+      $key = preg_replace("/^.*\n\n/sim","",$key);
+      /* Remove footer */
+      $key = preg_replace("/-----.*$/sim","",$key);
+    }
+
+    /* Create query
+     */
+    $xml_msg = "<xml> 
+                  <header>gosa_import_dak_key</header> 
+                  <target>".$server."</target> 
+                  <key>".$key."</key> 
+                  <source>GOSA</source>
+                </xml>";
+        
+    $res = $this->_send($xml_msg,TRUE);
+    return($this->is_error());
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: