/[volute]/trunk/projects/grid/vospace/php_endpoint/backends/file_system/vospace.php
ViewVC logotype

Contents of /trunk/projects/grid/vospace/php_endpoint/backends/file_system/vospace.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 738 - (show annotations)
Thu Aug 21 21:45:51 2008 UTC (12 years, 5 months ago) by richard.p.wagner
File size: 3528 byte(s)
added simple authorization mechanism
1 <?php
2
3 require_once(BACKEND.'config.backend.inc');
4 require_once(BACKEND.'properties.php');
5 require_once(BACKEND.'views.php');
6 require_once(BACKEND.'protocols.php');
7 require_once(BACKEND.'node.php');
8
9 class VOSpace {
10
11 private $AuthInfo;
12
13 function __construct(){
14 $this->AuthInfo = array('username' => Null,
15 'password' => Null,
16 'authenticated' => False);
17 }
18
19 function getAuthInfo( $sec_header ) {
20
21 $p = xml_parser_create();
22 xml_parse_into_struct($p, $sec_header->any, $vals, $index);
23 xml_parser_free($p);
24
25 $username = '';
26 $password = '';
27 foreach( $vals as $element){
28 if( strpos($element['tag'], "USERNAMETOKEN") === FALSE ){
29 if( strpos($element['tag'], "USERNAME") !== FALSE )
30 $this->AuthInfo['username'] = $element['value'];
31 if( strpos($element['tag'], "PASSWORD") !== FALSE )
32 $this->AuthInfo['password'] = $element['value'];
33 }
34 }
35
36 if( $this->AuthInfo['username'] == 'joe' &&
37 $this->AuthInfo['password'] == 'doe' ){
38 $this->AuthInfo['authenticated'] = True;
39 }else{
40 throw new SoapFault("Server", "Not authenticated.", " ",
41 array(),
42 "NotAuthenticatedFault");
43 }
44 }
45
46 function getAuthorization($method_name){
47 if( $this->AuthInfo['username'] == 'joe'
48 && $method_name == 'GetProperties')
49 return False;
50 else
51 return True;
52 }
53
54 function getViews(){
55 global $provided_views;
56 global $accepted_views;
57 return array('accepts' => $accepted_views,
58 'provides' => $provided_views);
59 }
60
61 function getProtocols(){
62 global $provided_protocols;
63 global $accepted_protocols;
64 return array('accepts' => $accepted_protocols,
65 'provides' => $provided_protocols);
66 }
67
68 function getProperties(){
69 global $provided_properties;
70 return array('accepts' => null,
71 'provides' => $provided_properties,
72 'contains' => $provided_properties);
73 }
74
75 function listNodes($node_request) {
76 // get uri to list
77 // need to parse this for cleanliness at some point
78 // (trailing slashes, etc.)
79 $uri = $node_request->nodes->node->uri;
80
81 $token=null;
82 $limit=False;
83 $detail='min';
84
85 if($node_request->token)
86 $token = $node_request->token;
87 if($node_request->limit)
88 $limit = $node_request->limit;
89 if($node_request->detail)
90 $detail = $node_request->detail;
91
92 $node_list = array('detail' => $detail,
93 'nodes' => array());
94
95 $path = str_replace( VOSPACE_ROOT, FILE_SYSTEM_ROOT, $uri );
96 // error_log(var_export($path.'\n', True), 3, "/var/tmp/my-errors.log");
97 // quick check to see if this is a single file
98 if(is_file($path)){
99 $node_uri = str_replace( FILE_SYSTEM_ROOT, VOSPACE_ROOT, $path );
100
101 $new_node = new Node($node_uri);
102 if($detail != 'min')
103 $new_node->populateProperties();
104 $node_list['nodes'][0] = $new_node;
105 }else{
106
107 // look for wildcards and trailing slashes
108 if( strpos($path, "*") === FALSE &&
109 $path[strlen($path) - 1] != '/' ){
110 $path = $path . "/*";
111 }
112
113 $i = 0;
114 foreach (glob($path) as $filename) {
115 $file = basename($filename);
116 if ($file != "." && $file != ".." && $file != ".svn") {
117 $node_uri = str_replace( FILE_SYSTEM_ROOT, VOSPACE_ROOT, $filename );
118
119 $new_node = new Node($node_uri);
120 if($detail != 'min')
121 $new_node->populateProperties();
122 $node_list['nodes'][$i++] = $new_node;
123 }
124 }
125 }
126
127 if(count($node_list['nodes']) == 0)
128 unset($node_list['nodes']);
129
130 return $node_list;
131 }
132
133 }
134
135 ?>

msdemlei@ari.uni-heidelberg.de
ViewVC Help
Powered by ViewVC 1.1.26