1<?php declare(strict_types=1); 2/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4/** 5 * Class ilSamlIdpMetadataInputGUI 6 */ 7class ilSamlIdpMetadataInputGUI extends ilTextAreaInputGUI 8{ 9 /** @var ilSamlIdpXmlMetadataParser */ 10 protected $idpMetadataParser; 11 12 /** 13 * ilSamlIdpMetadataInputGUI constructor. 14 * @param string $a_title 15 * @param string $a_postvar 16 * @param ilSamlIdpXmlMetadataParser|null $idpMetadataParser 17 */ 18 public function __construct($a_title = '', $a_postvar = '', ilSamlIdpXmlMetadataParser $idpMetadataParser = null) 19 { 20 parent::__construct($a_title, $a_postvar); 21 $this->idpMetadataParser = $idpMetadataParser; 22 } 23 24 /** 25 * @return ilSamlIdpXmlMetadataParser 26 */ 27 public function getIdpMetadataParser() 28 { 29 return $this->idpMetadataParser; 30 } 31 32 /** 33 * @inheritdoc 34 */ 35 public function checkInput() 36 { 37 $valid = parent::checkInput(); 38 if (!$valid) { 39 return false; 40 } 41 42 try { 43 $httpValue = $_POST[$this->getPostVar()]; 44 45 $this->idpMetadataParser->parse($httpValue); 46 if ($this->idpMetadataParser->hasErrors()) { 47 $this->setAlert(implode('<br />', $this->idpMetadataParser->getErrors())); 48 return false; 49 } 50 51 if (!$this->idpMetadataParser->getEntityId()) { 52 $this->setAlert($GLOBALS['DIC']->language()->txt('auth_saml_add_idp_md_error')); 53 return false; 54 } 55 } catch (\Exception $e) { 56 $this->setAlert($GLOBALS['DIC']->language()->txt('auth_saml_add_idp_md_error')); 57 return false; 58 } 59 60 return true; 61 } 62} 63