diff --git a/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgExtra.class.php b/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgExtra.class.php index 6b536c02b821a41840340c963a330de311e03fd8..fb9ea74a00bf7b140caa6bb9c9524fff70f8f60e 100755 --- a/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgExtra.class.php +++ b/info.textgrid.middleware.tgauth.rbac/rbacSoap/TgExtra.class.php @@ -3245,45 +3245,48 @@ class TgExtra { $i = 0; // Loop - if( preg_match( "/.+/", $inRequest->username ) - && !preg_match( "/^" . $inRequest->username . "$/i", $this->rbac->sessionUser( $inRequest->auth ) ) ) { + try { + $eppn = $this->rbac->sessionUser( $inRequest->auth ); + + if( preg_match( "/.+/", $inRequest->username ) + && !preg_match( "/^" . $inRequest->username . "$/i", $eppn) ) { - // The roles of the user - $arrRole = $this->rbac->assignedRoles( $inRequest->username ); + // The roles of the user + $arrRole = $this->rbac->assignedRoles( $inRequest->username ); + // Extract the different projects the user is + // assigned by his roles. + for( $i = 0; $i < sizeof( $arrRole ); $i++ ) { - // Extract the different projects the user is - // assigned by his roles. - for( $i = 0; $i < sizeof( $arrRole ); $i++ ) { + $arrSplit = preg_split( "/[,]/", $arrRole[$i] ); - $arrSplit = preg_split( "/[,]/", $arrRole[$i] ); + for( $j = 0; $j < sizeof( $arrSplit ); $j++ ) { - for( $j = 0; $j < sizeof( $arrSplit ); $j++ ) { + if( preg_match( "/TGPR.+/i", $arrSplit[$j] ) + && !in_array( trim( $arrSplit[$j] ), $arrProject ) ) { - if( preg_match( "/TGPR.+/i", $arrSplit[$j] ) - && !in_array( trim( $arrSplit[$j] ), $arrProject ) ) { + $arrProject[] = trim( $arrSplit[$j] ); + break; - $arrProject[] = trim( $arrSplit[$j] ); - break; + } } } - } - + // For each project the username is in, check if the + // session-ID has the right to display the assigned roles. + for( $i = 0; $i < sizeof( $arrProject ); $i++ ) { - // For each project the username is in, check if the - // session-ID has the right to display the assigned roles. - for( $i = 0; $i < sizeof( $arrProject ); $i++ ) { + if( $this->rbac->checkAccess( $inRequest->auth, "delegate", $arrProject[$i] ) ) { - if( $this->rbac->checkAccess( $inRequest->auth, "delegate", $arrProject[$i] ) ) { + for( $j = 0; $j < sizeof( $arrRole ); $j++ ) { - for( $j = 0; $j < sizeof( $arrRole ); $j++ ) { + if( preg_match( "/" . $arrProject[$i] . "/i", $arrRole[$j] ) ) { - if( preg_match( "/" . $arrProject[$i] . "/i", $arrRole[$j] ) ) { + $result->role[] = $arrRole[$j]; - $result->role[] = $arrRole[$j]; + } } @@ -3292,17 +3295,20 @@ class TgExtra { } } + else { + + $result->role = $this->rbac->assignedRoles( $eppn); + + } + } catch (RBACException $f) { + // return empty roleset if session does not exist + $result->role = Array(); } - else { - - $result->role = $this->rbac->assignedRoles( $this->rbac->sessionUser( $inRequest->auth ) ); - - } - return $result; + }