/**
  * @param string $samlMessageXml
  * @param string $class
  * @return SAML_Message
  */
 public function deserialize($samlMessageXml, $class)
 {
     $elementName = $this->getElementForClass($class);
     $document = new DOMDocument();
     $document->loadXML($samlMessageXml);
     $messageDomElement = $document->getElementsByTagNameNs('urn:oasis:names:tc:SAML:2.0:protocol', $elementName)->item(0);
     if ($class === 'SAML2_AuthnRequest') {
         return SAML2_AuthnRequest::fromXML($messageDomElement);
     } else {
         if ($class === 'SAML2_Response') {
             return SAML2_Response::fromXML($messageDomElement);
         }
     }
     throw new EngineBlock_Exception('Unknown message type for deserialization?');
 }