Skip to content

Commit

Permalink
add optional allow to set xsd for validation
Browse files Browse the repository at this point in the history
  • Loading branch information
janul committed Nov 17, 2014
1 parent 9314d9f commit 26a2805
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions application/libraries/Xmlvalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Xmlvalidator

private $xmlDOM;
private $pubKey;
private $rootSchemaFile;

function __construct()
{
Expand All @@ -18,6 +19,11 @@ function __construct()
$this->xmlDOM = new \DOMDocument();
$this->xmlDOM->strictErrorChecking = FALSE;
$this->xmlDOM->WarningChecking = FALSE;
$this->rootSchemaFile = $this->ci->config->item('rootSchemaFile');
if(empty($this->rootSchemaFile))
{
$this->rootSchemaFile = 'saml-schema-metadata-2.0.xsd';
}
}

public function validateMetadata($xml, $signed = FALSE, $pubkey = FALSE)
Expand Down Expand Up @@ -48,7 +54,7 @@ public function validateMetadata($xml, $signed = FALSE, $pubkey = FALSE)
}
if ($signed === FALSE)
{
$result = $this->xmlDOM->schemaValidate('schemas/old/saml-schema-metadata-2.0.xsd');
$result = $this->xmlDOM->schemaValidate('schemas/old/'.$this->rootSchemaFile.'');
$errors = libxml_get_errors();
if ($result === TRUE)
{
Expand Down Expand Up @@ -118,7 +124,7 @@ public function validateMetadata($xml, $signed = FALSE, $pubkey = FALSE)
}
else
{
$result = $this->xmlDOM->schemaValidate('schemas/old/saml-schema-metadata-2.0.xsd');
$result = $this->xmlDOM->schemaValidate('schemas/old/'.$this->rootSchemaFile.'');
$errors = libxml_get_errors();
if ($result === TRUE)
{
Expand Down

0 comments on commit 26a2805

Please sign in to comment.