/** * Returns the object representation of the SecurityTokenReference block * * @throws \Zend\InfoCard\XML\Exception * @return \Zend\InfoCard\XML\SecurityTokenReference */ public function getSecurityTokenReference() { $this->registerXPathNamespace('o', 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'); list($sectokenref) = $this->xpath('//o:SecurityTokenReference'); if (!$sectokenref instanceof \Zend\InfoCard\XML\AbstractElement) { throw new \Zend\InfoCard\XML\Exception\RuntimeException('Could not locate the Security Token Reference'); } return \Zend\InfoCard\XML\SecurityTokenReference::getInstance($sectokenref); }
public function testSecurityTokenReferenceThrowsExceptionsOnKeyReferenceRetrievalWithInvalidXml() { $doc = file_get_contents(__DIR__ . "/_files/security_token_bad_keyref.xml"); $this->setExpectedException('Zend\InfoCard\XML\Exception\RuntimeException', 'Unknown Key Reference Encoding Type:'); $si = XML\SecurityTokenReference::getInstance($doc); $si->getKeyReference(); }
public function testSecurityTokenReferenceErrors() { try { XML\SecurityTokenReference::getInstance("<foo/>"); $this->fail("Expected Exception Not thrown"); } catch (\Exception $e) { /* yay */ } try { XML\SecurityTokenReference::getInstance(10); $this->fail("Expected Exception Not thrown"); } catch (\Exception $e) { /* yay */ } $doc = file_get_contents(dirname(__FILE__) . "/_files/security_token_bad_keyref.xml"); try { $si = XML\SecurityTokenReference::getInstance($doc); $si->getKeyReference(); $this->fail("Expected Exception Not thrown"); } catch (\Exception $e) { /* yay */ } }