Skip to content

Commit

Permalink
Merge pull request #130 from Edugate/develop
Browse files Browse the repository at this point in the history
metadata validation
  • Loading branch information
janul committed Nov 17, 2014
2 parents a095179 + 26a2805 commit b5cea50
Show file tree
Hide file tree
Showing 6 changed files with 506 additions and 4 deletions.
10 changes: 8 additions & 2 deletions application/libraries/Metadata_validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@

class Metadata_validator
{
protected $rootSchemaFile;

function __construct()
{
$this->ci = &get_instance();
$this->em = $this->ci->doctrine->em;
$this->ci->load->helper('metadata_elements');
$this->rootSchemaFile = $this->ci->config->item('rootSchemaFile');
if(empty($this->rootSchemaFile))
{
$this->rootSchemaFile = 'saml-schema-metadata-2.0.xsd';
}
}

public function validateWithSchema($metadata = null)
Expand Down Expand Up @@ -40,11 +46,11 @@ function ($public, $system, $context) use ($mapping) {
throw new RuntimeException($message);
}
);
$schemaLocation = 'schemas/new/saml-schema-metadata-2.0.xsd';
$schemaLocation = 'schemas/new/'.$this->rootSchemaFile;
}
else
{
$schemaLocation = 'schemas/old/saml-schema-metadata-2.0.xsd';
$schemaLocation = 'schemas/old/'.$this->rootSchemaFile;
}


Expand Down
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
108 changes: 108 additions & 0 deletions schemas/new/oasis-200401-wss-wssecurity-utility-1.0.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS's procedures with respect to rights in OASIS specifications can be found at the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementors or users of this specification, can be obtained from the OASIS Executive Director.
OASIS invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights which may cover technology that may be required to implement this specification. Please address the information to the OASIS Executive Director.
Copyright © OASIS Open 2002-2004. All Rights Reserved.
This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself does not be modified in any way, such as by removing the copyright notice or references to OASIS, except as needed for the purpose of developing OASIS specifications, in which case the procedures for copyrights defined in the OASIS Intellectual Property Rights document must be followed, or as required to translate it into languages other than English.
The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns.
This document and the information contained herein is provided on an “AS IS” basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
-->
<xsd:schema targetNamespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"



xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.1">
<!-- // Fault Codes /////////////////////////////////////////// -->
<xsd:simpleType name="tTimestampFault">
<xsd:annotation>
<xsd:documentation>
This type defines the fault code value for Timestamp message expiration.
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:QName">
<xsd:enumeration value="wsu:MessageExpired"/>
</xsd:restriction>
</xsd:simpleType>
<!-- // Global attributes //////////////////////////////////// -->
<xsd:attribute name="Id" type="xsd:ID">
<xsd:annotation>
<xsd:documentation>
This global attribute supports annotating arbitrary elements with an ID.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attributeGroup name="commonAtts">
<xsd:annotation>
<xsd:documentation>
Convenience attribute group used to simplify this schema.
</xsd:documentation>
</xsd:annotation>
<xsd:attribute ref="wsu:Id" use="optional"/>
<xsd:anyAttribute namespace="##other" processContents="lax"/>
</xsd:attributeGroup>
<!-- // Utility types //////////////////////////////////////// -->
<xsd:complexType name="AttributedDateTime">
<xsd:annotation>
<xsd:documentation>
This type is for elements whose [children] is a psuedo-dateTime and can have arbitrary attributes.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attributeGroup ref="wsu:commonAtts"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="AttributedURI">
<xsd:annotation>
<xsd:documentation>
This type is for elements whose [children] is an anyURI and can have arbitrary attributes.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleContent>
<xsd:extension base="xsd:anyURI">
<xsd:attributeGroup ref="wsu:commonAtts"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<!-- // Timestamp header components /////////////////////////// -->
<xsd:complexType name="TimestampType">
<xsd:annotation>
<xsd:documentation>
This complex type ties together the timestamp related elements into a composite type.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element ref="wsu:Created" minOccurs="0"/>
<xsd:element ref="wsu:Expires" minOccurs="0"/>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:any namespace="##other" processContents="lax"/>
</xsd:choice>
</xsd:sequence>
<xsd:attributeGroup ref="wsu:commonAtts"/>
</xsd:complexType>
<xsd:element name="Timestamp" type="wsu:TimestampType">
<xsd:annotation>
<xsd:documentation>
This element allows Timestamps to be applied anywhere element wildcards are present,
including as a SOAP header.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<!-- global element decls to allow individual elements to appear anywhere -->
<xsd:element name="Expires" type="wsu:AttributedDateTime">
<xsd:annotation>
<xsd:documentation>
This element allows an expiration time to be applied anywhere element wildcards are present.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="Created" type="wsu:AttributedDateTime">
<xsd:annotation>
<xsd:documentation>
This element allows a creation time to be applied anywhere element wildcards are present.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:schema>
137 changes: 137 additions & 0 deletions schemas/new/ws-addr.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
W3C XML Schema defined in the Web Services Addressing 1.0 specification
http://www.w3.org/TR/ws-addr-core
Copyright © 2005 World Wide Web Consortium,
(Massachusetts Institute of Technology, European Research Consortium for
Informatics and Mathematics, Keio University). All Rights Reserved. This
work is distributed under the W3C® Software License [1] in the hope that
it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
$Id: ws-addr.xsd,v 1.2 2008/07/23 13:38:16 plehegar Exp $
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.w3.org/2005/08/addressing" targetNamespace="http://www.w3.org/2005/08/addressing" blockDefault="#all" elementFormDefault="qualified" finalDefault="" attributeFormDefault="unqualified">

