Skip to content
Snippets Groups Projects
Commit 805bfac9 authored by Martin Haase's avatar Martin Haase
Browse files

cleaned up 8082

git-svn-id: https://textgridlab.org/svn/textgrid/trunk/middleware/tgauth@4442 7c539038-3410-0410-b1ec-0f2a7bf1c452
parent 7fecd780
No related branches found
No related tags found
No related merge requests found
<?php
// #######################################################
// Author: Markus Widmer
// Creation date: 17.07.2007
// Modification date: 09.10.2007
// Version: 0.2.2
// #######################################################
class TgSystem {
// Global variables
protected $rbac;
protected $config;
// -----------------------------------------------------
// Constructor
// Input: none
// Output: object RBACcore
// Description:
// Creates initial connections to the LDAP-server and
// sets some configuration parameters.
// -----------------------------------------------------
public function __construct( $inConfigurationFilename, $inRbacConfFile, $inRbacBase ) {
$this->rbac = new RBAC( $inRbacConfFile, $inRbacBase );
$this->config = new SimpleConfig( $inConfigurationFilename );
}
public function checkAccess( $inSid, $inOperation, $inResource ) {
try {
$checkAccessResult = $this->rbac->checkAccess( $inSid, $inOperation, $inResource );
if( $checkAccessResult ) {
$checkAccessResult = "TRUE";
}
else {
$checkAccessResult = "FALSE";
}
}
catch( Exception $e ) {
$checkAccessResult = "FALSE";
}
return $checkAccessResult;
}
}
?>
<?php
echo base64_encode( "textgrid:TGPR4:CWDS+-+Band+1%2C+Seite+90%2C+Lemma+aftermuse:20080725T142745:xml%2Ftei:1" );
?>
<HTML>
<BODY>Hallo</BODY>
</HTML>
<?php
$arrQuery = Array( "sid" => "Fb4Gmbi5n6xHgVUMUZV5XY7Gx3JeSonbzNUVeO8r8GcKzqaeNVou4JH8XybPjuPFLcF",
"operation" => "read",
"resource" => "textgrid:TGPR4:CWDS+-+Band+1%2C+Seite+56%2C+Lemma+absetzkalb:20080725T140016:xml%2Ftei:1" );
$arrQuery = base64_encode( serialize( $arrQuery ) );
$sock = socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
socket_connect( $sock, '127.0.0.1', 6643 );
socket_write( $sock, $arrQuery, strlen( $arrQuery ) );
socket_write( $sock, "\r\n", strlen( "\r\n" ) );
$result = socket_read( $sock, 1024 );
echo unserialize( base64_decode( $result ) ) . "\n";
socket_shutdown( $sock, 2 );
socket_close( $sock );
?>
<?php
// Create socket with 50 connections in queue
//$sock = socket_create_listen( 6643, 50 );
//socket_set_nonblock( $sock );
$sock = socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
socket_bind( $sock, "127.0.0.1", 6643 );
socket_listen( $sock, 50 );
require_once( "../rbac/RBAC.class.php" );
require_once( "TgSystem.class.php" );
// Dont be so verbose with messages and notices.
error_reporting( E_ERROR | E_USER_ERROR );
$tgsystem = new TgSystem( "../conf/rbacSoap.conf", "../conf/system.conf", "../rbac/" );
while( $con = socket_accept( $sock ) ) {
socket_getpeername( $con, $raddr, $rport );
$query = socket_read( $con, 2048 );
$arrQuery = unserialize( base64_decode( $query ) );
$result = $tgsystem->checkAccess( $arrQuery['sid'], $arrQuery['operation'], $arrQuery['resource'] );
$result = base64_encode( serialize( $result ) );
socket_write( $con, $result, strlen( $result ) );
socket_write( $con, "\r\n", strlen( "\r\n" ) );
}
socket_close( $sock );
?>
<?php
// #######################################################
// Author: Markus Widmer
// Creation date: 13.10.2008
// Modification date: 13.10.2008
// Version: 1.0.0
// #######################################################
require_once( "../rbac/RBAC.class.php" );
require_once( "TgSystem.class.php" );
// Dont be so verbose with messages and notices.
error_reporting( E_ERROR | E_USER_ERROR );
$tgsystem = new TgSystem( "../conf/rbacSoap.conf", "../conf/system.conf", "../rbac/" );
header( "Content-Type: text/plain; charset=UTF-8" );
if( preg_match( "/checkaccess/i", $_REQUEST['method'] ) ) {
$arrQuery = Array( "sid" => $_REQUEST['the_session_id'],
"operation" => $_REQUEST['the_operation'],
"resource" => base64_decode( $_REQUEST['the_resource'] ) );
$arrQuery = base64_encode( serialize( $arrQuery ) );
$sock = socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
socket_connect( $sock, '127.0.0.1', 6643 );
socket_write( $sock, $arrQuery, strlen( $arrQuery ) );
socket_write( $sock, "\r\n", strlen( "\r\n" ) );
$result = socket_read( $sock, 1024 );
socket_shutdown( $sock, 2 );
socket_close( $sock );
echo unserialize( base64_decode( $result ) );
// echo $tgsystem->checkAccess( $_REQUEST['the_session_id'], $_REQUEST['the_operation'], base64_decode( $_REQUEST['the_resource'] ) );
}
else {
echo "FALSE";
}
?>
......@@ -1245,12 +1245,13 @@ class TgExtra {
if( $inRequest->secret === $this->config->getValue( "crud", "secret" ) ) {
// The TextGrid-resource naming-attribute
$resourceNamingAttribute = $this->rbac->getConfiguration()->getValue( "resource", "namingattribute" );
$sock = socket_create( AF_INET, SOCK_STREAM, SOL_TCP );
if( socket_connect( $sock, '127.0.0.1', 6645 ) ) {
if( socket_connect( $sock, '127.0.0.1', 6646 ) ) {
$freeNumber = socket_read( $sock, 1024 );
......@@ -1395,7 +1396,6 @@ class TgExtra {
}
return $result;
}
......@@ -1967,7 +1967,6 @@ class TgExtra {
}
}
$sid .= (integer) ( microtime(true) * 1000000) ;
return $sid;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment