From dfa060cb642e14fbc17fc905c626638fe13b24bd Mon Sep 17 00:00:00 2001
From: Martin Haase <martin.haase@daasi.de>
Date: Wed, 18 Jan 2012 17:34:04 +0000
Subject: [PATCH] corrected UUID generation

git-svn-id: https://textgridlab.org/svn/textgrid/trunk/middleware/tgauth@11756 7c539038-3410-0410-b1ec-0f2a7bf1c452
---
 .../rbacSoap/TgAdministration.class.php       |  6 ++---
 .../rbacSoap/TgExtra.class.php                |  2 +-
 .../rbacSoap/TgExtraCrud.class.php            | 22 ++++++++++++++-----
 3 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgAdministration.class.php b/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgAdministration.class.php
index cbdb13c..fe78b7b 100755
--- a/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgAdministration.class.php
+++ b/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgAdministration.class.php
@@ -95,9 +95,9 @@ class TgAdministration {
           $arrTree['objectclass'][] = "rbacresource";
           $arrTree['ou'][] = $userDomain;
 
-          $file = fopen( "/tmp/debug.log", "a+" );
-          fwrite( $file, $userTreeDn . "," . $this->config->getValue( "authentication", "base" ) );
-          fclose( $file );
+//          $file = fopen( "/tmp/debug.log", "a+" );
+//          fwrite( $file, $userTreeDn . "," . $this->config->getValue( "authentication", "base" ) );
+//          fclose( $file );
           $this->connection['user']->add( $userTreeDn . "," . $this->config->getValue( "authentication", "base" ), $arrTree );
 
         }
diff --git a/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgExtra.class.php b/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgExtra.class.php
index 7f62719..6b536c0 100755
--- a/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgExtra.class.php
+++ b/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgExtra.class.php
@@ -3491,7 +3491,7 @@ class TgExtra {
     $strResult .= substr( $strRandom, 8, 4 ) . "-";
     $strResult .= substr( $strRandom, 12, 4 ) . "-";
     $strResult .= substr( $strRandom, 16, 4 ) . "-";
-    $strResult .= substr( $strRandom, 20, 12 );
+    $strResult .= substr( $strRandom, 32, 12 );
 
 
     return $strResult;
diff --git a/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgExtraCrud.class.php b/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgExtraCrud.class.php
index b9db5c9..1cd9384 100755
--- a/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgExtraCrud.class.php
+++ b/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgExtraCrud.class.php
@@ -88,17 +88,17 @@ class TgExtraCrud {
 
     if( $this->rbac->checkAccess( $inRequest->auth, "publish", $inRequest->resource ) ) {
 
-      $file = fopen( "/tmp/debug.log", "a+" );
-      fwrite( $file, "Resource: " . serialize( $arrResource ) . "\n" );
-      fclose( $file );
+//      $file = fopen( "/tmp/debug.log", "a+" );
+//      fwrite( $file, "Resource: " . serialize( $arrResource ) . "\n" );
+//      fclose( $file );
       $arrModify['rbacpermission'] = Array();
 
 
       for( $loPermission = 0; $loPermission < sizeof( $arrResource[0]['rbacpermission'] ); $loPermission++ ) {
 
-        $file = fopen( "/tmp/debug.log", "a+" );
-        fwrite( $file, "Permission: " . serialize( $arrResource[0]['rbacpermission'][$loPermission] ) . "\n" );
-        fclose( $file );
+//        $file = fopen( "/tmp/debug.log", "a+" );
+//        fwrite( $file, "Permission: " . serialize( $arrResource[0]['rbacpermission'][$loPermission] ) . "\n" );
+//        fclose( $file );
         if(    preg_match( "/:-:publish$/i", $arrResource[0]['rbacpermission'][$loPermission] )
             || preg_match( "/:-:delete$/i", $arrResource[0]['rbacpermission'][$loPermission] ) ) {
 
@@ -114,6 +114,16 @@ class TgExtraCrud {
 
     }
     else {
+    // somehow checkAccess returned False. Debug it now.
+    $file = fopen ("/tmp/internal2error.debug", "a+");
+    fwrite ($file, date(DATE_RFC822) . "\n");
+    fwrite ($file, "This URI returned FALSE on 'publish' CheckAccess: " . $inRequest->resource  ."\n");
+    fwrite ($file, "The SID: " . $inRequest->auth  ."\n");
+    $secondtry = $this->rbac->checkAccess( $inRequest->auth, "publish", $inRequest->resource );
+    fwrite ($file, "Second Try CheckAccess: ". serialize ($secondtry) ."\n");
+    fwrite ($file, "--\n");
+    fclose ($file);
+
 
       $objFaultDetail->faultNo = $this->config->getValue( "errorCode", "INSUFFICIENT_ACCESS" );
       $objFaultDetail->faultMessage = $this->config->getValue( "errorDescription", "INSUFFICIENT_ACCESS" );
-- 
GitLab