<!-- Constructs from the WS-Addressing Core -->

<xs:element name="EndpointReference" type="tns:EndpointReferenceType"/>
<xs:complexType name="EndpointReferenceType" mixed="false">
<xs:sequence>
<xs:element name="Address" type="tns:AttributedURIType"/>
<xs:element ref="tns:ReferenceParameters" minOccurs="0"/>
<xs:element ref="tns:Metadata" minOccurs="0"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>

<xs:element name="ReferenceParameters" type="tns:ReferenceParametersType"/>
<xs:complexType name="ReferenceParametersType" mixed="false">
<xs:sequence>
<xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>

<xs:element name="Metadata" type="tns:MetadataType"/>
<xs:complexType name="MetadataType" mixed="false">
<xs:sequence>
<xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>

<xs:element name="MessageID" type="tns:AttributedURIType"/>
<xs:element name="RelatesTo" type="tns:RelatesToType"/>
<xs:complexType name="RelatesToType" mixed="false">
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:attribute name="RelationshipType" type="tns:RelationshipTypeOpenEnum" use="optional" default="http://www.w3.org/2005/08/addressing/reply"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:simpleType name="RelationshipTypeOpenEnum">
<xs:union memberTypes="tns:RelationshipType xs:anyURI"/>
</xs:simpleType>

<xs:simpleType name="RelationshipType">
<xs:restriction base="xs:anyURI">
<xs:enumeration value="http://www.w3.org/2005/08/addressing/reply"/>
</xs:restriction>
</xs:simpleType>

<xs:element name="ReplyTo" type="tns:EndpointReferenceType"/>
<xs:element name="From" type="tns:EndpointReferenceType"/>
<xs:element name="FaultTo" type="tns:EndpointReferenceType"/>
<xs:element name="To" type="tns:AttributedURIType"/>
<xs:element name="Action" type="tns:AttributedURIType"/>

<xs:complexType name="AttributedURIType" mixed="false">
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<!-- Constructs from the WS-Addressing SOAP binding -->

<xs:attribute name="IsReferenceParameter" type="xs:boolean"/>

<xs:simpleType name="FaultCodesOpenEnumType">
<xs:union memberTypes="tns:FaultCodesType xs:QName"/>
</xs:simpleType>

<xs:simpleType name="FaultCodesType">
<xs:restriction base="xs:QName">
<xs:enumeration value="tns:InvalidAddressingHeader"/>
<xs:enumeration value="tns:InvalidAddress"/>
<xs:enumeration value="tns:InvalidEPR"/>
<xs:enumeration value="tns:InvalidCardinality"/>
<xs:enumeration value="tns:MissingAddressInEPR"/>
<xs:enumeration value="tns:DuplicateMessageID"/>
<xs:enumeration value="tns:ActionMismatch"/>
<xs:enumeration value="tns:MessageAddressingHeaderRequired"/>
<xs:enumeration value="tns:DestinationUnreachable"/>
<xs:enumeration value="tns:ActionNotSupported"/>
<xs:enumeration value="tns:EndpointUnavailable"/>
</xs:restriction>
</xs:simpleType>

<xs:element name="RetryAfter" type="tns:AttributedUnsignedLongType"/>
<xs:complexType name="AttributedUnsignedLongType" mixed="false">
<xs:simpleContent>
<xs:extension base="xs:unsignedLong">
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:element name="ProblemHeaderQName" type="tns:AttributedQNameType"/>
<xs:complexType name="AttributedQNameType" mixed="false">
<xs:simpleContent>
<xs:extension base="xs:QName">
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:element name="ProblemIRI" type="tns:AttributedURIType"/>

<xs:element name="ProblemAction" type="tns:ProblemActionType"/>
<xs:complexType name="ProblemActionType" mixed="false">
<xs:sequence>
<xs:element ref="tns:Action" minOccurs="0"/>
<xs:element name="SoapAction" minOccurs="0" type="xs:anyURI"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>

</xs:schema>
Loading

0 comments on commit b5cea50

Please sign in to comment.