ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
frontpage_federation.php
Go to the documentation of this file.
1 <?php
2 
3 
4 
5 // Load SimpleSAMLphp, configuration
8 
9 // Check if valid local session exists.
10 if ($config->getBoolean('admin.protectindexpage', false)) {
12 }
15 
16 
17 
18 
19 
20 
21 
22 $links = array();
23 $links_welcome = array();
24 $links_config = array();
25 $links_auth = array();
27 
28 if ($config->getBoolean('idpdisco.enableremember', false)) {
29  $links_federation[] = array(
30  'href' => 'cleardiscochoices.php',
31  'text' => '{core:frontpage:link_cleardiscochoices}',
32  );
33 }
34 
35 
37  'href' => \SimpleSAML\Utils\HTTP::getBaseURL() . 'admin/metadata-converter.php',
38  'text' => '{core:frontpage:link_xmlconvert}',
39 );
40 
41 
42 
43 
44 $allLinks = array(
45  'links' => &$links,
46  'welcome' => &$links_welcome,
47  'config' => &$links_config,
48  'auth' => &$links_auth,
49  'federation' => &$links_federation,
50 );
52 
53 
54 $metadataHosted = array();
56 
57 
58 
59 
60 
61 
62 
63 
64 
66 
67 $metaentries = array('hosted' => $metadataHosted, 'remote' => array() );
68 
69 
70 if ($isadmin) {
71  $metaentries['remote']['saml20-idp-remote'] = $metadata->getList('saml20-idp-remote');
72  $metaentries['remote']['shib13-idp-remote'] = $metadata->getList('shib13-idp-remote');
73 }
74 
75 if ($config->getBoolean('enable.saml20-idp', false) === true) {
76  try {
77  $metaentries['hosted']['saml20-idp'] = $metadata->getMetaDataCurrent('saml20-idp-hosted');
78  $metaentries['hosted']['saml20-idp']['metadata-url'] =
79  $config->getBasePath().'saml2/idp/metadata.php?output=xhtml';
80  if ($isadmin)
81  $metaentries['remote']['saml20-sp-remote'] = $metadata->getList('saml20-sp-remote');
82  } catch(Exception $e) {
83  \SimpleSAML\Logger::error('Federation: Error loading saml20-idp: '.$e->getMessage());
84  }
85 }
86 if ($config->getBoolean('enable.shib13-idp', false) === true) {
87  try {
88  $metaentries['hosted']['shib13-idp'] = $metadata->getMetaDataCurrent('shib13-idp-hosted');
89  $metaentries['hosted']['shib13-idp']['metadata-url'] =
90  $config->getBasePath().'shib13/idp/metadata.php?output=xhtml';
91  if ($isadmin)
92  $metaentries['remote']['shib13-sp-remote'] = $metadata->getList('shib13-sp-remote');
93  } catch(Exception $e) {
94  \SimpleSAML\Logger::error('Federation: Error loading shib13-idp: ' . $e->getMessage());
95  }
96 }
97 if ($config->getBoolean('enable.adfs-idp', false) === true) {
98  try {
99  $metaentries['hosted']['adfs-idp'] = $metadata->getMetaDataCurrent('adfs-idp-hosted');
100  $metaentries['hosted']['adfs-idp']['metadata-url'] = \SimpleSAML\Module::getModuleURL(
101  'adfs/idp/metadata.php',
102  array('output' => 'xhtml')
103  );
104  if ($isadmin)
105  $metaentries['remote']['adfs-sp-remote'] = $metadata->getList('adfs-sp-remote');
106  } catch(Exception $e) {
107  SimpleSAML\Logger::error('Federation: Error loading adfs-idp: ' . $e->getMessage());
108  }
109 }
110 
111 foreach ($metaentries['remote'] as $key => $value) {
112  if (empty($value)) {
113  unset($metaentries['remote'][$key]);
114  }
115 }
116 
117 $t = new SimpleSAML_XHTML_Template($config, 'core:frontpage_federation.tpl.php');
118 $translator = $t->getTranslator();
119 
120 $language = $translator->getLanguage()->getLanguage();
121 $defaultLanguage = $config->getString('language.default', 'en');
122 
123 $translators = array(
124  'name' => 'name_translated',
125  'descr' => 'descr_translated',
126  'OrganizationDisplayName' => 'organizationdisplayname_translated',
127 );
128 
129 foreach ($metaentries['hosted'] as $index => $entity) {
130  foreach ($translators as $old => $new) {
131  if (isset($entity[$old][$language])) {
132  $metaentries['hosted'][$index][$new] = $entity[$old][$language];
133  } elseif (isset($entity[$old][$defaultLanguage])) {
134  $metaentries['hosted'][$index][$new] = $entity[$old][$defaultLanguage];
135  } elseif (isset($metaentries['hosted'][$index][$old])) {
136  $metaentries['hosted'][$index][$new] = $metaentries['hosted'][$index][$old];
137  }
138  }
139 }
140 foreach ($metaentries['remote'] as $key => $set) {
141  foreach ($set as $entityid => $entity) {
142  foreach ($translators as $old => $new) {
143  if (isset($entity[$old][$language])) {
144  $metaentries['remote'][$key][$entityid][$new] = $entity[$old][$language];
145  } elseif (isset($entity[$old][$defaultLanguage])) {
146  $metaentries['remote'][$key][$entityid][$new] = $entity[$old][$defaultLanguage];
147  } elseif (isset($metaentries['remote'][$key][$entityid][$old])) {
148  $metaentries['remote'][$key][$entityid][$new] = $metaentries['remote'][$key][$entityid][$old];
149  }
150  }
151  }
152 }
153 
154 # look up translated string
155 $mtype = array(
156  'saml20-sp-remote' => $translator->noop('{admin:metadata_saml20-sp}'),
157  'saml20-sp-hosted' => $translator->noop('{admin:metadata_saml20-sp}'),
158  'saml20-idp-remote' => $translator->noop('{admin:metadata_saml20-idp}'),
159  'saml20-idp-hosted' => $translator->noop('{admin:metadata_saml20-idp}'),
160  'shib13-sp-remote' => $translator->noop('{admin:metadata_shib13-sp}'),
161  'shib13-sp-hosted' => $translator->noop('{admin:metadata_shib13-sp}'),
162  'shib13-idp-remote' => $translator->noop('{admin:metadata_shib13-idp}'),
163  'shib13-idp-hosted' => $translator->noop('{admin:metadata_shib13-idp}'),
164  'adfs-sp-remote' => $translator->noop('{admin:metadata_adfs-sp}'),
165  'adfs-sp-hosted' => $translator->noop('{admin:metadata_adfs-sp}'),
166  'adfs-idp-remote' => $translator->noop('{admin:metadata_adfs-idp}'),
167  'adfs-idp-hosted' => $translator->noop('{admin:metadata_adfs-idp}'),
168 );
169 
170 $t->data['pageid'] = 'frontpage_federation';
171 $t->data['isadmin'] = $isadmin;
172 $t->data['loginurl'] = $loginurl;
173 
174 
175 $t->data['links'] = $links;
176 $t->data['links_welcome'] = $links_welcome;
177 $t->data['links_config'] = $links_config;
178 $t->data['links_auth'] = $links_auth;
179 $t->data['links_federation'] = $links_federation;
180 
181 
182 $t->data['metaentries'] = $metaentries;
183 $t->data['mtype'] = $mtype;
184 
185 
186 $t->show();
187 
static getMetadataHandler()
This function retrieves the current instance of the metadata handler.
static requireAdmin()
Require admin access to the current page.
Definition: Auth.php:60
static isAdmin()
Check whether the current user is admin.
Definition: Auth.php:42
static getAdminLoginURL($returnTo=null)
Retrieve a admin login URL.
Definition: Auth.php:22
if($isadmin) if($config->getBoolean('enable.saml20-idp', false)===true) if($config->getBoolean('enable.shib13-idp', false)===true) if($config->getBoolean('enable.adfs-idp', false)===true) foreach($metaentries['remote'] as $key=> $value) $t
static callHooks($hook, &$data=null)
Call a hook in all enabled modules.
Definition: Module.php:281
$index
Definition: metadata.php:60
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
Definition: Module.php:220
Attribute-related utility methods.
getBaseURL($t, $type='get', $key=null, $value=null)
Definition: showstats.php:145
foreach($metaentries['hosted'] as $index=> $entity) foreach($metaentries['remote'] as $key=> $set) $mtype
static error($string)
Definition: Logger.php:166
if($config->getBoolean('admin.protectindexpage', false)) $loginurl
$key
Definition: croninfo.php:18
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:241
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.