ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 */
7
8
9 private $metadata;
10 private $attributes;
11 private $prefix;
12 private $suffix;
13
20 $this->metadata = $metadata;
21
22 $this->prefix = $prefix;
23 $this->suffix = $suffix;
24
26 }
27
28 private function loadAttributeMap($attributemap) {
30 include($config->getPathValue('attributemap', 'attributemap/') . $attributemap . '.php');
31 $this->attributes = $attributemap;
32 }
33
34 private function surround($name) {
35 $ret = '';
36 if (!empty($this->prefix)) $ret .= $this->prefix;
37 $ret .= $name;
38 if (!empty($this->suffix)) $ret .= $this->suffix;
39 return $ret;
40 }
41
42 private function getAttributeID($name) {
43 if (empty($this->attributes)) {
44 return $this->surround($name);
45 }
46 if (array_key_exists($name, $this->attributes)) {
47 return $this->surround($this->attributes[$name]);
48 }
49 return $this->surround($name);
50 }
51
52 public function getXML() {
53
54 $xml = '<?xml version="1.0" encoding="UTF-8"?>
55<AttributeFilterPolicyGroup id="urn:mace:funet.fi:haka:kalmar" xmlns="urn:mace:shibboleth:2.0:afp"
56 xmlns:basic="urn:mace:shibboleth:2.0:afp:mf:basic" xmlns:saml="urn:mace:shibboleth:2.0:afp:mf:saml"
57 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
58 xsi:schemaLocation="urn:mace:shibboleth:2.0:afp classpath:/schema/shibboleth-2.0-afp.xsd
59 urn:mace:shibboleth:2.0:afp:mf:basic classpath:/schema/shibboleth-2.0-afp-mf-basic.xsd
60 urn:mace:shibboleth:2.0:afp:mf:saml classpath:/schema/shibboleth-2.0-afp-mf-saml.xsd">
61';
62
63
64 foreach($this->metadata AS $metadata) {
65 $xml .= $this->getEntryXML($metadata['metadata']);
66 }
67
68 $xml .= '</AttributeFilterPolicyGroup>';
69 return $xml;
70 }
71
72 private function getEntryXML($entry) {
73 $entityid = $entry['entityid'];
74 return ' <AttributeFilterPolicy id="' . $entityid . '">
75 <PolicyRequirementRule xsi:type="basic:AttributeRequesterString" value="' . $entityid . '" />
76' . $this->getEntryXMLcontent($entry) . '
77 </AttributeFilterPolicy>
78';
79 }
80
81 private function getEntryXMLcontent($entry) {
82 $ids = array();
83 if (!array_key_exists('attributes', $entry))
84 return '';
85
86 $ret = '';
87 foreach($entry['attributes'] AS $a) {
88
89 $ret .= ' <AttributeRule attributeID="' . $this->getAttributeID($a) . '">
90 <PermitValueRule xsi:type="basic:ANY" />
91 </AttributeRule>
92';
93
94 }
95 return $ret;
96 }
97
98}
99
$attributemap
Definition: addurnprefix.php:3
An exception for terminatinating execution or to throw for unit testing.
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
loadAttributeMap($attributemap)
Definition: ARP.php:28
__construct($metadata, $attributemap, $prefix, $suffix)
Constructor.
Definition: ARP.php:19
getEntryXML($entry)
Definition: ARP.php:72
getAttributeID($name)
Definition: ARP.php:42
getEntryXMLcontent($entry)
Definition: ARP.php:81
if($format !==null) $name
Definition: metadata.php:146
$xml
Definition: metadata.php:240
$ret
Definition: parser.php:6