ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ARP.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Andreas Åkre Solberg <andreas.solberg@uninett.no>
4  * @package SimpleSAMLphp
5  */
6 
8 {
12  private $metadata;
13 
17  private $attributes;
18 
22  private $prefix;
23 
27  private $suffix;
28 
38  {
39  $this->metadata = $metadata;
40  $this->prefix = $prefix;
41  $this->suffix = $suffix;
42 
43  if (isset($attributemap)) {
45  }
46  }
47 
53  private function loadAttributeMap($attributemap)
54  {
56  include($config->getPathValue('attributemap', 'attributemap/') . $attributemap . '.php');
57  // Note that $attributemap was a string before the call to include() and is now an array!
58  $this->attributes = $attributemap;
59  }
60 
66  private function surround($name)
67  {
68  $ret = '';
69  if (!empty($this->prefix)) {
71  }
72  $ret .= $name;
73  if (!empty($this->suffix)) {
75  }
76  return $ret;
77  }
78 
84  private function getAttributeID($name)
85  {
86  if (empty($this->attributes)) {
87  return $this->surround($name);
88  }
89  if (array_key_exists($name, $this->attributes)) {
90  return $this->surround($this->attributes[$name]);
91  }
92  return $this->surround($name);
93  }
94 
98  public function getXML()
99  {
100  $xml = <<<MSG
101  <?xml version="1.0" encoding="UTF-8"?>
102  <AttributeFilterPolicyGroup id="urn:mace:funet.fi:haka:kalmar" xmlns="urn:mace:shibboleth:2.0:afp"
103  xmlns:basic="urn:mace:shibboleth:2.0:afp:mf:basic" xmlns:saml="urn:mace:shibboleth:2.0:afp:mf:saml"
104  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
105  xsi:schemaLocation="urn:mace:shibboleth:2.0:afp classpath:/schema/shibboleth-2.0-afp.xsd
106  urn:mace:shibboleth:2.0:afp:mf:basic classpath:/schema/shibboleth-2.0-afp-mf-basic.xsd
107  urn:mace:shibboleth:2.0:afp:mf:saml classpath:/schema/shibboleth-2.0-afp-mf-saml.xsd">
108 MSG;
109 
110  foreach ($this->metadata as $metadata) {
111  $xml .= $this->getEntryXML($metadata['metadata']);
112  }
113 
114  $xml .= '</AttributeFilterPolicyGroup>';
115  return $xml;
116  }
117 
123  private function getEntryXML($entry)
124  {
125  $entityid = $entry['entityid'];
126  return ' <AttributeFilterPolicy id="' . $entityid .
127  '"><PolicyRequirementRule xsi:type="basic:AttributeRequesterString" value="' . $entityid .
128  '" />' . $this->getEntryXMLcontent($entry) . '</AttributeFilterPolicy>';
129  }
130 
136  private function getEntryXMLcontent($entry)
137  {
138  if (!array_key_exists('attributes', $entry)) {
139  return '';
140  }
141 
142  $ret = '';
143  foreach ($entry['attributes'] as $a) {
144  $ret .= ' <AttributeRule attributeID="' . $this->getAttributeID($a) .
145  '"><PermitValueRule xsi:type="basic:ANY" /></AttributeRule>';
146  }
147  return $ret;
148  }
149 }
$config
Definition: bootstrap.php:15
loadAttributeMap($attributemap)
Definition: ARP.php:53
getAttributeID($name)
Definition: ARP.php:84
getEntryXMLcontent($entry)
Definition: ARP.php:136
$attributemap
Definition: addurnprefix.php:3
$ret
Definition: parser.php:6
__construct($metadata, $attributemap, $prefix, $suffix)
Constructor.
Definition: ARP.php:37
getEntryXML($entry)
Definition: ARP.php:123
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.