Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
saml_account_manager_edit_fns.inc
1 <?php
17 require_once SQ_PACKAGES_PATH.'/cms/page_templates/page_asset_builder/page_asset_builder_edit_fns.inc';
18 
31 {
32 
33 
38  function __construct()
39  {
40  parent::__construct();
41  }//end constructor
42 
43 
44 
55  function paintSimplesamlphpInstall (&$asset, &$o, $prefix)
56  {
57  $installed = $asset->isSimplesamlphpInstalled();
58  if ($installed) {
59  echo '<span style="color:green;font-weight:bold">Installed</span>';
60  } else {
61  echo '<span style="color:red;font-weight:bold">Not Installed</span>';
62  }//end if
63 
64  }//end paintSimplesamlphpInstall()
65 
66 
77  function paintAuthSource(&$asset, &$o, $prefix)
78  {
79  $installed = $asset->isSimplesamlphpInstalled();
80  if ($installed) {
81  require SQ_TOOL_SIMPLESAMLPHP_PATH.'/config/authsources.php';
82  $options[''] = '';
83  foreach ($config as $name => $value) {
84  $options[$name] = $name;
85  }
86 
87  if (!$asset->writeAccess('attributes')) {
88  echo $options[$asset->attr('auth_source')];
89  } else {
90  combo_box($prefix.'_auth_source', $options, FALSE, $asset->attr('auth_source'));
91  }
92  }
93 
94  }//end paintAuthSource()
95 
96 
107  function processAuthSource(&$asset, &$o, $prefix)
108  {
109  if (isset($_POST[$prefix.'_auth_source'])) {
110  $id = trim($_POST[$prefix.'_auth_source']);
111  if (empty($id)) return FALSE;
112  $asset->setAttrValue('auth_source', $id);
113  return TRUE;
114  }
115  return FALSE;
116 
117  }//end processAuthSource()
118 
129  function paintMetadataUrl(&$asset, &$o, $prefix)
130  {
131  if($asset->attr('auth_source')) {
132  $url = $asset->getUrl();
133  echo '<a href="'.$url.'?showMetadata">'.$url.'?showMetadata'.'</a>';
134  }
135  }
136 
147  function paintAcsUrl(&$asset, &$o, $prefix)
148  {
149  $acs_asset = $GLOBALS['SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_TYPE_2, 'saml2_acs', TRUE, 'saml2_assertion_consumer_service', 'major', '1');
150  $acs_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($acs_asset['minorid']);
151  if($acs_asset) {
152  echo ($acs_asset->getUrl());
153  }
154  }
155 
156 
167  function paintSlsUrl(&$asset, &$o, $prefix)
168  {
169  $sls_asset = $GLOBALS['SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_TYPE_2, 'saml2_sls', TRUE, 'saml2_single_logout_service', 'major', '1');
170  $sls_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($sls_asset['minorid']);
171  if($sls_asset) {
172  echo ($sls_asset->getUrl());
173  }
174  }
175 
176 
177 
178 
189  function paintRedirectAssetid(&$asset, &$o, $prefix)
190  {
191  $redirect_asset = $asset->getRedirectAsset();
192  if ($asset->writeAccess('links')) {
193  asset_finder($prefix.'_redirect_assetid', (is_null($redirect_asset) ? 0 : $redirect_asset->id));
194  } else {
195  if (is_null($redirect_asset)) {
196  echo translate('saml_redirect_none_set');
197  } else {
198  echo get_asset_tag_line($redirect_asset->id);
199  }
200  }
201  return TRUE;
202 
203  }//end paintRedirectAssetid()
204 
205 
216  function processRedirectAssetid(&$asset, &$o, $prefix)
217  {
218  if (!isset($_POST[$prefix.'_redirect_assetid']['assetid']) || (isset($asset->_tmp['reverting_to_system_version']) && $asset->_tmp['reverting_to_system_version'])) {
219  return TRUE;
220  }
221 
222  $redirect_assetid = $_POST[$prefix.'_redirect_assetid']['assetid'];
223 
224  if ($redirect_assetid) {
225  $redirect_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($redirect_assetid);
226  } else {
227  $redirect_asset = NULL;
228  }
229 
230  return $asset->setRedirectAsset($redirect_asset);
231 
232  }//end processRedirectAssetid()
233 
234 
235 
246  function paintAddCreateType(&$asset, &$o, $prefix)
247  {
248  if (!$asset->writeAccess('attributes')) {
249  parent::paintAssetTypes($asset, $o, $prefix);
250  } else {
251  $user_types = $GLOBALS['SQ_SYSTEM']->am->getTypeDescendants('user');
252 
253  $options = Array('user' => 'User');
254  foreach ($user_types as $type_code) {
255  $info = $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($type_code);
256  if ($info['allowed_access'] != 'system' && $info['instantiable']) {
257  $options[$type_code] = $info['name'];
258  }
259  }
260  combo_box($prefix.'_create_type', $options, FALSE, array_keys($asset->attr('create_type')));
261  }
262 
263  }//end paintAddCreateType()
264 
265 
279  function processAddCreateType(&$asset, &$o, $prefix)
280  {
281  if (isset($_POST[$prefix.'_create_type'])) {
282  $type = trim($_POST[$prefix.'_create_type']);
283  if (empty($type)) return FALSE;
284  $types = Array($type => TRUE);
285  $asset->setAttrValue('create_type', $types);
286  return TRUE;
287  }
288  return FALSE;
289 
290  }//end processAddCreateType()
291 
292 
293 
304  function paintCreateFormCustomisation(&$asset, &$o, $prefix)
305  {
306  $customised_types = $asset->attr('create_form_customisations');
307  $wa = $asset->writeAccess('attributes');
308  if ($wa) {
309  hidden_field($prefix.'_customise_form_submitted', 1);
310  echo check_box($prefix.'_customise_form', 1, !empty($customised_types));
311  } else {
312  $fn = !empty($customised_types) ? 'tick' : 'cross';
313  echo '<img src="'.sq_web_path('lib').'/web/images/'.$fn.'.gif" />';
314  }
315 
316  }//end paintCreateFormCustomisation()
317 
318 
329  function processCreateFormCustomisation(&$asset, &$o, $prefix)
330  {
331  if ($asset->writeAccess('attributes') && isset($_POST[$prefix.'_customise_form_submitted'])) {
332  $customise = array_get_index($_POST, $prefix.'_customise_form');
333  $customised_types = $customise ? array_keys($asset->attr('create_type')) : Array();
334  return $asset->setAttrValue('create_form_customisations', $customised_types);
335  }
336  return FALSE;
337 
338  }//end processCreateFormCustomisation()
339 
340 
341 
342 
353  function paintParseMetadata (&$asset, &$o, $prefix)
354  {
355  $wa = $asset->writeAccess('attributes');
356  $xmldata = isset($_POST[$prefix.'_parse_metadata']) ? trim($_POST[$prefix.'_parse_metadata']) : '';
357  if ($wa) {
358  if (!empty($xmldata)) {
359  try {
360  SimpleSAML_Utilities::validateXMLDocument($xmldata, 'saml-meta');
361  $entities = SimpleSAML_Metadata_SAMLParser::parseDescriptorsString($xmldata);
362 
363  /* Get all metadata for the entities. */
364  foreach($entities as &$entity) {
365  $entity = array(
366  'saml20-idp-remote' => $entity->getMetadata20IdP(),
367  );
368 
369  }
370 
371  /* Transpose from $entities[entityid][type] to $output[type][entityid]. */
372  $output = SimpleSAML_Utilities::transposeArray($entities);
373  }
374  catch (Exception $e) {
375  trigger_error($e->getMessage());
376  return TRUE;
377  }
378  pre_echo($output['saml20-idp-remote']);
379  return TRUE;
380  }
381  else {
382  text_area($prefix.'_parse_metadata', '', 100, 5);
383  }
384  }
385  return TRUE;
386  }//end paintParseMetadata()
387 
388 
389 
390 
391 
401  function use_extensions (&$asset, $prefix)
402  {
403  $use_extensions = $asset->attr('use_extensions');
404  return ($use_extensions);
405  } // end use_extensions()
406 
416  function saml_userid_in_attribute (&$asset, $prefix)
417  {
418  $location = $asset->attr('saml_userid_location');
419  return ($location == 'attribute');
420  } // end saml_userid_in_attribute()
421 
422 
423 
424 
425 }//end class
426 
427 ?>