Blame view

bin/checkMergedMetadata.php 1.46 KB
e2d01488a   Esmeralda Pires   1ºVersão
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  #!/usr/bin/env php
  <?php
  
  define('SIMPLESAMLPATH', dirname(dirname(dirname(dirname(__FILE__)))));
  define('MODULEPATH', (dirname(dirname(__FILE__))));
  ini_set('error_level', E_ALL & E_STRICT);
  ini_set('display_errors', true);
  
  require(MODULEPATH.'/config/config.php');
  
  
  if(!($gen = @file_get_contents(SIMPLESAMLPATH.'/'.$destinationgenerated.'/saml20-sp-merged.php'))) {
  	echo("failed to get generated file's contents
  ");
  	exit(2);
  }
  
  $gen = preg_replace('/<\?php/', '', $gen);
  $gen = preg_replace('/\?>/', '', $gen);
  
  if(($ret = @eval($gen) === false)) {
  	echo("parse error in generated code
  ");
  	exit(2);
  }
  
  function _raise_error($msg) {
  	echo($msg."
  ");
  	exit(3);
  }
  
  if(!isset($metadata))
  	_raise_error('metadata variable not set');
  
  if(!is_array($metadata))
  	_raise_error('metadata variable is not an array');
  
  if(sizeof($metadata) < 10)
  	_raise_error('metadata array holds less than 10 items');
  
  foreach($metadata as $k => $m) {
  	if(!is_array($m))
  		_raise_error('metadata item '.((string)$k).' is not an array');
  	if(empty($m['entityid']) || !is_string($m['entityid']))
  		_raise_error('metadata item '.((string)$k).' has empty or non-string \'entityid\' member');
  	if(empty($m['authproc']) || !is_array($m['authproc']))
  		_raise_error('metadata item '.((string)$k).' has empty or non-array \'authproc\' member');
  	if(empty($m['attributes']) || !is_array($m['attributes']))
  		_raise_error('metadata item '.((string)$k).' has empty or non-array \'attributes\' member');
  }
  
  exit(0);
  
  ?>