From 504baa0bf64bc69cb1002adc34ab4cc48991201c Mon Sep 17 00:00:00 2001
From: Charles Bell <cb8@users.noreply.github.com>
Date: Sun, 29 Nov 2015 19:40:35 +0100
Subject: [PATCH 01/17] Rename SAML2_Const to SAML2_Constants

---
 src/SAML2/ArtifactResolve.php                 |  2 +-
 src/SAML2/Assertion.php                       | 76 +++++++++----------
 .../SubjectConfirmationMethod.php             |  4 +-
 src/SAML2/AttributeQuery.php                  | 14 ++--
 src/SAML2/AuthnRequest.php                    | 22 +++---
 src/SAML2/Binding.php                         |  8 +-
 src/SAML2/{Const.php => Constants.php}        |  2 +-
 src/SAML2/EncryptedAssertion.php              |  2 +-
 src/SAML2/LogoutRequest.php                   |  4 +-
 src/SAML2/Message.php                         | 18 ++---
 src/SAML2/Response.php                        |  2 +-
 .../ConstraintValidator/IsSuccessful.php      |  4 +-
 src/SAML2/StatusResponse.php                  | 12 +--
 src/SAML2/SubjectQuery.php                    |  2 +-
 src/SAML2/Utils.php                           | 10 +--
 .../XML/md/AdditionalMetadataLocation.php     |  2 +-
 src/SAML2/XML/md/AffiliationDescriptor.php    |  6 +-
 .../XML/md/AttributeAuthorityDescriptor.php   |  8 +-
 .../XML/md/AttributeConsumingService.php      | 10 +--
 src/SAML2/XML/md/AuthnAuthorityDescriptor.php |  4 +-
 src/SAML2/XML/md/ContactPerson.php            | 12 +--
 src/SAML2/XML/md/EndpointType.php             |  2 +-
 src/SAML2/XML/md/EntitiesDescriptor.php       |  4 +-
 src/SAML2/XML/md/EntityDescriptor.php         |  6 +-
 src/SAML2/XML/md/Extensions.php               |  2 +-
 src/SAML2/XML/md/IDPSSODescriptor.php         |  4 +-
 src/SAML2/XML/md/KeyDescriptor.php            |  2 +-
 src/SAML2/XML/md/Organization.php             | 14 ++--
 src/SAML2/XML/md/PDPDescriptor.php            |  4 +-
 src/SAML2/XML/md/RequestedAttribute.php       |  2 +-
 src/SAML2/XML/md/RoleDescriptor.php           |  2 +-
 src/SAML2/XML/md/SSODescriptorType.php        |  4 +-
 src/SAML2/XML/saml/Attribute.php              |  2 +-
 src/SAML2/XML/saml/AttributeValue.php         | 14 ++--
 src/SAML2/XML/saml/NameID.php                 |  2 +-
 src/SAML2/XML/saml/SubjectConfirmation.php    |  2 +-
 .../XML/saml/SubjectConfirmationData.php      |  2 +-
 src/SAML2/XML/samlp/Extensions.php            |  2 +-
 .../SubjectConfirmationMethodTest.php         |  4 +-
 tests/SAML2/AuthnRequestTest.php              |  6 +-
 tests/SAML2/LogoutRequestTest.php             |  2 +-
 .../ConstraintValidator/IsSuccessfulTest.php  |  2 +-
 tests/SAML2/ResponseTest.php                  |  4 +-
 tests/SAML2/UtilsTest.php                     |  8 +-
 .../XML/md/AdditionalMetadataLocationTest.php |  4 +-
 .../XML/md/AffiliationDescriptorTest.php      |  6 +-
 tests/SAML2/XML/md/EndpointTypeTest.php       |  2 +-
 tests/SAML2/XML/md/RoleDescriptorMock.php     |  2 +-
 tests/SAML2/XML/md/RoleDescriptorTest.php     |  2 +-
 tests/SAML2/XML/saml/AttributeTest.php        |  4 +-
 tests/SAML2/XML/saml/NameIDTest.php           |  2 +-
 .../XML/saml/SubjectConfirmationDataTest.php  |  2 +-
 .../XML/saml/SubjectConfirmationTest.php      |  2 +-
 53 files changed, 173 insertions(+), 173 deletions(-)
 rename src/SAML2/{Const.php => Constants.php} (99%)

diff --git a/src/SAML2/ArtifactResolve.php b/src/SAML2/ArtifactResolve.php
index c3daae028..36f222e8e 100644
--- a/src/SAML2/ArtifactResolve.php
+++ b/src/SAML2/ArtifactResolve.php
@@ -51,7 +51,7 @@ public function setArtifact($artifact)
     public function toUnsignedXML()
     {
         $root = parent::toUnsignedXML();
-        $artifactelement = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'Artifact', $this->artifact);
+        $artifactelement = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'Artifact', $this->artifact);
         $root->appendChild($artifactelement);
 
         return $root;
diff --git a/src/SAML2/Assertion.php b/src/SAML2/Assertion.php
index 2684401f3..1baed6362 100644
--- a/src/SAML2/Assertion.php
+++ b/src/SAML2/Assertion.php
@@ -216,7 +216,7 @@ public function __construct(DOMElement $xml = NULL)
         $this->issuer = '';
         $this->authnInstant = SAML2_Utilities_Temporal::getTime();
         $this->attributes = array();
-        $this->nameFormat = SAML2_Const::NAMEFORMAT_UNSPECIFIED;
+        $this->nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
         $this->certificates = array();
         $this->AuthenticatingAuthority = array();
         $this->SubjectConfirmation = array();
@@ -331,12 +331,12 @@ private function parseConditions(DOMElement $xml)
             if ($node instanceof DOMText) {
                 continue;
             }
-            if ($node->namespaceURI !== SAML2_Const::NS_SAML) {
+            if ($node->namespaceURI !== SAML2_Constants::NS_SAML) {
                 throw new Exception('Unknown namespace of condition: ' . var_export($node->namespaceURI, TRUE));
             }
             switch ($node->localName) {
                 case 'AudienceRestriction':
-                    $audiences = SAML2_Utils::extractStrings($node, SAML2_Const::NS_SAML, 'Audience');
+                    $audiences = SAML2_Utils::extractStrings($node, SAML2_Constants::NS_SAML, 'Audience');
                     if ($this->validAudiences === NULL) {
                         /* The first (and probably last) AudienceRestriction element. */
                         $this->validAudiences = $audiences;
@@ -450,7 +450,7 @@ private function parseAuthnContext(DOMElement $authnStatementEl)
 
         $this->AuthenticatingAuthority = SAML2_Utils::extractStrings(
             $authnContextEl,
-            SAML2_Const::NS_SAML,
+            SAML2_Constants::NS_SAML,
             'AuthenticatingAuthority'
         );
     }
@@ -474,7 +474,7 @@ private function parseAttributes(DOMElement $xml)
             if ($attribute->hasAttribute('NameFormat')) {
                 $nameFormat = $attribute->getAttribute('NameFormat');
             } else {
-                $nameFormat = SAML2_Const::NAMEFORMAT_UNSPECIFIED;
+                $nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
             }
 
             if ($firstAttribute) {
@@ -482,7 +482,7 @@ private function parseAttributes(DOMElement $xml)
                 $firstAttribute = FALSE;
             } else {
                 if ($this->nameFormat !== $nameFormat) {
-                    $this->nameFormat = SAML2_Const::NAMEFORMAT_UNSPECIFIED;
+                    $this->nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
                 }
             }
 
@@ -750,7 +750,7 @@ public function decryptAttributes(XMLSecurityKey $key, array $blacklist = array(
             if ($attribute->hasAttribute('NameFormat')) {
                 $nameFormat = $attribute->getAttribute('NameFormat');
             } else {
-                $nameFormat = SAML2_Const::NAMEFORMAT_UNSPECIFIED;
+                $nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
             }
 
             if ($firstAttribute) {
@@ -758,7 +758,7 @@ public function decryptAttributes(XMLSecurityKey $key, array $blacklist = array(
                 $firstAttribute = FALSE;
             } else {
                 if ($this->nameFormat !== $nameFormat) {
-                    $this->nameFormat = SAML2_Const::NAMEFORMAT_UNSPECIFIED;
+                    $this->nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
                 }
             }
 
@@ -1238,22 +1238,22 @@ public function toXML(DOMNode $parentElement = NULL)
             $document = $parentElement->ownerDocument;
         }
 
-        $root = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:' . 'Assertion');
+        $root = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:' . 'Assertion');
         $parentElement->appendChild($root);
 
         /* Ugly hack to add another namespace declaration to the root element. */
-        $root->setAttributeNS(SAML2_Const::NS_SAMLP, 'samlp:tmp', 'tmp');
-        $root->removeAttributeNS(SAML2_Const::NS_SAMLP, 'tmp');
-        $root->setAttributeNS(SAML2_Const::NS_XSI, 'xsi:tmp', 'tmp');
-        $root->removeAttributeNS(SAML2_Const::NS_XSI, 'tmp');
-        $root->setAttributeNS(SAML2_Const::NS_XS, 'xs:tmp', 'tmp');
-        $root->removeAttributeNS(SAML2_Const::NS_XS, 'tmp');
+        $root->setAttributeNS(SAML2_Constants::NS_SAMLP, 'samlp:tmp', 'tmp');
+        $root->removeAttributeNS(SAML2_Constants::NS_SAMLP, 'tmp');
+        $root->setAttributeNS(SAML2_Constants::NS_XSI, 'xsi:tmp', 'tmp');
+        $root->removeAttributeNS(SAML2_Constants::NS_XSI, 'tmp');
+        $root->setAttributeNS(SAML2_Constants::NS_XS, 'xs:tmp', 'tmp');
+        $root->removeAttributeNS(SAML2_Constants::NS_XS, 'tmp');
 
         $root->setAttribute('ID', $this->id);
         $root->setAttribute('Version', '2.0');
         $root->setAttribute('IssueInstant', gmdate('Y-m-d\TH:i:s\Z', $this->issueInstant));
 
-        $issuer = SAML2_Utils::addString($root, SAML2_Const::NS_SAML, 'saml:Issuer', $this->issuer);
+        $issuer = SAML2_Utils::addString($root, SAML2_Constants::NS_SAML, 'saml:Issuer', $this->issuer);
 
         $this->addSubject($root);
         $this->addConditions($root);
@@ -1284,13 +1284,13 @@ private function addSubject(DOMElement $root)
             return;
         }
 
-        $subject = $root->ownerDocument->createElementNS(SAML2_Const::NS_SAML, 'saml:Subject');
+        $subject = $root->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:Subject');
         $root->appendChild($subject);
 
         if ($this->encryptedNameId === NULL) {
             SAML2_Utils::addNameId($subject, $this->nameId);
         } else {
-            $eid = $subject->ownerDocument->createElementNS(SAML2_Const::NS_SAML, 'saml:' . 'EncryptedID');
+            $eid = $subject->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:' . 'EncryptedID');
             $subject->appendChild($eid);
             $eid->appendChild($subject->ownerDocument->importNode($this->encryptedNameId, TRUE));
         }
@@ -1310,7 +1310,7 @@ private function addConditions(DOMElement $root)
     {
         $document = $root->ownerDocument;
 
-        $conditions = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:Conditions');
+        $conditions = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:Conditions');
         $root->appendChild($conditions);
 
         if ($this->notBefore !== NULL) {
@@ -1321,10 +1321,10 @@ private function addConditions(DOMElement $root)
         }
 
         if ($this->validAudiences !== NULL) {
-            $ar = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:AudienceRestriction');
+            $ar = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:AudienceRestriction');
             $conditions->appendChild($ar);
 
-            SAML2_Utils::addStrings($ar, SAML2_Const::NS_SAML, 'saml:Audience', FALSE, $this->validAudiences);
+            SAML2_Utils::addStrings($ar, SAML2_Constants::NS_SAML, 'saml:Audience', FALSE, $this->validAudiences);
         }
     }
 
@@ -1350,7 +1350,7 @@ private function addAuthnStatement(DOMElement $root)
 
         $document = $root->ownerDocument;
 
-        $authnStatementEl = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:AuthnStatement');
+        $authnStatementEl = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:AuthnStatement');
         $root->appendChild($authnStatementEl);
 
         $authnStatementEl->setAttribute('AuthnInstant', gmdate('Y-m-d\TH:i:s\Z', $this->authnInstant));
@@ -1362,13 +1362,13 @@ private function addAuthnStatement(DOMElement $root)
             $authnStatementEl->setAttribute('SessionIndex', $this->sessionIndex);
         }
 
-        $authnContextEl = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:AuthnContext');
+        $authnContextEl = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:AuthnContext');
         $authnStatementEl->appendChild($authnContextEl);
 
         if (!empty($this->authnContextClassRef)) {
             SAML2_Utils::addString(
                 $authnContextEl,
-                SAML2_Const::NS_SAML,
+                SAML2_Constants::NS_SAML,
                 'saml:AuthnContextClassRef',
                 $this->authnContextClassRef
             );
@@ -1379,7 +1379,7 @@ private function addAuthnStatement(DOMElement $root)
         if (!empty($this->authnContextDeclRef)) {
             SAML2_Utils::addString(
                 $authnContextEl,
-                SAML2_Const::NS_SAML,
+                SAML2_Constants::NS_SAML,
                 'saml:AuthnContextDeclRef',
                 $this->authnContextDeclRef
             );
@@ -1387,7 +1387,7 @@ private function addAuthnStatement(DOMElement $root)
 
         SAML2_Utils::addStrings(
             $authnContextEl,
-            SAML2_Const::NS_SAML,
+            SAML2_Constants::NS_SAML,
             'saml:AuthenticatingAuthority',
             FALSE,
             $this->AuthenticatingAuthority
@@ -1408,15 +1408,15 @@ private function addAttributeStatement(DOMElement $root)
 
         $document = $root->ownerDocument;
 
-        $attributeStatement = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:AttributeStatement');
+        $attributeStatement = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:AttributeStatement');
         $root->appendChild($attributeStatement);
 
         foreach ($this->attributes as $name => $values) {
-            $attribute = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:Attribute');
+            $attribute = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:Attribute');
             $attributeStatement->appendChild($attribute);
             $attribute->setAttribute('Name', $name);
 
-            if ($this->nameFormat !== SAML2_Const::NAMEFORMAT_UNSPECIFIED) {
+            if ($this->nameFormat !== SAML2_Constants::NAMEFORMAT_UNSPECIFIED) {
                 $attribute->setAttribute('NameFormat', $this->nameFormat);
             }
 
@@ -1429,13 +1429,13 @@ private function addAttributeStatement(DOMElement $root)
                     $type = NULL;
                 }
 
-                $attributeValue = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:AttributeValue');
+                $attributeValue = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:AttributeValue');
                 $attribute->appendChild($attributeValue);
                 if ($type !== NULL) {
-                    $attributeValue->setAttributeNS(SAML2_Const::NS_XSI, 'xsi:type', $type);
+                    $attributeValue->setAttributeNS(SAML2_Constants::NS_XSI, 'xsi:type', $type);
                 }
                 if (is_null($value)) {
-                    $attributeValue->setAttributeNS(SAML2_Const::NS_XSI, 'xsi:nil', 'true');
+                    $attributeValue->setAttributeNS(SAML2_Constants::NS_XSI, 'xsi:nil', 'true');
                 }
 
                 if ($value instanceof DOMNodeList) {
@@ -1464,16 +1464,16 @@ private function addEncryptedAttributeStatement(DOMElement $root)
 
         $document = $root->ownerDocument;
 
-        $attributeStatement = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:AttributeStatement');
+        $attributeStatement = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:AttributeStatement');
         $root->appendChild($attributeStatement);
 
         foreach ($this->attributes as $name => $values) {
             $document2 = SAML2_DOMDocumentFactory::create();
-            $attribute = $document2->createElementNS(SAML2_Const::NS_SAML, 'saml:Attribute');
+            $attribute = $document2->createElementNS(SAML2_Constants::NS_SAML, 'saml:Attribute');
             $attribute->setAttribute('Name', $name);
             $document2->appendChild($attribute);
 
-            if ($this->nameFormat !== SAML2_Const::NAMEFORMAT_UNSPECIFIED) {
+            if ($this->nameFormat !== SAML2_Constants::NAMEFORMAT_UNSPECIFIED) {
                 $attribute->setAttribute('NameFormat', $this->nameFormat);
             }
 
@@ -1486,10 +1486,10 @@ private function addEncryptedAttributeStatement(DOMElement $root)
                     $type = NULL;
                 }
 
-                $attributeValue = $document2->createElementNS(SAML2_Const::NS_SAML, 'saml:AttributeValue');
+                $attributeValue = $document2->createElementNS(SAML2_Constants::NS_SAML, 'saml:AttributeValue');
                 $attribute->appendChild($attributeValue);
                 if ($type !== NULL) {
-                    $attributeValue->setAttributeNS(SAML2_Const::NS_XSI, 'xsi:type', $type);
+                    $attributeValue->setAttributeNS(SAML2_Constants::NS_XSI, 'xsi:type', $type);
                 }
 
                 if ($value instanceof DOMNodeList) {
@@ -1514,7 +1514,7 @@ private function addEncryptedAttributeStatement(DOMElement $root)
             $EncAssert->encryptKey($this->encryptionKey, $symmetricKey);
             $EncrNode = $EncAssert->encryptNode($symmetricKey);
 
-            $EncAttribute = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:EncryptedAttribute');
+            $EncAttribute = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:EncryptedAttribute');
             $attributeStatement->appendChild($EncAttribute);
             $n = $document->importNode($EncrNode, TRUE);
             $EncAttribute->appendChild($n);
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethod.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethod.php
index 3a8bb0676..fa1f1ce79 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethod.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethod.php
@@ -7,10 +7,10 @@ public function validate(
         SAML2_XML_saml_SubjectConfirmation $subjectConfirmation,
         SAML2_Assertion_Validation_Result $result
     ) {
-        if ($subjectConfirmation->Method !== SAML2_Const::CM_BEARER) {
+        if ($subjectConfirmation->Method !== SAML2_Constants::CM_BEARER) {
             $result->addError(sprintf(
                 'Invalid Method on SubjectConfirmation, current;y only Bearer (%s) is supported',
-                SAML2_Const::CM_BEARER
+                SAML2_Constants::CM_BEARER
             ));
         }
     }
diff --git a/src/SAML2/AttributeQuery.php b/src/SAML2/AttributeQuery.php
index b2f914f97..3d1926bf7 100644
--- a/src/SAML2/AttributeQuery.php
+++ b/src/SAML2/AttributeQuery.php
@@ -45,7 +45,7 @@ public function __construct(DOMElement $xml = NULL)
         parent::__construct('AttributeQuery', $xml);
 
         $this->attributes = array();
-        $this->nameFormat = SAML2_Const::NAMEFORMAT_UNSPECIFIED;
+        $this->nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
 
         if ($xml === NULL) {
             return;
@@ -62,7 +62,7 @@ public function __construct(DOMElement $xml = NULL)
             if ($attribute->hasAttribute('NameFormat')) {
                 $nameFormat = $attribute->getAttribute('NameFormat');
             } else {
-                $nameFormat = SAML2_Const::NAMEFORMAT_UNSPECIFIED;
+                $nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
             }
 
             if ($firstAttribute) {
@@ -70,7 +70,7 @@ public function __construct(DOMElement $xml = NULL)
                 $firstAttribute = FALSE;
             } else {
                 if ($this->nameFormat !== $nameFormat) {
-                    $this->nameFormat = SAML2_Const::NAMEFORMAT_UNSPECIFIED;
+                    $this->nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
                 }
             }
 
@@ -140,11 +140,11 @@ public function toUnsignedXML()
         $root = parent::toUnsignedXML();
 
         foreach ($this->attributes as $name => $values) {
-            $attribute = $root->ownerDocument->createElementNS(SAML2_Const::NS_SAML, 'saml:Attribute');
+            $attribute = $root->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:Attribute');
             $root->appendChild($attribute);
             $attribute->setAttribute('Name', $name);
 
-            if ($this->nameFormat !== SAML2_Const::NAMEFORMAT_UNSPECIFIED) {
+            if ($this->nameFormat !== SAML2_Constants::NAMEFORMAT_UNSPECIFIED) {
                 $attribute->setAttribute('NameFormat', $this->nameFormat);
             }
 
@@ -157,9 +157,9 @@ public function toUnsignedXML()
                     $type = NULL;
                 }
 
-                $attributeValue = SAML2_Utils::addString($attribute, SAML2_Const::NS_SAML, 'saml:AttributeValue', $value);
+                $attributeValue = SAML2_Utils::addString($attribute, SAML2_Constants::NS_SAML, 'saml:AttributeValue', $value);
                 if ($type !== NULL) {
-                    $attributeValue->setAttributeNS(SAML2_Const::NS_XSI, 'xsi:type', $type);
+                    $attributeValue->setAttributeNS(SAML2_Constants::NS_XSI, 'xsi:type', $type);
                 }
             }
         }
diff --git a/src/SAML2/AuthnRequest.php b/src/SAML2/AuthnRequest.php
index 0427620d2..9775a5424 100644
--- a/src/SAML2/AuthnRequest.php
+++ b/src/SAML2/AuthnRequest.php
@@ -237,7 +237,7 @@ protected function parseRequestedAuthnContext(DOMElement $xml)
 
         $rac = array(
             'AuthnContextClassRef' => array(),
-            'Comparison'           => SAML2_Const::COMPARISON_EXACT,
+            'Comparison'           => SAML2_Constants::COMPARISON_EXACT,
         );
 
         $accr = SAML2_Utils::xpQuery($requestedAuthnContext, './saml_assertion:AuthnContextClassRef');
@@ -701,7 +701,7 @@ public function toUnsignedXML()
         $this->addSubject($root);
 
         if (!empty($this->nameIdPolicy)) {
-            $nameIdPolicy = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'NameIDPolicy');
+            $nameIdPolicy = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'NameIDPolicy');
             if (array_key_exists('Format', $this->nameIdPolicy)) {
                 $nameIdPolicy->setAttribute('Format', $this->nameIdPolicy['Format']);
             }
@@ -716,26 +716,26 @@ public function toUnsignedXML()
 
         $rac = $this->requestedAuthnContext;
         if (!empty($rac) && !empty($rac['AuthnContextClassRef'])) {
-            $e = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'RequestedAuthnContext');
+            $e = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'RequestedAuthnContext');
             $root->appendChild($e);
-            if (isset($rac['Comparison']) && $rac['Comparison'] !== SAML2_Const::COMPARISON_EXACT) {
+            if (isset($rac['Comparison']) && $rac['Comparison'] !== SAML2_Constants::COMPARISON_EXACT) {
                 $e->setAttribute('Comparison', $rac['Comparison']);
             }
             foreach ($rac['AuthnContextClassRef'] as $accr) {
-                SAML2_Utils::addString($e, SAML2_Const::NS_SAML, 'AuthnContextClassRef', $accr);
+                SAML2_Utils::addString($e, SAML2_Constants::NS_SAML, 'AuthnContextClassRef', $accr);
             }
         }
 
         if ($this->ProxyCount !== NULL || count($this->IDPList) > 0 || count($this->RequesterID) > 0) {
-            $scoping = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'Scoping');
+            $scoping = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'Scoping');
             $root->appendChild($scoping);
             if ($this->ProxyCount !== NULL) {
                 $scoping->setAttribute('ProxyCount', $this->ProxyCount);
             }
             if (count($this->IDPList) > 0) {
-                $idplist = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'IDPList');
+                $idplist = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'IDPList');
                 foreach ($this->IDPList as $provider) {
-                    $idpEntry = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'IDPEntry');
+                    $idpEntry = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'IDPEntry');
                     if (is_string($provider)) {
                         $idpEntry->setAttribute('ProviderID', $provider);
                     } elseif (is_array($provider)) {
@@ -754,7 +754,7 @@ public function toUnsignedXML()
                 $scoping->appendChild($idplist);
             }
             if (count($this->RequesterID) > 0) {
-                SAML2_Utils::addStrings($scoping, SAML2_Const::NS_SAMLP, 'RequesterID', FALSE, $this->RequesterID);
+                SAML2_Utils::addStrings($scoping, SAML2_Constants::NS_SAMLP, 'RequesterID', FALSE, $this->RequesterID);
             }
         }
 
@@ -773,13 +773,13 @@ private function addSubject(DOMElement $root)
             return;
         }
 
-        $subject = $root->ownerDocument->createElementNS(SAML2_Const::NS_SAML, 'saml:Subject');
+        $subject = $root->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:Subject');
         $root->appendChild($subject);
 
         if ($this->encryptedNameId === NULL) {
             SAML2_Utils::addNameId($subject, $this->nameId);
         } else {
-            $eid = $subject->ownerDocument->createElementNS(SAML2_Const::NS_SAML, 'saml:EncryptedID');
+            $eid = $subject->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:EncryptedID');
             $eid->appendChild($subject->ownerDocument->importNode($this->encryptedNameId, TRUE));
             $subject->appendChild($eid);
         }
diff --git a/src/SAML2/Binding.php b/src/SAML2/Binding.php
index 966693e9c..bf6f8b28a 100644
--- a/src/SAML2/Binding.php
+++ b/src/SAML2/Binding.php
@@ -28,13 +28,13 @@ public static function getBinding($urn)
         assert('is_string($urn)');
 
         switch ($urn) {
-            case SAML2_Const::BINDING_HTTP_POST:
+            case SAML2_Constants::BINDING_HTTP_POST:
                 return new SAML2_HTTPPost();
-            case SAML2_Const::BINDING_HTTP_REDIRECT:
+            case SAML2_Constants::BINDING_HTTP_REDIRECT:
                 return new SAML2_HTTPRedirect();
-            case SAML2_Const::BINDING_HTTP_ARTIFACT:
+            case SAML2_Constants::BINDING_HTTP_ARTIFACT:
                 return new SAML2_HTTPArtifact();
-            case SAML2_Const::BINDING_HOK_SSO:
+            case SAML2_Constants::BINDING_HOK_SSO:
                 return new SAML2_HTTPPost();
             default:
                 throw new Exception('Unsupported binding: ' . var_export($urn, TRUE));
diff --git a/src/SAML2/Const.php b/src/SAML2/Constants.php
similarity index 99%
rename from src/SAML2/Const.php
rename to src/SAML2/Constants.php
index 9963063f7..6230f3710 100644
--- a/src/SAML2/Const.php
+++ b/src/SAML2/Constants.php
@@ -5,7 +5,7 @@
  *
  * @package SimpleSAMLphp
  */
-class SAML2_Const
+class SAML2_Constants
 {
     /**
      * Password authentication context.
diff --git a/src/SAML2/EncryptedAssertion.php b/src/SAML2/EncryptedAssertion.php
index 7596d5e13..f531879d7 100644
--- a/src/SAML2/EncryptedAssertion.php
+++ b/src/SAML2/EncryptedAssertion.php
@@ -107,7 +107,7 @@ public function toXML(DOMNode $parentElement = NULL)
             $document = $parentElement->ownerDocument;
         }
 
-        $root = $document->createElementNS(SAML2_Const::NS_SAML, 'saml:' . 'EncryptedAssertion');
+        $root = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:' . 'EncryptedAssertion');
         $parentElement->appendChild($root);
 
         $root->appendChild($document->importNode($this->encryptedData, TRUE));
diff --git a/src/SAML2/LogoutRequest.php b/src/SAML2/LogoutRequest.php
index 2725f7698..307f48a9b 100644
--- a/src/SAML2/LogoutRequest.php
+++ b/src/SAML2/LogoutRequest.php
@@ -259,13 +259,13 @@ public function toUnsignedXML()
         if ($this->encryptedNameId === NULL) {
             SAML2_Utils::addNameId($root, $this->nameId);
         } else {
-            $eid = $root->ownerDocument->createElementNS(SAML2_Const::NS_SAML, 'saml:' . 'EncryptedID');
+            $eid = $root->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:' . 'EncryptedID');
             $root->appendChild($eid);
             $eid->appendChild($root->ownerDocument->importNode($this->encryptedNameId, TRUE));
         }
 
         foreach ($this->sessionIndexes as $sessionIndex) {
-            SAML2_Utils::addString($root, SAML2_Const::NS_SAMLP, 'SessionIndex', $sessionIndex);
+            SAML2_Utils::addString($root, SAML2_Constants::NS_SAMLP, 'SessionIndex', $sessionIndex);
         }
 
         return $root;
diff --git a/src/SAML2/Message.php b/src/SAML2/Message.php
index 1eedae532..90e28daca 100644
--- a/src/SAML2/Message.php
+++ b/src/SAML2/Message.php
@@ -54,7 +54,7 @@ abstract class SAML2_Message implements SAML2_SignedElement
      *
      * @var string|NULL
      */
-    private $consent = SAML2_Const::CONSENT_UNSPECIFIED;
+    private $consent = SAML2_Constants::CONSENT_UNSPECIFIED;
 
     /**
      * The entity id of the issuer of this message, or NULL if unknown.
@@ -307,7 +307,7 @@ public function setDestination($destination)
      * Set the given consent for this message.
      *
      * Most likely (though not required) a value of rn:oasis:names:tc:SAML:2.0:consent.
-     * @see SAML2_Const
+     * @see SAML2_Constants
      *
      * @param string $consent
      */
@@ -322,7 +322,7 @@ public function setConsent($consent)
      * Set the given consent for this message.
      *
      * Most likely (though not required) a value of rn:oasis:names:tc:SAML:2.0:consent.
-     * @see SAML2_Const
+     * @see SAML2_Constants
      *
      * @return string Consent
      */
@@ -396,12 +396,12 @@ public function toUnsignedXML()
     {
         $this->document = SAML2_DOMDocumentFactory::create();
 
-        $root = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'samlp:' . $this->tagName);
+        $root = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'samlp:' . $this->tagName);
         $this->document->appendChild($root);
 
         /* Ugly hack to add another namespace declaration to the root element. */
-        $root->setAttributeNS(SAML2_Const::NS_SAML, 'saml:tmp', 'tmp');
-        $root->removeAttributeNS(SAML2_Const::NS_SAML, 'tmp');
+        $root->setAttributeNS(SAML2_Constants::NS_SAML, 'saml:tmp', 'tmp');
+        $root->removeAttributeNS(SAML2_Constants::NS_SAML, 'tmp');
 
         $root->setAttribute('ID', $this->id);
         $root->setAttribute('Version', '2.0');
@@ -410,12 +410,12 @@ public function toUnsignedXML()
         if ($this->destination !== NULL) {
             $root->setAttribute('Destination', $this->destination);
         }
-        if ($this->consent !== NULL && $this->consent !== SAML2_Const::CONSENT_UNSPECIFIED) {
+        if ($this->consent !== NULL && $this->consent !== SAML2_Constants::CONSENT_UNSPECIFIED) {
             $root->setAttribute('Consent', $this->consent);
         }
 
         if ($this->issuer !== NULL) {
-            SAML2_Utils::addString($root, SAML2_Const::NS_SAML, 'saml:Issuer', $this->issuer);
+            SAML2_Utils::addString($root, SAML2_Constants::NS_SAML, 'saml:Issuer', $this->issuer);
         }
 
         if (!empty($this->extensions)) {
@@ -521,7 +521,7 @@ public function getCertificates()
      */
     public static function fromXML(DOMElement $xml)
     {
-        if ($xml->namespaceURI !== SAML2_Const::NS_SAMLP) {
+        if ($xml->namespaceURI !== SAML2_Constants::NS_SAMLP) {
             throw new Exception('Unknown namespace of SAML message: ' . var_export($xml->namespaceURI, TRUE));
         }
 
diff --git a/src/SAML2/Response.php b/src/SAML2/Response.php
index bded9e1cc..3a4f4ea31 100644
--- a/src/SAML2/Response.php
+++ b/src/SAML2/Response.php
@@ -28,7 +28,7 @@ public function __construct(DOMElement $xml = NULL)
         }
 
         for ($node = $xml->firstChild; $node !== NULL; $node = $node->nextSibling) {
-            if ($node->namespaceURI !== SAML2_Const::NS_SAML) {
+            if ($node->namespaceURI !== SAML2_Constants::NS_SAML) {
                 continue;
             }
 
diff --git a/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php b/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php
index 3cdfb89df..cda3c46a5 100644
--- a/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php
+++ b/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php
@@ -35,8 +35,8 @@ private function buildMessage(array $responseStatus)
      */
     private function truncateStatus($status)
     {
-        $prefixLength = strlen(SAML2_Const::STATUS_PREFIX);
-        if (strpos($status, SAML2_Const::STATUS_PREFIX) !== 0) {
+        $prefixLength = strlen(SAML2_Constants::STATUS_PREFIX);
+        if (strpos($status, SAML2_Constants::STATUS_PREFIX) !== 0) {
             return $status;
         }
 
diff --git a/src/SAML2/StatusResponse.php b/src/SAML2/StatusResponse.php
index 40fa032ae..be340301d 100644
--- a/src/SAML2/StatusResponse.php
+++ b/src/SAML2/StatusResponse.php
@@ -50,7 +50,7 @@ protected function __construct($tagName, DOMElement $xml = NULL)
         parent::__construct($tagName, $xml);
 
         $this->status = array(
-            'Code' => SAML2_Const::STATUS_SUCCESS,
+            'Code' => SAML2_Constants::STATUS_SUCCESS,
             'SubCode' => NULL,
             'Message' => NULL,
             );
@@ -98,7 +98,7 @@ public function isSuccess()
     {
         assert('array_key_exists("Code", $this->status)');
 
-        if ($this->status['Code'] === SAML2_Const::STATUS_SUCCESS) {
+        if ($this->status['Code'] === SAML2_Constants::STATUS_SUCCESS) {
             return TRUE;
         }
 
@@ -173,21 +173,21 @@ public function toUnsignedXML()
             $root->setAttribute('InResponseTo', $this->inResponseTo);
         }
 
-        $status = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'Status');
+        $status = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'Status');
         $root->appendChild($status);
 
-        $statusCode = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'StatusCode');
+        $statusCode = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'StatusCode');
         $statusCode->setAttribute('Value', $this->status['Code']);
         $status->appendChild($statusCode);
 
         if (!is_null($this->status['SubCode'])) {
-            $subStatusCode = $this->document->createElementNS(SAML2_Const::NS_SAMLP, 'StatusCode');
+            $subStatusCode = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'StatusCode');
             $subStatusCode->setAttribute('Value', $this->status['SubCode']);
             $statusCode->appendChild($subStatusCode);
         }
 
         if (!is_null($this->status['Message'])) {
-            SAML2_Utils::addString($status, SAML2_Const::NS_SAMLP, 'StatusMessage', $this->status['Message']);
+            SAML2_Utils::addString($status, SAML2_Constants::NS_SAMLP, 'StatusMessage', $this->status['Message']);
         }
 
         return $root;
diff --git a/src/SAML2/SubjectQuery.php b/src/SAML2/SubjectQuery.php
index 948c33ff6..110556fe4 100644
--- a/src/SAML2/SubjectQuery.php
+++ b/src/SAML2/SubjectQuery.php
@@ -106,7 +106,7 @@ public function toUnsignedXML()
     {
         $root = parent::toUnsignedXML();
 
-        $subject = $root->ownerDocument->createElementNS(SAML2_Const::NS_SAML, 'saml:Subject');
+        $subject = $root->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:Subject');
         $root->appendChild($subject);
 
         SAML2_Utils::addNameId($subject, $this->nameId);
diff --git a/src/SAML2/Utils.php b/src/SAML2/Utils.php
index 509ab5875..37a38bc49 100644
--- a/src/SAML2/Utils.php
+++ b/src/SAML2/Utils.php
@@ -179,10 +179,10 @@ public static function xpQuery(DOMNode $node, $query)
 
         if ($xpCache === NULL || !$xpCache->document->isSameNode($doc)) {
             $xpCache = new DOMXPath($doc);
-            $xpCache->registerNamespace('soap-env', SAML2_Const::NS_SOAP);
-            $xpCache->registerNamespace('saml_protocol', SAML2_Const::NS_SAMLP);
-            $xpCache->registerNamespace('saml_assertion', SAML2_Const::NS_SAML);
-            $xpCache->registerNamespace('saml_metadata', SAML2_Const::NS_MD);
+            $xpCache->registerNamespace('soap-env', SAML2_Constants::NS_SOAP);
+            $xpCache->registerNamespace('saml_protocol', SAML2_Constants::NS_SAMLP);
+            $xpCache->registerNamespace('saml_assertion', SAML2_Constants::NS_SAML);
+            $xpCache->registerNamespace('saml_metadata', SAML2_Constants::NS_MD);
             $xpCache->registerNamespace('ds', XMLSecurityDSig::XMLDSIGNS);
             $xpCache->registerNamespace('xenc', XMLSecEnc::XMLENCNS);
         }
@@ -287,7 +287,7 @@ public static function addNameId(DOMElement $node, array $nameId)
     {
         assert('array_key_exists("Value", $nameId)');
 
-        $xml = SAML2_Utils::addString($node, SAML2_Const::NS_SAML, 'saml:NameID', $nameId['Value']);
+        $xml = SAML2_Utils::addString($node, SAML2_Constants::NS_SAML, 'saml:NameID', $nameId['Value']);
 
         if (array_key_exists('NameQualifier', $nameId) && $nameId['NameQualifier'] !== NULL) {
             $xml->setAttribute('NameQualifier', $nameId['NameQualifier']);
diff --git a/src/SAML2/XML/md/AdditionalMetadataLocation.php b/src/SAML2/XML/md/AdditionalMetadataLocation.php
index ba34e39d6..d2bd879db 100644
--- a/src/SAML2/XML/md/AdditionalMetadataLocation.php
+++ b/src/SAML2/XML/md/AdditionalMetadataLocation.php
@@ -52,7 +52,7 @@ public function toXML(DOMElement $parent)
         assert('is_string($this->namespace)');
         assert('is_string($this->location)');
 
-        $e = SAML2_Utils::addString($parent, SAML2_Const::NS_MD, 'md:AdditionalMetadataLocation', $this->location);
+        $e = SAML2_Utils::addString($parent, SAML2_Constants::NS_MD, 'md:AdditionalMetadataLocation', $this->location);
         $e->setAttribute('namespace', $this->namespace);
 
         return $e;
diff --git a/src/SAML2/XML/md/AffiliationDescriptor.php b/src/SAML2/XML/md/AffiliationDescriptor.php
index bfdcc4e92..86cf449c7 100644
--- a/src/SAML2/XML/md/AffiliationDescriptor.php
+++ b/src/SAML2/XML/md/AffiliationDescriptor.php
@@ -95,7 +95,7 @@ public function __construct(DOMElement $xml = NULL)
 
         $this->Extensions = SAML2_XML_md_Extensions::getList($xml);
 
-        $this->AffiliateMember = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'AffiliateMember');
+        $this->AffiliateMember = SAML2_Utils::extractStrings($xml, SAML2_Constants::NS_MD, 'AffiliateMember');
         if (empty($this->AffiliateMember)) {
             throw new Exception('Missing AffiliateMember in AffiliationDescriptor.');
         }
@@ -122,7 +122,7 @@ public function toXML(DOMElement $parent)
         assert('!empty($this->AffiliateMember)');
         assert('is_array($this->KeyDescriptor)');
 
-        $e = $parent->ownerDocument->createElementNS(SAML2_Const::NS_MD, 'md:AffiliationDescriptor');
+        $e = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_MD, 'md:AffiliationDescriptor');
         $parent->appendChild($e);
 
         $e->setAttribute('affiliationOwnerID', $this->affiliationOwnerID);
@@ -141,7 +141,7 @@ public function toXML(DOMElement $parent)
 
         SAML2_XML_md_Extensions::addList($e, $this->Extensions);
 
-        SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:AffiliateMember', FALSE, $this->AffiliateMember);
+        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:AffiliateMember', FALSE, $this->AffiliateMember);
 
         foreach ($this->KeyDescriptor as $kd) {
             $kd->toXML($e);
diff --git a/src/SAML2/XML/md/AttributeAuthorityDescriptor.php b/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
index 827a8a9bb..ae1d76014 100644
--- a/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
+++ b/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
@@ -77,9 +77,9 @@ public function __construct(DOMElement $xml = NULL)
             $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($ep);
         }
 
-        $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'NameIDFormat');
+        $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Constants::NS_MD, 'NameIDFormat');
 
-        $this->AttributeProfile = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'AttributeProfile');
+        $this->AttributeProfile = SAML2_Utils::extractStrings($xml, SAML2_Constants::NS_MD, 'AttributeProfile');
 
         foreach (SAML2_Utils::xpQuery($xml, './saml_assertion:Attribute') as $a) {
             $this->Attribute[] = new SAML2_XML_saml_Attribute($a);
@@ -111,9 +111,9 @@ public function toXML(DOMElement $parent)
             $ep->toXML($e, 'md:AssertionIDRequestService');
         }
 
-        SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
+        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
 
-        SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:AttributeProfile', FALSE, $this->AttributeProfile);
+        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:AttributeProfile', FALSE, $this->AttributeProfile);
 
         foreach ($this->Attribute as $a) {
             $a->toXML($e);
diff --git a/src/SAML2/XML/md/AttributeConsumingService.php b/src/SAML2/XML/md/AttributeConsumingService.php
index 34c3168cc..2d9527136 100644
--- a/src/SAML2/XML/md/AttributeConsumingService.php
+++ b/src/SAML2/XML/md/AttributeConsumingService.php
@@ -67,12 +67,12 @@ public function __construct(DOMElement $xml = NULL)
 
         $this->isDefault = SAML2_Utils::parseBoolean($xml, 'isDefault', NULL);
 
-        $this->ServiceName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'ServiceName');
+        $this->ServiceName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Constants::NS_MD, 'ServiceName');
         if (empty($this->ServiceName)) {
             throw new Exception('Missing ServiceName in AttributeConsumingService.');
         }
 
-        $this->ServiceDescription = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'ServiceDescription');
+        $this->ServiceDescription = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Constants::NS_MD, 'ServiceDescription');
 
         foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:RequestedAttribute') as $ra) {
             $this->RequestedAttribute[] = new SAML2_XML_md_RequestedAttribute($ra);
@@ -95,7 +95,7 @@ public function toXML(DOMElement $parent)
 
         $doc = $parent->ownerDocument;
 
-        $e = $doc->createElementNS(SAML2_Const::NS_MD, 'md:AttributeConsumingService');
+        $e = $doc->createElementNS(SAML2_Constants::NS_MD, 'md:AttributeConsumingService');
         $parent->appendChild($e);
 
         $e->setAttribute('index', (string) $this->index);
@@ -106,8 +106,8 @@ public function toXML(DOMElement $parent)
             $e->setAttribute('isDefault', 'false');
         }
 
-        SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:ServiceName', TRUE, $this->ServiceName);
-        SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:ServiceDescription', TRUE, $this->ServiceDescription);
+        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:ServiceName', TRUE, $this->ServiceName);
+        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:ServiceDescription', TRUE, $this->ServiceDescription);
 
         foreach ($this->RequestedAttribute as $ra) {
             $ra->toXML($e);
diff --git a/src/SAML2/XML/md/AuthnAuthorityDescriptor.php b/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
index e936dc923..2645bc290 100644
--- a/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
+++ b/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
@@ -59,7 +59,7 @@ public function __construct(DOMElement $xml = NULL)
             $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($ep);
         }
 
-        $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'NameIDFormat');
+        $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Constants::NS_MD, 'NameIDFormat');
     }
 
     /**
@@ -85,7 +85,7 @@ public function toXML(DOMElement $parent)
             $ep->toXML($e, 'md:AssertionIDRequestService');
         }
 
-        SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
+        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
 
         return $e;
     }
diff --git a/src/SAML2/XML/md/ContactPerson.php b/src/SAML2/XML/md/ContactPerson.php
index 5925423d7..b4ade615f 100644
--- a/src/SAML2/XML/md/ContactPerson.php
+++ b/src/SAML2/XML/md/ContactPerson.php
@@ -146,7 +146,7 @@ public function toXML(DOMElement $parent)
 
         $doc = $parent->ownerDocument;
 
-        $e = $doc->createElementNS(SAML2_Const::NS_MD, 'md:ContactPerson');
+        $e = $doc->createElementNS(SAML2_Constants::NS_MD, 'md:ContactPerson');
         $parent->appendChild($e);
 
         $e->setAttribute('contactType', $this->contactType);
@@ -154,19 +154,19 @@ public function toXML(DOMElement $parent)
         SAML2_XML_md_Extensions::addList($e, $this->Extensions);
 
         if (isset($this->Company)) {
-            SAML2_Utils::addString($e, SAML2_Const::NS_MD, 'md:Company', $this->Company);
+            SAML2_Utils::addString($e, SAML2_Constants::NS_MD, 'md:Company', $this->Company);
         }
         if (isset($this->GivenName)) {
-            SAML2_Utils::addString($e, SAML2_Const::NS_MD, 'md:GivenName', $this->GivenName);
+            SAML2_Utils::addString($e, SAML2_Constants::NS_MD, 'md:GivenName', $this->GivenName);
         }
         if (isset($this->SurName)) {
-            SAML2_Utils::addString($e, SAML2_Const::NS_MD, 'md:SurName', $this->SurName);
+            SAML2_Utils::addString($e, SAML2_Constants::NS_MD, 'md:SurName', $this->SurName);
         }
         if (!empty($this->EmailAddress)) {
-            SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:EmailAddress', FALSE, $this->EmailAddress);
+            SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:EmailAddress', FALSE, $this->EmailAddress);
         }
         if (!empty($this->TelephoneNumber)) {
-            SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:TelephoneNumber', FALSE, $this->TelephoneNumber);
+            SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:TelephoneNumber', FALSE, $this->TelephoneNumber);
         }
 
         return $e;
diff --git a/src/SAML2/XML/md/EndpointType.php b/src/SAML2/XML/md/EndpointType.php
index 9c5e7ba99..74578cb9b 100644
--- a/src/SAML2/XML/md/EndpointType.php
+++ b/src/SAML2/XML/md/EndpointType.php
@@ -167,7 +167,7 @@ public function toXML(DOMElement $parent, $name)
         assert('is_string($this->Location)');
         assert('is_null($this->ResponseLocation) || is_string($this->ResponseLocation)');
 
-        $e = $parent->ownerDocument->createElementNS(SAML2_Const::NS_MD, $name);
+        $e = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_MD, $name);
         $parent->appendChild($e);
 
         $e->setAttribute('Binding', $this->Binding);
diff --git a/src/SAML2/XML/md/EntitiesDescriptor.php b/src/SAML2/XML/md/EntitiesDescriptor.php
index e2c58e9f9..e4d91ce80 100644
--- a/src/SAML2/XML/md/EntitiesDescriptor.php
+++ b/src/SAML2/XML/md/EntitiesDescriptor.php
@@ -105,10 +105,10 @@ public function toXML(DOMElement $parent = NULL)
 
         if ($parent === NULL) {
             $doc = SAML2_DOMDocumentFactory::create();
-            $e = $doc->createElementNS(SAML2_Const::NS_MD, 'md:EntitiesDescriptor');
+            $e = $doc->createElementNS(SAML2_Constants::NS_MD, 'md:EntitiesDescriptor');
             $doc->appendChild($e);
         } else {
-            $e = $parent->ownerDocument->createElementNS(SAML2_Const::NS_MD, 'md:EntitiesDescriptor');
+            $e = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_MD, 'md:EntitiesDescriptor');
             $parent->appendChild($e);
         }
 
diff --git a/src/SAML2/XML/md/EntityDescriptor.php b/src/SAML2/XML/md/EntityDescriptor.php
index 79f150892..1e6709f81 100644
--- a/src/SAML2/XML/md/EntityDescriptor.php
+++ b/src/SAML2/XML/md/EntityDescriptor.php
@@ -117,7 +117,7 @@ public function __construct(DOMElement $xml = NULL)
                 continue;
             }
 
-            if ($node->namespaceURI !== SAML2_Const::NS_MD) {
+            if ($node->namespaceURI !== SAML2_Constants::NS_MD) {
                 continue;
             }
 
@@ -193,10 +193,10 @@ public function toXML(DOMElement $parent = NULL)
 
         if ($parent === NULL) {
             $doc = SAML2_DOMDocumentFactory::create();
-            $e = $doc->createElementNS(SAML2_Const::NS_MD, 'md:EntityDescriptor');
+            $e = $doc->createElementNS(SAML2_Constants::NS_MD, 'md:EntityDescriptor');
             $doc->appendChild($e);
         } else {
-            $e = $parent->ownerDocument->createElementNS(SAML2_Const::NS_MD, 'md:EntityDescriptor');
+            $e = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_MD, 'md:EntityDescriptor');
             $parent->appendChild($e);
         }
 
diff --git a/src/SAML2/XML/md/Extensions.php b/src/SAML2/XML/md/Extensions.php
index 5e38506eb..2b1aee81c 100644
--- a/src/SAML2/XML/md/Extensions.php
+++ b/src/SAML2/XML/md/Extensions.php
@@ -49,7 +49,7 @@ public static function addList(DOMElement $parent, array $extensions)
             return;
         }
 
-        $extElement = $parent->ownerDocument->createElementNS(SAML2_Const::NS_MD, 'md:Extensions');
+        $extElement = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_MD, 'md:Extensions');
         $parent->appendChild($extElement);
 
         foreach ($extensions as $ext) {
diff --git a/src/SAML2/XML/md/IDPSSODescriptor.php b/src/SAML2/XML/md/IDPSSODescriptor.php
index 4ee9a168b..119afe601 100644
--- a/src/SAML2/XML/md/IDPSSODescriptor.php
+++ b/src/SAML2/XML/md/IDPSSODescriptor.php
@@ -86,7 +86,7 @@ public function __construct(DOMElement $xml = NULL)
             $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($ep);
         }
 
-        $this->AttributeProfile = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'AttributeProfile');
+        $this->AttributeProfile = SAML2_Utils::extractStrings($xml, SAML2_Constants::NS_MD, 'AttributeProfile');
 
         foreach (SAML2_Utils::xpQuery($xml, './saml_assertion:Attribute') as $a) {
             $this->Attribute[] = new SAML2_XML_saml_Attribute($a);
@@ -128,7 +128,7 @@ public function toXML(DOMElement $parent)
             $ep->toXML($e, 'md:AssertionIDRequestService');
         }
 
-        SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:AttributeProfile', FALSE, $this->AttributeProfile);
+        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:AttributeProfile', FALSE, $this->AttributeProfile);
 
         foreach ($this->Attribute as $a) {
             $a->toXML($e);
diff --git a/src/SAML2/XML/md/KeyDescriptor.php b/src/SAML2/XML/md/KeyDescriptor.php
index 607b225d2..d68fb5086 100644
--- a/src/SAML2/XML/md/KeyDescriptor.php
+++ b/src/SAML2/XML/md/KeyDescriptor.php
@@ -76,7 +76,7 @@ public function toXML(DOMElement $parent)
 
         $doc = $parent->ownerDocument;
 
-        $e = $doc->createElementNS(SAML2_Const::NS_MD, 'md:KeyDescriptor');
+        $e = $doc->createElementNS(SAML2_Constants::NS_MD, 'md:KeyDescriptor');
         $parent->appendChild($e);
 
         if (isset($this->use)) {
diff --git a/src/SAML2/XML/md/Organization.php b/src/SAML2/XML/md/Organization.php
index 06040ca1e..a9dc7177d 100644
--- a/src/SAML2/XML/md/Organization.php
+++ b/src/SAML2/XML/md/Organization.php
@@ -50,17 +50,17 @@ public function __construct(DOMElement $xml = NULL)
 
         $this->Extensions = SAML2_XML_md_Extensions::getList($xml);
 
-        $this->OrganizationName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'OrganizationName');
+        $this->OrganizationName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Constants::NS_MD, 'OrganizationName');
         if (empty($this->OrganizationName)) {
             $this->OrganizationName = array('invalid' => '');
         }
 
-        $this->OrganizationDisplayName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'OrganizationDisplayName');
+        $this->OrganizationDisplayName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Constants::NS_MD, 'OrganizationDisplayName');
         if (empty($this->OrganizationDisplayName)) {
             $this->OrganizationDisplayName = array('invalid' => '');
         }
 
-        $this->OrganizationURL = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'OrganizationURL');
+        $this->OrganizationURL = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Constants::NS_MD, 'OrganizationURL');
         if (empty($this->OrganizationURL)) {
             $this->OrganizationURL = array('invalid' => '');
         }
@@ -84,14 +84,14 @@ public function toXML(DOMElement $parent)
 
         $doc = $parent->ownerDocument;
 
-        $e = $doc->createElementNS(SAML2_Const::NS_MD, 'md:Organization');
+        $e = $doc->createElementNS(SAML2_Constants::NS_MD, 'md:Organization');
         $parent->appendChild($e);
 
         SAML2_XML_md_Extensions::addList($e, $this->Extensions);
 
-        SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:OrganizationName', TRUE, $this->OrganizationName);
-        SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:OrganizationDisplayName', TRUE, $this->OrganizationDisplayName);
-        SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:OrganizationURL', TRUE, $this->OrganizationURL);
+        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:OrganizationName', TRUE, $this->OrganizationName);
+        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:OrganizationDisplayName', TRUE, $this->OrganizationDisplayName);
+        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:OrganizationURL', TRUE, $this->OrganizationURL);
 
         return $e;
     }
diff --git a/src/SAML2/XML/md/PDPDescriptor.php b/src/SAML2/XML/md/PDPDescriptor.php
index f4da42584..5627bf434 100644
--- a/src/SAML2/XML/md/PDPDescriptor.php
+++ b/src/SAML2/XML/md/PDPDescriptor.php
@@ -59,7 +59,7 @@ public function __construct(DOMElement $xml = NULL)
             $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($ep);
         }
 
-        $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'NameIDFormat');
+        $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Constants::NS_MD, 'NameIDFormat');
     }
 
     /**
@@ -85,7 +85,7 @@ public function toXML(DOMElement $parent)
             $ep->toXML($e, 'md:AssertionIDRequestService');
         }
 
-        SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
+        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
 
         return $e;
     }
diff --git a/src/SAML2/XML/md/RequestedAttribute.php b/src/SAML2/XML/md/RequestedAttribute.php
index a6494d147..5e10acf87 100644
--- a/src/SAML2/XML/md/RequestedAttribute.php
+++ b/src/SAML2/XML/md/RequestedAttribute.php
@@ -40,7 +40,7 @@ public function toXML(DOMElement $parent)
     {
         assert('is_bool($this->isRequired) || is_null($this->isRequired)');
 
-        $e = $this->toXMLInternal($parent, SAML2_Const::NS_MD, 'md:RequestedAttribute');
+        $e = $this->toXMLInternal($parent, SAML2_Constants::NS_MD, 'md:RequestedAttribute');
 
         if ($this->isRequired === TRUE) {
             $e->setAttribute('isRequired', 'true');
diff --git a/src/SAML2/XML/md/RoleDescriptor.php b/src/SAML2/XML/md/RoleDescriptor.php
index 5824806ab..5163c1cfb 100644
--- a/src/SAML2/XML/md/RoleDescriptor.php
+++ b/src/SAML2/XML/md/RoleDescriptor.php
@@ -156,7 +156,7 @@ protected function toXML(DOMElement $parent)
         assert('is_null($this->Organization) || $this->Organization instanceof SAML2_XML_md_Organization');
         assert('is_array($this->ContactPerson)');
 
-        $e = $parent->ownerDocument->createElementNS(SAML2_Const::NS_MD, $this->elementName);
+        $e = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_MD, $this->elementName);
         $parent->appendChild($e);
 
         if (isset($this->ID)) {
diff --git a/src/SAML2/XML/md/SSODescriptorType.php b/src/SAML2/XML/md/SSODescriptorType.php
index e97e70467..0b6d8021a 100644
--- a/src/SAML2/XML/md/SSODescriptorType.php
+++ b/src/SAML2/XML/md/SSODescriptorType.php
@@ -71,7 +71,7 @@ protected function __construct($elementName, DOMElement $xml = NULL)
             $this->ManageNameIDService[] = new SAML2_XML_md_EndpointType($ep);
         }
 
-        $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Const::NS_MD, 'NameIDFormat');
+        $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Constants::NS_MD, 'NameIDFormat');
     }
 
     /**
@@ -101,7 +101,7 @@ protected function toXML(DOMElement $parent)
             $ep->toXML($e, 'md:ManageNameIDService');
         }
 
-        SAML2_Utils::addStrings($e, SAML2_Const::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
+        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
 
         return $e;
     }
diff --git a/src/SAML2/XML/saml/Attribute.php b/src/SAML2/XML/saml/Attribute.php
index b18a90590..2b7f7d421 100644
--- a/src/SAML2/XML/saml/Attribute.php
+++ b/src/SAML2/XML/saml/Attribute.php
@@ -113,7 +113,7 @@ protected function toXMLInternal(DOMElement $parent, $namespace, $name)
      */
     public function toXML(DOMElement $parent)
     {
-        return $this->toXMLInternal($parent, SAML2_Const::NS_SAML, 'saml:Attribute');
+        return $this->toXMLInternal($parent, SAML2_Constants::NS_SAML, 'saml:Attribute');
     }
 
 }
diff --git a/src/SAML2/XML/saml/AttributeValue.php b/src/SAML2/XML/saml/AttributeValue.php
index b4ab28bc1..022fc4a5e 100644
--- a/src/SAML2/XML/saml/AttributeValue.php
+++ b/src/SAML2/XML/saml/AttributeValue.php
@@ -28,25 +28,25 @@ public function __construct($value)
 
         if (is_string($value)) {
             $doc = SAML2_DOMDocumentFactory::create();
-            $this->element = $doc->createElementNS(SAML2_Const::NS_SAML, 'saml:AttributeValue');
-            $this->element->setAttributeNS(SAML2_Const::NS_XSI, 'xsi:type', 'xs:string');
+            $this->element = $doc->createElementNS(SAML2_Constants::NS_SAML, 'saml:AttributeValue');
+            $this->element->setAttributeNS(SAML2_Constants::NS_XSI, 'xsi:type', 'xs:string');
             $this->element->appendChild($doc->createTextNode($value));
 
             /* Make sure that the xs-namespace is available in the AttributeValue (for xs:string). */
-            $this->element->setAttributeNS(SAML2_Const::NS_XS, 'xs:tmp', 'tmp');
-            $this->element->removeAttributeNS(SAML2_Const::NS_XS, 'tmp');
+            $this->element->setAttributeNS(SAML2_Constants::NS_XS, 'xs:tmp', 'tmp');
+            $this->element->removeAttributeNS(SAML2_Constants::NS_XS, 'tmp');
 
             return;
         }
 
-        if ($value->namespaceURI === SAML2_Const::NS_SAML && $value->localName === 'AttributeValue') {
+        if ($value->namespaceURI === SAML2_Constants::NS_SAML && $value->localName === 'AttributeValue') {
             $this->element = SAML2_Utils::copyElement($value);
 
             return;
         }
 
         $doc = SAML2_DOMDocumentFactory::create();
-        $this->element = $doc->createElementNS(SAML2_Const::NS_SAML, 'saml:AttributeValue');
+        $this->element = $doc->createElementNS(SAML2_Constants::NS_SAML, 'saml:AttributeValue');
         SAML2_Utils::copyElement($value, $this->element);
     }
 
@@ -59,7 +59,7 @@ public function __construct($value)
     public function toXML(DOMElement $parent)
     {
         assert('$this->element instanceof DOMElement');
-        assert('$this->element->namespaceURI === SAML2_Const::NS_SAML && $this->element->localName === "AttributeValue"');
+        assert('$this->element->namespaceURI === SAML2_Constants::NS_SAML && $this->element->localName === "AttributeValue"');
 
         $v = SAML2_Utils::copyElement($this->element, $parent);
 
diff --git a/src/SAML2/XML/saml/NameID.php b/src/SAML2/XML/saml/NameID.php
index 13d77d579..8142a0433 100644
--- a/src/SAML2/XML/saml/NameID.php
+++ b/src/SAML2/XML/saml/NameID.php
@@ -92,7 +92,7 @@ public function toXML(DOMElement $parent = NULL)
         } else {
             $doc = $parent->ownerDocument;
         }
-        $e = $doc->createElementNS(SAML2_Const::NS_SAML, 'saml:NameID');
+        $e = $doc->createElementNS(SAML2_Constants::NS_SAML, 'saml:NameID');
         $parent->appendChild($e);
 
         if ($this->NameQualifier !== NULL) {
diff --git a/src/SAML2/XML/saml/SubjectConfirmation.php b/src/SAML2/XML/saml/SubjectConfirmation.php
index 49d747ec7..da4bccc6f 100644
--- a/src/SAML2/XML/saml/SubjectConfirmation.php
+++ b/src/SAML2/XML/saml/SubjectConfirmation.php
@@ -72,7 +72,7 @@ public function toXML(DOMElement $parent)
         assert('is_null($this->NameID) || $this->NameID instanceof SAML2_XML_saml_NameID');
         assert('is_null($this->SubjectConfirmationData) || $this->SubjectConfirmationData instanceof SAML2_XML_saml_SubjectConfirmationData');
 
-        $e = $parent->ownerDocument->createElementNS(SAML2_Const::NS_SAML, 'saml:SubjectConfirmation');
+        $e = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:SubjectConfirmation');
         $parent->appendChild($e);
 
         $e->setAttribute('Method', $this->Method);
diff --git a/src/SAML2/XML/saml/SubjectConfirmationData.php b/src/SAML2/XML/saml/SubjectConfirmationData.php
index ff8a57bf1..24ceb4dd3 100644
--- a/src/SAML2/XML/saml/SubjectConfirmationData.php
+++ b/src/SAML2/XML/saml/SubjectConfirmationData.php
@@ -111,7 +111,7 @@ public function toXML(DOMElement $parent)
         assert('is_null($this->InResponseTo) || is_string($this->InResponseTo)');
         assert('is_null($this->Address) || is_string($this->Address)');
 
-        $e = $parent->ownerDocument->createElementNS(SAML2_Const::NS_SAML, 'saml:SubjectConfirmationData');
+        $e = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:SubjectConfirmationData');
         $parent->appendChild($e);
 
         if (isset($this->NotBefore)) {
diff --git a/src/SAML2/XML/samlp/Extensions.php b/src/SAML2/XML/samlp/Extensions.php
index 23153a895..9f01f90d4 100644
--- a/src/SAML2/XML/samlp/Extensions.php
+++ b/src/SAML2/XML/samlp/Extensions.php
@@ -35,7 +35,7 @@ public static function addList(DOMElement $parent, array $extensions)
             return;
         }
 
-        $extElement = $parent->ownerDocument->createElementNS(SAML2_Const::NS_SAMLP, 'samlp:Extensions');
+        $extElement = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_SAMLP, 'samlp:Extensions');
         $parent->appendChild($extElement);
 
         foreach ($extensions as $ext) {
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
index 0c0cf8423..8088ffd85 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
@@ -20,7 +20,7 @@ public function setUp()
      */
     public function a_subject_confirmation_with_bearer_method_is_valid()
     {
-        $this->subjectConfirmation->Method = SAML2_Const::CM_BEARER;
+        $this->subjectConfirmation->Method = SAML2_Constants::CM_BEARER;
 
         $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationMethod();
         $result = new SAML2_Assertion_Validation_Result();
@@ -36,7 +36,7 @@ public function a_subject_confirmation_with_bearer_method_is_valid()
      */
     public function a_subject_confirmation_with_holder_of_key_method_is_not_valid()
     {
-        $this->subjectConfirmation->Method = SAML2_Const::CM_HOK;
+        $this->subjectConfirmation->Method = SAML2_Constants::CM_HOK;
 
         $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationMethod();
         $result    = new SAML2_Assertion_Validation_Result();
diff --git a/tests/SAML2/AuthnRequestTest.php b/tests/SAML2/AuthnRequestTest.php
index 40830be8f..d1ba3a1aa 100644
--- a/tests/SAML2/AuthnRequestTest.php
+++ b/tests/SAML2/AuthnRequestTest.php
@@ -134,7 +134,7 @@ public function testThatTheSubjectIsCorrectlyRead()
     public function testThatTheSubjectCanBeSetBySettingTheNameId()
     {
         $request = new SAML2_AuthnRequest();
-        $request->setNameId(array('Value' => 'user@example.org', 'Format' => SAML2_Const::NAMEID_UNSPECIFIED));
+        $request->setNameId(array('Value' => 'user@example.org', 'Format' => SAML2_Constants::NAMEID_UNSPECIFIED));
 
         $requestAsXML = $request->toUnsignedXML()->ownerDocument->saveXML();
         $expected = '<saml:Subject><saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">user@example.org</saml:NameID></saml:Subject>';
@@ -180,7 +180,7 @@ public function testThatAnEncryptedNameIdCanBeDecrypted()
         $key = SAML2_CertificatesMock::getPrivateKey();
         $authnRequest->decryptNameId($key);
 
-        $expectedNameId = array('Value' => md5('Arthur Dent'), 'Format' => SAML2_Const::NAMEID_ENCRYPTED);
+        $expectedNameId = array('Value' => md5('Arthur Dent'), 'Format' => SAML2_Constants::NAMEID_ENCRYPTED);
 
         $this->assertEquals($expectedNameId, $authnRequest->getNameId());
     }
@@ -193,7 +193,7 @@ public function testThatAnEncryptedNameIdCanBeDecrypted()
     public function testThatAnEncryptedNameIdResultsInTheCorrectXmlStructure()
     {
         // the NameID we're going to encrypt
-        $nameId = array('Value' => md5('Arthur Dent'), 'Format' => SAML2_Const::NAMEID_ENCRYPTED);
+        $nameId = array('Value' => md5('Arthur Dent'), 'Format' => SAML2_Constants::NAMEID_ENCRYPTED);
 
         // basic AuthnRequest
         $request = new SAML2_AuthnRequest();
diff --git a/tests/SAML2/LogoutRequestTest.php b/tests/SAML2/LogoutRequestTest.php
index ccdff3963..29e30206c 100644
--- a/tests/SAML2/LogoutRequestTest.php
+++ b/tests/SAML2/LogoutRequestTest.php
@@ -52,7 +52,7 @@ public function testMarshalling()
 
         $logoutRequestElement = $logoutRequest->toUnsignedXML();
         $this->assertEquals('LogoutRequest', $logoutRequestElement->localName);
-        $this->assertEquals(SAML2_Const::NS_SAMLP, $logoutRequestElement->namespaceURI);
+        $this->assertEquals(SAML2_Constants::NS_SAMLP, $logoutRequestElement->namespaceURI);
 
         $nameIdElements = SAML2_Utils::xpQuery($logoutRequestElement, './saml_assertion:NameID');
         $this->assertCount(1, $nameIdElements);
diff --git a/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php b/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
index 37128044b..855d278cc 100644
--- a/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
+++ b/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
@@ -36,7 +36,7 @@ public function an_unsuccessful_response_is_not_valid_and_generates_a_proper_err
     {
         $responseStatus = array(
             'Code'    => 'foo',
-            'SubCode' => SAML2_Const::STATUS_PREFIX . 'bar',
+            'SubCode' => SAML2_Constants::STATUS_PREFIX . 'bar',
             'Message' => 'this is a test message'
         );
         $this->response->shouldReceive('isSuccess')->once()->andReturn(false);
diff --git a/tests/SAML2/ResponseTest.php b/tests/SAML2/ResponseTest.php
index 8a5969dea..3c65cda41 100644
--- a/tests/SAML2/ResponseTest.php
+++ b/tests/SAML2/ResponseTest.php
@@ -8,12 +8,12 @@ class SAML2_ResponseTest extends PHPUnit_Framework_TestCase
     public function testMarshalling()
     {
         $response = new SAML2_Response();
-        $response->setConsent(SAML2_Const::CONSENT_EXPLICIT);
+        $response->setConsent(SAML2_Constants::CONSENT_EXPLICIT);
         $response->setIssuer('SomeIssuer');
         $responseElement = $response->toUnsignedXML();
 
         $this->assertTrue($responseElement->hasAttribute('Consent'));
-        $this->assertEquals($responseElement->getAttribute('Consent'), SAML2_Const::CONSENT_EXPLICIT);
+        $this->assertEquals($responseElement->getAttribute('Consent'), SAML2_Constants::CONSENT_EXPLICIT);
 
         $issuerElements = SAML2_Utils::xpQuery($responseElement, './saml_assertion:Issuer');
         $this->assertCount(1, $issuerElements);
diff --git a/tests/SAML2/UtilsTest.php b/tests/SAML2/UtilsTest.php
index 7110ff184..74c545382 100644
--- a/tests/SAML2/UtilsTest.php
+++ b/tests/SAML2/UtilsTest.php
@@ -135,7 +135,7 @@ public function testGetAddStrings()
     public function testExtractString()
     {
         $document = SAML2_DOMDocumentFactory::fromString(
-            '<root xmlns="' . SAML2_Const::NS_MD . '">'.
+            '<root xmlns="' . SAML2_Constants::NS_MD . '">'.
             '<somenode>value1</somenode>'.
             '<somenode>value2</somenode>'.
             '</root>'
@@ -143,7 +143,7 @@ public function testExtractString()
 
         $stringValues = SAML2_Utils::extractStrings(
             $document->firstChild,
-            SAML2_Const::NS_MD,
+            SAML2_Constants::NS_MD,
             'somenode'
         );
 
@@ -158,7 +158,7 @@ public function testExtractString()
     public function testExtractLocalizedString()
     {
         $document = SAML2_DOMDocumentFactory::fromString(
-            '<root xmlns="' . SAML2_Const::NS_MD . '">'.
+            '<root xmlns="' . SAML2_Constants::NS_MD . '">'.
             '<somenode xml:lang="en">value (en)</somenode>'.
             '<somenode xml:lang="no">value (no)</somenode>'.
             '</root>'
@@ -166,7 +166,7 @@ public function testExtractLocalizedString()
 
         $localizedStringValues = SAML2_Utils::extractLocalizedStrings(
             $document->firstChild,
-            SAML2_Const::NS_MD,
+            SAML2_Constants::NS_MD,
             'somenode'
         );
 
diff --git a/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php b/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
index 43497e78f..255797993 100644
--- a/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
+++ b/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
@@ -28,7 +28,7 @@ public function testMarshalling()
     public function testUnmarshalling()
     {
         $document = SAML2_DOMDocumentFactory::fromString(
-            '<md:AdditionalMetadataLocation xmlns:md="' . SAML2_Const::NS_MD . '"'.
+            '<md:AdditionalMetadataLocation xmlns:md="' . SAML2_Constants::NS_MD . '"'.
             ' namespace="TheNamespaceAttribute">LocationText</md:AdditionalMetadataLocation>'
         );
         $additionalMetadataLocation = new SAML2_XML_md_AdditionalMetadataLocation($document->firstChild);
@@ -36,7 +36,7 @@ public function testUnmarshalling()
         $this->assertEquals('LocationText', $additionalMetadataLocation->location);
 
         $document->loadXML(
-            '<md:AdditionalMetadataLocation xmlns:md="' . SAML2_Const::NS_MD . '"'.
+            '<md:AdditionalMetadataLocation xmlns:md="' . SAML2_Constants::NS_MD . '"'.
             '>LocationText</md:AdditionalMetadataLocation>'
         );
         $this->setExpectedException('Exception', 'Missing namespace attribute on AdditionalMetadataLocation element.');
diff --git a/tests/SAML2/XML/md/AffiliationDescriptorTest.php b/tests/SAML2/XML/md/AffiliationDescriptorTest.php
index b4fa78c35..73bcad0c2 100644
--- a/tests/SAML2/XML/md/AffiliationDescriptorTest.php
+++ b/tests/SAML2/XML/md/AffiliationDescriptorTest.php
@@ -38,7 +38,7 @@ public function testMarshalling()
 
     public function testUnmarshalling()
     {
-        $mdNamespace = SAML2_Const::NS_MD;
+        $mdNamespace = SAML2_Constants::NS_MD;
         $document = SAML2_DOMDocumentFactory::fromString(<<<XML
 <md:AffiliationDescriptor xmlns:md="{$mdNamespace}" affiliationOwnerID="TheOwner" ID="TheID" validUntil="2009-02-13T23:31:30Z" cacheDuration="PT5000S">
     <md:AffiliateMember>Member</md:AffiliateMember>
@@ -59,7 +59,7 @@ public function testUnmarshalling()
 
     public function testUnmarshallingWithoutMembers()
     {
-        $mdNamespace = SAML2_Const::NS_MD;
+        $mdNamespace = SAML2_Constants::NS_MD;
         $document = SAML2_DOMDocumentFactory::fromString(
 <<<XML
 <md:AffiliationDescriptor xmlns:md="{$mdNamespace}" affiliationOwnerID="TheOwner" ID="TheID" validUntil="2009-02-13T23:31:30Z" cacheDuration="PT5000S">
@@ -72,7 +72,7 @@ public function testUnmarshallingWithoutMembers()
 
     public function testUnmarshallingWithoutOwner()
     {
-        $mdNamespace = SAML2_Const::NS_MD;
+        $mdNamespace = SAML2_Constants::NS_MD;
         $document = SAML2_DOMDocumentFactory::fromString(
             <<<XML
     <md:AffiliationDescriptor xmlns:md="{$mdNamespace}" ID="TheID" validUntil="2009-02-13T23:31:30Z" cacheDuration="PT5000S">
diff --git a/tests/SAML2/XML/md/EndpointTypeTest.php b/tests/SAML2/XML/md/EndpointTypeTest.php
index 208737bae..209e0421c 100644
--- a/tests/SAML2/XML/md/EndpointTypeTest.php
+++ b/tests/SAML2/XML/md/EndpointTypeTest.php
@@ -36,7 +36,7 @@ public function testMarshalling()
 
     public function testUnmarshalling()
     {
-        $mdNamespace = SAML2_Const::NS_MD;
+        $mdNamespace = SAML2_Constants::NS_MD;
         $document = SAML2_DOMDocumentFactory::fromString(
 <<<XML
 <md:Test xmlns:md="{$mdNamespace}" Binding="urn:something" Location="https://whatever/" xmlns:test="urn:test" test:attr="value" />
diff --git a/tests/SAML2/XML/md/RoleDescriptorMock.php b/tests/SAML2/XML/md/RoleDescriptorMock.php
index 62bf1cba8..f0e66e21b 100644
--- a/tests/SAML2/XML/md/RoleDescriptorMock.php
+++ b/tests/SAML2/XML/md/RoleDescriptorMock.php
@@ -8,7 +8,7 @@ public function __construct(DOMElement $xml = NULL) {
 
     public function toXML(DOMElement $parent) {
         $xml = parent::toXML($parent);
-        $xml->setAttributeNS(SAML2_Const::NS_XSI, 'xsi:type', 'myns:MyElement');
+        $xml->setAttributeNS(SAML2_Constants::NS_XSI, 'xsi:type', 'myns:MyElement');
         $xml->setAttributeNS('http://example.org/mynsdefinition', 'myns:tmp', 'tmp');
         $xml->removeAttributeNS('http://example.org/mynsdefinition', 'tmp');
         return $xml;
diff --git a/tests/SAML2/XML/md/RoleDescriptorTest.php b/tests/SAML2/XML/md/RoleDescriptorTest.php
index d0bb51376..ff4153fdd 100644
--- a/tests/SAML2/XML/md/RoleDescriptorTest.php
+++ b/tests/SAML2/XML/md/RoleDescriptorTest.php
@@ -27,7 +27,7 @@ public function testMarshalling()
         $this->assertEquals('2009-02-13T23:31:30Z', $roleDescriptorElement->getAttribute("validUntil"));
         $this->assertEquals('PT5000S', $roleDescriptorElement->getAttribute("cacheDuration"));
         $this->assertEquals('protocol1 protocol2', $roleDescriptorElement->getAttribute("protocolSupportEnumeration"));
-        $this->assertEquals('myns:MyElement', $roleDescriptorElement->getAttributeNS(SAML2_Const::NS_XSI, "type"));
+        $this->assertEquals('myns:MyElement', $roleDescriptorElement->getAttributeNS(SAML2_Constants::NS_XSI, "type"));
         $this->assertEquals('http://example.org/mynsdefinition', $roleDescriptorElement->lookupNamespaceURI("myns"));
     }
 }
diff --git a/tests/SAML2/XML/saml/AttributeTest.php b/tests/SAML2/XML/saml/AttributeTest.php
index 3d063abf5..f1cf2eaad 100644
--- a/tests/SAML2/XML/saml/AttributeTest.php
+++ b/tests/SAML2/XML/saml/AttributeTest.php
@@ -30,7 +30,7 @@ public function testMarshalling()
 
     public function testUnmarshalling()
     {
-        $samlNamespace = SAML2_Const::NS_SAML;
+        $samlNamespace = SAML2_Constants::NS_SAML;
         $document = SAML2_DOMDocumentFactory::fromString(<<<XML
 <saml:Attribute xmlns:saml="{$samlNamespace}" Name="TheName" NameFormat="TheNameFormat" FriendlyName="TheFriendlyName">
     <saml:AttributeValue>FirstValue</saml:AttributeValue>
@@ -51,7 +51,7 @@ public function testUnmarshalling()
 
     public function testUnmarshallingFailure()
     {
-        $samlNamespace = SAML2_Const::NS_SAML;
+        $samlNamespace = SAML2_Constants::NS_SAML;
         $document = SAML2_DOMDocumentFactory::fromString(<<<XML
 <saml:Attribute xmlns:saml="{$samlNamespace}" NameFormat="TheNameFormat" FriendlyName="TheFriendlyName">
     <saml:AttributeValue>FirstValue</saml:AttributeValue>
diff --git a/tests/SAML2/XML/saml/NameIDTest.php b/tests/SAML2/XML/saml/NameIDTest.php
index f74c463ff..64dcc14fa 100644
--- a/tests/SAML2/XML/saml/NameIDTest.php
+++ b/tests/SAML2/XML/saml/NameIDTest.php
@@ -28,7 +28,7 @@ public function testMarshalling()
 
     public function testUnmarshalling()
     {
-        $samlNamespace = SAML2_Const::NS_SAML;
+        $samlNamespace = SAML2_Constants::NS_SAML;
         $document = SAML2_DOMDocumentFactory::fromString(<<<XML
 <saml:NameID xmlns:saml="{$samlNamespace}" NameQualifier="TheNameQualifier" SPNameQualifier="TheSPNameQualifier" Format="TheFormat" SPProvidedID="TheSPProvidedID">TheNameIDValue</saml:NameID>
 XML
diff --git a/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php b/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php
index b8f91174e..2a8f15e53 100644
--- a/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php
+++ b/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php
@@ -33,7 +33,7 @@ public function testMarshalling()
 
     public function testUnmarshalling()
     {
-        $samlNamespace = SAML2_Const::NS_SAML;
+        $samlNamespace = SAML2_Constants::NS_SAML;
         $document = SAML2_DOMDocumentFactory::fromString(<<<XML
 <saml:SubjectConfirmationData
     xmlns:saml="{$samlNamespace}"
diff --git a/tests/SAML2/XML/saml/SubjectConfirmationTest.php b/tests/SAML2/XML/saml/SubjectConfirmationTest.php
index 8028d6a10..0f65d3957 100644
--- a/tests/SAML2/XML/saml/SubjectConfirmationTest.php
+++ b/tests/SAML2/XML/saml/SubjectConfirmationTest.php
@@ -26,7 +26,7 @@ public function testMarshalling()
 
     public function testUnmarshalling()
     {
-        $samlNamespace = SAML2_Const::NS_SAML;
+        $samlNamespace = SAML2_Constants::NS_SAML;
         $document = SAML2_DOMDocumentFactory::fromString(
 <<<XML
 <saml:SubjectConfirmation xmlns:saml="{$samlNamespace}" Method="SomeMethod">

From 0bbe6ca475912b6b3bcc063ff7b9cec557b5848d Mon Sep 17 00:00:00 2001
From: Charles Bell <cb8@users.noreply.github.com>
Date: Sun, 29 Nov 2015 19:40:41 +0100
Subject: [PATCH 02/17] Fix LogoutRequestTest class name

---
 tests/SAML2/LogoutRequestTest.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/SAML2/LogoutRequestTest.php b/tests/SAML2/LogoutRequestTest.php
index 29e30206c..dc4afd9b7 100644
--- a/tests/SAML2/LogoutRequestTest.php
+++ b/tests/SAML2/LogoutRequestTest.php
@@ -3,9 +3,9 @@
 require_once 'CertificatesMock.php';
 
 /**
- * Class LogoutRequestTest
+ * Class SAML2_LogoutRequestTest
  */
-class LogoutRequestTest extends \PHPUnit_Framework_TestCase
+class SAML2_LogoutRequestTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @var DOMElement

From f11a9c3ad92bfd43dcc26523f24e66e89bef905a Mon Sep 17 00:00:00 2001
From: Charles Bell <cb8@users.noreply.github.com>
Date: Sun, 29 Nov 2015 19:40:43 +0100
Subject: [PATCH 03/17] Remove obsolete includes

---
 tests/SAML2/LogoutRequestTest.php       | 2 --
 tests/SAML2/SignedElementHelperTest.php | 3 ---
 2 files changed, 5 deletions(-)

diff --git a/tests/SAML2/LogoutRequestTest.php b/tests/SAML2/LogoutRequestTest.php
index dc4afd9b7..5b3d7fd49 100644
--- a/tests/SAML2/LogoutRequestTest.php
+++ b/tests/SAML2/LogoutRequestTest.php
@@ -1,7 +1,5 @@
 <?php
 
-require_once 'CertificatesMock.php';
-
 /**
  * Class SAML2_LogoutRequestTest
  */
diff --git a/tests/SAML2/SignedElementHelperTest.php b/tests/SAML2/SignedElementHelperTest.php
index f0bb89345..8e7a3380c 100644
--- a/tests/SAML2/SignedElementHelperTest.php
+++ b/tests/SAML2/SignedElementHelperTest.php
@@ -1,8 +1,5 @@
 <?php
 
-require_once 'SignedElementHelperMock.php';
-require_once 'CertificatesMock.php';
-
 /**
  * Class SAML2_SignedElementHelperTest
  */

From 431576a6f104b682f8e2f328cf0dc9a959ef510f Mon Sep 17 00:00:00 2001
From: Charles Bell <cb8@users.noreply.github.com>
Date: Sun, 29 Nov 2015 19:40:45 +0100
Subject: [PATCH 04/17] Use PHP namespaces

---
 src/SAML2/ArtifactResolve.php                 |   8 +-
 src/SAML2/ArtifactResponse.php                |   8 +-
 src/SAML2/Assertion.php                       | 192 +++++++++---------
 src/SAML2/Assertion/Decrypter.php             |  30 ++-
 .../Exception/InvalidAssertionException.php   |   6 +-
 .../InvalidSubjectConfirmationException.php   |   6 +-
 .../Exception/NotDecryptedException.php       |   6 +-
 src/SAML2/Assertion/Processor.php             |  76 ++++---
 src/SAML2/Assertion/ProcessorBuilder.php      |  87 +++++---
 .../Transformer/DecodeBase64Transformer.php   |  18 +-
 .../NameIdDecryptionTransformer.php           |  34 ++--
 .../Assertion/Transformer/Transformer.php     |  12 +-
 .../Transformer/TransformerChain.php          |  32 +--
 .../AssertionConstraintValidator.php          |   8 +-
 .../Validation/AssertionValidator.php         |  34 ++--
 .../ConstraintValidator/NotBefore.php         |  15 +-
 .../ConstraintValidator/NotOnOrAfter.php      |  15 +-
 .../SessionNotOnOrAfter.php                   |  15 +-
 .../ConstraintValidator/SpIsValidAudience.php |  20 +-
 .../SubjectConfirmationMethod.php             |  19 +-
 .../SubjectConfirmationNotBefore.php          |  17 +-
 .../SubjectConfirmationNotOnOrAfter.php       |  17 +-
 .../SubjectConfirmationRecipientMatches.php   |  21 +-
 .../SubjectConfirmationResponseToMatches.php  |  17 +-
 src/SAML2/Assertion/Validation/Result.php     |   8 +-
 ...SubjectConfirmationConstraintValidator.php |  10 +-
 .../SubjectConfirmationValidator.php          |  30 ++-
 src/SAML2/AttributeQuery.php                  |  22 +-
 src/SAML2/AuthnRequest.php                    |  84 ++++----
 src/SAML2/Binding.php                         |  44 ++--
 .../InvalidCertificateStructureException.php  |   8 +-
 .../Exception/InvalidKeyUsageException.php    |  11 +-
 .../Exception/NoKeysFoundException.php        |   6 +-
 src/SAML2/Certificate/Fingerprint.php         |  12 +-
 .../Certificate/FingerprintCollection.php     |  19 +-
 src/SAML2/Certificate/FingerprintLoader.php   |  27 ++-
 src/SAML2/Certificate/Key.php                 |  11 +-
 src/SAML2/Certificate/KeyCollection.php       |  13 +-
 src/SAML2/Certificate/KeyLoader.php           |  49 +++--
 src/SAML2/Certificate/PrivateKey.php          |  10 +-
 src/SAML2/Certificate/PrivateKeyLoader.php    |  41 ++--
 src/SAML2/Certificate/X509.php                |  10 +-
 src/SAML2/Compat/AbstractContainer.php        |   4 +-
 src/SAML2/Compat/ContainerSingleton.php       |  20 +-
 src/SAML2/Compat/MockContainer.php            |   6 +-
 src/SAML2/Compat/Ssp/Container.php            |   8 +-
 src/SAML2/Compat/Ssp/Logger.php               |   4 +-
 src/SAML2/Configuration/ArrayAdapter.php      |   4 +-
 .../Configuration/CertificateProvider.php     |   4 +-
 .../Configuration/DecryptionProvider.php      |   4 +-
 src/SAML2/Configuration/Destination.php       |  12 +-
 src/SAML2/Configuration/EntityIdProvider.php  |   6 +-
 src/SAML2/Configuration/IdentityProvider.php  |  12 +-
 .../Configuration/IdentityProviderAware.php   |   6 +-
 src/SAML2/Configuration/PrivateKey.php        |  12 +-
 src/SAML2/Configuration/Queryable.php         |   6 +-
 src/SAML2/Configuration/ServiceProvider.php   |  12 +-
 .../Configuration/ServiceProviderAware.php    |   6 +-
 .../Configuration/SimpleSAMLConverter.php     |  20 +-
 src/SAML2/Constants.php                       |   4 +-
 src/SAML2/DOMDocumentFactory.php              |  24 ++-
 src/SAML2/EncryptedAssertion.php              |  24 ++-
 .../Exception/InvalidArgumentException.php    |   6 +-
 src/SAML2/Exception/RuntimeException.php      |   4 +-
 src/SAML2/Exception/Throwable.php             |   6 +-
 .../Exception/UnparseableXmlException.php     |   4 +-
 src/SAML2/HTTPArtifact.php                    |  34 ++--
 src/SAML2/HTTPPost.php                        |  22 +-
 src/SAML2/HTTPRedirect.php                    |  30 +--
 src/SAML2/LogoutRequest.php                   |  34 ++--
 src/SAML2/LogoutResponse.php                  |   4 +-
 src/SAML2/Message.php                         |  61 +++---
 src/SAML2/Request.php                         |   6 +-
 src/SAML2/Response.php                        |  16 +-
 .../Exception/InvalidResponseException.php    |   6 +-
 .../Exception/InvalidSignatureException.php   |   4 +-
 .../Exception/NoAssertionsFoundException.php  |   4 +-
 .../Exception/PreconditionNotMetException.php |   8 +-
 .../UnencryptedAssertionFoundException.php    |   8 +-
 .../Exception/UnsignedResponseException.php   |   6 +-
 src/SAML2/Response/Processor.php              |  72 ++++---
 .../Validation/ConstraintValidator.php        |   8 +-
 .../DestinationMatches.php                    |  19 +-
 .../ConstraintValidator/IsSuccessful.php      |  19 +-
 .../Validation/PreconditionValidator.php      |  14 +-
 src/SAML2/Response/Validation/Result.php      |   8 +-
 src/SAML2/Response/Validation/Validator.php   |  14 +-
 src/SAML2/SOAP.php                            |  20 +-
 src/SAML2/SOAPClient.php                      |  44 ++--
 .../Signature/AbstractChainedValidator.php    |  12 +-
 src/SAML2/Signature/ChainedValidator.php      |  17 +-
 src/SAML2/Signature/FingerprintValidator.php  |  29 ++-
 .../MissingConfigurationException.php         |   6 +-
 src/SAML2/Signature/PublicKeyValidator.php    |  36 ++--
 src/SAML2/Signature/Validator.php             |  19 +-
 src/SAML2/Signature/ValidatorChain.php        |  25 ++-
 src/SAML2/Signature/ValidatorInterface.php    |  15 +-
 src/SAML2/SignedElement.php                   |   4 +-
 src/SAML2/SignedElementHelper.php             |   8 +-
 src/SAML2/StatusResponse.php                  |  26 +--
 src/SAML2/SubjectQuery.php                    |  22 +-
 src/SAML2/Utilities/ArrayCollection.php       |   8 +-
 src/SAML2/Utilities/Certificate.php           |   4 +-
 src/SAML2/Utilities/Collection.php            |  10 +-
 src/SAML2/Utilities/File.php                  |  13 +-
 src/SAML2/Utilities/Temporal.php              |   4 +-
 src/SAML2/Utils.php                           |  47 +++--
 src/SAML2/XML/Chunk.php                       |  15 +-
 src/SAML2/XML/ds/KeyInfo.php                  |  20 +-
 src/SAML2/XML/ds/KeyName.php                  |   8 +-
 src/SAML2/XML/ds/X509Certificate.php          |   8 +-
 src/SAML2/XML/ds/X509Data.php                 |  18 +-
 .../XML/md/AdditionalMetadataLocation.php     |   9 +-
 src/SAML2/XML/md/AffiliationDescriptor.php    |  28 ++-
 .../XML/md/AttributeAuthorityDescriptor.php   |  36 ++--
 .../XML/md/AttributeConsumingService.php      |  25 ++-
 src/SAML2/XML/md/AuthnAuthorityDescriptor.php |  23 ++-
 src/SAML2/XML/md/ContactPerson.php            |  25 ++-
 src/SAML2/XML/md/EndpointType.php             |   8 +-
 src/SAML2/XML/md/EntitiesDescriptor.php       |  31 +--
 src/SAML2/XML/md/EntityDescriptor.php         |  65 +++---
 src/SAML2/XML/md/Extensions.php               |  49 +++--
 src/SAML2/XML/md/IDPSSODescriptor.php         |  40 ++--
 src/SAML2/XML/md/IndexedEndpointType.php      |   8 +-
 src/SAML2/XML/md/KeyDescriptor.php            |  25 ++-
 src/SAML2/XML/md/Organization.php             |  25 ++-
 src/SAML2/XML/md/PDPDescriptor.php            |  23 ++-
 src/SAML2/XML/md/RequestedAttribute.php       |  12 +-
 src/SAML2/XML/md/RoleDescriptor.php           |  38 ++--
 src/SAML2/XML/md/SPSSODescriptor.php          |  24 ++-
 src/SAML2/XML/md/SSODescriptorType.php        |  29 +--
 src/SAML2/XML/md/UnknownRoleDescriptor.php    |  10 +-
 src/SAML2/XML/mdattr/EntityAttributes.php     |  22 +-
 src/SAML2/XML/mdrpi/Common.php                |   4 +-
 src/SAML2/XML/mdrpi/PublicationInfo.php       |  14 +-
 src/SAML2/XML/mdrpi/RegistrationInfo.php      |  14 +-
 src/SAML2/XML/mdui/DiscoHints.php             |  27 ++-
 src/SAML2/XML/mdui/Keywords.php               |   6 +-
 src/SAML2/XML/mdui/Logo.php                   |   6 +-
 src/SAML2/XML/mdui/UIInfo.php                 |  33 +--
 src/SAML2/XML/saml/Attribute.php              |  17 +-
 src/SAML2/XML/saml/AttributeValue.php         |  32 +--
 src/SAML2/XML/saml/NameID.php                 |  11 +-
 src/SAML2/XML/saml/SubjectConfirmation.php    |  21 +-
 .../XML/saml/SubjectConfirmationData.php      |  27 ++-
 src/SAML2/XML/samlp/Extensions.php            |  16 +-
 src/SAML2/XML/shibmd/Scope.php                |  10 +-
 .../ConstraintValidator/NotBeforeTest.php     |  19 +-
 .../ConstraintValidator/NotOnOrAfterTest.php  |  19 +-
 .../SessionNotOnOrAfterTest.php               |  19 +-
 .../SpIsValidAudienceTest.php                 |  18 +-
 .../SubjectConfirmationMethodTest.php         |  19 +-
 .../SubjectConfirmationNotBeforeTest.php      |  19 +-
 .../SubjectConfirmationNotOnOrAfterTest.php   |  19 +-
 ...bjectConfirmationRecipientMathchesTest.php |  19 +-
 ...bjectConfirmationResponseToMatchesTest.php |  26 ++-
 tests/SAML2/AssertionTest.php                 |  52 ++---
 tests/SAML2/AttributeQueryTest.php            |  16 +-
 tests/SAML2/AuthnRequestTest.php              |  40 ++--
 .../Certificate/FingerprintLoaderTest.php     |  23 ++-
 tests/SAML2/Certificate/FingerprintTest.php   |  10 +-
 tests/SAML2/Certificate/KeyLoaderTest.php     |  28 +--
 tests/SAML2/Certificate/KeyTest.php           |  18 +-
 .../Certificate/PrivateKeyLoaderTest.php      |  22 +-
 .../Certificate/Stub/ImplementsToString.php   |   4 +-
 tests/SAML2/Certificate/X509Test.php          |  10 +-
 tests/SAML2/CertificatesMock.php              |   6 +-
 .../SAML2/Configuration/ArrayAdapterTest.php  |   8 +-
 tests/SAML2/Configuration/DestinationTest.php |  16 +-
 tests/SAML2/ControlledTimeTest.php            |   4 +-
 tests/SAML2/DOMDocumentFactoryTest.php        |  44 ++--
 tests/SAML2/LogoutRequestTest.php             |  34 ++--
 .../Response/SignatureValidationTest.php      |  88 ++++----
 .../DestinationMatchesTest.php                |  19 +-
 .../ConstraintValidator/IsSuccessfulTest.php  |  17 +-
 .../SAML2/Response/Validation/ResultTest.php  |  12 +-
 .../Response/XmlSignatureWrappingTest.php     |  31 ++-
 tests/SAML2/ResponseTest.php                  |  18 +-
 .../Signature/FingerprintValidatorTest.php    |  49 +++--
 .../SAML2/Signature/MockChainedValidator.php  |  15 +-
 .../Signature/PublicKeyValidatorTest.php      |  50 +++--
 tests/SAML2/Signature/ValidatorChainTest.php  |  39 ++--
 tests/SAML2/SignedElementHelperMock.php       |   8 +-
 tests/SAML2/SignedElementHelperTest.php       |  48 ++---
 tests/SAML2/SimpleTestLogger.php              |   4 +-
 tests/SAML2/StatusResponseTest.php            |  16 +-
 tests/SAML2/Utilities/FileTest.php            |  14 +-
 tests/SAML2/UtilsTest.php                     |  44 ++--
 .../XML/md/AdditionalMetadataLocationTest.php |  26 ++-
 .../XML/md/AffiliationDescriptorTest.php      |  34 ++--
 tests/SAML2/XML/md/EndpointTypeTest.php       |  26 ++-
 tests/SAML2/XML/md/EntityDescriptorTest.php   |  46 +++--
 .../SAML2/XML/md/IndexedEndpointTypeTest.php  |  19 +-
 tests/SAML2/XML/md/RoleDescriptorMock.php     |   8 +-
 tests/SAML2/XML/md/RoleDescriptorTest.php     |  16 +-
 tests/SAML2/XML/mdrpi/PublicationInfoTest.php |  21 +-
 tests/SAML2/XML/saml/AttributeTest.php        |  34 ++--
 tests/SAML2/XML/saml/NameIDTest.php           |  21 +-
 .../XML/saml/SubjectConfirmationDataTest.php  |  22 +-
 .../XML/saml/SubjectConfirmationTest.php      |  34 ++--
 200 files changed, 2592 insertions(+), 1673 deletions(-)

diff --git a/src/SAML2/ArtifactResolve.php b/src/SAML2/ArtifactResolve.php
index 36f222e8e..cc8422645 100644
--- a/src/SAML2/ArtifactResolve.php
+++ b/src/SAML2/ArtifactResolve.php
@@ -1,4 +1,6 @@
 <?php
+
+namespace SAML2;
 /**
  * The Artifact is part of the SAML 2.0 IdP code, and it builds an artifact object.
  * I am using strings, because I find them easier to work with.
@@ -7,7 +9,7 @@
  * @author Danny Bollaert, UGent AS. <danny.bollaert@ugent.be>
  * @package SimpleSAMLphp
  */
-class SAML2_ArtifactResolve extends SAML2_Request
+class ArtifactResolve extends Request
 {
     private $artifact;
 
@@ -16,7 +18,7 @@ public function __construct(DOMElement $xml = NULL)
         parent::__construct('ArtifactResolve', $xml);
 
         if (!is_null($xml)) {
-            $results = SAML2_Utils::xpQuery($xml, './saml_protocol:Artifact');
+            $results = Utils::xpQuery($xml, './saml_protocol:Artifact');
             $this->artifact = $results[0]->textContent;
         }
 
@@ -51,7 +53,7 @@ public function setArtifact($artifact)
     public function toUnsignedXML()
     {
         $root = parent::toUnsignedXML();
-        $artifactelement = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'Artifact', $this->artifact);
+        $artifactelement = $this->document->createElementNS(Constants::NS_SAMLP, 'Artifact', $this->artifact);
         $root->appendChild($artifactelement);
 
         return $root;
diff --git a/src/SAML2/ArtifactResponse.php b/src/SAML2/ArtifactResponse.php
index 3bc089a6e..2af6b18ba 100644
--- a/src/SAML2/ArtifactResponse.php
+++ b/src/SAML2/ArtifactResponse.php
@@ -1,12 +1,14 @@
 <?php
 
+namespace SAML2;
+
 /**
- * The SAML2_ArtifactResponse, is the response to the SAML2_ArtifactResolve.
+ * The \SAML2\ArtifactResponse, is the response to the \SAML2\ArtifactResolve.
  *
  * @author Danny Bollaert, UGent AS. <danny.bollaert@ugent.be>
  * @package SimpleSAMLphp
  */
-class SAML2_ArtifactResponse extends SAML2_StatusResponse
+class ArtifactResponse extends StatusResponse
 {
     /**
      * The DOMElement with the message the artifact refers
@@ -23,7 +25,7 @@ public function __construct(DOMElement $xml = NULL)
 
         if (!is_null($xml)) {
 
-            $status = SAML2_Utils::xpQuery($xml, './saml_protocol:Status');
+            $status = Utils::xpQuery($xml, './saml_protocol:Status');
             assert('!empty($status)'); /* Will have failed during StatusResponse parsing. */
 
             $status = $status[0];
diff --git a/src/SAML2/Assertion.php b/src/SAML2/Assertion.php
index 1baed6362..eba3afaa4 100644
--- a/src/SAML2/Assertion.php
+++ b/src/SAML2/Assertion.php
@@ -1,11 +1,17 @@
 <?php
 
+namespace SAML2;
+
+use SAML2\Utilities\Temporal;
+use SAML2\XML\saml\SubjectConfirmation;
+use SAML2\XML\Chunk;
+
 /**
  * Class representing a SAML 2 assertion.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_Assertion implements SAML2_SignedElement
+class Assertion implements SignedElement
 {
     /**
      * The identifier of this assertion.
@@ -123,7 +129,7 @@ class SAML2_Assertion implements SAML2_SignedElement
      * See:
      * @url http://docs.oasis-open.org/security/saml/v2.0/saml-authn-context-2.0-os.pdf
      *
-     * @var \SAML2_XML_Chunk
+     * @var \SAML2\XML\Chunk
      */
     private $authnContextDecl;
 
@@ -132,7 +138,7 @@ class SAML2_Assertion implements SAML2_SignedElement
      *
      * The URI reference MAY directly resolve into an XML document containing the referenced declaration.
      *
-     * @var \SAML2_XML_Chunk
+     * @var \SAML2\XML\Chunk
      */
     private $authnContextDeclRef;
 
@@ -194,7 +200,7 @@ class SAML2_Assertion implements SAML2_SignedElement
     /**
      * The SubjectConfirmation elements of the Subject in the assertion.
      *
-     * @var SAML2_XML_saml_SubjectConfirmation[].
+     * @var \SAML2\XML\saml\SubjectConfirmation[].
      */
     private $SubjectConfirmation;
 
@@ -211,12 +217,12 @@ class SAML2_Assertion implements SAML2_SignedElement
      */
     public function __construct(DOMElement $xml = NULL)
     {
-        $this->id = SAML2_Utils::getContainer()->generateId();
-        $this->issueInstant = SAML2_Utilities_Temporal::getTime();
+        $this->id = Utils::getContainer()->generateId();
+        $this->issueInstant = Temporal::getTime();
         $this->issuer = '';
-        $this->authnInstant = SAML2_Utilities_Temporal::getTime();
+        $this->authnInstant = Temporal::getTime();
         $this->attributes = array();
-        $this->nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
+        $this->nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
         $this->certificates = array();
         $this->AuthenticatingAuthority = array();
         $this->SubjectConfirmation = array();
@@ -235,9 +241,9 @@ public function __construct(DOMElement $xml = NULL)
             throw new Exception('Unsupported version: ' . $xml->getAttribute('Version'));
         }
 
-        $this->issueInstant = SAML2_Utils::xsDateTimeToTimestamp($xml->getAttribute('IssueInstant'));
+        $this->issueInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('IssueInstant'));
 
-        $issuer = SAML2_Utils::xpQuery($xml, './saml_assertion:Issuer');
+        $issuer = Utils::xpQuery($xml, './saml_assertion:Issuer');
         if (empty($issuer)) {
             throw new Exception('Missing <saml:Issuer> in assertion.');
         }
@@ -259,7 +265,7 @@ public function __construct(DOMElement $xml = NULL)
      */
     private function parseSubject(DOMElement $xml)
     {
-        $subject = SAML2_Utils::xpQuery($xml, './saml_assertion:Subject');
+        $subject = Utils::xpQuery($xml, './saml_assertion:Subject');
         if (empty($subject)) {
             /* No Subject node. */
 
@@ -269,7 +275,7 @@ private function parseSubject(DOMElement $xml)
         }
         $subject = $subject[0];
 
-        $nameId = SAML2_Utils::xpQuery(
+        $nameId = Utils::xpQuery(
             $subject,
             './saml_assertion:NameID | ./saml_assertion:EncryptedID/xenc:EncryptedData'
         );
@@ -283,16 +289,16 @@ private function parseSubject(DOMElement $xml)
             /* The NameID element is encrypted. */
             $this->encryptedNameId = $nameId;
         } else {
-            $this->nameId = SAML2_Utils::parseNameId($nameId);
+            $this->nameId = Utils::parseNameId($nameId);
         }
 
-        $subjectConfirmation = SAML2_Utils::xpQuery($subject, './saml_assertion:SubjectConfirmation');
+        $subjectConfirmation = Utils::xpQuery($subject, './saml_assertion:SubjectConfirmation');
         if (empty($subjectConfirmation)) {
             throw new Exception('Missing <saml:SubjectConfirmation> in <saml:Subject>.');
         }
 
         foreach ($subjectConfirmation as $sc) {
-            $this->SubjectConfirmation[] = new SAML2_XML_saml_SubjectConfirmation($sc);
+            $this->SubjectConfirmation[] = new SubjectConfirmation($sc);
         }
     }
 
@@ -304,7 +310,7 @@ private function parseSubject(DOMElement $xml)
      */
     private function parseConditions(DOMElement $xml)
     {
-        $conditions = SAML2_Utils::xpQuery($xml, './saml_assertion:Conditions');
+        $conditions = Utils::xpQuery($xml, './saml_assertion:Conditions');
         if (empty($conditions)) {
             /* No <saml:Conditions> node. */
 
@@ -315,13 +321,13 @@ private function parseConditions(DOMElement $xml)
         $conditions = $conditions[0];
 
         if ($conditions->hasAttribute('NotBefore')) {
-            $notBefore = SAML2_Utils::xsDateTimeToTimestamp($conditions->getAttribute('NotBefore'));
+            $notBefore = Utils::xsDateTimeToTimestamp($conditions->getAttribute('NotBefore'));
             if ($this->notBefore === NULL || $this->notBefore < $notBefore) {
                 $this->notBefore = $notBefore;
             }
         }
         if ($conditions->hasAttribute('NotOnOrAfter')) {
-            $notOnOrAfter = SAML2_Utils::xsDateTimeToTimestamp($conditions->getAttribute('NotOnOrAfter'));
+            $notOnOrAfter = Utils::xsDateTimeToTimestamp($conditions->getAttribute('NotOnOrAfter'));
             if ($this->notOnOrAfter === NULL || $this->notOnOrAfter > $notOnOrAfter) {
                 $this->notOnOrAfter = $notOnOrAfter;
             }
@@ -331,12 +337,12 @@ private function parseConditions(DOMElement $xml)
             if ($node instanceof DOMText) {
                 continue;
             }
-            if ($node->namespaceURI !== SAML2_Constants::NS_SAML) {
+            if ($node->namespaceURI !== Constants::NS_SAML) {
                 throw new Exception('Unknown namespace of condition: ' . var_export($node->namespaceURI, TRUE));
             }
             switch ($node->localName) {
                 case 'AudienceRestriction':
-                    $audiences = SAML2_Utils::extractStrings($node, SAML2_Constants::NS_SAML, 'Audience');
+                    $audiences = Utils::extractStrings($node, Constants::NS_SAML, 'Audience');
                     if ($this->validAudiences === NULL) {
                         /* The first (and probably last) AudienceRestriction element. */
                         $this->validAudiences = $audiences;
@@ -370,7 +376,7 @@ private function parseConditions(DOMElement $xml)
      */
     private function parseAuthnStatement(DOMElement $xml)
     {
-        $authnStatements = SAML2_Utils::xpQuery($xml, './saml_assertion:AuthnStatement');
+        $authnStatements = Utils::xpQuery($xml, './saml_assertion:AuthnStatement');
         if (empty($authnStatements)) {
             $this->authnInstant = NULL;
 
@@ -383,10 +389,10 @@ private function parseAuthnStatement(DOMElement $xml)
         if (!$authnStatement->hasAttribute('AuthnInstant')) {
             throw new Exception('Missing required AuthnInstant attribute on <saml:AuthnStatement>.');
         }
-        $this->authnInstant = SAML2_Utils::xsDateTimeToTimestamp($authnStatement->getAttribute('AuthnInstant'));
+        $this->authnInstant = Utils::xsDateTimeToTimestamp($authnStatement->getAttribute('AuthnInstant'));
 
         if ($authnStatement->hasAttribute('SessionNotOnOrAfter')) {
-            $this->sessionNotOnOrAfter = SAML2_Utils::xsDateTimeToTimestamp($authnStatement->getAttribute('SessionNotOnOrAfter'));
+            $this->sessionNotOnOrAfter = Utils::xsDateTimeToTimestamp($authnStatement->getAttribute('SessionNotOnOrAfter'));
         }
 
         if ($authnStatement->hasAttribute('SessionIndex')) {
@@ -405,7 +411,7 @@ private function parseAuthnStatement(DOMElement $xml)
     private function parseAuthnContext(DOMElement $authnStatementEl)
     {
         // Get the AuthnContext element
-        $authnContexts = SAML2_Utils::xpQuery($authnStatementEl, './saml_assertion:AuthnContext');
+        $authnContexts = Utils::xpQuery($authnStatementEl, './saml_assertion:AuthnContext');
         if (count($authnContexts) > 1) {
             throw new Exception('More than one <saml:AuthnContext> in <saml:AuthnStatement>.');
         } elseif (empty($authnContexts)) {
@@ -414,7 +420,7 @@ private function parseAuthnContext(DOMElement $authnStatementEl)
         $authnContextEl = $authnContexts[0];
 
         // Get the AuthnContextDeclRef (if available)
-        $authnContextDeclRefs = SAML2_Utils::xpQuery($authnContextEl, './saml_assertion:AuthnContextDeclRef');
+        $authnContextDeclRefs = Utils::xpQuery($authnContextEl, './saml_assertion:AuthnContextDeclRef');
         if (count($authnContextDeclRefs) > 1) {
             throw new Exception(
                 'More than one <saml:AuthnContextDeclRef> found?'
@@ -424,17 +430,17 @@ private function parseAuthnContext(DOMElement $authnStatementEl)
         }
 
         // Get the AuthnContextDecl (if available)
-        $authnContextDecls = SAML2_Utils::xpQuery($authnContextEl, './saml_assertion:AuthnContextDecl');
+        $authnContextDecls = Utils::xpQuery($authnContextEl, './saml_assertion:AuthnContextDecl');
         if (count($authnContextDecls) > 1) {
             throw new Exception(
                 'More than one <saml:AuthnContextDecl> found?'
             );
         } elseif (count($authnContextDecls) === 1) {
-            $this->setAuthnContextDecl(new SAML2_XML_Chunk($authnContextDecls[0]));
+            $this->setAuthnContextDecl(new Chunk($authnContextDecls[0]));
         }
 
         // Get the AuthnContextClassRef (if available)
-        $authnContextClassRefs = SAML2_Utils::xpQuery($authnContextEl, './saml_assertion:AuthnContextClassRef');
+        $authnContextClassRefs = Utils::xpQuery($authnContextEl, './saml_assertion:AuthnContextClassRef');
         if (count($authnContextClassRefs) > 1) {
             throw new Exception('More than one <saml:AuthnContextClassRef> in <saml:AuthnContext>.');
         } elseif (count($authnContextClassRefs) === 1) {
@@ -448,9 +454,9 @@ private function parseAuthnContext(DOMElement $authnStatementEl)
             );
         }
 
-        $this->AuthenticatingAuthority = SAML2_Utils::extractStrings(
+        $this->AuthenticatingAuthority = Utils::extractStrings(
             $authnContextEl,
-            SAML2_Constants::NS_SAML,
+            Constants::NS_SAML,
             'AuthenticatingAuthority'
         );
     }
@@ -464,7 +470,7 @@ private function parseAuthnContext(DOMElement $authnStatementEl)
     private function parseAttributes(DOMElement $xml)
     {
         $firstAttribute = TRUE;
-        $attributes = SAML2_Utils::xpQuery($xml, './saml_assertion:AttributeStatement/saml_assertion:Attribute');
+        $attributes = Utils::xpQuery($xml, './saml_assertion:AttributeStatement/saml_assertion:Attribute');
         foreach ($attributes as $attribute) {
             if (!$attribute->hasAttribute('Name')) {
                 throw new Exception('Missing name on <saml:Attribute> element.');
@@ -474,7 +480,7 @@ private function parseAttributes(DOMElement $xml)
             if ($attribute->hasAttribute('NameFormat')) {
                 $nameFormat = $attribute->getAttribute('NameFormat');
             } else {
-                $nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
+                $nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
             }
 
             if ($firstAttribute) {
@@ -482,7 +488,7 @@ private function parseAttributes(DOMElement $xml)
                 $firstAttribute = FALSE;
             } else {
                 if ($this->nameFormat !== $nameFormat) {
-                    $this->nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
+                    $this->nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
                 }
             }
 
@@ -490,7 +496,7 @@ private function parseAttributes(DOMElement $xml)
                 $this->attributes[$name] = array();
             }
 
-            $values = SAML2_Utils::xpQuery($attribute, './saml_assertion:AttributeValue');
+            $values = Utils::xpQuery($attribute, './saml_assertion:AttributeValue');
             foreach ($values as $value) {
                 $this->attributes[$name][] = trim($value->textContent);
             }
@@ -504,7 +510,7 @@ private function parseAttributes(DOMElement $xml)
      */
     private function parseEncryptedAttributes(DOMElement $xml)
     {
-        $this->encryptedAttributes = SAML2_Utils::xpQuery(
+        $this->encryptedAttributes = Utils::xpQuery(
             $xml,
             './saml_assertion:AttributeStatement/saml_assertion:EncryptedAttribute'
         );
@@ -518,7 +524,7 @@ private function parseEncryptedAttributes(DOMElement $xml)
     private function parseSignature(DOMElement $xml)
     {
         /* Validate the signature element of the message. */
-        $sig = SAML2_Utils::validateElement($xml);
+        $sig = Utils::validateElement($xml);
         if ($sig !== FALSE) {
             $this->wasSignedAtConstruction = TRUE;
             $this->certificates = $sig['Certificates'];
@@ -544,7 +550,7 @@ public function validate(XMLSecurityKey $key)
             return FALSE;
         }
 
-        SAML2_Utils::validateSignature($this->signatureData, $key);
+        Utils::validateSignature($this->signatureData, $key);
 
         return TRUE;
     }
@@ -618,9 +624,9 @@ public function setIssuer($issuer)
     /**
      * Retrieve the NameId of the subject in the assertion.
      *
-     * The returned NameId is in the format used by SAML2_Utils::addNameId().
+     * The returned NameId is in the format used by \SAML2\Utils::addNameId().
      *
-     * @see SAML2_Utils::addNameId()
+     * @see \SAML2\Utils::addNameId()
      * @return array|NULL The name identifier of the assertion.
      * @throws Exception
      */
@@ -636,9 +642,9 @@ public function getNameId()
     /**
      * Set the NameId of the subject in the assertion.
      *
-     * The NameId must be in the format accepted by SAML2_Utils::addNameId().
+     * The NameId must be in the format accepted by \SAML2\Utils::addNameId().
      *
-     * @see SAML2_Utils::addNameId()
+     * @see \SAML2\Utils::addNameId()
      * @param array|NULL $nameId The name identifier of the assertion.
      */
     public function setNameId($nameId)
@@ -666,13 +672,13 @@ public function isNameIdEncrypted()
     public function encryptNameId(XMLSecurityKey $key)
     {
         /* First create a XML representation of the NameID. */
-        $doc = SAML2_DOMDocumentFactory::create();
+        $doc = DOMDocumentFactory::create();
         $root = $doc->createElement('root');
         $doc->appendChild($root);
-        SAML2_Utils::addNameId($root, $this->nameId);
+        Utils::addNameId($root, $this->nameId);
         $nameId = $root->firstChild;
 
-        SAML2_Utils::getContainer()->debugMessage($nameId, 'encrypt');
+        Utils::getContainer()->debugMessage($nameId, 'encrypt');
 
         /* Encrypt the NameID. */
         $enc = new XMLSecEnc();
@@ -703,9 +709,9 @@ public function decryptNameId(XMLSecurityKey $key, array $blacklist = array())
             return;
         }
 
-        $nameId = SAML2_Utils::decryptElement($this->encryptedNameId, $key, $blacklist);
-        SAML2_Utils::getContainer()->debugMessage($nameId, 'decrypt');
-        $this->nameId = SAML2_Utils::parseNameId($nameId);
+        $nameId = Utils::decryptElement($this->encryptedNameId, $key, $blacklist);
+        Utils::getContainer()->debugMessage($nameId, 'decrypt');
+        $this->nameId = Utils::parseNameId($nameId);
 
         $this->encryptedNameId = NULL;
     }
@@ -736,7 +742,7 @@ public function decryptAttributes(XMLSecurityKey $key, array $blacklist = array(
         $attributes = $this->encryptedAttributes;
         foreach ($attributes as $attributeEnc) {
             /*Decrypt node <EncryptedAttribute>*/
-            $attribute = SAML2_Utils::decryptElement(
+            $attribute = Utils::decryptElement(
                 $attributeEnc->getElementsByTagName('EncryptedData')->item(0),
                 $key,
                 $blacklist
@@ -750,7 +756,7 @@ public function decryptAttributes(XMLSecurityKey $key, array $blacklist = array(
             if ($attribute->hasAttribute('NameFormat')) {
                 $nameFormat = $attribute->getAttribute('NameFormat');
             } else {
-                $nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
+                $nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
             }
 
             if ($firstAttribute) {
@@ -758,7 +764,7 @@ public function decryptAttributes(XMLSecurityKey $key, array $blacklist = array(
                 $firstAttribute = FALSE;
             } else {
                 if ($this->nameFormat !== $nameFormat) {
-                    $this->nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
+                    $this->nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
                 }
             }
 
@@ -766,7 +772,7 @@ public function decryptAttributes(XMLSecurityKey $key, array $blacklist = array(
                 $this->attributes[$name] = array();
             }
 
-            $values = SAML2_Utils::xpQuery($attribute, './saml_assertion:AttributeValue');
+            $values = Utils::xpQuery($attribute, './saml_assertion:AttributeValue');
             foreach ($values as $value) {
                 $this->attributes[$name][] = trim($value->textContent);
             }
@@ -1006,10 +1012,10 @@ public function setAuthnContextClassRef($authnContextClassRef)
     /**
      * Set the authentication context declaration.
      *
-     * @param \SAML2_XML_Chunk $authnContextDecl
+     * @param \SAML2\XML\Chunk $authnContextDecl
      * @throws Exception
      */
-    public function setAuthnContextDecl(SAML2_XML_Chunk $authnContextDecl)
+    public function setAuthnContextDecl(Chunk $authnContextDecl)
     {
         if (!empty($this->authnContextDeclRef)) {
             throw new Exception(
@@ -1026,7 +1032,7 @@ public function setAuthnContextDecl(SAML2_XML_Chunk $authnContextDecl)
      * See:
      * @url http://docs.oasis-open.org/security/saml/v2.0/saml-authn-context-2.0-os.pdf
      *
-     * @return \SAML2_XML_Chunk|NULL
+     * @return \SAML2\XML\Chunk|NULL
      */
     public function getAuthnContextDecl()
     {
@@ -1133,7 +1139,7 @@ public function setAttributeNameFormat($nameFormat)
     /**
      * Retrieve the SubjectConfirmation elements we have in our Subject element.
      *
-     * @return array Array of SAML2_XML_saml_SubjectConfirmation elements.
+     * @return array Array of \SAML2\XML\saml\SubjectConfirmation elements.
      */
     public function getSubjectConfirmation()
     {
@@ -1143,7 +1149,7 @@ public function getSubjectConfirmation()
     /**
      * Set the SubjectConfirmation elements that should be included in the assertion.
      *
-     * @param array $SubjectConfirmation Array of SAML2_XML_saml_SubjectConfirmation elements.
+     * @param array $SubjectConfirmation Array of \SAML2\XML\saml\SubjectConfirmation elements.
      */
     public function setSubjectConfirmation(array $SubjectConfirmation)
     {
@@ -1232,28 +1238,28 @@ public function getWasSignedAtConstruction()
     public function toXML(DOMNode $parentElement = NULL)
     {
         if ($parentElement === NULL) {
-            $document = SAML2_DOMDocumentFactory::create();
+            $document = DOMDocumentFactory::create();
             $parentElement = $document;
         } else {
             $document = $parentElement->ownerDocument;
         }
 
-        $root = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:' . 'Assertion');
+        $root = $document->createElementNS(Constants::NS_SAML, 'saml:' . 'Assertion');
         $parentElement->appendChild($root);
 
         /* Ugly hack to add another namespace declaration to the root element. */
-        $root->setAttributeNS(SAML2_Constants::NS_SAMLP, 'samlp:tmp', 'tmp');
-        $root->removeAttributeNS(SAML2_Constants::NS_SAMLP, 'tmp');
-        $root->setAttributeNS(SAML2_Constants::NS_XSI, 'xsi:tmp', 'tmp');
-        $root->removeAttributeNS(SAML2_Constants::NS_XSI, 'tmp');
-        $root->setAttributeNS(SAML2_Constants::NS_XS, 'xs:tmp', 'tmp');
-        $root->removeAttributeNS(SAML2_Constants::NS_XS, 'tmp');
+        $root->setAttributeNS(Constants::NS_SAMLP, 'samlp:tmp', 'tmp');
+        $root->removeAttributeNS(Constants::NS_SAMLP, 'tmp');
+        $root->setAttributeNS(Constants::NS_XSI, 'xsi:tmp', 'tmp');
+        $root->removeAttributeNS(Constants::NS_XSI, 'tmp');
+        $root->setAttributeNS(Constants::NS_XS, 'xs:tmp', 'tmp');
+        $root->removeAttributeNS(Constants::NS_XS, 'tmp');
 
         $root->setAttribute('ID', $this->id);
         $root->setAttribute('Version', '2.0');
         $root->setAttribute('IssueInstant', gmdate('Y-m-d\TH:i:s\Z', $this->issueInstant));
 
-        $issuer = SAML2_Utils::addString($root, SAML2_Constants::NS_SAML, 'saml:Issuer', $this->issuer);
+        $issuer = Utils::addString($root, Constants::NS_SAML, 'saml:Issuer', $this->issuer);
 
         $this->addSubject($root);
         $this->addConditions($root);
@@ -1265,7 +1271,7 @@ public function toXML(DOMNode $parentElement = NULL)
         }
 
         if ($this->signatureKey !== NULL) {
-            SAML2_Utils::insertSignature($this->signatureKey, $this->certificates, $root, $issuer->nextSibling);
+            Utils::insertSignature($this->signatureKey, $this->certificates, $root, $issuer->nextSibling);
         }
 
         return $root;
@@ -1284,13 +1290,13 @@ private function addSubject(DOMElement $root)
             return;
         }
 
-        $subject = $root->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:Subject');
+        $subject = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:Subject');
         $root->appendChild($subject);
 
         if ($this->encryptedNameId === NULL) {
-            SAML2_Utils::addNameId($subject, $this->nameId);
+            Utils::addNameId($subject, $this->nameId);
         } else {
-            $eid = $subject->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:' . 'EncryptedID');
+            $eid = $subject->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:' . 'EncryptedID');
             $subject->appendChild($eid);
             $eid->appendChild($subject->ownerDocument->importNode($this->encryptedNameId, TRUE));
         }
@@ -1310,7 +1316,7 @@ private function addConditions(DOMElement $root)
     {
         $document = $root->ownerDocument;
 
-        $conditions = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:Conditions');
+        $conditions = $document->createElementNS(Constants::NS_SAML, 'saml:Conditions');
         $root->appendChild($conditions);
 
         if ($this->notBefore !== NULL) {
@@ -1321,10 +1327,10 @@ private function addConditions(DOMElement $root)
         }
 
         if ($this->validAudiences !== NULL) {
-            $ar = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:AudienceRestriction');
+            $ar = $document->createElementNS(Constants::NS_SAML, 'saml:AudienceRestriction');
             $conditions->appendChild($ar);
 
-            SAML2_Utils::addStrings($ar, SAML2_Constants::NS_SAML, 'saml:Audience', FALSE, $this->validAudiences);
+            Utils::addStrings($ar, Constants::NS_SAML, 'saml:Audience', FALSE, $this->validAudiences);
         }
     }
 
@@ -1350,7 +1356,7 @@ private function addAuthnStatement(DOMElement $root)
 
         $document = $root->ownerDocument;
 
-        $authnStatementEl = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:AuthnStatement');
+        $authnStatementEl = $document->createElementNS(Constants::NS_SAML, 'saml:AuthnStatement');
         $root->appendChild($authnStatementEl);
 
         $authnStatementEl->setAttribute('AuthnInstant', gmdate('Y-m-d\TH:i:s\Z', $this->authnInstant));
@@ -1362,13 +1368,13 @@ private function addAuthnStatement(DOMElement $root)
             $authnStatementEl->setAttribute('SessionIndex', $this->sessionIndex);
         }
 
-        $authnContextEl = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:AuthnContext');
+        $authnContextEl = $document->createElementNS(Constants::NS_SAML, 'saml:AuthnContext');
         $authnStatementEl->appendChild($authnContextEl);
 
         if (!empty($this->authnContextClassRef)) {
-            SAML2_Utils::addString(
+            Utils::addString(
                 $authnContextEl,
-                SAML2_Constants::NS_SAML,
+                Constants::NS_SAML,
                 'saml:AuthnContextClassRef',
                 $this->authnContextClassRef
             );
@@ -1377,17 +1383,17 @@ private function addAuthnStatement(DOMElement $root)
             $this->authnContextDecl->toXML($authnContextEl);
         }
         if (!empty($this->authnContextDeclRef)) {
-            SAML2_Utils::addString(
+            Utils::addString(
                 $authnContextEl,
-                SAML2_Constants::NS_SAML,
+                Constants::NS_SAML,
                 'saml:AuthnContextDeclRef',
                 $this->authnContextDeclRef
             );
         }
 
-        SAML2_Utils::addStrings(
+        Utils::addStrings(
             $authnContextEl,
-            SAML2_Constants::NS_SAML,
+            Constants::NS_SAML,
             'saml:AuthenticatingAuthority',
             FALSE,
             $this->AuthenticatingAuthority
@@ -1408,15 +1414,15 @@ private function addAttributeStatement(DOMElement $root)
 
         $document = $root->ownerDocument;
 
-        $attributeStatement = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:AttributeStatement');
+        $attributeStatement = $document->createElementNS(Constants::NS_SAML, 'saml:AttributeStatement');
         $root->appendChild($attributeStatement);
 
         foreach ($this->attributes as $name => $values) {
-            $attribute = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:Attribute');
+            $attribute = $document->createElementNS(Constants::NS_SAML, 'saml:Attribute');
             $attributeStatement->appendChild($attribute);
             $attribute->setAttribute('Name', $name);
 
-            if ($this->nameFormat !== SAML2_Constants::NAMEFORMAT_UNSPECIFIED) {
+            if ($this->nameFormat !== Constants::NAMEFORMAT_UNSPECIFIED) {
                 $attribute->setAttribute('NameFormat', $this->nameFormat);
             }
 
@@ -1429,13 +1435,13 @@ private function addAttributeStatement(DOMElement $root)
                     $type = NULL;
                 }
 
-                $attributeValue = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:AttributeValue');
+                $attributeValue = $document->createElementNS(Constants::NS_SAML, 'saml:AttributeValue');
                 $attribute->appendChild($attributeValue);
                 if ($type !== NULL) {
-                    $attributeValue->setAttributeNS(SAML2_Constants::NS_XSI, 'xsi:type', $type);
+                    $attributeValue->setAttributeNS(Constants::NS_XSI, 'xsi:type', $type);
                 }
                 if (is_null($value)) {
-                    $attributeValue->setAttributeNS(SAML2_Constants::NS_XSI, 'xsi:nil', 'true');
+                    $attributeValue->setAttributeNS(Constants::NS_XSI, 'xsi:nil', 'true');
                 }
 
                 if ($value instanceof DOMNodeList) {
@@ -1464,16 +1470,16 @@ private function addEncryptedAttributeStatement(DOMElement $root)
 
         $document = $root->ownerDocument;
 
-        $attributeStatement = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:AttributeStatement');
+        $attributeStatement = $document->createElementNS(Constants::NS_SAML, 'saml:AttributeStatement');
         $root->appendChild($attributeStatement);
 
         foreach ($this->attributes as $name => $values) {
-            $document2 = SAML2_DOMDocumentFactory::create();
-            $attribute = $document2->createElementNS(SAML2_Constants::NS_SAML, 'saml:Attribute');
+            $document2 = DOMDocumentFactory::create();
+            $attribute = $document2->createElementNS(Constants::NS_SAML, 'saml:Attribute');
             $attribute->setAttribute('Name', $name);
             $document2->appendChild($attribute);
 
-            if ($this->nameFormat !== SAML2_Constants::NAMEFORMAT_UNSPECIFIED) {
+            if ($this->nameFormat !== Constants::NAMEFORMAT_UNSPECIFIED) {
                 $attribute->setAttribute('NameFormat', $this->nameFormat);
             }
 
@@ -1486,10 +1492,10 @@ private function addEncryptedAttributeStatement(DOMElement $root)
                     $type = NULL;
                 }
 
-                $attributeValue = $document2->createElementNS(SAML2_Constants::NS_SAML, 'saml:AttributeValue');
+                $attributeValue = $document2->createElementNS(Constants::NS_SAML, 'saml:AttributeValue');
                 $attribute->appendChild($attributeValue);
                 if ($type !== NULL) {
-                    $attributeValue->setAttributeNS(SAML2_Constants::NS_XSI, 'xsi:type', $type);
+                    $attributeValue->setAttributeNS(Constants::NS_XSI, 'xsi:type', $type);
                 }
 
                 if ($value instanceof DOMNodeList) {
@@ -1514,7 +1520,7 @@ private function addEncryptedAttributeStatement(DOMElement $root)
             $EncAssert->encryptKey($this->encryptionKey, $symmetricKey);
             $EncrNode = $EncAssert->encryptNode($symmetricKey);
 
-            $EncAttribute = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:EncryptedAttribute');
+            $EncAttribute = $document->createElementNS(Constants::NS_SAML, 'saml:EncryptedAttribute');
             $attributeStatement->appendChild($EncAttribute);
             $n = $document->importNode($EncrNode, TRUE);
             $EncAttribute->appendChild($n);
diff --git a/src/SAML2/Assertion/Decrypter.php b/src/SAML2/Assertion/Decrypter.php
index da49a8f11..7835b2223 100644
--- a/src/SAML2/Assertion/Decrypter.php
+++ b/src/SAML2/Assertion/Decrypter.php
@@ -1,19 +1,27 @@
 <?php
 
-class SAML2_Assertion_Decrypter
+namespace SAML2\Assertion;
+
+use SAML2\Configuration\IdentityProvider;
+use SAML2\Configuration\ServiceProvider;
+use SAML2\Certificate\PrivateKeyLoader;
+use SAML2\EncryptedAssertion;
+use SAML2\Assertion\Exception\NotDecryptedException;
+
+class Decrypter
 {
     /**
-     * @var SAML2_Configuration_IdentityProvider
+     * @var \SAML2\Configuration\IdentityProvider
      */
     private $identityProvider;
 
     /**
-     * @var SAML2_Configuration_ServiceProvider
+     * @var \SAML2\Configuration\ServiceProvider
      */
     private $serviceProvider;
 
     /**
-     * @var SAML2_Certificate_PrivateKeyLoader
+     * @var \SAML2\Certificate\PrivateKeyLoader
      */
     private $privateKeyLoader;
 
@@ -24,9 +32,9 @@ class SAML2_Assertion_Decrypter
 
     public function __construct(
         \Psr\Log\LoggerInterface $logger,
-        SAML2_Configuration_IdentityProvider $identityProvider,
-        SAML2_Configuration_ServiceProvider $serviceProvider,
-        SAML2_Certificate_PrivateKeyLoader $privateKeyLoader
+        IdentityProvider $identityProvider,
+        ServiceProvider $serviceProvider,
+        PrivateKeyLoader $privateKeyLoader
     ) {
         $this->logger = $logger;
         $this->identityProvider = $identityProvider;
@@ -44,11 +52,11 @@ public function isEncryptionRequired()
     }
 
     /**
-     * @param SAML2_EncryptedAssertion $assertion
+     * @param \SAML2\EncryptedAssertion $assertion
      *
-     * @return SAML2_Assertion
+     * @return \SAML2\Assertion
      */
-    public function decrypt(SAML2_EncryptedAssertion $assertion)
+    public function decrypt(EncryptedAssertion $assertion)
     {
         $decryptionKeys = $this->privateKeyLoader->loadDecryptionKeys($this->identityProvider, $this->serviceProvider);
         $blacklistedKeys = $this->identityProvider->getBlacklistedAlgorithms();
@@ -75,7 +83,7 @@ public function decrypt(SAML2_EncryptedAssertion $assertion)
             }
         }
 
-        throw new SAML2_Assertion_Exception_NotDecryptedException(sprintf(
+        throw new NotDecryptedException(sprintf(
             'Could not decrypt the assertion, tried with "%d" keys. See the debug log for more information',
             count($decryptionKeys)
         ));
diff --git a/src/SAML2/Assertion/Exception/InvalidAssertionException.php b/src/SAML2/Assertion/Exception/InvalidAssertionException.php
index c5be5fd1a..3a4cea3d4 100644
--- a/src/SAML2/Assertion/Exception/InvalidAssertionException.php
+++ b/src/SAML2/Assertion/Exception/InvalidAssertionException.php
@@ -1,5 +1,9 @@
 <?php
 
-class SAML2_Assertion_Exception_InvalidAssertionException extends SAML2_Exception_RuntimeException
+namespace SAML2\Assertion\Exception;
+
+use SAML2\Exception\RuntimeException;
+
+class InvalidAssertionException extends RuntimeException
 {
 }
diff --git a/src/SAML2/Assertion/Exception/InvalidSubjectConfirmationException.php b/src/SAML2/Assertion/Exception/InvalidSubjectConfirmationException.php
index 587d967d9..a6836840a 100644
--- a/src/SAML2/Assertion/Exception/InvalidSubjectConfirmationException.php
+++ b/src/SAML2/Assertion/Exception/InvalidSubjectConfirmationException.php
@@ -1,5 +1,9 @@
 <?php
 
-class SAML2_Assertion_Exception_InvalidSubjectConfirmationException extends SAML2_Exception_RuntimeException
+namespace SAML2\Assertion\Exception;
+
+use SAML2\Exception\RuntimeException;
+
+class InvalidSubjectConfirmationException extends RuntimeException
 {
 }
diff --git a/src/SAML2/Assertion/Exception/NotDecryptedException.php b/src/SAML2/Assertion/Exception/NotDecryptedException.php
index 2bc1abbe9..a04874f99 100644
--- a/src/SAML2/Assertion/Exception/NotDecryptedException.php
+++ b/src/SAML2/Assertion/Exception/NotDecryptedException.php
@@ -1,5 +1,9 @@
 <?php
 
-class SAML2_Assertion_Exception_NotDecryptedException extends SAML2_Exception_RuntimeException
+namespace SAML2\Assertion\Exception;
+
+use SAML2\Exception\RuntimeException;
+
+class NotDecryptedException extends RuntimeException
 {
 }
diff --git a/src/SAML2/Assertion/Processor.php b/src/SAML2/Assertion/Processor.php
index c75066fd8..738e3cc03 100644
--- a/src/SAML2/Assertion/Processor.php
+++ b/src/SAML2/Assertion/Processor.php
@@ -1,37 +1,51 @@
 <?php
 
+namespace SAML2\Assertion;
+
+use SAML2\Signature\Validator;
+use SAML2\Assertion\Validation\AssertionValidator;
+use SAML2\Assertion\Validation\SubjectConfirmationValidator;
+use SAML2\Assertion\Transformer\Transformer;
+use SAML2\Configuration\IdentityProvider;
+use SAML2\Utilities\ArrayCollection;
+use SAML2\Response\Exception\InvalidSignatureException;
+use SAML2\Assertion;
+use SAML2\Response\Exception\UnencryptedAssertionFoundException;
+use SAML2\Assertion\Exception\InvalidAssertionException;
+use SAML2\Assertion\Exception\InvalidSubjectConfirmationException;
+
 /**
  * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - due to all the named exceptions
  */
-class SAML2_Assertion_Processor
+class Processor
 {
     /**
-     * @var SAML2_Assertion_Decrypter
+     * @var \SAML2\Assertion\Decrypter
      */
     private $decrypter;
 
     /**
-     * @var SAML2_Assertion_Validation_AssertionValidator
+     * @var \SAML2\Assertion\Validation\AssertionValidator
      */
     private $assertionValidator;
 
     /**
-     * @var SAML2_Assertion_Validation_SubjectConfirmationValidator
+     * @var \SAML2\Assertion\Validation\SubjectConfirmationValidator
      */
     private $subjectConfirmationValidator;
 
     /**
-     * @var SAML2_Assertion_Transformer_Transformer
+     * @var \SAML2\Assertion\Transformer\Transformer
      */
     private $transformer;
 
     /**
-     * @var SAML2_Signature_Validator
+     * @var \SAML2\Signature\Validator
      */
     private $signatureValidator;
 
     /**
-     * @var SAML2_Configuration_IdentityProvider
+     * @var \SAML2\Configuration\IdentityProvider
      */
     private $identityProviderConfiguration;
 
@@ -41,12 +55,12 @@ class SAML2_Assertion_Processor
     private $logger;
 
     public function __construct(
-        SAML2_Assertion_Decrypter $decrypter,
-        SAML2_Signature_Validator $signatureValidator,
-        SAML2_Assertion_Validation_AssertionValidator $assertionValidator,
-        SAML2_Assertion_Validation_SubjectConfirmationValidator $subjectConfirmationValidator,
-        SAML2_Assertion_Transformer_Transformer $transformer,
-        SAML2_Configuration_IdentityProvider $identityProviderConfiguration,
+        Decrypter $decrypter,
+        Validator $signatureValidator,
+        AssertionValidator $assertionValidator,
+        SubjectConfirmationValidator $subjectConfirmationValidator,
+        Transformer $transformer,
+        IdentityProvider $identityProviderConfiguration,
         \Psr\Log\LoggerInterface $logger
     ) {
         $this->assertionValidator            = $assertionValidator;
@@ -59,13 +73,13 @@ public function __construct(
     }
 
     /**
-     * @param SAML2_Utilities_ArrayCollection $assertions
+     * @param \SAML2\Utilities\ArrayCollection $assertions
      *
-     * @return SAML2_Assertion[] Collection (SAML2_Utilities_ArrayCollection) of processed assertions
+     * @return \SAML2\Assertion[] Collection (\SAML2\Utilities\ArrayCollection) of processed assertions
      */
     public function processAssertions($assertions)
     {
-        $processed = new SAML2_Utilities_ArrayCollection();
+        $processed = new ArrayCollection();
         foreach ($assertions as $assertion) {
             $processed->add($this->process($assertion));
         }
@@ -74,9 +88,9 @@ public function processAssertions($assertions)
     }
 
     /**
-     * @param SAML2_Assertion|SAML2_EncryptedAssertion $assertion
+     * @param \SAML2\Assertion|\SAML2\EncryptedAssertion $assertion
      *
-     * @return SAML2_Assertion
+     * @return \SAML2\Assertion
      */
     public function process($assertion)
     {
@@ -91,7 +105,7 @@ public function process($assertion)
             $this->logger->info(sprintf('Verifying signature of Assertion with id "%s"', $assertion->getId()));
 
             if (!$this->signatureValidator->hasValidSignature($assertion, $this->identityProviderConfiguration)) {
-                throw new SAML2_Response_Exception_InvalidSignatureException();
+                throw new InvalidSignatureException();
             }
         }
 
@@ -103,17 +117,17 @@ public function process($assertion)
     }
 
     /**
-     * @param SAML2_Assertion|SAML2_EncryptedAssertion $assertion
+     * @param \SAML2\Assertion|\SAML2\EncryptedAssertion $assertion
      *
-     * @return SAML2_Assertion
+     * @return \SAML2\Assertion
      */
     private function decryptAssertion($assertion)
     {
-        if ($this->decrypter->isEncryptionRequired() && $assertion instanceof SAML2_Assertion) {
-            throw new SAML2_Response_Exception_UnencryptedAssertionFoundException();
+        if ($this->decrypter->isEncryptionRequired() && $assertion instanceof Assertion) {
+            throw new UnencryptedAssertionFoundException();
         }
 
-        if ($assertion instanceof SAML2_Assertion) {
+        if ($assertion instanceof Assertion) {
             return $assertion;
         }
 
@@ -121,13 +135,13 @@ private function decryptAssertion($assertion)
     }
 
     /**
-     * @param SAML2_Assertion $assertion
+     * @param \SAML2\Assertion $assertion
      */
-    public function validateAssertion(SAML2_Assertion $assertion)
+    public function validateAssertion(Assertion $assertion)
     {
         $assertionValidationResult = $this->assertionValidator->validate($assertion);
         if (!$assertionValidationResult->isValid()) {
-            throw new SAML2_Assertion_Exception_InvalidAssertionException(sprintf(
+            throw new InvalidAssertionException(sprintf(
                 'Invalid Assertion in SAML Response, erorrs: "%s"',
                 implode('", "', $assertionValidationResult->getErrors())
             ));
@@ -138,7 +152,7 @@ public function validateAssertion(SAML2_Assertion $assertion)
                 $subjectConfirmation
             );
             if (!$subjectConfirmationValidationResult->isValid()) {
-                throw new SAML2_Assertion_Exception_InvalidSubjectConfirmationException(sprintf(
+                throw new InvalidSubjectConfirmationException(sprintf(
                     'Invalid SubjectConfirmation in Assertion, errors: "%s"',
                     implode('", "', $subjectConfirmationValidationResult->getErrors())
                 ));
@@ -147,11 +161,11 @@ public function validateAssertion(SAML2_Assertion $assertion)
     }
 
     /**
-     * @param SAML2_Assertion $assertion
+     * @param \SAML2\Assertion $assertion
      *
-     * @return SAML2_Assertion
+     * @return \SAML2\Assertion
      */
-    private function transformAssertion(SAML2_Assertion $assertion)
+    private function transformAssertion(Assertion $assertion)
     {
         return $this->transformer->transform($assertion);
     }
diff --git a/src/SAML2/Assertion/ProcessorBuilder.php b/src/SAML2/Assertion/ProcessorBuilder.php
index baf6729f2..129392d4f 100644
--- a/src/SAML2/Assertion/ProcessorBuilder.php
+++ b/src/SAML2/Assertion/ProcessorBuilder.php
@@ -1,5 +1,28 @@
 <?php
 
+namespace SAML2\Assertion;
+
+use SAML2\Signature\Validator;
+use SAML2\Configuration\Destination;
+use SAML2\Configuration\IdentityProvider;
+use SAML2\Configuration\ServiceProvider;
+use SAML2\Response;
+use SAML2\Certificate\PrivateKeyLoader;
+use SAML2\Assertion\Validation\AssertionValidator;
+use SAML2\Assertion\Validation\ConstraintValidator\NotBefore;
+use SAML2\Assertion\Validation\ConstraintValidator\NotOnOrAfter;
+use SAML2\Assertion\Validation\ConstraintValidator\SessionNotOnOrAfter;
+use SAML2\Assertion\Validation\ConstraintValidator\SpIsValidAudience;
+use SAML2\Assertion\Validation\SubjectConfirmationValidator;
+use SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationMethod;
+use SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationNotBefore;
+use SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationNotOnOrAfter;
+use SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationRecipientMatches;
+use SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationResponseToMatches;
+use SAML2\Assertion\Transformer\TransformerChain;
+use SAML2\Assertion\Transformer\DecodeBase64Transformer;
+use SAML2\Assertion\Transformer\NameIdDecryptionTransformer;
+
 /**
  * Simple Builder that allows to build a new Assertion Processor.
  *
@@ -7,18 +30,18 @@
  *
  * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
-class SAML2_Assertion_ProcessorBuilder
+class ProcessorBuilder
 {
     public static function build(
         Psr\Log\LoggerInterface $logger,
-        SAML2_Signature_Validator $signatureValidator,
-        SAML2_Configuration_Destination $currentDestination,
-        SAML2_Configuration_IdentityProvider $identityProvider,
-        SAML2_Configuration_ServiceProvider $serviceProvider,
-        SAML2_Response $response
+        Validator $signatureValidator,
+        Destination $currentDestination,
+        IdentityProvider $identityProvider,
+        ServiceProvider $serviceProvider,
+        Response $response
     ) {
-        $keyloader = new SAML2_Certificate_PrivateKeyLoader();
-        $decrypter = new SAML2_Assertion_Decrypter($logger, $identityProvider, $serviceProvider, $keyloader);
+        $keyloader = new PrivateKeyLoader();
+        $decrypter = new Decrypter($logger, $identityProvider, $serviceProvider, $keyloader);
         $assertionValidator = self::createAssertionValidator($identityProvider, $serviceProvider);
         $subjectConfirmationValidator = self::createSubjectConfirmationValidator(
             $identityProvider,
@@ -34,7 +57,7 @@ public static function build(
             $serviceProvider
         );
 
-        return new SAML2_Assertion_Processor(
+        return new Processor(
             $decrypter,
             $signatureValidator,
             $assertionValidator,
@@ -46,41 +69,41 @@ public static function build(
     }
 
     private static function createAssertionValidator(
-        SAML2_Configuration_IdentityProvider $identityProvider,
-        SAML2_Configuration_ServiceProvider $serviceProvider
+        IdentityProvider $identityProvider,
+        ServiceProvider $serviceProvider
     ) {
-        $validator = new SAML2_Assertion_Validation_AssertionValidator($identityProvider, $serviceProvider);
-        $validator->addConstraintValidator(new SAML2_Assertion_Validation_ConstraintValidator_NotBefore());
-        $validator->addConstraintValidator(new SAML2_Assertion_Validation_ConstraintValidator_NotOnOrAfter());
-        $validator->addConstraintValidator(new SAML2_Assertion_Validation_ConstraintValidator_SessionNotOnOrAfter());
-        $validator->addConstraintValidator(new SAML2_Assertion_Validation_ConstraintValidator_SpIsValidAudience());
+        $validator = new AssertionValidator($identityProvider, $serviceProvider);
+        $validator->addConstraintValidator(new NotBefore());
+        $validator->addConstraintValidator(new NotOnOrAfter());
+        $validator->addConstraintValidator(new SessionNotOnOrAfter());
+        $validator->addConstraintValidator(new SpIsValidAudience());
 
         return $validator;
     }
 
     private static function createSubjectConfirmationValidator(
-        SAML2_Configuration_IdentityProvider $identityProvider,
-        SAML2_Configuration_ServiceProvider $serviceProvider,
-        SAML2_Configuration_Destination $currentDestination,
-        SAML2_Response $response
+        IdentityProvider $identityProvider,
+        ServiceProvider $serviceProvider,
+        Destination $currentDestination,
+        Response $response
     ) {
-        $validator = new SAML2_Assertion_Validation_SubjectConfirmationValidator($identityProvider, $serviceProvider);
+        $validator = new SubjectConfirmationValidator($identityProvider, $serviceProvider);
         $validator->addConstraintValidator(
-            new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationMethod()
+            new SubjectConfirmationMethod()
         );
         $validator->addConstraintValidator(
-            new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationNotBefore()
+            new SubjectConfirmationNotBefore()
         );
         $validator->addConstraintValidator(
-            new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationNotOnOrAfter()
+            new SubjectConfirmationNotOnOrAfter()
         );
         $validator->addConstraintValidator(
-            new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationRecipientMatches(
+            new SubjectConfirmationRecipientMatches(
                 $currentDestination
             )
         );
         $validator->addConstraintValidator(
-            new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationResponseToMatches(
+            new SubjectConfirmationResponseToMatches(
                 $response
             )
         );
@@ -90,14 +113,14 @@ private static function createSubjectConfirmationValidator(
 
     private static function createAssertionTransformerChain(
         \Psr\Log\LoggerInterface $logger,
-        SAML2_Certificate_PrivateKeyLoader $keyloader,
-        SAML2_Configuration_IdentityProvider $identityProvider,
-        SAML2_Configuration_ServiceProvider $serviceProvider
+        PrivateKeyLoader $keyloader,
+        IdentityProvider $identityProvider,
+        ServiceProvider $serviceProvider
     ) {
-        $chain = new SAML2_Assertion_Transformer_TransformerChain($identityProvider, $serviceProvider);
-        $chain->addTransformerStep(new SAML2_Assertion_Transformer_DecodeBase64Transformer());
+        $chain = new TransformerChain($identityProvider, $serviceProvider);
+        $chain->addTransformerStep(new DecodeBase64Transformer());
         $chain->addTransformerStep(
-            new SAML2_Assertion_Transformer_NameIdDecryptionTransformer($logger, $keyloader)
+            new NameIdDecryptionTransformer($logger, $keyloader)
         );
 
         return $chain;
diff --git a/src/SAML2/Assertion/Transformer/DecodeBase64Transformer.php b/src/SAML2/Assertion/Transformer/DecodeBase64Transformer.php
index acacfca81..5da384c1e 100644
--- a/src/SAML2/Assertion/Transformer/DecodeBase64Transformer.php
+++ b/src/SAML2/Assertion/Transformer/DecodeBase64Transformer.php
@@ -1,20 +1,26 @@
 <?php
 
-class SAML2_Assertion_Transformer_DecodeBase64Transformer implements
-    SAML2_Assertion_Transformer_Transformer,
-    SAML2_Configuration_IdentityProviderAware
+namespace SAML2\Assertion\Transformer;
+
+use SAML2\Configuration\IdentityProviderAware;
+use SAML2\Configuration\IdentityProvider;
+use SAML2\Assertion;
+
+class DecodeBase64Transformer implements
+    Transformer,
+    IdentityProviderAware
 {
     /**
-     * @var SAML2_Configuration_IdentityProvider
+     * @var \SAML2\Configuration\IdentityProvider
      */
     private $identityProvider;
 
-    public function setIdentityProvider(SAML2_Configuration_IdentityProvider $identityProvider)
+    public function setIdentityProvider(IdentityProvider $identityProvider)
     {
         $this->identityProvider = $identityProvider;
     }
 
-    public function transform(SAML2_Assertion $assertion)
+    public function transform(Assertion $assertion)
     {
         if (!$this->identityProvider->hasBase64EncodedAttributes()) {
             return $assertion;
diff --git a/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php b/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
index 5836ac6c8..56c9c4118 100644
--- a/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
+++ b/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
@@ -1,22 +1,32 @@
 <?php
 
-class SAML2_Assertion_Transformer_NameIdDecryptionTransformer implements
-    SAML2_Assertion_Transformer_Transformer,
-    SAML2_Configuration_IdentityProviderAware,
-    SAML2_Configuration_ServiceProviderAware
+namespace SAML2\Assertion\Transformer;
+
+use SAML2\Configuration\IdentityProviderAware;
+use SAML2\Configuration\ServiceProviderAware;
+use SAML2\Certificate\PrivateKeyLoader;
+use SAML2\Assertion;
+use SAML2\Assertion\Exception\NotDecryptedException;
+use SAML2\Configuration\IdentityProvider;
+use SAML2\Configuration\ServiceProvider;
+
+class NameIdDecryptionTransformer implements
+    Transformer,
+    IdentityProviderAware,
+    ServiceProviderAware
 {
     /**
-     * @var SAML2_Certificate_PrivateKeyLoader
+     * @var \SAML2\Certificate\PrivateKeyLoader
      */
     private $privateKeyLoader;
 
     /**
-     * @var SAML2_Configuration_IdentityProvider
+     * @var \SAML2\Configuration\IdentityProvider
      */
     private $identityProvider;
 
     /**
-     * @var SAML2_Configuration_ServiceProvider
+     * @var \SAML2\Configuration\ServiceProvider
      */
     private $serviceProvider;
 
@@ -27,12 +37,12 @@ class SAML2_Assertion_Transformer_NameIdDecryptionTransformer implements
 
     public function __construct(
         \Psr\Log\LoggerInterface $logger,
-        SAML2_Certificate_PrivateKeyLoader $privateKeyLoader
+        PrivateKeyLoader $privateKeyLoader
     ) {
         $this->privateKeyLoader = $privateKeyLoader;
     }
 
-    public function transform(SAML2_Assertion $assertion)
+    public function transform(Assertion $assertion)
     {
         if (!$assertion->isNameIdEncrypted()) {
             return $assertion;
@@ -59,7 +69,7 @@ public function transform(SAML2_Assertion $assertion)
         }
 
         if ($assertion->isNameIdEncrypted()) {
-            throw new SAML2_Assertion_Exception_NotDecryptedException(
+            throw new NotDecryptedException(
                 'Could not decrypt the assertion NameId with the configured keys, see the debug log for information'
             );
         }
@@ -67,12 +77,12 @@ public function transform(SAML2_Assertion $assertion)
         return $assertion;
     }
 
-    public function setIdentityProvider(SAML2_Configuration_IdentityProvider $identityProvider)
+    public function setIdentityProvider(IdentityProvider $identityProvider)
     {
         $this->identityProvider = $identityProvider;
     }
 
-    public function setServiceProvider(SAML2_Configuration_ServiceProvider $serviceProvider)
+    public function setServiceProvider(ServiceProvider $serviceProvider)
     {
         $this->serviceProvider = $serviceProvider;
     }
diff --git a/src/SAML2/Assertion/Transformer/Transformer.php b/src/SAML2/Assertion/Transformer/Transformer.php
index 92ea2d84d..ad3afab94 100644
--- a/src/SAML2/Assertion/Transformer/Transformer.php
+++ b/src/SAML2/Assertion/Transformer/Transformer.php
@@ -1,11 +1,15 @@
 <?php
 
-interface SAML2_Assertion_Transformer_Transformer
+namespace SAML2\Assertion\Transformer;
+
+use SAML2\Assertion;
+
+interface Transformer
 {
     /**
-     * @param SAML2_Assertion $assertion
+     * @param \SAML2\Assertion $assertion
      *
-     * @return SAML2_Assertion
+     * @return \SAML2\Assertion
      */
-    public function transform(SAML2_Assertion $assertion);
+    public function transform(Assertion $assertion);
 }
diff --git a/src/SAML2/Assertion/Transformer/TransformerChain.php b/src/SAML2/Assertion/Transformer/TransformerChain.php
index 196125e84..d33d16e5d 100644
--- a/src/SAML2/Assertion/Transformer/TransformerChain.php
+++ b/src/SAML2/Assertion/Transformer/TransformerChain.php
@@ -1,37 +1,45 @@
 <?php
 
-class SAML2_Assertion_Transformer_TransformerChain implements SAML2_Assertion_Transformer_Transformer
+namespace SAML2\Assertion\Transformer;
+
+use SAML2\Configuration\IdentityProvider;
+use SAML2\Configuration\ServiceProvider;
+use SAML2\Configuration\IdentityProviderAware;
+use SAML2\Configuration\ServiceProviderAware;
+use SAML2\Assertion;
+
+class TransformerChain implements Transformer
 {
     /**
-     * @var SAML2_Assertion_Transformer_Transformer[]
+     * @var \SAML2\Assertion\Transformer\Transformer[]
      */
     private $transformers = array();
 
     /**
-     * @var SAML2_Configuration_IdentityProvider
+     * @var \SAML2\Configuration\IdentityProvider
      */
     private $identityProvider;
 
     /**
-     * @var SAML2_Configuration_ServiceProvider
+     * @var \SAML2\Configuration\ServiceProvider
      */
     private $serviceProvider;
 
     public function __construct(
-        SAML2_Configuration_IdentityProvider $identityProvider,
-        SAML2_Configuration_ServiceProvider $serviceProvider
+        IdentityProvider $identityProvider,
+        ServiceProvider $serviceProvider
     ) {
         $this->identityProvider = $identityProvider;
         $this->serviceProvider  = $serviceProvider;
     }
 
-    public function addTransformerStep(SAML2_Assertion_Transformer_Transformer $transformer)
+    public function addTransformerStep(Transformer $transformer)
     {
-        if ($transformer instanceof SAML2_Configuration_IdentityProviderAware) {
+        if ($transformer instanceof IdentityProviderAware) {
             $transformer->setIdentityProvider($this->identityProvider);
         }
 
-        if ($transformer instanceof SAML2_Configuration_ServiceProviderAware) {
+        if ($transformer instanceof ServiceProviderAware) {
             $transformer->setServiceProvider($this->serviceProvider);
         }
 
@@ -39,11 +47,11 @@ public function addTransformerStep(SAML2_Assertion_Transformer_Transformer $tran
     }
 
     /**
-     * @param SAML2_Assertion $assertion
+     * @param \SAML2\Assertion $assertion
      *
-     * @return SAML2_Assertion
+     * @return \SAML2\Assertion
      */
-    public function transform(SAML2_Assertion $assertion)
+    public function transform(Assertion $assertion)
     {
         foreach ($this->transformers as $transformer) {
             $assertion = $transformer->transform($assertion);
diff --git a/src/SAML2/Assertion/Validation/AssertionConstraintValidator.php b/src/SAML2/Assertion/Validation/AssertionConstraintValidator.php
index 8a358a4ba..1efc08a79 100644
--- a/src/SAML2/Assertion/Validation/AssertionConstraintValidator.php
+++ b/src/SAML2/Assertion/Validation/AssertionConstraintValidator.php
@@ -1,6 +1,10 @@
 <?php
 
-interface SAML2_Assertion_Validation_AssertionConstraintValidator
+namespace SAML2\Assertion\Validation;
+
+use SAML2\Assertion;
+
+interface AssertionConstraintValidator
 {
-    public function validate(SAML2_Assertion $assertion, SAML2_Assertion_Validation_Result $result);
+    public function validate(Assertion $assertion, Result $result);
 }
diff --git a/src/SAML2/Assertion/Validation/AssertionValidator.php b/src/SAML2/Assertion/Validation/AssertionValidator.php
index 6a66a7806..f005ea76d 100644
--- a/src/SAML2/Assertion/Validation/AssertionValidator.php
+++ b/src/SAML2/Assertion/Validation/AssertionValidator.php
@@ -1,50 +1,58 @@
 <?php
 
-class SAML2_Assertion_Validation_AssertionValidator
+namespace SAML2\Assertion\Validation;
+
+use SAML2\Configuration\IdentityProvider;
+use SAML2\Configuration\ServiceProvider;
+use SAML2\Configuration\IdentityProviderAware;
+use SAML2\Configuration\ServiceProviderAware;
+use SAML2\Assertion;
+
+class AssertionValidator
 {
     /**
-     * @var SAML2_Assertion_Validation_AssertionConstraintValidator[]
+     * @var \SAML2\Assertion\Validation\AssertionConstraintValidator[]
      */
     protected $constraints;
 
     /**
-     * @var SAML2_Configuration_IdentityProvider
+     * @var \SAML2\Configuration\IdentityProvider
      */
     private $identityProvider;
 
     /**
-     * @var SAML2_Configuration_ServiceProvider
+     * @var \SAML2\Configuration\ServiceProvider
      */
     private $serviceProvider;
 
     /**
-     * @param SAML2_Configuration_IdentityProvider $identityProvider
-     * @param SAML2_Configuration_ServiceProvider  $serviceProvider
+     * @param \SAML2\Configuration\IdentityProvider $identityProvider
+     * @param \SAML2\Configuration\ServiceProvider  $serviceProvider
      */
     public function __construct(
-        SAML2_Configuration_IdentityProvider $identityProvider,
-        SAML2_Configuration_ServiceProvider $serviceProvider
+        IdentityProvider $identityProvider,
+        ServiceProvider $serviceProvider
     ) {
         $this->identityProvider = $identityProvider;
         $this->serviceProvider = $serviceProvider;
     }
 
-    public function addConstraintValidator(SAML2_Assertion_Validation_AssertionConstraintValidator $constraint)
+    public function addConstraintValidator(AssertionConstraintValidator $constraint)
     {
-        if ($constraint instanceof SAML2_Configuration_IdentityProviderAware) {
+        if ($constraint instanceof IdentityProviderAware) {
             $constraint->setIdentityProvider($this->identityProvider);
         }
 
-        if ($constraint instanceof SAML2_Configuration_ServiceProviderAware) {
+        if ($constraint instanceof ServiceProviderAware) {
             $constraint->setServiceProvider($this->serviceProvider);
         }
 
         $this->constraints[] = $constraint;
     }
 
-    public function validate(SAML2_Assertion $assertion)
+    public function validate(Assertion $assertion)
     {
-        $result = new SAML2_Assertion_Validation_Result();
+        $result = new Result();
         foreach ($this->constraints as $validator) {
             $validator->validate($assertion, $result);
         }
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/NotBefore.php b/src/SAML2/Assertion/Validation/ConstraintValidator/NotBefore.php
index a15eb70a1..071cffe55 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/NotBefore.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/NotBefore.php
@@ -1,12 +1,19 @@
 <?php
 
-class SAML2_Assertion_Validation_ConstraintValidator_NotBefore implements
-    SAML2_Assertion_Validation_AssertionConstraintValidator
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\Assertion\Validation\AssertionConstraintValidator;
+use SAML2\Assertion;
+use SAML2\Assertion\Validation\Result;
+use SAML2\Utilities\Temporal;
+
+class NotBefore implements
+    AssertionConstraintValidator
 {
-    public function validate(SAML2_Assertion $assertion, SAML2_Assertion_Validation_Result $result)
+    public function validate(Assertion $assertion, Result $result)
     {
         $notBeforeTimestamp = $assertion->getNotBefore();
-        if ($notBeforeTimestamp && $notBeforeTimestamp > SAML2_Utilities_Temporal::getTime() + 60) {
+        if ($notBeforeTimestamp && $notBeforeTimestamp > Temporal::getTime() + 60) {
             $result->addError(
                 'Received an assertion that is valid in the future. Check clock synchronization on IdP and SP.'
             );
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfter.php b/src/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfter.php
index 6e6f9473e..3b214eb5c 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfter.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfter.php
@@ -1,12 +1,19 @@
 <?php
 
-class SAML2_Assertion_Validation_ConstraintValidator_NotOnOrAfter implements
-    SAML2_Assertion_Validation_AssertionConstraintValidator
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\Assertion\Validation\AssertionConstraintValidator;
+use SAML2\Assertion;
+use SAML2\Assertion\Validation\Result;
+use SAML2\Utilities\Temporal;
+
+class NotOnOrAfter implements
+    AssertionConstraintValidator
 {
-    public function validate(SAML2_Assertion $assertion, SAML2_Assertion_Validation_Result $result)
+    public function validate(Assertion $assertion, Result $result)
     {
         $notValidOnOrAfterTimestamp = $assertion->getNotOnOrAfter();
-        if ($notValidOnOrAfterTimestamp && $notValidOnOrAfterTimestamp <= SAML2_Utilities_Temporal::getTime() - 60) {
+        if ($notValidOnOrAfterTimestamp && $notValidOnOrAfterTimestamp <= Temporal::getTime() - 60) {
             $result->addError(
                 'Received an assertion that has expired. Check clock synchronization on IdP and SP.'
             );
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfter.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfter.php
index 7d80bf841..157324345 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfter.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfter.php
@@ -1,12 +1,19 @@
 <?php
 
-class SAML2_Assertion_Validation_ConstraintValidator_SessionNotOnOrAfter implements
-    SAML2_Assertion_Validation_AssertionConstraintValidator
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\Assertion\Validation\AssertionConstraintValidator;
+use SAML2\Assertion;
+use SAML2\Assertion\Validation\Result;
+use SAML2\Utilities\Temporal;
+
+class SessionNotOnOrAfter implements
+    AssertionConstraintValidator
 {
-    public function validate(SAML2_Assertion $assertion, SAML2_Assertion_Validation_Result $result)
+    public function validate(Assertion $assertion, Result $result)
     {
         $sessionNotOnOrAfterTimestamp = $assertion->getSessionNotOnOrAfter();
-        $currentTime = SAML2_Utilities_Temporal::getTime();
+        $currentTime = Temporal::getTime();
         if ($sessionNotOnOrAfterTimestamp && $sessionNotOnOrAfterTimestamp <= $currentTime - 60) {
             $result->addError(
                 'Received an assertion with a session that has expired. Check clock synchronization on IdP and SP.'
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php
index ccf8ba483..ece7d8733 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php
@@ -1,20 +1,28 @@
 <?php
 
-class SAML2_Assertion_Validation_ConstraintValidator_SpIsValidAudience implements
-    SAML2_Assertion_Validation_AssertionConstraintValidator,
-    SAML2_Configuration_ServiceProviderAware
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\Assertion\Validation\AssertionConstraintValidator;
+use SAML2\Configuration\ServiceProviderAware;
+use SAML2\Configuration\ServiceProvider;
+use SAML2\Assertion;
+use SAML2\Assertion\Validation\Result;
+
+class SpIsValidAudience implements
+    AssertionConstraintValidator,
+    ServiceProviderAware
 {
     /**
-     * @var SAML2_Configuration_ServiceProvider
+     * @var \SAML2\Configuration\ServiceProvider
      */
     private $serviceProvider;
 
-    public function setServiceProvider(SAML2_Configuration_ServiceProvider $serviceProvider)
+    public function setServiceProvider(ServiceProvider $serviceProvider)
     {
         $this->serviceProvider = $serviceProvider;
     }
 
-    public function validate(SAML2_Assertion $assertion, SAML2_Assertion_Validation_Result $result)
+    public function validate(Assertion $assertion, Result $result)
     {
         $intendedAudiences = $assertion->getValidAudiences();
         if ($intendedAudiences === NULL) {
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethod.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethod.php
index fa1f1ce79..2d1ce9d1f 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethod.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethod.php
@@ -1,16 +1,23 @@
 <?php
 
-class SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationMethod implements
-    SAML2_Assertion_Validation_SubjectConfirmationConstraintValidator
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
+use SAML2\XML\saml\SubjectConfirmation;
+use SAML2\Assertion\Validation\Result;
+use SAML2\Constants;
+
+class SubjectConfirmationMethod implements
+    SubjectConfirmationConstraintValidator
 {
     public function validate(
-        SAML2_XML_saml_SubjectConfirmation $subjectConfirmation,
-        SAML2_Assertion_Validation_Result $result
+        SubjectConfirmation $subjectConfirmation,
+        Result $result
     ) {
-        if ($subjectConfirmation->Method !== SAML2_Constants::CM_BEARER) {
+        if ($subjectConfirmation->Method !== Constants::CM_BEARER) {
             $result->addError(sprintf(
                 'Invalid Method on SubjectConfirmation, current;y only Bearer (%s) is supported',
-                SAML2_Constants::CM_BEARER
+                Constants::CM_BEARER
             ));
         }
     }
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBefore.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBefore.php
index 6f57ce790..199707eb7 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBefore.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBefore.php
@@ -1,14 +1,21 @@
 <?php
 
-class SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationNotBefore implements
-    SAML2_Assertion_Validation_SubjectConfirmationConstraintValidator
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
+use SAML2\XML\saml\SubjectConfirmation;
+use SAML2\Assertion\Validation\Result;
+use SAML2\Utilities\Temporal;
+
+class SubjectConfirmationNotBefore implements
+    SubjectConfirmationConstraintValidator
 {
     public function validate(
-        SAML2_XML_saml_SubjectConfirmation $subjectConfirmation,
-        SAML2_Assertion_Validation_Result $result
+        SubjectConfirmation $subjectConfirmation,
+        Result $result
     ) {
         $notBefore = $subjectConfirmation->SubjectConfirmationData->NotBefore;
-        if ($notBefore && $notBefore > SAML2_Utilities_Temporal::getTime() + 60) {
+        if ($notBefore && $notBefore > Temporal::getTime() + 60) {
             $result->addError('NotBefore in SubjectConfirmationData is in the future');
         }
     }
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfter.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfter.php
index af3592bd4..d947b9764 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfter.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfter.php
@@ -1,14 +1,21 @@
 <?php
 
-class SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationNotOnOrAfter implements
-    SAML2_Assertion_Validation_SubjectConfirmationConstraintValidator
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
+use SAML2\XML\saml\SubjectConfirmation;
+use SAML2\Assertion\Validation\Result;
+use SAML2\Utilities\Temporal;
+
+class SubjectConfirmationNotOnOrAfter implements
+    SubjectConfirmationConstraintValidator
 {
     public function validate(
-        SAML2_XML_saml_SubjectConfirmation $subjectConfirmation,
-        SAML2_Assertion_Validation_Result $result
+        SubjectConfirmation $subjectConfirmation,
+        Result $result
     ) {
         $notOnOrAfter = $subjectConfirmation->SubjectConfirmationData->NotOnOrAfter;
-        if ($notOnOrAfter && $notOnOrAfter <= SAML2_Utilities_Temporal::getTime() - 60) {
+        if ($notOnOrAfter && $notOnOrAfter <= Temporal::getTime() - 60) {
             $result->addError('NotOnOrAfter in SubjectConfirmationData is in the past');
         }
     }
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMatches.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMatches.php
index 87cf089c6..3f29aed43 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMatches.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMatches.php
@@ -1,24 +1,31 @@
 <?php
 
-class SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationRecipientMatches implements
-    SAML2_Assertion_Validation_SubjectConfirmationConstraintValidator
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
+use SAML2\Configuration\Destination;
+use SAML2\XML\saml\SubjectConfirmation;
+use SAML2\Assertion\Validation\Result;
+
+class SubjectConfirmationRecipientMatches implements
+    SubjectConfirmationConstraintValidator
 {
     /**
-     * @var SAML2_Configuration_Destination
+     * @var \SAML2\Configuration\Destination
      */
     private $destination;
 
-    public function __construct(SAML2_Configuration_Destination $destination)
+    public function __construct(Destination $destination)
     {
         $this->destination = $destination;
     }
 
     public function validate(
-        SAML2_XML_saml_SubjectConfirmation $subjectConfirmation,
-        SAML2_Assertion_Validation_Result $result
+        SubjectConfirmation $subjectConfirmation,
+        Result $result
     ) {
         $recipient = $subjectConfirmation->SubjectConfirmationData->Recipient;
-        if ($recipient && !$this->destination->equals(new SAML2_Configuration_Destination($recipient))) {
+        if ($recipient && !$this->destination->equals(new Destination($recipient))) {
             $result->addError(sprintf(
                 'Recipient in SubjectConfirmationData ("%s") does not match the current destination ("%s")',
                 $recipient,
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatches.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatches.php
index e17b4199a..dec78f2df 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatches.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatches.php
@@ -1,18 +1,25 @@
 <?php
 
-class SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationResponseToMatches implements
-    SAML2_Assertion_Validation_SubjectConfirmationConstraintValidator
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
+use SAML2\Response;
+use SAML2\XML\saml\SubjectConfirmation;
+use SAML2\Assertion\Validation\Result;
+
+class SubjectConfirmationResponseToMatches implements
+    SubjectConfirmationConstraintValidator
 {
     private $response;
 
-    public function __construct(SAML2_Response $response)
+    public function __construct(Response $response)
     {
         $this->response = $response;
     }
 
     public function validate(
-        SAML2_XML_saml_SubjectConfirmation $subjectConfirmation,
-        SAML2_Assertion_Validation_Result $result
+        SubjectConfirmation $subjectConfirmation,
+        Result $result
     ) {
         $inResponseTo = $subjectConfirmation->SubjectConfirmationData->InResponseTo;
         if ($inResponseTo && $this->getInResponseTo() && $this->getInResponseTo() !== $inResponseTo) {
diff --git a/src/SAML2/Assertion/Validation/Result.php b/src/SAML2/Assertion/Validation/Result.php
index c679d41ed..bc4116bb3 100644
--- a/src/SAML2/Assertion/Validation/Result.php
+++ b/src/SAML2/Assertion/Validation/Result.php
@@ -1,9 +1,13 @@
 <?php
 
+namespace SAML2\Assertion\Validation;
+
+use SAML2\Exception\InvalidArgumentException;
+
 /**
  * Simple Result object
  */
-class SAML2_Assertion_Validation_Result
+class Result
 {
     /**
      * @var array
@@ -16,7 +20,7 @@ class SAML2_Assertion_Validation_Result
     public function addError($message)
     {
         if (!is_string($message)) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType('string', $message);
+            throw InvalidArgumentException::invalidType('string', $message);
         }
 
         $this->errors[] = $message;
diff --git a/src/SAML2/Assertion/Validation/SubjectConfirmationConstraintValidator.php b/src/SAML2/Assertion/Validation/SubjectConfirmationConstraintValidator.php
index f8f27dc44..18b624cf2 100644
--- a/src/SAML2/Assertion/Validation/SubjectConfirmationConstraintValidator.php
+++ b/src/SAML2/Assertion/Validation/SubjectConfirmationConstraintValidator.php
@@ -1,9 +1,13 @@
 <?php
 
-interface SAML2_Assertion_Validation_SubjectConfirmationConstraintValidator
+namespace SAML2\Assertion\Validation;
+
+use SAML2\XML\saml\SubjectConfirmation;
+
+interface SubjectConfirmationConstraintValidator
 {
     public function validate(
-        SAML2_XML_saml_SubjectConfirmation $subjectConfirmation,
-        SAML2_Assertion_Validation_Result $result
+        SubjectConfirmation $subjectConfirmation,
+        Result $result
     );
 }
diff --git a/src/SAML2/Assertion/Validation/SubjectConfirmationValidator.php b/src/SAML2/Assertion/Validation/SubjectConfirmationValidator.php
index a8ede2cde..e8bc2cccf 100644
--- a/src/SAML2/Assertion/Validation/SubjectConfirmationValidator.php
+++ b/src/SAML2/Assertion/Validation/SubjectConfirmationValidator.php
@@ -1,47 +1,55 @@
 <?php
 
-class SAML2_Assertion_Validation_SubjectConfirmationValidator
+namespace SAML2\Assertion\Validation;
+
+use SAML2\Configuration\IdentityProvider;
+use SAML2\Configuration\ServiceProvider;
+use SAML2\Configuration\IdentityProviderAware;
+use SAML2\Configuration\ServiceProviderAware;
+use SAML2\XML\saml\SubjectConfirmation;
+
+class SubjectConfirmationValidator
 {
     /**
-     * @var SAML2_Assertion_Validation_SubjectConfirmationConstraintValidator[]
+     * @var \SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator[]
      */
     protected $constraints;
 
     /**
-     * @var SAML2_Configuration_IdentityProvider
+     * @var \SAML2\Configuration\IdentityProvider
      */
     protected $identityProvider;
 
     /**
-     * @var SAML2_Configuration_ServiceProvider
+     * @var \SAML2\Configuration\ServiceProvider
      */
     protected $serviceProvider;
 
     public function __construct(
-        SAML2_Configuration_IdentityProvider $identityProvider,
-        SAML2_Configuration_ServiceProvider $serviceProvider
+        IdentityProvider $identityProvider,
+        ServiceProvider $serviceProvider
     ) {
         $this->identityProvider = $identityProvider;
         $this->serviceProvider = $serviceProvider;
     }
 
     public function addConstraintValidator(
-        SAML2_Assertion_Validation_SubjectConfirmationConstraintValidator $constraint
+        SubjectConfirmationConstraintValidator $constraint
     ) {
-        if ($constraint instanceof SAML2_Configuration_IdentityProviderAware) {
+        if ($constraint instanceof IdentityProviderAware) {
             $constraint->setIdentityProvider($this->identityProvider);
         }
 
-        if ($constraint instanceof SAML2_Configuration_ServiceProviderAware) {
+        if ($constraint instanceof ServiceProviderAware) {
             $constraint->setServiceProvider($this->serviceProvider);
         }
 
         $this->constraints[] = $constraint;
     }
 
-    public function validate(SAML2_XML_saml_SubjectConfirmation $subjectConfirmation)
+    public function validate(SubjectConfirmation $subjectConfirmation)
     {
-        $result = new SAML2_Assertion_Validation_Result();
+        $result = new Result();
         foreach ($this->constraints as $validator) {
             $validator->validate($subjectConfirmation, $result);
         }
diff --git a/src/SAML2/AttributeQuery.php b/src/SAML2/AttributeQuery.php
index 3d1926bf7..8a90ef86e 100644
--- a/src/SAML2/AttributeQuery.php
+++ b/src/SAML2/AttributeQuery.php
@@ -1,5 +1,7 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Class for SAML 2 attribute query messages.
  *
@@ -15,7 +17,7 @@
  *
  * @package SimpleSAMLphp
  */
-class SAML2_AttributeQuery extends SAML2_SubjectQuery
+class AttributeQuery extends SubjectQuery
 {
     /**
      * The attributes, as an associative array.
@@ -45,14 +47,14 @@ public function __construct(DOMElement $xml = NULL)
         parent::__construct('AttributeQuery', $xml);
 
         $this->attributes = array();
-        $this->nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
+        $this->nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
 
         if ($xml === NULL) {
             return;
         }
 
         $firstAttribute = TRUE;
-        $attributes = SAML2_Utils::xpQuery($xml, './saml_assertion:Attribute');
+        $attributes = Utils::xpQuery($xml, './saml_assertion:Attribute');
         foreach ($attributes as $attribute) {
             if (!$attribute->hasAttribute('Name')) {
                 throw new Exception('Missing name on <saml:Attribute> element.');
@@ -62,7 +64,7 @@ public function __construct(DOMElement $xml = NULL)
             if ($attribute->hasAttribute('NameFormat')) {
                 $nameFormat = $attribute->getAttribute('NameFormat');
             } else {
-                $nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
+                $nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
             }
 
             if ($firstAttribute) {
@@ -70,7 +72,7 @@ public function __construct(DOMElement $xml = NULL)
                 $firstAttribute = FALSE;
             } else {
                 if ($this->nameFormat !== $nameFormat) {
-                    $this->nameFormat = SAML2_Constants::NAMEFORMAT_UNSPECIFIED;
+                    $this->nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
                 }
             }
 
@@ -78,7 +80,7 @@ public function __construct(DOMElement $xml = NULL)
                 $this->attributes[$name] = array();
             }
 
-            $values = SAML2_Utils::xpQuery($attribute, './saml_assertion:AttributeValue');
+            $values = Utils::xpQuery($attribute, './saml_assertion:AttributeValue');
             foreach ($values as $value) {
                 $this->attributes[$name][] = trim($value->textContent);
             }
@@ -140,11 +142,11 @@ public function toUnsignedXML()
         $root = parent::toUnsignedXML();
 
         foreach ($this->attributes as $name => $values) {
-            $attribute = $root->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:Attribute');
+            $attribute = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:Attribute');
             $root->appendChild($attribute);
             $attribute->setAttribute('Name', $name);
 
-            if ($this->nameFormat !== SAML2_Constants::NAMEFORMAT_UNSPECIFIED) {
+            if ($this->nameFormat !== Constants::NAMEFORMAT_UNSPECIFIED) {
                 $attribute->setAttribute('NameFormat', $this->nameFormat);
             }
 
@@ -157,9 +159,9 @@ public function toUnsignedXML()
                     $type = NULL;
                 }
 
-                $attributeValue = SAML2_Utils::addString($attribute, SAML2_Constants::NS_SAML, 'saml:AttributeValue', $value);
+                $attributeValue = Utils::addString($attribute, Constants::NS_SAML, 'saml:AttributeValue', $value);
                 if ($type !== NULL) {
-                    $attributeValue->setAttributeNS(SAML2_Constants::NS_XSI, 'xsi:type', $type);
+                    $attributeValue->setAttributeNS(Constants::NS_XSI, 'xsi:type', $type);
                 }
             }
         }
diff --git a/src/SAML2/AuthnRequest.php b/src/SAML2/AuthnRequest.php
index 9775a5424..aa8a8782d 100644
--- a/src/SAML2/AuthnRequest.php
+++ b/src/SAML2/AuthnRequest.php
@@ -1,11 +1,15 @@
 <?php
 
+namespace SAML2;
+
+use SAML2\XML\saml\SubjectConfirmation;
+
 /**
  * Class for SAML 2 authentication request messages.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_AuthnRequest extends SAML2_Request
+class AuthnRequest extends Request
 {
     /**
      * The options for what type of name identifier should be returned.
@@ -102,7 +106,7 @@ class SAML2_AuthnRequest extends SAML2_Request
     private $requestedAuthnContext;
 
     /**
-     * @var SAML2_XML_saml_SubjectConfirmation[]
+     * @var \SAML2\XML\saml\SubjectConfirmation[]
      */
     private $subjectConfirmation = array();
 
@@ -134,8 +138,8 @@ public function __construct(DOMElement $xml = NULL)
             return;
         }
 
-        $this->forceAuthn = SAML2_Utils::parseBoolean($xml, 'ForceAuthn', FALSE);
-        $this->isPassive = SAML2_Utils::parseBoolean($xml, 'IsPassive', FALSE);
+        $this->forceAuthn = Utils::parseBoolean($xml, 'ForceAuthn', FALSE);
+        $this->isPassive = Utils::parseBoolean($xml, 'IsPassive', FALSE);
 
         if ($xml->hasAttribute('AssertionConsumerServiceURL')) {
             $this->assertionConsumerServiceURL = $xml->getAttribute('AssertionConsumerServiceURL');
@@ -166,7 +170,7 @@ public function __construct(DOMElement $xml = NULL)
      */
     private function parseSubject(DOMElement $xml)
     {
-        $subject = SAML2_Utils::xpQuery($xml, './saml_assertion:Subject');
+        $subject = Utils::xpQuery($xml, './saml_assertion:Subject');
         if (empty($subject)) {
             return;
         }
@@ -176,7 +180,7 @@ private function parseSubject(DOMElement $xml)
         }
         $subject = $subject[0];
 
-        $nameId = SAML2_Utils::xpQuery(
+        $nameId = Utils::xpQuery(
             $subject,
             './saml_assertion:NameID | ./saml_assertion:EncryptedID/xenc:EncryptedData'
         );
@@ -190,12 +194,12 @@ private function parseSubject(DOMElement $xml)
             /* The NameID element is encrypted. */
             $this->encryptedNameId = $nameId;
         } else {
-            $this->nameId = SAML2_Utils::parseNameId($nameId);
+            $this->nameId = Utils::parseNameId($nameId);
         }
 
-        $subjectConfirmation = SAML2_Utils::xpQuery($subject, './saml_assertion:SubjectConfirmation');
+        $subjectConfirmation = Utils::xpQuery($subject, './saml_assertion:SubjectConfirmation');
         foreach ($subjectConfirmation as $sc) {
-            $this->subjectConfirmation[] = new SAML2_XML_saml_SubjectConfirmation($sc);
+            $this->subjectConfirmation[] = new SubjectConfirmation($sc);
         }
     }
 
@@ -206,7 +210,7 @@ private function parseSubject(DOMElement $xml)
      */
     protected function parseNameIdPolicy(DOMElement $xml)
     {
-        $nameIdPolicy = SAML2_Utils::xpQuery($xml, './saml_protocol:NameIDPolicy');
+        $nameIdPolicy = Utils::xpQuery($xml, './saml_protocol:NameIDPolicy');
         if (empty($nameIdPolicy)) {
             return;
         }
@@ -219,7 +223,7 @@ protected function parseNameIdPolicy(DOMElement $xml)
             $this->nameIdPolicy['SPNameQualifier'] = $nameIdPolicy->getAttribute('SPNameQualifier');
         }
         if ($nameIdPolicy->hasAttribute('AllowCreate')) {
-            $this->nameIdPolicy['AllowCreate'] = SAML2_Utils::parseBoolean($nameIdPolicy, 'AllowCreate', FALSE);
+            $this->nameIdPolicy['AllowCreate'] = Utils::parseBoolean($nameIdPolicy, 'AllowCreate', FALSE);
         }
     }
 
@@ -228,7 +232,7 @@ protected function parseNameIdPolicy(DOMElement $xml)
      */
     protected function parseRequestedAuthnContext(DOMElement $xml)
     {
-        $requestedAuthnContext = SAML2_Utils::xpQuery($xml, './saml_protocol:RequestedAuthnContext');
+        $requestedAuthnContext = Utils::xpQuery($xml, './saml_protocol:RequestedAuthnContext');
         if (empty($requestedAuthnContext)) {
             return;
         }
@@ -237,10 +241,10 @@ protected function parseRequestedAuthnContext(DOMElement $xml)
 
         $rac = array(
             'AuthnContextClassRef' => array(),
-            'Comparison'           => SAML2_Constants::COMPARISON_EXACT,
+            'Comparison'           => Constants::COMPARISON_EXACT,
         );
 
-        $accr = SAML2_Utils::xpQuery($requestedAuthnContext, './saml_assertion:AuthnContextClassRef');
+        $accr = Utils::xpQuery($requestedAuthnContext, './saml_assertion:AuthnContextClassRef');
         foreach ($accr as $i) {
             $rac['AuthnContextClassRef'][] = trim($i->textContent);
         }
@@ -259,7 +263,7 @@ protected function parseRequestedAuthnContext(DOMElement $xml)
      */
     protected function parseScoping(DOMElement $xml)
     {
-        $scoping = SAML2_Utils::xpQuery($xml, './saml_protocol:Scoping');
+        $scoping = Utils::xpQuery($xml, './saml_protocol:Scoping');
         if (empty($scoping)) {
             return;
         }
@@ -269,7 +273,7 @@ protected function parseScoping(DOMElement $xml)
         if ($scoping->hasAttribute('ProxyCount')) {
             $this->ProxyCount = (int) $scoping->getAttribute('ProxyCount');
         }
-        $idpEntries = SAML2_Utils::xpQuery($scoping, './saml_protocol:IDPList/saml_protocol:IDPEntry');
+        $idpEntries = Utils::xpQuery($scoping, './saml_protocol:IDPList/saml_protocol:IDPEntry');
 
         foreach ($idpEntries as $idpEntry) {
             if (!$idpEntry->hasAttribute('ProviderID')) {
@@ -278,7 +282,7 @@ protected function parseScoping(DOMElement $xml)
             $this->IDPList[] = $idpEntry->getAttribute('ProviderID');
         }
 
-        $requesterIDs = SAML2_Utils::xpQuery($scoping, './saml_protocol:RequesterID');
+        $requesterIDs = Utils::xpQuery($scoping, './saml_protocol:RequesterID');
         foreach ($requesterIDs as $requesterID) {
             $this->RequesterID[] = trim($requesterID->textContent);
         }
@@ -287,7 +291,7 @@ protected function parseScoping(DOMElement $xml)
     /**
      * Retrieve the NameIdPolicy.
      *
-     * @see SAML2_AuthnRequest::setNameIdPolicy()
+     * @see \SAML2\AuthnRequest::setNameIdPolicy()
      * @return array The NameIdPolicy.
      */
     public function getNameIdPolicy()
@@ -560,9 +564,9 @@ public function setRequestedAuthnContext($requestedAuthnContext)
     /**
      * Retrieve the NameId of the subject in the assertion.
      *
-     * The returned NameId is in the format used by SAML2_Utils::addNameId().
+     * The returned NameId is in the format used by \SAML2\Utils::addNameId().
      *
-     * @see SAML2_Utils::addNameId()
+     * @see \SAML2\Utils::addNameId()
      * @return array|NULL The name identifier of the assertion.
      * @throws Exception
      */
@@ -578,9 +582,9 @@ public function getNameId()
     /**
      * Set the NameId of the subject in the assertion.
      *
-     * The NameId must be in the format accepted by SAML2_Utils::addNameId().
+     * The NameId must be in the format accepted by \SAML2\Utils::addNameId().
      *
-     * @see SAML2_Utils::addNameId()
+     * @see \SAML2\Utils::addNameId()
      *
      * @param array|NULL $nameId The name identifier of the assertion.
      */
@@ -602,10 +606,10 @@ public function encryptNameId(XMLSecurityKey $key)
         $doc  = new DOMDocument();
         $root = $doc->createElement('root');
         $doc->appendChild($root);
-        SAML2_Utils::addNameId($root, $this->nameId);
+        Utils::addNameId($root, $this->nameId);
         $nameId = $root->firstChild;
 
-        SAML2_Utils::getContainer()->debugMessage($nameId, 'encrypt');
+        Utils::getContainer()->debugMessage($nameId, 'encrypt');
 
         /* Encrypt the NameID. */
         $enc = new XMLSecEnc();
@@ -635,9 +639,9 @@ public function decryptNameId(XMLSecurityKey $key, array $blacklist = array())
             return;
         }
 
-        $nameId = SAML2_Utils::decryptElement($this->encryptedNameId, $key, $blacklist);
-        SAML2_Utils::getContainer()->debugMessage($nameId, 'decrypt');
-        $this->nameId = SAML2_Utils::parseNameId($nameId);
+        $nameId = Utils::decryptElement($this->encryptedNameId, $key, $blacklist);
+        Utils::getContainer()->debugMessage($nameId, 'decrypt');
+        $this->nameId = Utils::parseNameId($nameId);
 
         $this->encryptedNameId = NULL;
     }
@@ -645,7 +649,7 @@ public function decryptNameId(XMLSecurityKey $key, array $blacklist = array())
     /**
      * Retrieve the SubjectConfirmation elements we have in our Subject element.
      *
-     * @return SAML2_XML_saml_SubjectConfirmation[]
+     * @return \SAML2\XML\saml\SubjectConfirmation[]
      */
     public function getSubjectConfirmation()
     {
@@ -655,7 +659,7 @@ public function getSubjectConfirmation()
     /**
      * Set the SubjectConfirmation elements that should be included in the assertion.
      *
-     * @param array SAML2_XML_saml_SubjectConfirmation[]
+     * @param array \SAML2\XML\saml\SubjectConfirmation[]
      */
     public function setSubjectConfirmation(array $subjectConfirmation)
     {
@@ -701,7 +705,7 @@ public function toUnsignedXML()
         $this->addSubject($root);
 
         if (!empty($this->nameIdPolicy)) {
-            $nameIdPolicy = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'NameIDPolicy');
+            $nameIdPolicy = $this->document->createElementNS(Constants::NS_SAMLP, 'NameIDPolicy');
             if (array_key_exists('Format', $this->nameIdPolicy)) {
                 $nameIdPolicy->setAttribute('Format', $this->nameIdPolicy['Format']);
             }
@@ -716,26 +720,26 @@ public function toUnsignedXML()
 
         $rac = $this->requestedAuthnContext;
         if (!empty($rac) && !empty($rac['AuthnContextClassRef'])) {
-            $e = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'RequestedAuthnContext');
+            $e = $this->document->createElementNS(Constants::NS_SAMLP, 'RequestedAuthnContext');
             $root->appendChild($e);
-            if (isset($rac['Comparison']) && $rac['Comparison'] !== SAML2_Constants::COMPARISON_EXACT) {
+            if (isset($rac['Comparison']) && $rac['Comparison'] !== Constants::COMPARISON_EXACT) {
                 $e->setAttribute('Comparison', $rac['Comparison']);
             }
             foreach ($rac['AuthnContextClassRef'] as $accr) {
-                SAML2_Utils::addString($e, SAML2_Constants::NS_SAML, 'AuthnContextClassRef', $accr);
+                Utils::addString($e, Constants::NS_SAML, 'AuthnContextClassRef', $accr);
             }
         }
 
         if ($this->ProxyCount !== NULL || count($this->IDPList) > 0 || count($this->RequesterID) > 0) {
-            $scoping = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'Scoping');
+            $scoping = $this->document->createElementNS(Constants::NS_SAMLP, 'Scoping');
             $root->appendChild($scoping);
             if ($this->ProxyCount !== NULL) {
                 $scoping->setAttribute('ProxyCount', $this->ProxyCount);
             }
             if (count($this->IDPList) > 0) {
-                $idplist = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'IDPList');
+                $idplist = $this->document->createElementNS(Constants::NS_SAMLP, 'IDPList');
                 foreach ($this->IDPList as $provider) {
-                    $idpEntry = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'IDPEntry');
+                    $idpEntry = $this->document->createElementNS(Constants::NS_SAMLP, 'IDPEntry');
                     if (is_string($provider)) {
                         $idpEntry->setAttribute('ProviderID', $provider);
                     } elseif (is_array($provider)) {
@@ -754,7 +758,7 @@ public function toUnsignedXML()
                 $scoping->appendChild($idplist);
             }
             if (count($this->RequesterID) > 0) {
-                SAML2_Utils::addStrings($scoping, SAML2_Constants::NS_SAMLP, 'RequesterID', FALSE, $this->RequesterID);
+                Utils::addStrings($scoping, Constants::NS_SAMLP, 'RequesterID', FALSE, $this->RequesterID);
             }
         }
 
@@ -773,13 +777,13 @@ private function addSubject(DOMElement $root)
             return;
         }
 
-        $subject = $root->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:Subject');
+        $subject = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:Subject');
         $root->appendChild($subject);
 
         if ($this->encryptedNameId === NULL) {
-            SAML2_Utils::addNameId($subject, $this->nameId);
+            Utils::addNameId($subject, $this->nameId);
         } else {
-            $eid = $subject->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:EncryptedID');
+            $eid = $subject->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:EncryptedID');
             $eid->appendChild($subject->ownerDocument->importNode($this->encryptedNameId, TRUE));
             $subject->appendChild($eid);
         }
diff --git a/src/SAML2/Binding.php b/src/SAML2/Binding.php
index bf6f8b28a..0f608464d 100644
--- a/src/SAML2/Binding.php
+++ b/src/SAML2/Binding.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Base class for SAML 2 bindings.
  *
  * @package SimpleSAMLphp
  */
-abstract class SAML2_Binding
+abstract class Binding
 {
     /**
      * The destination of messages.
@@ -20,7 +22,7 @@ abstract class SAML2_Binding
      * Will throw an exception if it is unable to locate the binding.
      *
      * @param  string        $urn The URN of the binding.
-     * @return SAML2_Binding The binding.
+     * @return \SAML2\Binding The binding.
      * @throws Exception
      */
     public static function getBinding($urn)
@@ -28,14 +30,14 @@ public static function getBinding($urn)
         assert('is_string($urn)');
 
         switch ($urn) {
-            case SAML2_Constants::BINDING_HTTP_POST:
-                return new SAML2_HTTPPost();
-            case SAML2_Constants::BINDING_HTTP_REDIRECT:
-                return new SAML2_HTTPRedirect();
-            case SAML2_Constants::BINDING_HTTP_ARTIFACT:
-                return new SAML2_HTTPArtifact();
-            case SAML2_Constants::BINDING_HOK_SSO:
-                return new SAML2_HTTPPost();
+            case Constants::BINDING_HTTP_POST:
+                return new HTTPPost();
+            case Constants::BINDING_HTTP_REDIRECT:
+                return new HTTPRedirect();
+            case Constants::BINDING_HTTP_ARTIFACT:
+                return new HTTPArtifact();
+            case Constants::BINDING_HOK_SSO:
+                return new HTTPPost();
             default:
                 throw new Exception('Unsupported binding: ' . var_export($urn, TRUE));
         }
@@ -45,11 +47,11 @@ public static function getBinding($urn)
      * Guess the current binding.
      *
      * This function guesses the current binding and creates an instance
-     * of SAML2_Binding matching that binding.
+     * of \SAML2\Binding matching that binding.
      *
      * An exception will be thrown if it is unable to guess the binding.
      *
-     * @return SAML2_Binding The binding.
+     * @return \SAML2\Binding The binding.
      * @throws Exception
      */
     public static function getCurrentBinding()
@@ -57,9 +59,9 @@ public static function getCurrentBinding()
         switch ($_SERVER['REQUEST_METHOD']) {
             case 'GET':
                 if (array_key_exists('SAMLRequest', $_GET) || array_key_exists('SAMLResponse', $_GET)) {
-                    return new SAML2_HTTPRedirect();
+                    return new HTTPRedirect();
                 } elseif (array_key_exists('SAMLart', $_GET)) {
-                    return new SAML2_HTTPArtifact();
+                    return new HTTPArtifact();
                 }
                 break;
 
@@ -72,16 +74,16 @@ public static function getCurrentBinding()
                     $contentType = NULL;
                 }
                 if (array_key_exists('SAMLRequest', $_POST) || array_key_exists('SAMLResponse', $_POST)) {
-                    return new SAML2_HTTPPost();
+                    return new HTTPPost();
                 } elseif (array_key_exists('SAMLart', $_POST)) {
-                    return new SAML2_HTTPArtifact();
+                    return new HTTPArtifact();
                 } elseif ($contentType === 'text/xml') {
-                    return new SAML2_SOAP();
+                    return new SOAP();
                 }
                 break;
         }
 
-        $logger = SAML2_Utils::getContainer()->getLogger();
+        $logger = Utils::getContainer()->getLogger();
         $logger->warning('Unable to find the SAML 2 binding used for this request.');
         $logger->warning('Request method: ' . var_export($_SERVER['REQUEST_METHOD'], TRUE));
         if (!empty($_GET)) {
@@ -127,9 +129,9 @@ public function setDestination($destination)
      * This function will send a message using the specified binding.
      * The message will be delivered to the destination set in the message.
      *
-     * @param SAML2_Message $message The message which should be sent.
+     * @param \SAML2\Message $message The message which should be sent.
      */
-    abstract public function send(SAML2_Message $message);
+    abstract public function send(Message $message);
 
     /**
      * Receive a SAML 2 message.
@@ -137,7 +139,7 @@ abstract public function send(SAML2_Message $message);
      * This function will extract the message from the current request.
      * An exception will be thrown if we are unable to process the message.
      *
-     * @return SAML2_Message The received message.
+     * @return \SAML2\Message The received message.
      */
     abstract public function receive();
 
diff --git a/src/SAML2/Certificate/Exception/InvalidCertificateStructureException.php b/src/SAML2/Certificate/Exception/InvalidCertificateStructureException.php
index b07cddebf..a82de953c 100644
--- a/src/SAML2/Certificate/Exception/InvalidCertificateStructureException.php
+++ b/src/SAML2/Certificate/Exception/InvalidCertificateStructureException.php
@@ -1,10 +1,14 @@
 <?php
 
+namespace SAML2\Certificate\Exception;
+
+use SAML2\Exception\Throwable;
+
 /**
  * Named Exception for what the name describes. This should not occur, as it has to be
  * caught on the configuration side.
  */
-class SAML2_Certificate_Exception_InvalidCertificateStructureException extends DomainException implements
-    SAML2_Exception_Throwable
+class InvalidCertificateStructureException extends DomainException implements
+    Throwable
 {
 }
diff --git a/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php b/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php
index 6708d3fb8..29c65bbc5 100644
--- a/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php
+++ b/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php
@@ -1,10 +1,15 @@
 <?php
 
+namespace SAML2\Certificate\Exception;
+
+use SAML2\Exception\Throwable;
+use SAML2\Certificate\Key;
+
 /**
  * Named exception for when a non-existent key-usage is given
  */
-class SAML2_Certificate_Exception_InvalidKeyUsageException extends InvalidArgumentException implements
-    SAML2_Exception_Throwable
+class InvalidKeyUsageException extends InvalidArgumentException implements
+    Throwable
 {
     /**
      * @param string $usage
@@ -14,7 +19,7 @@ public function __construct($usage)
         $message = sprintf(
             'Invalid key usage given: "%s", usages "%s" allowed',
             is_string($usage) ? $usage : gettype($usage),
-            implode('", "', SAML2_Certificate_Key::getValidKeyUsages())
+            implode('", "', Key::getValidKeyUsages())
         );
 
         parent::__construct($message);
diff --git a/src/SAML2/Certificate/Exception/NoKeysFoundException.php b/src/SAML2/Certificate/Exception/NoKeysFoundException.php
index 50304632c..deebc5ef8 100644
--- a/src/SAML2/Certificate/Exception/NoKeysFoundException.php
+++ b/src/SAML2/Certificate/Exception/NoKeysFoundException.php
@@ -1,8 +1,12 @@
 <?php
 
+namespace SAML2\Certificate\Exception;
+
+use SAML2\Exception\Throwable;
+
 /**
  * Named exception. Indicates that although required, no keys could be loaded from the configuration
  */
-class SAML2_Certificate_Exception_NoKeysFoundException extends DomainException implements SAML2_Exception_Throwable
+class NoKeysFoundException extends DomainException implements Throwable
 {
 }
diff --git a/src/SAML2/Certificate/Fingerprint.php b/src/SAML2/Certificate/Fingerprint.php
index 54f524d8a..7cd9e5430 100644
--- a/src/SAML2/Certificate/Fingerprint.php
+++ b/src/SAML2/Certificate/Fingerprint.php
@@ -1,9 +1,13 @@
 <?php
 
+namespace SAML2\Certificate;
+
+use SAML2\Exception\InvalidArgumentException;
+
 /**
  * Simple representation of the fingerprint of a certificate
  */
-class SAML2_Certificate_Fingerprint
+class Fingerprint
 {
     /**
      * @var string
@@ -16,7 +20,7 @@ class SAML2_Certificate_Fingerprint
     public function __construct($fingerPrint)
     {
         if (!is_string($fingerPrint)) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType('string', $fingerPrint);
+            throw InvalidArgumentException::invalidType('string', $fingerPrint);
         }
 
         $this->contents = $fingerPrint;
@@ -41,11 +45,11 @@ public function getNormalized()
     }
 
     /**
-     * @param SAML2_Certificate_Fingerprint $fingerprint
+     * @param \SAML2\Certificate\Fingerprint $fingerprint
      *
      * @return bool
      */
-    public function equals(SAML2_Certificate_Fingerprint $fingerprint)
+    public function equals(Fingerprint $fingerprint)
     {
         return $this->getNormalized() === $fingerprint->getNormalized();
     }
diff --git a/src/SAML2/Certificate/FingerprintCollection.php b/src/SAML2/Certificate/FingerprintCollection.php
index 0323f0544..ccd234529 100644
--- a/src/SAML2/Certificate/FingerprintCollection.php
+++ b/src/SAML2/Certificate/FingerprintCollection.php
@@ -1,19 +1,24 @@
 <?php
 
+namespace SAML2\Certificate;
+
+use SAML2\Utilities\ArrayCollection;
+use SAML2\Exception\InvalidArgumentException;
+
 /**
  * Simple collection object for transporting keys
  */
-class SAML2_Certificate_FingerprintCollection extends SAML2_Utilities_ArrayCollection
+class FingerprintCollection extends ArrayCollection
 {
     /**
      * Add a key to the collection
      *
-     * @param SAML2_Certificate_Fingerprint $fingerprint
+     * @param \SAML2\Certificate\Fingerprint $fingerprint
      */
     public function add($fingerprint)
     {
-        if (!$fingerprint instanceof SAML2_Certificate_Fingerprint) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType(
+        if (!$fingerprint instanceof Fingerprint) {
+            throw InvalidArgumentException::invalidType(
                 'SAML2_Certificate_Fingerprint ',
                 $fingerprint
             );
@@ -23,14 +28,14 @@ public function add($fingerprint)
     }
 
     /**
-     * @param SAML2_Certificate_Fingerprint $otherFingerprint
+     * @param \SAML2\Certificate\Fingerprint $otherFingerprint
      *
      * @return bool
      */
-    public function contains(SAML2_Certificate_Fingerprint $otherFingerprint)
+    public function contains(Fingerprint $otherFingerprint)
     {
         foreach ($this->elements as $fingerprint) {
-            /** @var SAML2_Certificate_Fingerprint $fingerprint */
+            /** @var \SAML2\Certificate\Fingerprint $fingerprint */
             if ($fingerprint->equals($otherFingerprint)) {
                 return TRUE;
             }
diff --git a/src/SAML2/Certificate/FingerprintLoader.php b/src/SAML2/Certificate/FingerprintLoader.php
index 1cd4e3e61..1e4ed2793 100644
--- a/src/SAML2/Certificate/FingerprintLoader.php
+++ b/src/SAML2/Certificate/FingerprintLoader.php
@@ -1,15 +1,20 @@
 <?php
 
-class SAML2_Certificate_FingerprintLoader
+namespace SAML2\Certificate;
+
+use SAML2\Configuration\CertificateProvider;
+use SAML2\Exception\InvalidArgumentException;
+
+class FingerprintLoader
 {
     /**
      * Static method mainly for BC, should be replaced with DI.
      *
-     * @param SAML2_Configuration_CertificateProvider $configuration
+     * @param \SAML2\Configuration\CertificateProvider $configuration
      *
-     * @return SAML2_Certificate_FingerprintCollection
+     * @return \SAML2\Certificate\FingerprintCollection
      */
-    public static function loadFromConfiguration(SAML2_Configuration_CertificateProvider $configuration)
+    public static function loadFromConfiguration(CertificateProvider $configuration)
     {
         $loader = new self();
 
@@ -19,30 +24,30 @@ public static function loadFromConfiguration(SAML2_Configuration_CertificateProv
     /**
      * Loads the fingerprints from a configurationValue
      *
-     * @param SAML2_Configuration_CertificateProvider $configuration
+     * @param \SAML2\Configuration\CertificateProvider $configuration
      *
-     * @return SAML2_Certificate_FingerprintCollection
+     * @return \SAML2\Certificate\FingerprintCollection
      */
-    public function loadFingerprints(SAML2_Configuration_CertificateProvider $configuration)
+    public function loadFingerprints(CertificateProvider $configuration)
     {
         $fingerprints = $configuration->getCertificateFingerprints();
         if (!is_array($fingerprints) && !$fingerprints instanceof \Traversable) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType(
+            throw InvalidArgumentException::invalidType(
                 'array or instanceof \Traversable',
                 $fingerprints
             );
         }
 
-        $collection = new SAML2_Certificate_FingerprintCollection();
+        $collection = new FingerprintCollection();
         foreach ($fingerprints as $fingerprint) {
             if (!is_string($fingerprint) && !(is_object($fingerprint) && method_exists($fingerprint, '__toString'))) {
-                throw SAML2_Exception_InvalidArgumentException::invalidType(
+                throw InvalidArgumentException::invalidType(
                     'fingerprint as string or object that can be casted to string',
                     $fingerprint
                 );
             }
 
-            $collection->add(new SAML2_Certificate_Fingerprint((string) $fingerprint));
+            $collection->add(new Fingerprint((string) $fingerprint));
         }
 
         return $collection;
diff --git a/src/SAML2/Certificate/Key.php b/src/SAML2/Certificate/Key.php
index a47dc0c61..7a7fb0433 100644
--- a/src/SAML2/Certificate/Key.php
+++ b/src/SAML2/Certificate/Key.php
@@ -1,10 +1,15 @@
 <?php
 
+namespace SAML2\Certificate;
+
+use SAML2\Certificate\Exception\InvalidKeyUsageException;
+use SAML2\Exception\InvalidArgumentException;
+
 /**
  * Simple DTO wrapper for (X509) keys. Implements ArrayAccess
  * for easier backwards compatibility.
  */
-class SAML2_Certificate_Key implements ArrayAccess
+class Key implements ArrayAccess
 {
     // Possible key usages
     const USAGE_SIGNING = 'signing';
@@ -35,7 +40,7 @@ public function __construct(array $keyData)
     public function canBeUsedFor($usage)
     {
         if (!in_array($usage, static::getValidKeyUsages())) {
-            throw new SAML2_Certificate_Exception_InvalidKeyUsageException($usage);
+            throw new InvalidKeyUsageException($usage);
         }
 
         return isset($this->keyData[$usage]) && $this->keyData[$usage];
@@ -88,7 +93,7 @@ public function offsetUnset($offset)
     protected function assertIsString($test)
     {
         if (!is_string($test)) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType('string', $test);
+            throw InvalidArgumentException::invalidType('string', $test);
         }
     }
 }
diff --git a/src/SAML2/Certificate/KeyCollection.php b/src/SAML2/Certificate/KeyCollection.php
index 8511acff2..6ff2e323e 100644
--- a/src/SAML2/Certificate/KeyCollection.php
+++ b/src/SAML2/Certificate/KeyCollection.php
@@ -1,19 +1,24 @@
 <?php
 
+namespace SAML2\Certificate;
+
+use SAML2\Utilities\ArrayCollection;
+use SAML2\Exception\InvalidArgumentException;
+
 /**
  * Simple collection object for transporting keys
  */
-class SAML2_Certificate_KeyCollection extends SAML2_Utilities_ArrayCollection
+class KeyCollection extends ArrayCollection
 {
     /**
      * Add a key to the collection
      *
-     * @param SAML2_Certificate_Key $key
+     * @param \SAML2\Certificate\Key $key
      */
     public function add($key)
     {
-        if (!$key instanceof SAML2_Certificate_Key) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType(
+        if (!$key instanceof Key) {
+            throw InvalidArgumentException::invalidType(
                 'SAML2_Certificate_Key',
                 $key
             );
diff --git a/src/SAML2/Certificate/KeyLoader.php b/src/SAML2/Certificate/KeyLoader.php
index 75353423e..dee6d1b4b 100644
--- a/src/SAML2/Certificate/KeyLoader.php
+++ b/src/SAML2/Certificate/KeyLoader.php
@@ -1,33 +1,42 @@
 <?php
 
+namespace SAML2\Certificate;
+
+use SAML2\Configuration\CertificateProvider;
+use SAML2\Certificate\Exception\NoKeysFoundException;
+use SAML2\Exception\InvalidArgumentException;
+use SAML2\Utilities\File;
+use SAML2\Utilities\Certificate;
+use SAML2\Certificate\Exception\InvalidCertificateStructureException;
+
 /**
  * KeyLoader
  */
-class SAML2_Certificate_KeyLoader
+class KeyLoader
 {
     /**
-     * @var SAML2_Certificate_KeyCollection
+     * @var \SAML2\Certificate\KeyCollection
      */
     private $loadedKeys;
 
     public function __construct()
     {
-        $this->loadedKeys = new SAML2_Certificate_KeyCollection();
+        $this->loadedKeys = new KeyCollection();
     }
 
     /**
      * Extracts the public keys given by the configuration. Mainly exists for BC purposes.
      * Prioritisation order is keys > certData > certificate
      *
-     * @param SAML2_Configuration_CertificateProvider $config
+     * @param \SAML2\Configuration\CertificateProvider $config
      * @param null                                    $usage
      * @param bool                                    $required
      * @param string                                  $prefix
      *
-     * @return SAML2_Certificate_KeyCollection
+     * @return \SAML2\Certificate\KeyCollection
      */
     public static function extractPublicKeys(
-        SAML2_Configuration_CertificateProvider $config,
+        CertificateProvider $config,
         $usage = NULL,
         $required = FALSE,
         $prefix = ''
@@ -38,14 +47,14 @@ public static function extractPublicKeys(
     }
 
     /**
-     * @param SAML2_Configuration_CertificateProvider $config
+     * @param \SAML2\Configuration\CertificateProvider $config
      * @param NULL|string                             $usage
      * @param bool                                    $required
      *
-     * @return SAML2_Certificate_KeyCollection
+     * @return \SAML2\Certificate\KeyCollection
      */
     public function loadKeysFromConfiguration(
-        SAML2_Configuration_CertificateProvider $config,
+        CertificateProvider $config,
         $usage = NULL,
         $required = FALSE
     ) {
@@ -62,7 +71,7 @@ public function loadKeysFromConfiguration(
         }
 
         if ($required && !$this->hasKeys()) {
-            throw new SAML2_Certificate_Exception_NoKeysFoundException(
+            throw new NoKeysFoundException(
                 'No keys found in configured metadata, please ensure that either the "keys", "certData" or '
                 . '"certificate" entries is available.'
             );
@@ -82,9 +91,9 @@ public function loadKeys(array $configuredKeys, $usage)
     {
         foreach ($configuredKeys as $keyData) {
             if (isset($key['X509Certificate'])) {
-                $key = new SAML2_Certificate_X509($keyData);
+                $key = new X509($keyData);
             } else {
-                $key = new SAML2_Certificate_Key($keyData);
+                $key = new Key($keyData);
             }
 
             if ($usage && !$key->canBeUsedFor($usage)) {
@@ -103,10 +112,10 @@ public function loadKeys(array $configuredKeys, $usage)
     public function loadCertificateData($certificateData)
     {
         if (!is_string($certificateData)) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType('string', $certificateData);
+            throw InvalidArgumentException::invalidType('string', $certificateData);
         }
 
-        $this->loadedKeys->add(SAML2_Certificate_X509::createFromCertificateData($certificateData));
+        $this->loadedKeys->add(X509::createFromCertificateData($certificateData));
     }
 
     /**
@@ -116,22 +125,22 @@ public function loadCertificateData($certificateData)
      */
     public function loadCertificateFile($certificateFile)
     {
-        $certificate = SAML2_Utilities_File::getFileContents($certificateFile);
+        $certificate = File::getFileContents($certificateFile);
 
-        if (!SAML2_Utilities_Certificate::hasValidStructure($certificate)) {
-            throw new SAML2_Certificate_Exception_InvalidCertificateStructureException(sprintf(
+        if (!Certificate::hasValidStructure($certificate)) {
+            throw new InvalidCertificateStructureException(sprintf(
                 'Could not find PEM encoded certificate in "%s"',
                 $certificateFile
             ));
         }
 
         // capture the certificate contents without the delimiters
-        preg_match(SAML2_Utilities_Certificate::CERTIFICATE_PATTERN, $certificate, $matches);
-        $this->loadedKeys->add(SAML2_Certificate_X509::createFromCertificateData($matches[1]));
+        preg_match(Certificate::CERTIFICATE_PATTERN, $certificate, $matches);
+        $this->loadedKeys->add(X509::createFromCertificateData($matches[1]));
     }
 
     /**
-     * @return SAML2_Certificate_KeyCollection
+     * @return \SAML2\Certificate\KeyCollection
      */
     public function getKeys()
     {
diff --git a/src/SAML2/Certificate/PrivateKey.php b/src/SAML2/Certificate/PrivateKey.php
index 453e2cd14..405dd9590 100644
--- a/src/SAML2/Certificate/PrivateKey.php
+++ b/src/SAML2/Certificate/PrivateKey.php
@@ -1,15 +1,19 @@
 <?php
 
-class SAML2_Certificate_PrivateKey extends SAML2_Certificate_Key
+namespace SAML2\Certificate;
+
+use SAML2\Exception\InvalidArgumentException;
+
+class PrivateKey extends Key
 {
     public static function create($keyContents, $passphrase = NULL)
     {
         if (!is_string($keyContents)) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType('string', $keyContents);
+            throw InvalidArgumentException::invalidType('string', $keyContents);
         }
 
         if ($passphrase && !is_string($passphrase)) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType('string', $passphrase);
+            throw InvalidArgumentException::invalidType('string', $passphrase);
         }
 
         $keyData = array ('PEM' => $keyContents, self::USAGE_ENCRYPTION => TRUE);
diff --git a/src/SAML2/Certificate/PrivateKeyLoader.php b/src/SAML2/Certificate/PrivateKeyLoader.php
index a055a0e07..7493deb7e 100644
--- a/src/SAML2/Certificate/PrivateKeyLoader.php
+++ b/src/SAML2/Certificate/PrivateKeyLoader.php
@@ -1,33 +1,40 @@
 <?php
 
-class SAML2_Certificate_PrivateKeyLoader
+namespace SAML2\Certificate;
+
+use SAML2\Configuration\PrivateKey;
+use SAML2\Utilities\File;
+use SAML2\Configuration\DecryptionProvider;
+use SAML2\Utilities\ArrayCollection;
+
+class PrivateKeyLoader
 {
     /**
      * Loads a private key based on the configuration given.
      *
-     * @param SAML2_Configuration_PrivateKey $key
+     * @param \SAML2\Configuration\PrivateKey $key
      *
-     * @return SAML2_Certificate_PrivateKey
+     * @return \SAML2\Certificate\PrivateKey
      */
-    public function loadPrivateKey(SAML2_Configuration_PrivateKey $key)
+    public function loadPrivateKey(PrivateKey $key)
     {
-        $privateKey = SAML2_Utilities_File::getFileContents($key->getFilePath());
+        $privateKey = File::getFileContents($key->getFilePath());
 
-        return SAML2_Certificate_PrivateKey::create($privateKey, $key->getPassPhrase());
+        return PrivateKey::create($privateKey, $key->getPassPhrase());
     }
 
     /**
-     * @param SAML2_Configuration_DecryptionProvider $identityProvider
-     * @param SAML2_Configuration_DecryptionProvider $serviceProvider
+     * @param \SAML2\Configuration\DecryptionProvider $identityProvider
+     * @param \SAML2\Configuration\DecryptionProvider $serviceProvider
      *
-     * @return SAML2_Utilities_ArrayCollection
+     * @return \SAML2\Utilities\ArrayCollection
      * @throws Exception
      */
     public function loadDecryptionKeys(
-        SAML2_Configuration_DecryptionProvider $identityProvider,
-        SAML2_Configuration_DecryptionProvider $serviceProvider
+        DecryptionProvider $identityProvider,
+        DecryptionProvider $serviceProvider
     ) {
-        $decryptionKeys = new SAML2_Utilities_ArrayCollection();
+        $decryptionKeys = new ArrayCollection();
 
         $senderSharedKey = $identityProvider->getSharedKey();
         if ($senderSharedKey) {
@@ -38,13 +45,13 @@ public function loadDecryptionKeys(
             return $decryptionKeys;
         }
 
-        $newPrivateKey = $serviceProvider->getPrivateKey(SAML2_Configuration_PrivateKey::NAME_NEW);
-        if ($newPrivateKey instanceof SAML2_Configuration_PrivateKey) {
+        $newPrivateKey = $serviceProvider->getPrivateKey(PrivateKey::NAME_NEW);
+        if ($newPrivateKey instanceof PrivateKey) {
             $loadedKey = $this->loadPrivateKey($newPrivateKey);
             $decryptionKeys->add($this->convertPrivateKeyToRsaKey($loadedKey));
         }
 
-        $privateKey = $serviceProvider->getPrivateKey(SAML2_Configuration_PrivateKey::NAME_DEFAULT, TRUE);
+        $privateKey = $serviceProvider->getPrivateKey(PrivateKey::NAME_DEFAULT, TRUE);
         $loadedKey  = $this->loadPrivateKey($privateKey);
         $decryptionKeys->add($this->convertPrivateKeyToRsaKey($loadedKey));
 
@@ -52,12 +59,12 @@ public function loadDecryptionKeys(
     }
 
     /**
-     * @param SAML2_Certificate_PrivateKey $privateKey
+     * @param \SAML2\Certificate\PrivateKey $privateKey
      *
      * @return XMLSecurityKey
      * @throws Exception
      */
-    private function convertPrivateKeyToRsaKey(SAML2_Certificate_PrivateKey $privateKey)
+    private function convertPrivateKeyToRsaKey(PrivateKey $privateKey)
     {
         $key        = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, array('type' => 'private'));
         $passphrase = $privateKey->getPassphrase();
diff --git a/src/SAML2/Certificate/X509.php b/src/SAML2/Certificate/X509.php
index 58cbe59a7..6686be76f 100644
--- a/src/SAML2/Certificate/X509.php
+++ b/src/SAML2/Certificate/X509.php
@@ -1,12 +1,14 @@
 <?php
 
+namespace SAML2\Certificate;
+
 /**
  * Specific Certificate Key.
  */
-class SAML2_Certificate_X509 extends SAML2_Certificate_Key
+class X509 extends Key
 {
     /**
-     * @var SAML2_Certificate_Fingerprint
+     * @var \SAML2\Certificate\Fingerprint
      */
     private $fingerprint;
 
@@ -47,7 +49,7 @@ public function getCertificate()
     }
 
     /**
-     * @return SAML2_Certificate_Fingerprint
+     * @return \SAML2\Certificate\Fingerprint
      */
     public function getFingerprint()
     {
@@ -57,6 +59,6 @@ public function getFingerprint()
 
         $fingerprint = strtolower(sha1(base64_decode($this->keyData['X509Certificate'])));
 
-        return $this->fingerprint = new SAML2_Certificate_Fingerprint($fingerprint);
+        return $this->fingerprint = new Fingerprint($fingerprint);
     }
 }
diff --git a/src/SAML2/Compat/AbstractContainer.php b/src/SAML2/Compat/AbstractContainer.php
index 22af19dc4..a96120429 100644
--- a/src/SAML2/Compat/AbstractContainer.php
+++ b/src/SAML2/Compat/AbstractContainer.php
@@ -1,6 +1,8 @@
 <?php
 
-abstract class SAML2_Compat_AbstractContainer
+namespace SAML2\Compat;
+
+abstract class AbstractContainer
 {
     /**
      * Get a PSR-3 compatible logger.
diff --git a/src/SAML2/Compat/ContainerSingleton.php b/src/SAML2/Compat/ContainerSingleton.php
index 398939ee3..652487f90 100644
--- a/src/SAML2/Compat/ContainerSingleton.php
+++ b/src/SAML2/Compat/ContainerSingleton.php
@@ -1,14 +1,18 @@
 <?php
 
-class SAML2_Compat_ContainerSingleton
+namespace SAML2\Compat;
+
+use SAML2\Compat\Ssp\Container;
+
+class ContainerSingleton
 {
     /**
-     * @var SAML2_Compat_Ssp_Container
+     * @var \SAML2\Compat\Ssp\Container
      */
     protected static $container;
 
     /**
-     * @return SAML2_Compat_Ssp_Container
+     * @return \SAML2\Compat\Ssp\Container
      */
     public static function getInstance()
     {
@@ -21,20 +25,20 @@ public static function getInstance()
     /**
      * Set a container to use.
      *
-     * @param SAML2_Compat_AbstractContainer $container
-     * @return SAML2_Compat_AbstractContainer
+     * @param \SAML2\Compat\AbstractContainer $container
+     * @return \SAML2\Compat\AbstractContainer
      */
-    public static function setContainer(SAML2_Compat_AbstractContainer $container)
+    public static function setContainer(AbstractContainer $container)
     {
         self::$container = $container;
         return $container;
     }
 
     /**
-     * @return SAML2_Compat_Ssp_Container
+     * @return \SAML2\Compat\Ssp\Container
      */
     public static function initSspContainer()
     {
-        return new SAML2_Compat_Ssp_Container();
+        return new Container();
     }
 }
diff --git a/src/SAML2/Compat/MockContainer.php b/src/SAML2/Compat/MockContainer.php
index cdd91adaa..df512d8d6 100644
--- a/src/SAML2/Compat/MockContainer.php
+++ b/src/SAML2/Compat/MockContainer.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace SAML2\Compat;
+
 /**
- * Class SAML2_Compat_MockContainer
+ * Class \SAML2\Compat\MockContainer
  */
-class SAML2_Compat_MockContainer extends SAML2_Compat_AbstractContainer
+class MockContainer extends AbstractContainer
 {
     /**
      * @var string
diff --git a/src/SAML2/Compat/Ssp/Container.php b/src/SAML2/Compat/Ssp/Container.php
index d7dfbb1ee..ea9cc77ff 100644
--- a/src/SAML2/Compat/Ssp/Container.php
+++ b/src/SAML2/Compat/Ssp/Container.php
@@ -1,6 +1,10 @@
 <?php
 
-class SAML2_Compat_Ssp_Container extends SAML2_Compat_AbstractContainer
+namespace SAML2\Compat\Ssp;
+
+use SAML2\Compat\AbstractContainer;
+
+class Container extends AbstractContainer
 {
     /**
      * @var Psr\Log\LoggerInterface
@@ -12,7 +16,7 @@ class SAML2_Compat_Ssp_Container extends SAML2_Compat_AbstractContainer
      */
     public function __construct()
     {
-        $this->logger = new SAML2_Compat_Ssp_Logger();
+        $this->logger = new Logger();
     }
 
     /**
diff --git a/src/SAML2/Compat/Ssp/Logger.php b/src/SAML2/Compat/Ssp/Logger.php
index 0718d4700..46a63cce9 100644
--- a/src/SAML2/Compat/Ssp/Logger.php
+++ b/src/SAML2/Compat/Ssp/Logger.php
@@ -1,6 +1,8 @@
 <?php
 
-class SAML2_Compat_Ssp_Logger implements Psr\Log\LoggerInterface
+namespace SAML2\Compat\Ssp;
+
+class Logger implements Psr\Log\LoggerInterface
 {
     /**
      * System is unusable.
diff --git a/src/SAML2/Configuration/ArrayAdapter.php b/src/SAML2/Configuration/ArrayAdapter.php
index 22e7050b1..64d24198a 100644
--- a/src/SAML2/Configuration/ArrayAdapter.php
+++ b/src/SAML2/Configuration/ArrayAdapter.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace SAML2\Configuration;
+
 /**
  * Default implementation for configuration
  */
-class SAML2_Configuration_ArrayAdapter implements SAML2_Configuration_Queryable
+class ArrayAdapter implements Queryable
 {
     /**
      * @var array
diff --git a/src/SAML2/Configuration/CertificateProvider.php b/src/SAML2/Configuration/CertificateProvider.php
index 9564cd5ec..849e2fcea 100644
--- a/src/SAML2/Configuration/CertificateProvider.php
+++ b/src/SAML2/Configuration/CertificateProvider.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace SAML2\Configuration;
+
 /**
  * CertificateProvider interface.
  */
-interface SAML2_Configuration_CertificateProvider extends SAML2_Configuration_Queryable
+interface CertificateProvider extends Queryable
 {
     /**
      * Returns an array or \Traversable of keys, where each element represents a configured key.
diff --git a/src/SAML2/Configuration/DecryptionProvider.php b/src/SAML2/Configuration/DecryptionProvider.php
index aa9623d05..eb3e651bd 100644
--- a/src/SAML2/Configuration/DecryptionProvider.php
+++ b/src/SAML2/Configuration/DecryptionProvider.php
@@ -1,6 +1,8 @@
 <?php
 
-interface SAML2_Configuration_DecryptionProvider
+namespace SAML2\Configuration;
+
+interface DecryptionProvider
 {
     /**
      * @return null|bool
diff --git a/src/SAML2/Configuration/Destination.php b/src/SAML2/Configuration/Destination.php
index 2935fc2c4..cbba14af8 100644
--- a/src/SAML2/Configuration/Destination.php
+++ b/src/SAML2/Configuration/Destination.php
@@ -1,9 +1,13 @@
 <?php
 
+namespace SAML2\Configuration;
+
+use SAML2\Exception\InvalidArgumentException;
+
 /**
  * Value Object representing the current destination
  */
-class SAML2_Configuration_Destination
+class Destination
 {
     /**
      * @var string
@@ -16,18 +20,18 @@ class SAML2_Configuration_Destination
     public function __construct($destination)
     {
         if (!is_string($destination)) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType('string', $destination);
+            throw InvalidArgumentException::invalidType('string', $destination);
         }
 
         $this->destination = $destination;
     }
 
     /**
-     * @param SAML2_Configuration_Destination $otherDestination
+     * @param \SAML2\Configuration\Destination $otherDestination
      *
      * @return bool
      */
-    public function equals(SAML2_Configuration_Destination $otherDestination)
+    public function equals(Destination $otherDestination)
     {
         return $this->destination === $otherDestination->destination;
     }
diff --git a/src/SAML2/Configuration/EntityIdProvider.php b/src/SAML2/Configuration/EntityIdProvider.php
index 9655006b0..5457e8b3c 100644
--- a/src/SAML2/Configuration/EntityIdProvider.php
+++ b/src/SAML2/Configuration/EntityIdProvider.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace SAML2\Configuration;
+
 /**
- * Interface SAML2_Configuration_EntityIdProvider
+ * Interface \SAML2\Configuration\EntityIdProvider
  */
-interface SAML2_Configuration_EntityIdProvider
+interface EntityIdProvider
 {
     /**
      * @return null|string
diff --git a/src/SAML2/Configuration/IdentityProvider.php b/src/SAML2/Configuration/IdentityProvider.php
index 471edad76..366c8cadd 100644
--- a/src/SAML2/Configuration/IdentityProvider.php
+++ b/src/SAML2/Configuration/IdentityProvider.php
@@ -1,12 +1,14 @@
 <?php
 
+namespace SAML2\Configuration;
+
 /**
  * Basic configuration wrapper
  */
-class SAML2_Configuration_IdentityProvider extends SAML2_Configuration_ArrayAdapter implements
-    SAML2_Configuration_CertificateProvider,
-    SAML2_Configuration_DecryptionProvider,
-    SAML2_Configuration_EntityIdProvider
+class IdentityProvider extends ArrayAdapter implements
+    CertificateProvider,
+    DecryptionProvider,
+    EntityIdProvider
 {
     public function getKeys()
     {
@@ -46,7 +48,7 @@ public function hasBase64EncodedAttributes()
     public function getPrivateKey($name, $required = FALSE)
     {
         $privateKeys = $this->get('privateKeys');
-        $key = array_filter($privateKeys, function (SAML2_Configuration_PrivateKey $key) use ($name) {
+        $key = array_filter($privateKeys, function (PrivateKey $key) use ($name) {
             return $key->getName() === $name;
         });
 
diff --git a/src/SAML2/Configuration/IdentityProviderAware.php b/src/SAML2/Configuration/IdentityProviderAware.php
index e10b51712..f954d144c 100644
--- a/src/SAML2/Configuration/IdentityProviderAware.php
+++ b/src/SAML2/Configuration/IdentityProviderAware.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace SAML2\Configuration;
+
 /**
  * Interface for triggering setter injection
  */
-interface SAML2_Configuration_IdentityProviderAware
+interface IdentityProviderAware
 {
-    public function setIdentityProvider(SAML2_Configuration_IdentityProvider $identityProvider);
+    public function setIdentityProvider(IdentityProvider $identityProvider);
 }
diff --git a/src/SAML2/Configuration/PrivateKey.php b/src/SAML2/Configuration/PrivateKey.php
index 248aa7d15..6b45982f7 100644
--- a/src/SAML2/Configuration/PrivateKey.php
+++ b/src/SAML2/Configuration/PrivateKey.php
@@ -1,9 +1,13 @@
 <?php
 
+namespace SAML2\Configuration;
+
+use SAML2\Exception\InvalidArgumentException;
+
 /**
  * Configuration of a private key.
  */
-class SAML2_Configuration_PrivateKey extends SAML2_Configuration_ArrayAdapter
+class PrivateKey extends ArrayAdapter
 {
     const NAME_NEW     = 'new';
     const NAME_DEFAULT = 'default';
@@ -26,15 +30,15 @@ class SAML2_Configuration_PrivateKey extends SAML2_Configuration_ArrayAdapter
     public function __construct($filePath, $name, $passphrase = NULL)
     {
         if (!is_string($filePath)) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType('string', $filePath);
+            throw InvalidArgumentException::invalidType('string', $filePath);
         }
 
         if (!is_string($name)) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType('string', $name);
+            throw InvalidArgumentException::invalidType('string', $name);
         }
 
         if ($passphrase && !is_string($passphrase)) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType('string', $passphrase);
+            throw InvalidArgumentException::invalidType('string', $passphrase);
         }
 
         $this->filePath = $filePath;
diff --git a/src/SAML2/Configuration/Queryable.php b/src/SAML2/Configuration/Queryable.php
index b41373279..8de48bed2 100644
--- a/src/SAML2/Configuration/Queryable.php
+++ b/src/SAML2/Configuration/Queryable.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace SAML2\Configuration;
+
 /**
- * Interface SAML2_Configuration_Queryable
+ * Interface \SAML2\Configuration\Queryable
  */
-interface SAML2_Configuration_Queryable
+interface Queryable
 {
     /**
      * Query for whether or not the configuration has a value for the key
diff --git a/src/SAML2/Configuration/ServiceProvider.php b/src/SAML2/Configuration/ServiceProvider.php
index c43eda98c..bd6e0c0ba 100644
--- a/src/SAML2/Configuration/ServiceProvider.php
+++ b/src/SAML2/Configuration/ServiceProvider.php
@@ -1,12 +1,14 @@
 <?php
 
+namespace SAML2\Configuration;
+
 /**
  * Basic Configuration Wrapper
  */
-class SAML2_Configuration_ServiceProvider extends SAML2_Configuration_ArrayAdapter implements
-    SAML2_Configuration_CertificateProvider,
-    SAML2_Configuration_DecryptionProvider,
-    SAML2_Configuration_EntityIdProvider
+class ServiceProvider extends ArrayAdapter implements
+    CertificateProvider,
+    DecryptionProvider,
+    EntityIdProvider
 {
     public function getKeys()
     {
@@ -46,7 +48,7 @@ public function getSharedKey()
     public function getPrivateKey($name, $required = FALSE)
     {
         $privateKeys = $this->get('privateKeys');
-        $key         = array_filter($privateKeys, function (SAML2_Configuration_PrivateKey $key) use ($name) {
+        $key         = array_filter($privateKeys, function (PrivateKey $key) use ($name) {
             return $key->getName() === $name;
         });
 
diff --git a/src/SAML2/Configuration/ServiceProviderAware.php b/src/SAML2/Configuration/ServiceProviderAware.php
index 55d25709a..02a72b628 100644
--- a/src/SAML2/Configuration/ServiceProviderAware.php
+++ b/src/SAML2/Configuration/ServiceProviderAware.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace SAML2\Configuration;
+
 /**
  * Interface for triggering setter injection
  */
-interface SAML2_Configuration_ServiceProviderAware
+interface ServiceProviderAware
 {
-    public function setServiceProvider(SAML2_Configuration_ServiceProvider $serviceProvider);
+    public function setServiceProvider(ServiceProvider $serviceProvider);
 }
diff --git a/src/SAML2/Configuration/SimpleSAMLConverter.php b/src/SAML2/Configuration/SimpleSAMLConverter.php
index cb031e492..64c755ca7 100644
--- a/src/SAML2/Configuration/SimpleSAMLConverter.php
+++ b/src/SAML2/Configuration/SimpleSAMLConverter.php
@@ -1,15 +1,17 @@
 <?php
 
+namespace SAML2\Configuration;
+
 /**
  * Backwards compatibility helper for SimpleSAMLphp
  */
-class SAML2_Configuration_SimpleSAMLConverter
+class SimpleSAMLConverter
 {
     /**
      * @param SimpleSAML_Configuration $configuration
      * @param string                   $certificatePrefix
      *
-     * @return SAML2_Configuration_IdentityProvider
+     * @return \SAML2\Configuration\IdentityProvider
      */
     public static function convertToIdentityProvider(
         SimpleSAML_Configuration $configuration,
@@ -19,14 +21,14 @@ public static function convertToIdentityProvider(
         static::enrichForDecryptionProvider($configuration, $pluckedConfiguration);
         static::enrichForIdentityProvider($configuration, $pluckedConfiguration);
 
-        return new SAML2_Configuration_IdentityProvider($pluckedConfiguration);
+        return new IdentityProvider($pluckedConfiguration);
     }
 
     /**
      * @param SimpleSAML_Configuration $configuration
      * @param string                   $certificatePrefix
      *
-     * @return SAML2_Configuration_ServiceProvider
+     * @return \SAML2\Configuration\ServiceProvider
      */
     public static function convertToServiceProvider(
         SimpleSAML_Configuration $configuration,
@@ -36,7 +38,7 @@ public static function convertToServiceProvider(
         static::enrichForServiceProvider($configuration, $pluckedConfiguration);
         static::enrichForDecryptionProvider($configuration, $pluckedConfiguration);
 
-        return new SAML2_Configuration_ServiceProvider($pluckedConfiguration);
+        return new ServiceProvider($pluckedConfiguration);
     }
 
     /**
@@ -102,17 +104,17 @@ private static function enrichForDecryptionProvider(
         }
 
         if ($configuration->has('new_privatekey')) {
-            $baseConfiguration['privateKeys'][] = new SAML2_Configuration_PrivateKey(
+            $baseConfiguration['privateKeys'][] = new PrivateKey(
                 $configuration->getString('new_privatekey'),
-                SAML2_Configuration_PrivateKey::NAME_NEW,
+                PrivateKey::NAME_NEW,
                 $configuration->getString('new_privatekey_pass', NULL)
             );
         }
 
         if ($configuration->getBoolean('assertion.encryption', FALSE)) {
-            $baseConfiguration['privateKeys'][] = new SAML2_Configuration_PrivateKey(
+            $baseConfiguration['privateKeys'][] = new PrivateKey(
                 $configuration->getString('privatekey'),
-                SAML2_Configuration_PrivateKey::NAME_DEFAULT,
+                PrivateKey::NAME_DEFAULT,
                 $configuration->getString('privatekey_pass', NULL)
             );
 
diff --git a/src/SAML2/Constants.php b/src/SAML2/Constants.php
index 6230f3710..4fa5bc933 100644
--- a/src/SAML2/Constants.php
+++ b/src/SAML2/Constants.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Various SAML 2 constants.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_Constants
+class Constants
 {
     /**
      * Password authentication context.
diff --git a/src/SAML2/DOMDocumentFactory.php b/src/SAML2/DOMDocumentFactory.php
index 4ba640778..232254bf9 100644
--- a/src/SAML2/DOMDocumentFactory.php
+++ b/src/SAML2/DOMDocumentFactory.php
@@ -1,6 +1,12 @@
 <?php
 
-final class SAML2_DOMDocumentFactory
+namespace SAML2;
+
+use SAML2\Exception\InvalidArgumentException;
+use SAML2\Exception\UnparseableXmlException;
+use SAML2\Exception\RuntimeException;
+
+final class DOMDocumentFactory
 {
     private function __construct()
     {
@@ -14,7 +20,7 @@ private function __construct()
     public static function fromString($xml)
     {
         if (!is_string($xml) || trim($xml) === '') {
-            throw SAML2_Exception_InvalidArgumentException::invalidType('non-empty string', $xml);
+            throw InvalidArgumentException::invalidType('non-empty string', $xml);
         }
 
         $entityLoader   = libxml_disable_entity_loader(TRUE);
@@ -36,14 +42,14 @@ public static function fromString($xml)
             $error = libxml_get_last_error();
             libxml_clear_errors();
 
-            throw new SAML2_Exception_UnparseableXmlException($error);
+            throw new UnparseableXmlException($error);
         }
 
         libxml_clear_errors();
 
         foreach ($domDocument->childNodes as $child) {
             if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
-                throw new SAML2_Exception_RuntimeException(
+                throw new RuntimeException(
                     'Dangerous XML detected, DOCTYPE nodes are not allowed in the XML body'
                 );
             }
@@ -60,29 +66,29 @@ public static function fromString($xml)
     public static function fromFile($file)
     {
         if (!is_string($file)) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType('string', $file);
+            throw InvalidArgumentException::invalidType('string', $file);
         }
 
         if (!is_file($file)) {
-            throw new SAML2_Exception_InvalidArgumentException(sprintf('Path "%s" is not a file', $file));
+            throw new InvalidArgumentException(sprintf('Path "%s" is not a file', $file));
         }
 
         if (!is_readable($file)) {
-            throw new SAML2_Exception_InvalidArgumentException(sprintf('File "%s" is not readable', $file));
+            throw new InvalidArgumentException(sprintf('File "%s" is not readable', $file));
         }
 
         // libxml_disable_entity_loader(true) disables DOMDocument::load() method
         // so we need to read the content and use DOMDocument::loadXML()
         $xml = file_get_contents($file);
         if ($xml === FALSE) {
-            throw new SAML2_Exception_RuntimeException(sprintf(
+            throw new RuntimeException(sprintf(
                 'Contents of readable file "%s" could not be gotten',
                 $file
             ));
         }
 
         if (trim($xml) === '') {
-            throw new SAML2_Exception_RuntimeException(sprintf('File "%s" does not have content', $file));
+            throw new RuntimeException(sprintf('File "%s" does not have content', $file));
         }
 
         return static::fromString($xml);
diff --git a/src/SAML2/EncryptedAssertion.php b/src/SAML2/EncryptedAssertion.php
index f531879d7..388983b6b 100644
--- a/src/SAML2/EncryptedAssertion.php
+++ b/src/SAML2/EncryptedAssertion.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Class handling encrypted assertions.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_EncryptedAssertion
+class EncryptedAssertion
 {
     /**
      * The current encrypted assertion.
@@ -26,7 +28,7 @@ public function __construct(DOMElement $xml = NULL)
             return;
         }
 
-        $data = SAML2_Utils::xpQuery($xml, './xenc:EncryptedData');
+        $data = Utils::xpQuery($xml, './xenc:EncryptedData');
         if (count($data) === 0) {
             throw new Exception('Missing encrypted data in <saml:EncryptedAssertion>.');
         } elseif (count($data) > 1) {
@@ -38,15 +40,15 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Set the assertion.
      *
-     * @param SAML2_Assertion $assertion The assertion.
+     * @param \SAML2\Assertion $assertion The assertion.
      * @param XMLSecurityKey  $key       The key we should use to encrypt the assertion.
      * @throws Exception
      */
-    public function setAssertion(SAML2_Assertion $assertion, XMLSecurityKey $key)
+    public function setAssertion(Assertion $assertion, XMLSecurityKey $key)
     {
         $xml = $assertion->toXML();
 
-        SAML2_Utils::getContainer()->debugMessage($xml, 'encrypt');
+        Utils::getContainer()->debugMessage($xml, 'encrypt');
 
         $enc = new XMLSecEnc();
         $enc->setNode($xml);
@@ -81,15 +83,15 @@ public function setAssertion(SAML2_Assertion $assertion, XMLSecurityKey $key)
      *
      * @param  XMLSecurityKey  $inputKey  The key we should use to decrypt the assertion.
      * @param  array           $blacklist Blacklisted decryption algorithms.
-     * @return SAML2_Assertion The decrypted assertion.
+     * @return \SAML2\Assertion The decrypted assertion.
      */
     public function getAssertion(XMLSecurityKey $inputKey, array $blacklist = array())
     {
-        $assertionXML = SAML2_Utils::decryptElement($this->encryptedData, $inputKey, $blacklist);
+        $assertionXML = Utils::decryptElement($this->encryptedData, $inputKey, $blacklist);
 
-        SAML2_Utils::getContainer()->debugMessage($assertionXML, 'decrypt');
+        Utils::getContainer()->debugMessage($assertionXML, 'decrypt');
 
-        return new SAML2_Assertion($assertionXML);
+        return new Assertion($assertionXML);
     }
 
     /**
@@ -101,13 +103,13 @@ public function getAssertion(XMLSecurityKey $inputKey, array $blacklist = array(
     public function toXML(DOMNode $parentElement = NULL)
     {
         if ($parentElement === NULL) {
-            $document = SAML2_DOMDocumentFactory::create();
+            $document = DOMDocumentFactory::create();
             $parentElement = $document;
         } else {
             $document = $parentElement->ownerDocument;
         }
 
-        $root = $document->createElementNS(SAML2_Constants::NS_SAML, 'saml:' . 'EncryptedAssertion');
+        $root = $document->createElementNS(Constants::NS_SAML, 'saml:' . 'EncryptedAssertion');
         $parentElement->appendChild($root);
 
         $root->appendChild($document->importNode($this->encryptedData, TRUE));
diff --git a/src/SAML2/Exception/InvalidArgumentException.php b/src/SAML2/Exception/InvalidArgumentException.php
index 877e273b1..8def35a42 100644
--- a/src/SAML2/Exception/InvalidArgumentException.php
+++ b/src/SAML2/Exception/InvalidArgumentException.php
@@ -1,12 +1,14 @@
 <?php
 
-class SAML2_Exception_InvalidArgumentException extends InvalidArgumentException implements SAML2_Exception_Throwable
+namespace SAML2\Exception;
+
+class InvalidArgumentException extends InvalidArgumentException implements Throwable
 {
     /**
      * @param string $expected description of expected type
      * @param mixed  $parameter the parameter that is not of the expected type.
      *
-     * @return SAML2_Exception_InvalidArgumentException
+     * @return \SAML2\Exception\InvalidArgumentException
      */
     public static function invalidType($expected, $parameter)
     {
diff --git a/src/SAML2/Exception/RuntimeException.php b/src/SAML2/Exception/RuntimeException.php
index c428722a8..ca5750b4c 100644
--- a/src/SAML2/Exception/RuntimeException.php
+++ b/src/SAML2/Exception/RuntimeException.php
@@ -1,8 +1,10 @@
 <?php
 
+namespace SAML2\Exception;
+
 /**
  * Named exception
  */
-class SAML2_Exception_RuntimeException extends RuntimeException implements SAML2_Exception_Throwable
+class RuntimeException extends RuntimeException implements Throwable
 {
 }
diff --git a/src/SAML2/Exception/Throwable.php b/src/SAML2/Exception/Throwable.php
index 5cca96dae..5384fbac7 100644
--- a/src/SAML2/Exception/Throwable.php
+++ b/src/SAML2/Exception/Throwable.php
@@ -1,10 +1,12 @@
 <?php
 
+namespace SAML2\Exception;
+
 /**
- * Interface SAML2_Exception_ExceptionInterface
+ * Interface \SAML2\Exception\ExceptionInterface
  *
  * Marker interface to identify SAML2 Exceptions
  */
-interface SAML2_Exception_Throwable
+interface Throwable
 {
 }
diff --git a/src/SAML2/Exception/UnparseableXmlException.php b/src/SAML2/Exception/UnparseableXmlException.php
index e052d5120..28ea7b913 100644
--- a/src/SAML2/Exception/UnparseableXmlException.php
+++ b/src/SAML2/Exception/UnparseableXmlException.php
@@ -1,6 +1,8 @@
 <?php
 
-final class SAML2_Exception_UnparseableXmlException extends SAML2_Exception_RuntimeException
+namespace SAML2\Exception;
+
+final class UnparseableXmlException extends RuntimeException
 {
     private static $levelMap = array(
         LIBXML_ERR_WARNING => 'WARNING',
diff --git a/src/SAML2/HTTPArtifact.php b/src/SAML2/HTTPArtifact.php
index a67eccb6b..ec48dfdee 100644
--- a/src/SAML2/HTTPArtifact.php
+++ b/src/SAML2/HTTPArtifact.php
@@ -1,5 +1,9 @@
 <?php
 
+namespace SAML2;
+
+use SAML2\Utilities\Temporal;
+
 /**
  * Class which implements the HTTP-Artifact binding.
  *
@@ -8,7 +12,7 @@
  *
  * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
-class SAML2_HTTPArtifact extends SAML2_Binding
+class HTTPArtifact extends Binding
 {
     /**
      * @var SimpleSAML_Configuration
@@ -18,11 +22,11 @@ class SAML2_HTTPArtifact extends SAML2_Binding
     /**
      * Create the redirect URL for a message.
      *
-     * @param  SAML2_Message $message The message.
+     * @param  \SAML2\Message $message The message.
      * @return string        The URL the user should be redirected to in order to send a message.
      * @throws Exception
      */
-    public function getRedirectURL(SAML2_Message $message)
+    public function getRedirectURL(Message $message)
     {
         $store = SimpleSAML_Store::getInstance();
         if ($store === FALSE) {
@@ -34,7 +38,7 @@ public function getRedirectURL(SAML2_Message $message)
         $artifactData = $message->toUnsignedXML();
         $artifactDataString = $artifactData->ownerDocument->saveXML($artifactData);
 
-        $store->set('artifact', $artifact, $artifactDataString, SAML2_Utilities_Temporal::getTime() + 15*60);
+        $store->set('artifact', $artifact, $artifactDataString, Temporal::getTime() + 15*60);
 
         $params = array(
             'SAMLart' => $artifact,
@@ -52,12 +56,12 @@ public function getRedirectURL(SAML2_Message $message)
      *
      * Note: This function never returns.
      *
-     * @param SAML2_Message $message The message we should send.
+     * @param \SAML2\Message $message The message we should send.
      */
-    public function send(SAML2_Message $message)
+    public function send(Message $message)
     {
         $destination = $this->getRedirectURL($message);
-        SAML2_Utils::getContainer()->redirect($destination);
+        Utils::getContainer()->redirect($destination);
     }
 
     /**
@@ -65,7 +69,7 @@ public function send(SAML2_Message $message)
      *
      * Throws an exception if it is unable receive the message.
      *
-     * @return SAML2_Message The received message.
+     * @return \SAML2\Message The received message.
      * @throws Exception
      */
     public function receive()
@@ -99,10 +103,10 @@ public function receive()
             throw new Exception('No ArtifactResolutionService with the correct index.');
         }
 
-        SAML2_Utils::getContainer()->getLogger()->debug("ArtifactResolutionService endpoint being used is := " . $endpoint['Location']);
+        Utils::getContainer()->getLogger()->debug("ArtifactResolutionService endpoint being used is := " . $endpoint['Location']);
 
         //Construct the ArtifactResolve Request
-        $ar = new SAML2_ArtifactResolve();
+        $ar = new ArtifactResolve();
 
         /* Set the request attributes */
 
@@ -113,10 +117,10 @@ public function receive()
         /* Sign the request */
         sspmod_saml_Message::addSign($this->spMetadata, $idpMetadata, $ar); // Shoaib - moved from the SOAPClient.
 
-        $soap = new SAML2_SOAPClient();
+        $soap = new SOAPClient();
 
         // Send message through SoapClient
-        /** @var SAML2_ArtifactResponse $artifactResponse */
+        /** @var \SAML2\ArtifactResponse $artifactResponse */
         $artifactResponse = $soap->send($ar, $this->spMetadata);
 
         if (!$artifactResponse->isSuccess()) {
@@ -130,7 +134,7 @@ public function receive()
             return NULL;
         }
 
-        $samlResponse = SAML2_Message::fromXML($xml);
+        $samlResponse = Message::fromXML($xml);
         $samlResponse->addValidator(array(get_class($this), 'validateSignature'), $artifactResponse);
 
         if (isset($_REQUEST['RelayState'])) {
@@ -151,11 +155,11 @@ public function setSPMetadata(SimpleSAML_Configuration $sp)
     /**
      * A validator which returns TRUE if the ArtifactResponse was signed with the given key
      *
-     * @param SAML2_ArtifactResponse $message
+     * @param \SAML2\ArtifactResponse $message
      * @param XMLSecurityKey $key
      * @return bool
      */
-    public static function validateSignature(SAML2_ArtifactResponse $message, XMLSecurityKey $key)
+    public static function validateSignature(ArtifactResponse $message, XMLSecurityKey $key)
     {
         return $message->validate($key);
     }
diff --git a/src/SAML2/HTTPPost.php b/src/SAML2/HTTPPost.php
index 5167de303..b6ee4757e 100644
--- a/src/SAML2/HTTPPost.php
+++ b/src/SAML2/HTTPPost.php
@@ -1,20 +1,22 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Class which implements the HTTP-POST binding.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_HTTPPost extends SAML2_Binding
+class HTTPPost extends Binding
 {
     /**
      * Send a SAML 2 message using the HTTP-POST binding.
      *
      * Note: This function never returns.
      *
-     * @param SAML2_Message $message The message we should send.
+     * @param \SAML2\Message $message The message we should send.
      */
-    public function send(SAML2_Message $message)
+    public function send(Message $message)
     {
         if ($this->destination === NULL) {
             $destination = $message->getDestination();
@@ -26,11 +28,11 @@ public function send(SAML2_Message $message)
         $msgStr = $message->toSignedXML();
         $msgStr = $msgStr->ownerDocument->saveXML($msgStr);
 
-        SAML2_Utils::getContainer()->debugMessage($msgStr, 'out');
+        Utils::getContainer()->debugMessage($msgStr, 'out');
 
         $msgStr = base64_encode($msgStr);
 
-        if ($message instanceof SAML2_Request) {
+        if ($message instanceof Request) {
             $msgType = 'SAMLRequest';
         } else {
             $msgType = 'SAMLResponse';
@@ -43,7 +45,7 @@ public function send(SAML2_Message $message)
             $post['RelayState'] = $relayState;
         }
 
-        SAML2_Utils::getContainer()->postRedirect($destination, $post);
+        Utils::getContainer()->postRedirect($destination, $post);
     }
 
     /**
@@ -51,7 +53,7 @@ public function send(SAML2_Message $message)
      *
      * Throws an exception if it is unable receive the message.
      *
-     * @return SAML2_Message The received message.
+     * @return \SAML2\Message The received message.
      * @throws Exception
      */
     public function receive()
@@ -66,12 +68,12 @@ public function receive()
 
         $msg = base64_decode($msg);
 
-        SAML2_Utils::getContainer()->debugMessage($msg, 'in');
+        Utils::getContainer()->debugMessage($msg, 'in');
 
-        $document = SAML2_DOMDocumentFactory::fromString($msg);
+        $document = DOMDocumentFactory::fromString($msg);
         $xml = $document->firstChild;
 
-        $msg = SAML2_Message::fromXML($xml);
+        $msg = Message::fromXML($xml);
 
         if (array_key_exists('RelayState', $_POST)) {
             $msg->setRelayState($_POST['RelayState']);
diff --git a/src/SAML2/HTTPRedirect.php b/src/SAML2/HTTPRedirect.php
index 0854c08d7..0b95d32f6 100644
--- a/src/SAML2/HTTPRedirect.php
+++ b/src/SAML2/HTTPRedirect.php
@@ -1,21 +1,23 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Class which implements the HTTP-Redirect binding.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_HTTPRedirect extends SAML2_Binding
+class HTTPRedirect extends Binding
 {
     const DEFLATE = 'urn:oasis:names:tc:SAML:2.0:bindings:URL-Encoding:DEFLATE';
 
     /**
      * Create the redirect URL for a message.
      *
-     * @param  SAML2_Message $message The message.
+     * @param  \SAML2\Message $message The message.
      * @return string        The URL the user should be redirected to in order to send a message.
      */
-    public function getRedirectURL(SAML2_Message $message)
+    public function getRedirectURL(Message $message)
     {
         if ($this->destination === NULL) {
             $destination = $message->getDestination();
@@ -30,14 +32,14 @@ public function getRedirectURL(SAML2_Message $message)
         $msgStr = $message->toUnsignedXML();
         $msgStr = $msgStr->ownerDocument->saveXML($msgStr);
 
-        SAML2_Utils::getContainer()->debugMessage($msgStr, 'out');
+        Utils::getContainer()->debugMessage($msgStr, 'out');
 
         $msgStr = gzdeflate($msgStr);
         $msgStr = base64_encode($msgStr);
 
         /* Build the query string. */
 
-        if ($message instanceof SAML2_Request) {
+        if ($message instanceof Request) {
             $msg = 'SAMLRequest=';
         } else {
             $msg = 'SAMLResponse=';
@@ -70,13 +72,13 @@ public function getRedirectURL(SAML2_Message $message)
      *
      * Note: This function never returns.
      *
-     * @param SAML2_Message $message The message we should send.
+     * @param \SAML2\Message $message The message we should send.
      */
-    public function send(SAML2_Message $message)
+    public function send(Message $message)
     {
         $destination = $this->getRedirectURL($message);
-        SAML2_Utils::getContainer()->getLogger()->debug('Redirect to ' . strlen($destination) . ' byte URL: ' . $destination);
-        SAML2_Utils::getContainer()->redirect($destination);
+        Utils::getContainer()->getLogger()->debug('Redirect to ' . strlen($destination) . ' byte URL: ' . $destination);
+        Utils::getContainer()->redirect($destination);
     }
 
     /**
@@ -84,7 +86,7 @@ public function send(SAML2_Message $message)
      *
      * Throws an exception if it is unable receive the message.
      *
-     * @return SAML2_Message The received message.
+     * @return \SAML2\Message The received message.
      * @throws Exception
      *
      * NPath is currently too high but solving that just moves code around.
@@ -115,10 +117,10 @@ public function receive()
             throw new Exception('Error while inflating SAML message.');
         }
 
-        SAML2_Utils::getContainer()->debugMessage($message, 'in');
-        $document = SAML2_DOMDocumentFactory::fromString($message);
+        Utils::getContainer()->debugMessage($message, 'in');
+        $document = DOMDocumentFactory::fromString($message);
         $xml      = $document->firstChild;
-        $message  = SAML2_Message::fromXML($xml);
+        $message  = Message::fromXML($xml);
 
         if (array_key_exists('RelayState', $data)) {
             $message->setRelayState($data['RelayState']);
@@ -219,7 +221,7 @@ public static function validateSignature(array $data, XMLSecurityKey $key)
             throw new Exception('Invalid key type for validating signature on query string.');
         }
         if ($key->type !== $sigAlg) {
-            $key = SAML2_Utils::castKey($key, $sigAlg);
+            $key = Utils::castKey($key, $sigAlg);
         }
 
         if (!$key->verifySignature($query, $signature)) {
diff --git a/src/SAML2/LogoutRequest.php b/src/SAML2/LogoutRequest.php
index 307f48a9b..78ac261c3 100644
--- a/src/SAML2/LogoutRequest.php
+++ b/src/SAML2/LogoutRequest.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Class for SAML 2 logout request messages.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_LogoutRequest extends SAML2_Request
+class LogoutRequest extends Request
 {
     /**
      * The expiration time of this request.
@@ -54,10 +56,10 @@ public function __construct(DOMElement $xml = NULL)
         }
 
         if ($xml->hasAttribute('NotOnOrAfter')) {
-            $this->notOnOrAfter = SAML2_Utils::xsDateTimeToTimestamp($xml->getAttribute('NotOnOrAfter'));
+            $this->notOnOrAfter = Utils::xsDateTimeToTimestamp($xml->getAttribute('NotOnOrAfter'));
         }
 
-        $nameId = SAML2_Utils::xpQuery($xml, './saml_assertion:NameID | ./saml_assertion:EncryptedID/xenc:EncryptedData');
+        $nameId = Utils::xpQuery($xml, './saml_assertion:NameID | ./saml_assertion:EncryptedID/xenc:EncryptedData');
         if (empty($nameId)) {
             throw new Exception('Missing <saml:NameID> or <saml:EncryptedID> in <samlp:LogoutRequest>.');
         } elseif (count($nameId) > 1) {
@@ -68,10 +70,10 @@ public function __construct(DOMElement $xml = NULL)
             /* The NameID element is encrypted. */
             $this->encryptedNameId = $nameId;
         } else {
-            $this->nameId = SAML2_Utils::parseNameId($nameId);
+            $this->nameId = Utils::parseNameId($nameId);
         }
 
-        $sessionIndexes = SAML2_Utils::xpQuery($xml, './saml_protocol:SessionIndex');
+        $sessionIndexes = Utils::xpQuery($xml, './saml_protocol:SessionIndex');
         foreach ($sessionIndexes as $sessionIndex) {
             $this->sessionIndexes[] = trim($sessionIndex->textContent);
         }
@@ -121,13 +123,13 @@ public function isNameIdEncrypted()
     public function encryptNameId(XMLSecurityKey $key)
     {
         /* First create a XML representation of the NameID. */
-        $doc = SAML2_DOMDocumentFactory::create();
+        $doc = DOMDocumentFactory::create();
         $root = $doc->createElement('root');
         $doc->appendChild($root);
-        SAML2_Utils::addNameId($root, $this->nameId);
+        Utils::addNameId($root, $this->nameId);
         $nameId = $root->firstChild;
 
-        SAML2_Utils::getContainer()->debugMessage($nameId, 'encrypt');
+        Utils::getContainer()->debugMessage($nameId, 'encrypt');
 
         /* Encrypt the NameID. */
         $enc = new XMLSecEnc();
@@ -156,9 +158,9 @@ public function decryptNameId(XMLSecurityKey $key, array $blacklist = array())
             return;
         }
 
-        $nameId = SAML2_Utils::decryptElement($this->encryptedNameId, $key, $blacklist);
-        SAML2_Utils::getContainer()->debugMessage($nameId, 'decrypt');
-        $this->nameId = SAML2_Utils::parseNameId($nameId);
+        $nameId = Utils::decryptElement($this->encryptedNameId, $key, $blacklist);
+        Utils::getContainer()->debugMessage($nameId, 'decrypt');
+        $this->nameId = Utils::parseNameId($nameId);
 
         $this->encryptedNameId = NULL;
     }
@@ -181,9 +183,9 @@ public function getNameId()
     /**
      * Set the name identifier of the session that should be terminated.
      *
-     * The name identifier must be in the format accepted by SAML2_message::buildNameId().
+     * The name identifier must be in the format accepted by \SAML2\message::buildNameId().
      *
-     * @see SAML2_message::buildNameId()
+     * @see \SAML2\message::buildNameId()
      * @param array $nameId The name identifier of the session that should be terminated.
      */
     public function setNameId($nameId)
@@ -257,15 +259,15 @@ public function toUnsignedXML()
         }
 
         if ($this->encryptedNameId === NULL) {
-            SAML2_Utils::addNameId($root, $this->nameId);
+            Utils::addNameId($root, $this->nameId);
         } else {
-            $eid = $root->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:' . 'EncryptedID');
+            $eid = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:' . 'EncryptedID');
             $root->appendChild($eid);
             $eid->appendChild($root->ownerDocument->importNode($this->encryptedNameId, TRUE));
         }
 
         foreach ($this->sessionIndexes as $sessionIndex) {
-            SAML2_Utils::addString($root, SAML2_Constants::NS_SAMLP, 'SessionIndex', $sessionIndex);
+            Utils::addString($root, Constants::NS_SAMLP, 'SessionIndex', $sessionIndex);
         }
 
         return $root;
diff --git a/src/SAML2/LogoutResponse.php b/src/SAML2/LogoutResponse.php
index 4ebee4da4..20f05278f 100644
--- a/src/SAML2/LogoutResponse.php
+++ b/src/SAML2/LogoutResponse.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Class for SAML 2 LogoutResponse messages.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_LogoutResponse extends SAML2_StatusResponse
+class LogoutResponse extends StatusResponse
 {
     /**
      * Constructor for SAML 2 response messages.
diff --git a/src/SAML2/Message.php b/src/SAML2/Message.php
index 90e28daca..9f9e55df2 100644
--- a/src/SAML2/Message.php
+++ b/src/SAML2/Message.php
@@ -1,5 +1,10 @@
 <?php
 
+namespace SAML2;
+
+use SAML2\Utilities\Temporal;
+use SAML2\XML\samlp\Extensions;
+
 /**
  * Base class for all SAML 2 messages.
  *
@@ -10,7 +15,7 @@
  *
  * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
  */
-abstract class SAML2_Message implements SAML2_SignedElement
+abstract class Message implements SignedElement
 {
     /**
      * Request extensions.
@@ -54,7 +59,7 @@ abstract class SAML2_Message implements SAML2_SignedElement
      *
      * @var string|NULL
      */
-    private $consent = SAML2_Constants::CONSENT_UNSPECIFIED;
+    private $consent = Constants::CONSENT_UNSPECIFIED;
 
     /**
      * The entity id of the issuer of this message, or NULL if unknown.
@@ -127,8 +132,8 @@ protected function __construct($tagName, DOMElement $xml = NULL)
         assert('is_string($tagName)');
         $this->tagName = $tagName;
 
-        $this->id = SAML2_Utils::getContainer()->generateId();
-        $this->issueInstant = SAML2_Utilities_Temporal::getTime();
+        $this->id = Utils::getContainer()->generateId();
+        $this->issueInstant = Temporal::getTime();
         $this->certificates = array();
         $this->validators = array();
 
@@ -146,7 +151,7 @@ protected function __construct($tagName, DOMElement $xml = NULL)
             throw new Exception('Unsupported version: ' . $xml->getAttribute('Version'));
         }
 
-        $this->issueInstant = SAML2_Utils::xsDateTimeToTimestamp($xml->getAttribute('IssueInstant'));
+        $this->issueInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('IssueInstant'));
 
         if ($xml->hasAttribute('Destination')) {
             $this->destination = $xml->getAttribute('Destination');
@@ -156,14 +161,14 @@ protected function __construct($tagName, DOMElement $xml = NULL)
             $this->consent = $xml->getAttribute('Consent');
         }
 
-        $issuer = SAML2_Utils::xpQuery($xml, './saml_assertion:Issuer');
+        $issuer = Utils::xpQuery($xml, './saml_assertion:Issuer');
         if (!empty($issuer)) {
             $this->issuer = trim($issuer[0]->textContent);
         }
 
         /* Validate the signature element of the message. */
         try {
-            $sig = SAML2_Utils::validateElement($xml);
+            $sig = Utils::validateElement($xml);
 
             if ($sig !== FALSE) {
                 $this->messageContainedSignatureUponConstruction = TRUE;
@@ -178,7 +183,7 @@ protected function __construct($tagName, DOMElement $xml = NULL)
             /* Ignore signature validation errors. */
         }
 
-        $this->extensions = SAML2_XML_samlp_Extensions::getList($xml);
+        $this->extensions = Extensions::getList($xml);
     }
 
     /**
@@ -307,7 +312,7 @@ public function setDestination($destination)
      * Set the given consent for this message.
      *
      * Most likely (though not required) a value of rn:oasis:names:tc:SAML:2.0:consent.
-     * @see SAML2_Constants
+     * @see \SAML2\Constants
      *
      * @param string $consent
      */
@@ -322,7 +327,7 @@ public function setConsent($consent)
      * Set the given consent for this message.
      *
      * Most likely (though not required) a value of rn:oasis:names:tc:SAML:2.0:consent.
-     * @see SAML2_Constants
+     * @see \SAML2\Constants
      *
      * @return string Consent
      */
@@ -394,14 +399,14 @@ public function setRelayState($relayState)
      */
     public function toUnsignedXML()
     {
-        $this->document = SAML2_DOMDocumentFactory::create();
+        $this->document = DOMDocumentFactory::create();
 
-        $root = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'samlp:' . $this->tagName);
+        $root = $this->document->createElementNS(Constants::NS_SAMLP, 'samlp:' . $this->tagName);
         $this->document->appendChild($root);
 
         /* Ugly hack to add another namespace declaration to the root element. */
-        $root->setAttributeNS(SAML2_Constants::NS_SAML, 'saml:tmp', 'tmp');
-        $root->removeAttributeNS(SAML2_Constants::NS_SAML, 'tmp');
+        $root->setAttributeNS(Constants::NS_SAML, 'saml:tmp', 'tmp');
+        $root->removeAttributeNS(Constants::NS_SAML, 'tmp');
 
         $root->setAttribute('ID', $this->id);
         $root->setAttribute('Version', '2.0');
@@ -410,16 +415,16 @@ public function toUnsignedXML()
         if ($this->destination !== NULL) {
             $root->setAttribute('Destination', $this->destination);
         }
-        if ($this->consent !== NULL && $this->consent !== SAML2_Constants::CONSENT_UNSPECIFIED) {
+        if ($this->consent !== NULL && $this->consent !== Constants::CONSENT_UNSPECIFIED) {
             $root->setAttribute('Consent', $this->consent);
         }
 
         if ($this->issuer !== NULL) {
-            SAML2_Utils::addString($root, SAML2_Constants::NS_SAML, 'saml:Issuer', $this->issuer);
+            Utils::addString($root, Constants::NS_SAML, 'saml:Issuer', $this->issuer);
         }
 
         if (!empty($this->extensions)) {
-            SAML2_XML_samlp_Extensions::addList($root, $this->extensions);
+            Extensions::addList($root, $this->extensions);
         }
 
         return $root;
@@ -458,7 +463,7 @@ public function toSignedXML()
         }
 
 
-        SAML2_Utils::insertSignature($this->signatureKey, $this->certificates, $root, $insertBefore);
+        Utils::insertSignature($this->signatureKey, $this->certificates, $root, $insertBefore);
 
         return $root;
     }
@@ -516,30 +521,30 @@ public function getCertificates()
      * Convert an XML element into a message.
      *
      * @param  DOMElement    $xml The root XML element.
-     * @return SAML2_Message The message.
+     * @return \SAML2\Message The message.
      * @throws Exception
      */
     public static function fromXML(DOMElement $xml)
     {
-        if ($xml->namespaceURI !== SAML2_Constants::NS_SAMLP) {
+        if ($xml->namespaceURI !== Constants::NS_SAMLP) {
             throw new Exception('Unknown namespace of SAML message: ' . var_export($xml->namespaceURI, TRUE));
         }
 
         switch ($xml->localName) {
             case 'AttributeQuery':
-                return new SAML2_AttributeQuery($xml);
+                return new AttributeQuery($xml);
             case 'AuthnRequest':
-                return new SAML2_AuthnRequest($xml);
+                return new AuthnRequest($xml);
             case 'LogoutResponse':
-                return new SAML2_LogoutResponse($xml);
+                return new LogoutResponse($xml);
             case 'LogoutRequest':
-                return new SAML2_LogoutRequest($xml);
+                return new LogoutRequest($xml);
             case 'Response':
-                return new SAML2_Response($xml);
+                return new Response($xml);
             case 'ArtifactResponse':
-                return new SAML2_ArtifactResponse($xml);
+                return new ArtifactResponse($xml);
             case 'ArtifactResolve':
-                return new SAML2_ArtifactResolve($xml);
+                return new ArtifactResolve($xml);
             default:
                 throw new Exception('Unknown SAML message: ' . var_export($xml->localName, TRUE));
         }
@@ -549,7 +554,7 @@ public static function fromXML(DOMElement $xml)
     /**
      * Retrieve the Extensions.
      *
-     * @return SAML2_XML_samlp_Extensions.
+     * @return \SAML2\XML\samlp\Extensions.
      */
     public function getExtensions()
     {
diff --git a/src/SAML2/Request.php b/src/SAML2/Request.php
index dc7e3d53e..a18a70426 100644
--- a/src/SAML2/Request.php
+++ b/src/SAML2/Request.php
@@ -1,14 +1,16 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Base class for all SAML 2 request messages.
  *
  * Implements samlp:RequestAbstractType. All of the elements in that type is
- * stored in the SAML2_Message class, and this class is therefore empty. It
+ * stored in the \SAML2\Message class, and this class is therefore empty. It
  * is included mainly to make it easy to separate requests from responses.
  *
  * @package SimpleSAMLphp
  */
-abstract class SAML2_Request extends SAML2_Message
+abstract class Request extends Message
 {
 }
diff --git a/src/SAML2/Response.php b/src/SAML2/Response.php
index 3a4f4ea31..4987c069b 100644
--- a/src/SAML2/Response.php
+++ b/src/SAML2/Response.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Class for SAML 2 Response messages.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_Response extends SAML2_StatusResponse
+class Response extends StatusResponse
 {
     /**
      * The assertions in this response.
@@ -28,14 +30,14 @@ public function __construct(DOMElement $xml = NULL)
         }
 
         for ($node = $xml->firstChild; $node !== NULL; $node = $node->nextSibling) {
-            if ($node->namespaceURI !== SAML2_Constants::NS_SAML) {
+            if ($node->namespaceURI !== Constants::NS_SAML) {
                 continue;
             }
 
             if ($node->localName === 'Assertion') {
-                $this->assertions[] = new SAML2_Assertion($node);
+                $this->assertions[] = new Assertion($node);
             } elseif ($node->localName === 'EncryptedAssertion') {
-                $this->assertions[] = new SAML2_EncryptedAssertion($node);
+                $this->assertions[] = new EncryptedAssertion($node);
             }
         }
     }
@@ -43,7 +45,7 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Retrieve the assertions in this response.
      *
-     * @return SAML2_Assertion[]|SAML2_EncryptedAssertion[]
+     * @return \SAML2\Assertion[]|\SAML2\EncryptedAssertion[]
      */
     public function getAssertions()
     {
@@ -53,7 +55,7 @@ public function getAssertions()
     /**
      * Set the assertions that should be included in this response.
      *
-     * @param SAML2_Assertion[]|SAML2_EncryptedAssertion[] The assertions.
+     * @param \SAML2\Assertion[]|\SAML2\EncryptedAssertion[] The assertions.
      */
     public function setAssertions(array $assertions)
     {
@@ -69,7 +71,7 @@ public function toUnsignedXML()
     {
         $root = parent::toUnsignedXML();
 
-        /** @var SAML2_Assertion|SAML2_EncryptedAssertion $assertion */
+        /** @var \SAML2\Assertion|\SAML2\EncryptedAssertion $assertion */
         foreach ($this->assertions as $assertion) {
 
             $assertion->toXML($root);
diff --git a/src/SAML2/Response/Exception/InvalidResponseException.php b/src/SAML2/Response/Exception/InvalidResponseException.php
index 992e36e88..4bbc2e308 100644
--- a/src/SAML2/Response/Exception/InvalidResponseException.php
+++ b/src/SAML2/Response/Exception/InvalidResponseException.php
@@ -1,5 +1,9 @@
 <?php
 
-class SAML2_Response_Exception_InvalidResponseException extends \RuntimeException implements SAML2_Exception_Throwable
+namespace SAML2\Response\Exception;
+
+use SAML2\Exception\Throwable;
+
+class InvalidResponseException extends \RuntimeException implements Throwable
 {
 }
diff --git a/src/SAML2/Response/Exception/InvalidSignatureException.php b/src/SAML2/Response/Exception/InvalidSignatureException.php
index b79a97575..fdcc6c502 100644
--- a/src/SAML2/Response/Exception/InvalidSignatureException.php
+++ b/src/SAML2/Response/Exception/InvalidSignatureException.php
@@ -1,5 +1,7 @@
 <?php
 
-class SAML2_Response_Exception_InvalidSignatureException extends SAML2_Response_Exception_InvalidResponseException
+namespace SAML2\Response\Exception;
+
+class InvalidSignatureException extends InvalidResponseException
 {
 }
diff --git a/src/SAML2/Response/Exception/NoAssertionsFoundException.php b/src/SAML2/Response/Exception/NoAssertionsFoundException.php
index e6decfea8..c357223dd 100644
--- a/src/SAML2/Response/Exception/NoAssertionsFoundException.php
+++ b/src/SAML2/Response/Exception/NoAssertionsFoundException.php
@@ -1,5 +1,7 @@
 <?php
 
-class SAML2_Response_Exception_NoAssertionsFoundException extends SAML2_Response_Exception_InvalidResponseException
+namespace SAML2\Response\Exception;
+
+class NoAssertionsFoundException extends InvalidResponseException
 {
 }
diff --git a/src/SAML2/Response/Exception/PreconditionNotMetException.php b/src/SAML2/Response/Exception/PreconditionNotMetException.php
index bab4cade4..41a9ada0d 100644
--- a/src/SAML2/Response/Exception/PreconditionNotMetException.php
+++ b/src/SAML2/Response/Exception/PreconditionNotMetException.php
@@ -1,11 +1,15 @@
 <?php
 
+namespace SAML2\Response\Exception;
+
+use SAML2\Response\Validation\Result;
+
 /**
  * Named exception to indicate that the preconditions for processing the SAML response have not been met.
  */
-class SAML2_Response_Exception_PreconditionNotMetException extends SAML2_Response_Exception_InvalidResponseException
+class PreconditionNotMetException extends InvalidResponseException
 {
-    public static function createFromValidationResult(SAML2_Response_Validation_Result $result)
+    public static function createFromValidationResult(Result $result)
     {
         $message = sprintf(
             'Cannot process response, preconditions not met: "%s"',
diff --git a/src/SAML2/Response/Exception/UnencryptedAssertionFoundException.php b/src/SAML2/Response/Exception/UnencryptedAssertionFoundException.php
index 637299e56..c2d426686 100644
--- a/src/SAML2/Response/Exception/UnencryptedAssertionFoundException.php
+++ b/src/SAML2/Response/Exception/UnencryptedAssertionFoundException.php
@@ -1,6 +1,10 @@
 <?php
 
-class SAML2_Response_Exception_UnencryptedAssertionFoundException extends \RuntimeException implements
-    SAML2_Exception_Throwable
+namespace SAML2\Response\Exception;
+
+use SAML2\Exception\Throwable;
+
+class UnencryptedAssertionFoundException extends \RuntimeException implements
+    Throwable
 {
 }
diff --git a/src/SAML2/Response/Exception/UnsignedResponseException.php b/src/SAML2/Response/Exception/UnsignedResponseException.php
index 05cb05f30..e47ad3688 100644
--- a/src/SAML2/Response/Exception/UnsignedResponseException.php
+++ b/src/SAML2/Response/Exception/UnsignedResponseException.php
@@ -1,5 +1,9 @@
 <?php
 
-class SAML2_Response_Exception_UnsignedResponseException extends RuntimeException implements SAML2_Exception_Throwable
+namespace SAML2\Response\Exception;
+
+use SAML2\Exception\Throwable;
+
+class UnsignedResponseException extends RuntimeException implements Throwable
 {
 }
diff --git a/src/SAML2/Response/Processor.php b/src/SAML2/Response/Processor.php
index 652e51d5f..5f7440ace 100644
--- a/src/SAML2/Response/Processor.php
+++ b/src/SAML2/Response/Processor.php
@@ -1,9 +1,23 @@
 <?php
 
+namespace SAML2\Response;
+
+use SAML2\Signature\Validator;
+use SAML2\Configuration\ServiceProvider;
+use SAML2\Configuration\IdentityProvider;
+use SAML2\Configuration\Destination;
+use SAML2\Response;
+use SAML2\Response\Validation\PreconditionValidator;
+use SAML2\Assertion\ProcessorBuilder;
+use SAML2\Response\Exception\PreconditionNotMetException;
+use SAML2\Response\Exception\InvalidResponseException;
+use SAML2\Response\Exception\NoAssertionsFoundException;
+use SAML2\Response\Exception\UnsignedResponseException;
+
 /**
  * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - due to specific exceptions
  */
-class SAML2_Response_Processor
+class Processor
 {
     /**
      * @var \Psr\Log\LoggerInterface
@@ -11,17 +25,17 @@ class SAML2_Response_Processor
     private $logger;
 
     /**
-     * @var SAML2_Response_Validation_PreconditionValidator
+     * @var \SAML2\Response\Validation\PreconditionValidator
      */
     private $preconditionValidator;
 
     /**
-     * @var SAML2_Signature_Validator
+     * @var \SAML2\Signature\Validator
      */
     private $signatureValidator;
 
     /**
-     * @var SAML2_Assertion_Processor
+     * @var \SAML2\Assertion\Processor
      */
     private $assertionProcessor;
 
@@ -41,25 +55,25 @@ public function __construct(\Psr\Log\LoggerInterface $logger)
     {
         $this->logger = $logger;
 
-        $this->signatureValidator = new SAML2_Signature_Validator($logger);
+        $this->signatureValidator = new Validator($logger);
     }
 
     /**
-     * @param SAML2_Configuration_ServiceProvider  $serviceProviderConfiguration
-     * @param SAML2_Configuration_IdentityProvider $identityProviderConfiguration
-     * @param SAML2_Configuration_Destination      $currentDestination
-     * @param SAML2_Response                       $response
+     * @param \SAML2\Configuration\ServiceProvider  $serviceProviderConfiguration
+     * @param \SAML2\Configuration\IdentityProvider $identityProviderConfiguration
+     * @param \SAML2\Configuration\Destination      $currentDestination
+     * @param \SAML2\Response                       $response
      *
-     * @return SAML2_Assertion[] Collection (SAML2_Utilities_ArrayCollection) of SAML2_Assertion objects
+     * @return \SAML2\Assertion[] Collection (\SAML2\Utilities\ArrayCollection) of \SAML2\Assertion objects
      */
     public function process(
-        SAML2_Configuration_ServiceProvider $serviceProviderConfiguration,
-        SAML2_Configuration_IdentityProvider $identityProviderConfiguration,
-        SAML2_Configuration_Destination $currentDestination,
-        SAML2_Response $response
+        ServiceProvider $serviceProviderConfiguration,
+        IdentityProvider $identityProviderConfiguration,
+        Destination $currentDestination,
+        Response $response
     ) {
-        $this->preconditionValidator = new SAML2_Response_Validation_PreconditionValidator($currentDestination);
-        $this->assertionProcessor = SAML2_Assertion_ProcessorBuilder::build(
+        $this->preconditionValidator = new PreconditionValidator($currentDestination);
+        $this->assertionProcessor = ProcessorBuilder::build(
             $this->logger,
             $this->signatureValidator,
             $currentDestination,
@@ -76,24 +90,24 @@ public function process(
     /**
      * Checks the preconditions that must be valid in order for the response to be processed.
      *
-     * @param SAML2_Response $response
+     * @param \SAML2\Response $response
      */
-    private function enforcePreconditions(SAML2_Response $response)
+    private function enforcePreconditions(Response $response)
     {
         $result = $this->preconditionValidator->validate($response);
 
         if (!$result->isValid()) {
-            throw SAML2_Response_Exception_PreconditionNotMetException::createFromValidationResult($result);
+            throw PreconditionNotMetException::createFromValidationResult($result);
         }
     }
 
     /**
-     * @param SAML2_Response                       $response
-     * @param SAML2_Configuration_IdentityProvider $identityProviderConfiguration
+     * @param \SAML2\Response                       $response
+     * @param \SAML2\Configuration\IdentityProvider $identityProviderConfiguration
      */
     private function verifySignature(
-        SAML2_Response $response,
-        SAML2_Configuration_IdentityProvider $identityProviderConfiguration
+        Response $response,
+        IdentityProvider $identityProviderConfiguration
     ) {
         if (!$response->isMessageConstructedWithSignature()) {
             $this->logger->info(sprintf(
@@ -113,26 +127,26 @@ private function verifySignature(
         $this->responseIsSigned = TRUE;
 
         if (!$this->signatureValidator->hasValidSignature($response, $identityProviderConfiguration)) {
-            throw new SAML2_Response_Exception_InvalidResponseException();
+            throw new InvalidResponseException();
         }
     }
 
     /**
-     * @param SAML2_Response $response
+     * @param \SAML2\Response $response
      *
-     * @return SAML2_Assertion[]
+     * @return \SAML2\Assertion[]
      */
-    private function processAssertions(SAML2_Response $response)
+    private function processAssertions(Response $response)
     {
         $assertions = $response->getAssertions();
         if (empty($assertions)) {
-            throw new SAML2_Response_Exception_NoAssertionsFoundException('No assertions found in response from IdP.');
+            throw new NoAssertionsFoundException('No assertions found in response from IdP.');
         }
 
         if (!$this->responseIsSigned) {
             foreach ($assertions as $assertion) {
                 if (!$assertion->getWasSignedAtConstruction()) {
-                    throw new SAML2_Response_Exception_UnsignedResponseException(
+                    throw new UnsignedResponseException(
                         'Both the response and the assertion it containes are not signed.'
                     );
                 }
diff --git a/src/SAML2/Response/Validation/ConstraintValidator.php b/src/SAML2/Response/Validation/ConstraintValidator.php
index 402c54337..47b253692 100644
--- a/src/SAML2/Response/Validation/ConstraintValidator.php
+++ b/src/SAML2/Response/Validation/ConstraintValidator.php
@@ -1,6 +1,10 @@
 <?php
 
-interface SAML2_Response_Validation_ConstraintValidator
+namespace SAML2\Response\Validation;
+
+use SAML2\Response;
+
+interface ConstraintValidator
 {
-    public function validate(SAML2_Response $response, SAML2_Response_Validation_Result $result);
+    public function validate(Response $response, Result $result);
 }
diff --git a/src/SAML2/Response/Validation/ConstraintValidator/DestinationMatches.php b/src/SAML2/Response/Validation/ConstraintValidator/DestinationMatches.php
index f67584dad..b1be9b605 100644
--- a/src/SAML2/Response/Validation/ConstraintValidator/DestinationMatches.php
+++ b/src/SAML2/Response/Validation/ConstraintValidator/DestinationMatches.php
@@ -1,22 +1,29 @@
 <?php
 
-class SAML2_Response_Validation_ConstraintValidator_DestinationMatches implements
-    SAML2_Response_Validation_ConstraintValidator
+namespace SAML2\Response\Validation\ConstraintValidator;
+
+use SAML2\Response\Validation\ConstraintValidator;
+use SAML2\Configuration\Destination;
+use SAML2\Response;
+use SAML2\Response\Validation\Result;
+
+class DestinationMatches implements
+    ConstraintValidator
 {
     /**
-     * @var SAML2_Configuration_Destination
+     * @var \SAML2\Configuration\Destination
      */
     private $expectedDestination;
 
-    public function __construct(SAML2_Configuration_Destination $destination)
+    public function __construct(Destination $destination)
     {
         $this->expectedDestination = $destination;
     }
 
-    public function validate(SAML2_Response $response, SAML2_Response_Validation_Result $result)
+    public function validate(Response $response, Result $result)
     {
         $destination = $response->getDestination();
-        if (!$this->expectedDestination->equals(new SAML2_Configuration_Destination($destination))) {
+        if (!$this->expectedDestination->equals(new Destination($destination))) {
             $result->addError(sprintf(
                 'Destination in response "%s" does not match the expected destination "%s"',
                 $destination,
diff --git a/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php b/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php
index cda3c46a5..1f5c901e6 100644
--- a/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php
+++ b/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php
@@ -1,11 +1,18 @@
 <?php
 
-class SAML2_Response_Validation_ConstraintValidator_IsSuccessful implements
-    SAML2_Response_Validation_ConstraintValidator
+namespace SAML2\Response\Validation\ConstraintValidator;
+
+use SAML2\Response\Validation\ConstraintValidator;
+use SAML2\Response;
+use SAML2\Response\Validation\Result;
+use SAML2\Constants;
+
+class IsSuccessful implements
+    ConstraintValidator
 {
     public function validate(
-        SAML2_Response $response,
-        SAML2_Response_Validation_Result $result
+        Response $response,
+        Result $result
     ) {
         if (!$response->isSuccess()) {
             $result->addError($this->buildMessage($response->getStatus()));
@@ -35,8 +42,8 @@ private function buildMessage(array $responseStatus)
      */
     private function truncateStatus($status)
     {
-        $prefixLength = strlen(SAML2_Constants::STATUS_PREFIX);
-        if (strpos($status, SAML2_Constants::STATUS_PREFIX) !== 0) {
+        $prefixLength = strlen(Constants::STATUS_PREFIX);
+        if (strpos($status, Constants::STATUS_PREFIX) !== 0) {
             return $status;
         }
 
diff --git a/src/SAML2/Response/Validation/PreconditionValidator.php b/src/SAML2/Response/Validation/PreconditionValidator.php
index 589f9379d..89dc8efbd 100644
--- a/src/SAML2/Response/Validation/PreconditionValidator.php
+++ b/src/SAML2/Response/Validation/PreconditionValidator.php
@@ -1,16 +1,22 @@
 <?php
 
+namespace SAML2\Response\Validation;
+
+use SAML2\Configuration\Destination;
+use SAML2\Response\Validation\ConstraintValidator\IsSuccessful;
+use SAML2\Response\Validation\ConstraintValidator\DestinationMatches;
+
 /**
  * Validates the preconditions that have to be met prior to processing of the response.
  */
-class SAML2_Response_Validation_PreconditionValidator extends SAML2_Response_Validation_Validator
+class PreconditionValidator extends Validator
 {
-    public function __construct(SAML2_Configuration_Destination $destination)
+    public function __construct(Destination $destination)
     {
         // move to DI
-        $this->addConstraintValidator(new SAML2_Response_Validation_ConstraintValidator_IsSuccessful());
+        $this->addConstraintValidator(new IsSuccessful());
         $this->addConstraintValidator(
-            new SAML2_Response_Validation_ConstraintValidator_DestinationMatches($destination)
+            new DestinationMatches($destination)
         );
     }
 }
diff --git a/src/SAML2/Response/Validation/Result.php b/src/SAML2/Response/Validation/Result.php
index ddd506129..9d8ae1748 100644
--- a/src/SAML2/Response/Validation/Result.php
+++ b/src/SAML2/Response/Validation/Result.php
@@ -1,9 +1,13 @@
 <?php
 
+namespace SAML2\Response\Validation;
+
+use SAML2\Exception\InvalidArgumentException;
+
 /**
  * Simple Result object
  */
-class SAML2_Response_Validation_Result
+class Result
 {
     /**
      * @var array
@@ -16,7 +20,7 @@ class SAML2_Response_Validation_Result
     public function addError($message)
     {
         if (!is_string($message)) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType('string', $message);
+            throw InvalidArgumentException::invalidType('string', $message);
         }
 
         $this->errors[] = $message;
diff --git a/src/SAML2/Response/Validation/Validator.php b/src/SAML2/Response/Validation/Validator.php
index 1203f6fde..39ca5670b 100644
--- a/src/SAML2/Response/Validation/Validator.php
+++ b/src/SAML2/Response/Validation/Validator.php
@@ -1,20 +1,24 @@
 <?php
 
-class SAML2_Response_Validation_Validator
+namespace SAML2\Response\Validation;
+
+use SAML2\Response;
+
+class Validator
 {
     /**
-     * @var SAML2_Response_Validation_ConstraintValidator[]
+     * @var \SAML2\Response\Validation\ConstraintValidator[]
      */
     protected $constraints;
 
-    public function addConstraintValidator(SAML2_Response_Validation_ConstraintValidator $constraint)
+    public function addConstraintValidator(ConstraintValidator $constraint)
     {
         $this->constraints[] = $constraint;
     }
 
-    public function validate(SAML2_Response $response)
+    public function validate(Response $response)
     {
-        $result = new SAML2_Response_Validation_Result();
+        $result = new Result();
         foreach ($this->constraints as $validator) {
             $validator->validate($response, $result);
         }
diff --git a/src/SAML2/SOAP.php b/src/SAML2/SOAP.php
index 6bdb0beab..008abec05 100644
--- a/src/SAML2/SOAP.php
+++ b/src/SAML2/SOAP.php
@@ -1,27 +1,29 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Class which implements the SOAP binding.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_SOAP extends SAML2_Binding
+class SOAP extends Binding
 {
     /**
      * Send a SAML 2 message using the SOAP binding.
      *
      * Note: This function never returns.
      *
-     * @param SAML2_Message $message The message we should send.
+     * @param \SAML2\Message $message The message we should send.
      */
-    public function send(SAML2_Message $message)
+    public function send(Message $message)
     {
         header('Content-Type: text/xml', TRUE);
         $outputFromIdp = '<?xml version="1.0" encoding="UTF-8"?>';
         $outputFromIdp .= '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">';
         $outputFromIdp .= '<SOAP-ENV:Body>';
         $xmlMessage = $message->toSignedXML();
-        SAML2_Utils::getContainer()->debugMessage($xmlMessage, 'out');
+        Utils::getContainer()->debugMessage($xmlMessage, 'out');
         $tempOutputFromIdp = $xmlMessage->ownerDocument->saveXML($xmlMessage);
         $outputFromIdp .= $tempOutputFromIdp;
         $outputFromIdp .= '</SOAP-ENV:Body>';
@@ -35,7 +37,7 @@ public function send(SAML2_Message $message)
      *
      * Throws an exception if it is unable receive the message.
      *
-     * @return SAML2_Message The received message.
+     * @return \SAML2\Message The received message.
      * @throws Exception
      */
     public function receive()
@@ -46,12 +48,12 @@ public function receive()
             throw new Exception('Invalid message received to AssertionConsumerService endpoint.');
         }
 
-        $document = SAML2_DOMDocumentFactory::fromString($postText);
+        $document = DOMDocumentFactory::fromString($postText);
         $xml = $document->firstChild;
-        SAML2_Utils::getContainer()->debugMessage($xml, 'in');
-        $results = SAML2_Utils::xpQuery($xml, '/soap-env:Envelope/soap-env:Body/*[1]');
+        Utils::getContainer()->debugMessage($xml, 'in');
+        $results = Utils::xpQuery($xml, '/soap-env:Envelope/soap-env:Body/*[1]');
 
-        return SAML2_Message::fromXML($results[0]);
+        return Message::fromXML($results[0]);
     }
 
 }
diff --git a/src/SAML2/SOAPClient.php b/src/SAML2/SOAPClient.php
index 7de34ff6f..90d231b95 100644
--- a/src/SAML2/SOAPClient.php
+++ b/src/SAML2/SOAPClient.php
@@ -1,12 +1,16 @@
 <?php
 
+namespace SAML2;
+
+use SAML2\Exception\RuntimeException;
+
 /**
  * Implementation of the SAML 2.0 SOAP binding.
  *
  * @author Shoaib Ali
  * @package SimpleSAMLphp
  */
-class SAML2_SOAPClient
+class SOAPClient
 {
     const START_SOAP_ENVELOPE = '<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Header/><soap-env:Body>';
     const END_SOAP_ENVELOPE = '</soap-env:Body></soap-env:Envelope>';
@@ -14,13 +18,13 @@ class SAML2_SOAPClient
     /**
      * This function sends the SOAP message to the service location and returns SOAP response
      *
-     * @param  SAML2_Message            $msg         The request that should be sent.
+     * @param  \SAML2\Message            $msg         The request that should be sent.
      * @param  SimpleSAML_Configuration $srcMetadata The metadata of the issuer of the message.
      * @param  SimpleSAML_Configuration $dstMetadata The metadata of the destination of the message.
-     * @return SAML2_Message            The response we received.
+     * @return \SAML2\Message            The response we received.
      * @throws Exception
      */
-    public function send(SAML2_Message $msg, SimpleSAML_Configuration $srcMetadata, SimpleSAML_Configuration $dstMetadata = NULL)
+    public function send(Message $msg, SimpleSAML_Configuration $srcMetadata, SimpleSAML_Configuration $dstMetadata = NULL)
     {
         $issuer = $msg->getIssuer();
 
@@ -105,7 +109,7 @@ public function send(SAML2_Message $msg, SimpleSAML_Configuration $srcMetadata,
         $request = $msg->toSignedXML();
         $request = self::START_SOAP_ENVELOPE . $request->ownerDocument->saveXML($request) . self::END_SOAP_ENVELOPE;
 
-        SAML2_Utils::getContainer()->debugMessage($request, 'out');
+        Utils::getContainer()->debugMessage($request, 'out');
 
         $action = 'http://www.oasis-open.org/committees/security';
         $version = '1.1';
@@ -117,12 +121,12 @@ public function send(SAML2_Message $msg, SimpleSAML_Configuration $srcMetadata,
             throw new Exception('Empty SOAP response, check peer certificate.');
         }
 
-        SAML2_Utils::getContainer()->debugMessage($soapresponsexml, 'in');
+        Utils::getContainer()->debugMessage($soapresponsexml, 'in');
 
         // Convert to SAML2_Message (DOMElement)
         try {
-            $dom = SAML2_DOMDocumentFactory::fromString($soapresponsexml);
-        } catch (SAML2_Exception_RuntimeException $e) {
+            $dom = DOMDocumentFactory::fromString($soapresponsexml);
+        } catch (RuntimeException $e) {
             throw new Exception('Not a SOAP response.', 0, $e);
         }
 
@@ -131,13 +135,13 @@ public function send(SAML2_Message $msg, SimpleSAML_Configuration $srcMetadata,
             throw new Exception($soapfault);
         }
         //Extract the message from the response
-        $samlresponse = SAML2_Utils::xpQuery($dom->firstChild, '/soap-env:Envelope/soap-env:Body/*[1]');
-        $samlresponse = SAML2_Message::fromXML($samlresponse[0]);
+        $samlresponse = Utils::xpQuery($dom->firstChild, '/soap-env:Envelope/soap-env:Body/*[1]');
+        $samlresponse = Message::fromXML($samlresponse[0]);
 
         /* Add validator to message which uses the SSL context. */
         self::addSSLValidator($samlresponse, $context);
 
-        SAML2_Utils::getContainer()->getLogger()->debug("Valid ArtifactResponse received from IdP");
+        Utils::getContainer()->getLogger()->debug("Valid ArtifactResponse received from IdP");
 
         return $samlresponse;
 
@@ -146,10 +150,10 @@ public function send(SAML2_Message $msg, SimpleSAML_Configuration $srcMetadata,
     /**
      * Add a signature validator based on a SSL context.
      *
-     * @param SAML2_Message $msg     The message we should add a validator to.
+     * @param \SAML2\Message $msg     The message we should add a validator to.
      * @param resource      $context The stream context.
      */
-    private static function addSSLValidator(SAML2_Message $msg, $context)
+    private static function addSSLValidator(Message $msg, $context)
     {
         $options = stream_context_get_options($context);
         if (!isset($options['ssl']['peer_certificate'])) {
@@ -161,20 +165,20 @@ private static function addSSLValidator(SAML2_Message $msg, $context)
 
         $key = openssl_pkey_get_public($options['ssl']['peer_certificate']);
         if ($key === FALSE) {
-            SAML2_Utils::getContainer()->getLogger()->warning('Unable to get public key from peer certificate.');
+            Utils::getContainer()->getLogger()->warning('Unable to get public key from peer certificate.');
 
             return;
         }
 
         $keyInfo = openssl_pkey_get_details($key);
         if ($keyInfo === FALSE) {
-            SAML2_Utils::getContainer()->getLogger()->warning('Unable to get key details from public key.');
+            Utils::getContainer()->getLogger()->warning('Unable to get key details from public key.');
 
             return;
         }
 
         if (!isset($keyInfo['key'])) {
-            SAML2_Utils::getContainer()->getLogger()->warning('Missing key in public key details.');
+            Utils::getContainer()->getLogger()->warning('Missing key in public key details.');
 
             return;
         }
@@ -203,12 +207,12 @@ public static function validateSSL($data, XMLSecurityKey $key)
         }
 
         if ($keyInfo['key'] !== $data) {
-            SAML2_Utils::getContainer()->getLogger()->debug('Key on SSL connection did not match key we validated against.');
+            Utils::getContainer()->getLogger()->debug('Key on SSL connection did not match key we validated against.');
 
             return;
         }
 
-        SAML2_Utils::getContainer()->getLogger()->debug('Message validated based on SSL certificate.');
+        Utils::getContainer()->getLogger()->debug('Message validated based on SSL certificate.');
     }
 
     /*
@@ -218,7 +222,7 @@ public static function validateSSL($data, XMLSecurityKey $key)
      */
     private function getSOAPFault($soapMessage)
     {
-        $soapFault = SAML2_Utils::xpQuery($soapMessage->firstChild, '/soap-env:Envelope/soap-env:Body/soap-env:Fault');
+        $soapFault = Utils::xpQuery($soapMessage->firstChild, '/soap-env:Envelope/soap-env:Body/soap-env:Fault');
 
         if (empty($soapFault)) {
             /* No fault. */
@@ -229,7 +233,7 @@ private function getSOAPFault($soapMessage)
         // There is a fault element but we haven't found out what the fault string is
         $soapFaultString = "Unknown fault string found";
         // find out the fault string
-        $faultStringElement =   SAML2_Utils::xpQuery($soapFaultElement, './soap-env:faultstring') ;
+        $faultStringElement =   Utils::xpQuery($soapFaultElement, './soap-env:faultstring') ;
         if (!empty($faultStringElement)) {
             return $faultStringElement[0]->textContent;
         }
diff --git a/src/SAML2/Signature/AbstractChainedValidator.php b/src/SAML2/Signature/AbstractChainedValidator.php
index 6adb0920b..1524d92c6 100644
--- a/src/SAML2/Signature/AbstractChainedValidator.php
+++ b/src/SAML2/Signature/AbstractChainedValidator.php
@@ -1,6 +1,10 @@
 <?php
 
-abstract class SAML2_Signature_AbstractChainedValidator implements SAML2_Signature_ChainedValidator
+namespace SAML2\Signature;
+
+use SAML2\SignedElement;
+
+abstract class AbstractChainedValidator implements ChainedValidator
 {
     /**
      * @var \Psr\Log\LoggerInterface
@@ -15,14 +19,14 @@ public function __construct(\Psr\Log\LoggerInterface $logger)
     /**
      * BC compatible version of the signature check
      *
-     * @param SAML2_SignedElement      $element
-     * @param SAML2_Certificate_X509[] $pemCandidates
+     * @param \SAML2\SignedElement      $element
+     * @param \SAML2\Certificate\X509[] $pemCandidates
      *
      * @throws Exception
      *
      * @return bool
      */
-    protected function validateElementWithKeys(SAML2_SignedElement $element, $pemCandidates)
+    protected function validateElementWithKeys(SignedElement $element, $pemCandidates)
     {
         $lastException = NULL;
         foreach ($pemCandidates as $index => $candidateKey) {
diff --git a/src/SAML2/Signature/ChainedValidator.php b/src/SAML2/Signature/ChainedValidator.php
index 7a7a37950..1519dd2ba 100644
--- a/src/SAML2/Signature/ChainedValidator.php
+++ b/src/SAML2/Signature/ChainedValidator.php
@@ -1,22 +1,27 @@
 <?php
 
+namespace SAML2\Signature;
+
+use SAML2\SignedElement;
+use SAML2\Configuration\CertificateProvider;
+
 /**
- * Interface SAML2_Validator_Responsible
+ * Interface \SAML2\Validator\Responsible
  *
  * should be renamed.
  */
-interface SAML2_Signature_ChainedValidator extends SAML2_Signature_ValidatorInterface
+interface ChainedValidator extends ValidatorInterface
 {
     /**
      * Test whether or not this link in the chain can validate the signedElement signature.
      *
-     * @param SAML2_SignedElement             $signedElement
-     * @param SAML2_Configuration_CertificateProvider $configuration
+     * @param \SAML2\SignedElement             $signedElement
+     * @param \SAML2\Configuration\CertificateProvider $configuration
      *
      * @return bool
      */
     public function canValidate(
-        SAML2_SignedElement $signedElement,
-        SAML2_Configuration_CertificateProvider $configuration
+        SignedElement $signedElement,
+        CertificateProvider $configuration
     );
 }
diff --git a/src/SAML2/Signature/FingerprintValidator.php b/src/SAML2/Signature/FingerprintValidator.php
index 211c2a88e..b6a46f407 100644
--- a/src/SAML2/Signature/FingerprintValidator.php
+++ b/src/SAML2/Signature/FingerprintValidator.php
@@ -1,9 +1,16 @@
 <?php
 
+namespace SAML2\Signature;
+
+use SAML2\Certificate\FingerprintLoader;
+use SAML2\SignedElement;
+use SAML2\Configuration\CertificateProvider;
+use SAML2\Certificate\X509;
+
 /**
  * Validates the signature based on the fingerprint of the certificate
  */
-class SAML2_Signature_FingerprintValidator extends SAML2_Signature_AbstractChainedValidator
+class FingerprintValidator extends AbstractChainedValidator
 {
     /**
      * @var array
@@ -11,13 +18,13 @@ class SAML2_Signature_FingerprintValidator extends SAML2_Signature_AbstractChain
     private $certificates;
 
     /**
-     * @var SAML2_Certificate_FingerprintLoader
+     * @var \SAML2\Certificate\FingerprintLoader
      */
     private $fingerprintLoader;
 
     public function __construct(
         \Psr\Log\LoggerInterface $logger,
-        SAML2_Certificate_FingerprintLoader $fingerprintLoader
+        FingerprintLoader $fingerprintLoader
     ) {
         $this->fingerprintLoader = $fingerprintLoader;
 
@@ -25,8 +32,8 @@ public function __construct(
     }
 
     public function canValidate(
-        SAML2_SignedElement $signedElement,
-        SAML2_Configuration_CertificateProvider $configuration
+        SignedElement $signedElement,
+        CertificateProvider $configuration
     ) {
         if ($configuration->getCertificateFingerprints() === NULL) {
             $this->logger->debug(
@@ -48,24 +55,24 @@ public function canValidate(
     }
 
     /**
-     * @param SAML2_SignedElement             $signedElement
-     * @param SAML2_Configuration_CertificateProvider $configuration
+     * @param \SAML2\SignedElement             $signedElement
+     * @param \SAML2\Configuration\CertificateProvider $configuration
      *
      * @return bool
      */
     public function hasValidSignature(
-        SAML2_SignedElement $signedElement,
-        SAML2_Configuration_CertificateProvider $configuration
+        SignedElement $signedElement,
+        CertificateProvider $configuration
     ) {
         $this->certificates = array_map(function ($certificate) {
-            return SAML2_Certificate_X509::createFromCertificateData($certificate);
+            return X509::createFromCertificateData($certificate);
         }, $this->certificates);
 
         $fingerprintCollection = $this->fingerprintLoader->loadFromConfiguration($configuration);
 
         $pemCandidates = array();
         foreach ($this->certificates as $certificate) {
-            /** @var SAML2_Certificate_X509 $certificate */
+            /** @var \SAML2\Certificate\X509 $certificate */
             $certificateFingerprint = $certificate->getFingerprint();
             if ($fingerprintCollection->contains($certificateFingerprint)) {
                 $pemCandidates[] = $certificate;
diff --git a/src/SAML2/Signature/MissingConfigurationException.php b/src/SAML2/Signature/MissingConfigurationException.php
index ca4edea29..2483dfe51 100644
--- a/src/SAML2/Signature/MissingConfigurationException.php
+++ b/src/SAML2/Signature/MissingConfigurationException.php
@@ -1,5 +1,9 @@
 <?php
 
-class SAML2_Signature_MissingConfigurationException extends RuntimeException implements SAML2_Exception_Throwable
+namespace SAML2\Signature;
+
+use SAML2\Exception\Throwable;
+
+class MissingConfigurationException extends RuntimeException implements Throwable
 {
 }
diff --git a/src/SAML2/Signature/PublicKeyValidator.php b/src/SAML2/Signature/PublicKeyValidator.php
index b004c11d1..d504cae55 100644
--- a/src/SAML2/Signature/PublicKeyValidator.php
+++ b/src/SAML2/Signature/PublicKeyValidator.php
@@ -1,18 +1,26 @@
 <?php
 
-class SAML2_Signature_PublicKeyValidator extends SAML2_Signature_AbstractChainedValidator
+namespace SAML2\Signature;
+
+use SAML2\Certificate\KeyLoader;
+use SAML2\SignedElement;
+use SAML2\Configuration\CertificateProvider;
+use SAML2\Certificate\Key;
+use SAML2\Certificate\X509;
+
+class PublicKeyValidator extends AbstractChainedValidator
 {
     /**
-     * @var SAML2_Certificate_KeyCollection
+     * @var \SAML2\Certificate\KeyCollection
      */
     private $configuredKeys;
 
     /**
-     * @var SAML2_Certificate_KeyLoader
+     * @var \SAML2\Certificate\KeyLoader
      */
     private $keyLoader;
 
-    public function __construct(\Psr\Log\LoggerInterface $logger, SAML2_Certificate_KeyLoader $keyLoader)
+    public function __construct(\Psr\Log\LoggerInterface $logger, KeyLoader $keyLoader)
     {
         $this->keyLoader = $keyLoader;
 
@@ -20,14 +28,14 @@ public function __construct(\Psr\Log\LoggerInterface $logger, SAML2_Certificate_
     }
 
     /**
-     * @param SAML2_SignedElement             $signedElement
-     * @param SAML2_Configuration_CertificateProvider $configuration
+     * @param \SAML2\SignedElement             $signedElement
+     * @param \SAML2\Configuration\CertificateProvider $configuration
      *
      * @return bool
      */
     public function canValidate(
-        SAML2_SignedElement $signedElement,
-        SAML2_Configuration_CertificateProvider $configuration
+        SignedElement $signedElement,
+        CertificateProvider $configuration
     ) {
         $this->configuredKeys = $this->keyLoader->extractPublicKeys($configuration);
 
@@ -35,18 +43,18 @@ public function canValidate(
     }
 
     /**
-     * @param SAML2_SignedElement             $signedElement
-     * @param SAML2_Configuration_CertificateProvider $configuration
+     * @param \SAML2\SignedElement             $signedElement
+     * @param \SAML2\Configuration\CertificateProvider $configuration
      *
      * @return bool
      */
     public function hasValidSignature(
-        SAML2_SignedElement $signedElement,
-        SAML2_Configuration_CertificateProvider $configuration
+        SignedElement $signedElement,
+        CertificateProvider $configuration
     ) {
         $logger = $this->logger;
-        $pemCandidates = $this->configuredKeys->filter(function (SAML2_Certificate_Key $key) use ($logger) {
-            if (!$key instanceof SAML2_Certificate_X509) {
+        $pemCandidates = $this->configuredKeys->filter(function (Key $key) use ($logger) {
+            if (!$key instanceof X509) {
                 $logger->debug(sprintf('Skipping unknown key type: "%s"', $key['type']));
                 return FALSE;
             }
diff --git a/src/SAML2/Signature/Validator.php b/src/SAML2/Signature/Validator.php
index 84629a66b..e363bac6a 100644
--- a/src/SAML2/Signature/Validator.php
+++ b/src/SAML2/Signature/Validator.php
@@ -1,9 +1,16 @@
 <?php
 
+namespace SAML2\Signature;
+
+use SAML2\SignedElement;
+use SAML2\Configuration\CertificateProvider;
+use SAML2\Certificate\KeyLoader;
+use SAML2\Certificate\FingerprintLoader;
+
 /**
  * Signature Validator.
  */
-class SAML2_Signature_Validator
+class Validator
 {
     /**
      * @var \Psr\Log\LoggerInterface
@@ -16,15 +23,15 @@ public function __construct(\Psr\Log\LoggerInterface $logger)
     }
 
     public function hasValidSignature(
-        SAML2_SignedElement $signedElement,
-        SAML2_Configuration_CertificateProvider $configuration
+        SignedElement $signedElement,
+        CertificateProvider $configuration
     ) {
         // should be DI
-        $validator = new SAML2_Signature_ValidatorChain(
+        $validator = new ValidatorChain(
             $this->logger,
             array(
-                new SAML2_Signature_PublicKeyValidator($this->logger, new SAML2_Certificate_KeyLoader()),
-                new SAML2_Signature_FingerprintValidator($this->logger, new SAML2_Certificate_FingerprintLoader())
+                new PublicKeyValidator($this->logger, new KeyLoader()),
+                new FingerprintValidator($this->logger, new FingerprintLoader())
             )
         );
 
diff --git a/src/SAML2/Signature/ValidatorChain.php b/src/SAML2/Signature/ValidatorChain.php
index 7818d98e4..892f7463a 100644
--- a/src/SAML2/Signature/ValidatorChain.php
+++ b/src/SAML2/Signature/ValidatorChain.php
@@ -1,12 +1,17 @@
 <?php
 
+namespace SAML2\Signature;
+
+use SAML2\SignedElement;
+use SAML2\Configuration\CertificateProvider;
+
 /**
  * Allows for validation of a signature trying different validators till a validator is found
  * that can validate the signature.
  *
  * If no validation is possible an exception is thrown.
  */
-class SAML2_Signature_ValidatorChain implements SAML2_Signature_ValidatorInterface
+class ValidatorChain implements ValidatorInterface
 {
     /**
      * @var \Psr\Log\LoggerInterface
@@ -14,13 +19,13 @@ class SAML2_Signature_ValidatorChain implements SAML2_Signature_ValidatorInterfa
     private $logger;
 
     /**
-     * @var  SAML2_Signature_ChainedValidator[]
+     * @var  \SAML2\Signature\ChainedValidator[]
      */
     private $validators = array();
 
     /**
      * @param \Psr\Log\LoggerInterface           $logger
-     * @param SAML2_Signature_ChainedValidator[] $validators
+     * @param \SAML2\Signature\ChainedValidator[] $validators
      */
     public function __construct(\Psr\Log\LoggerInterface $logger, array $validators)
     {
@@ -33,22 +38,22 @@ public function __construct(\Psr\Log\LoggerInterface $logger, array $validators)
     }
 
     /**
-     * @param SAML2_Signature_ChainedValidator $validator
+     * @param \SAML2\Signature\ChainedValidator $validator
      */
-    public function appendValidator(SAML2_Signature_ChainedValidator $validator)
+    public function appendValidator(ChainedValidator $validator)
     {
         $this->validators[] = $validator;
     }
 
     /**
-     * @param SAML2_SignedElement             $signedElement
-     * @param SAML2_Configuration_CertificateProvider $configuration
+     * @param \SAML2\SignedElement             $signedElement
+     * @param \SAML2\Configuration\CertificateProvider $configuration
      *
      * @return bool
      */
     public function hasValidSignature(
-        SAML2_SignedElement $signedElement,
-        SAML2_Configuration_CertificateProvider $configuration
+        SignedElement $signedElement,
+        CertificateProvider $configuration
     ) {
         foreach ($this->validators as $validator) {
             if ($validator->canValidate($signedElement, $configuration)) {
@@ -66,7 +71,7 @@ public function hasValidSignature(
             ));
         }
 
-        throw new SAML2_Signature_MissingConfigurationException(sprintf(
+        throw new MissingConfigurationException(sprintf(
             'No certificates or fingerprints have been configured%s',
             $configuration->has('entityid') ? ' for "' . $configuration->get('entityid') . '"' : ''
         ));
diff --git a/src/SAML2/Signature/ValidatorInterface.php b/src/SAML2/Signature/ValidatorInterface.php
index 53969546e..63252eead 100644
--- a/src/SAML2/Signature/ValidatorInterface.php
+++ b/src/SAML2/Signature/ValidatorInterface.php
@@ -1,17 +1,22 @@
 <?php
 
-interface SAML2_Signature_ValidatorInterface
+namespace SAML2\Signature;
+
+use SAML2\SignedElement;
+use SAML2\Configuration\CertificateProvider;
+
+interface ValidatorInterface
 {
     /**
      * Validate the signature of the signed Element based on the configuration
      *
-     * @param SAML2_SignedElement             $signedElement
-     * @param SAML2_Configuration_CertificateProvider $configuration
+     * @param \SAML2\SignedElement             $signedElement
+     * @param \SAML2\Configuration\CertificateProvider $configuration
      *
      * @return bool
      */
     public function hasValidSignature(
-        SAML2_SignedElement $signedElement,
-        SAML2_Configuration_CertificateProvider $configuration
+        SignedElement $signedElement,
+        CertificateProvider $configuration
     );
 }
diff --git a/src/SAML2/SignedElement.php b/src/SAML2/SignedElement.php
index ef3275401..8928d32f0 100644
--- a/src/SAML2/SignedElement.php
+++ b/src/SAML2/SignedElement.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Interface to a SAML 2 element which may be signed.
  *
  * @package SimpleSAMLphp
  */
-interface SAML2_SignedElement
+interface SignedElement
 {
     /**
      * Validate this element against a public key.
diff --git a/src/SAML2/SignedElementHelper.php b/src/SAML2/SignedElementHelper.php
index 97588e3b2..72434438a 100644
--- a/src/SAML2/SignedElementHelper.php
+++ b/src/SAML2/SignedElementHelper.php
@@ -1,5 +1,7 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Helper class for processing signed elements.
  *
@@ -7,7 +9,7 @@
  *
  * @package SimpleSAMLphp
  */
-class SAML2_SignedElementHelper implements SAML2_SignedElement
+class SignedElementHelper implements SignedElement
 {
     /**
      * The private key we should use to sign the message.
@@ -48,7 +50,7 @@ protected function __construct(DOMElement $xml = NULL)
 
         /* Validate the signature element of the message. */
         try {
-            $sig = SAML2_Utils::validateElement($xml);
+            $sig = Utils::validateElement($xml);
 
             if ($sig !== FALSE) {
                 $this->certificates = $sig['Certificates'];
@@ -209,7 +211,7 @@ protected function signElement(DOMElement $root, DOMElement $insertBefore = NULL
             return NULL;
         }
 
-        SAML2_Utils::insertSignature($this->signatureKey, $this->certificates, $root, $insertBefore);
+        Utils::insertSignature($this->signatureKey, $this->certificates, $root, $insertBefore);
 
         return $root;
     }
diff --git a/src/SAML2/StatusResponse.php b/src/SAML2/StatusResponse.php
index be340301d..2bc0fb6ae 100644
--- a/src/SAML2/StatusResponse.php
+++ b/src/SAML2/StatusResponse.php
@@ -1,10 +1,12 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Base class for all SAML 2 response messages.
  *
  * Implements samlp:StatusResponseType. All of the elements in that type is
- * stored in the SAML2_Message class, and this class is therefore more
+ * stored in the \SAML2\Message class, and this class is therefore more
  * or less empty. It is included mainly to make it easy to separate requests from
  * responses.
  *
@@ -20,7 +22,7 @@
  *
  * @package SimpleSAMLphp
  */
-abstract class SAML2_StatusResponse extends SAML2_Message
+abstract class StatusResponse extends Message
 {
     /**
      * The ID of the request this is a response to, or NULL if this is an unsolicited response.
@@ -50,7 +52,7 @@ protected function __construct($tagName, DOMElement $xml = NULL)
         parent::__construct($tagName, $xml);
 
         $this->status = array(
-            'Code' => SAML2_Constants::STATUS_SUCCESS,
+            'Code' => Constants::STATUS_SUCCESS,
             'SubCode' => NULL,
             'Message' => NULL,
             );
@@ -63,13 +65,13 @@ protected function __construct($tagName, DOMElement $xml = NULL)
             $this->inResponseTo = $xml->getAttribute('InResponseTo');
         }
 
-        $status = SAML2_Utils::xpQuery($xml, './saml_protocol:Status');
+        $status = Utils::xpQuery($xml, './saml_protocol:Status');
         if (empty($status)) {
             throw new Exception('Missing status code on response.');
         }
         $status = $status[0];
 
-        $statusCode = SAML2_Utils::xpQuery($status, './saml_protocol:StatusCode');
+        $statusCode = Utils::xpQuery($status, './saml_protocol:StatusCode');
         if (empty($statusCode)) {
             throw new Exception('Missing status code in status element.');
         }
@@ -77,12 +79,12 @@ protected function __construct($tagName, DOMElement $xml = NULL)
 
         $this->status['Code'] = $statusCode->getAttribute('Value');
 
-        $subCode = SAML2_Utils::xpQuery($statusCode, './saml_protocol:StatusCode');
+        $subCode = Utils::xpQuery($statusCode, './saml_protocol:StatusCode');
         if (!empty($subCode)) {
             $this->status['SubCode'] = $subCode[0]->getAttribute('Value');
         }
 
-        $message = SAML2_Utils::xpQuery($status, './saml_protocol:StatusMessage');
+        $message = Utils::xpQuery($status, './saml_protocol:StatusMessage');
         if (!empty($message)) {
             $this->status['Message'] = trim($message[0]->textContent);
         }
@@ -98,7 +100,7 @@ public function isSuccess()
     {
         assert('array_key_exists("Code", $this->status)');
 
-        if ($this->status['Code'] === SAML2_Constants::STATUS_SUCCESS) {
+        if ($this->status['Code'] === Constants::STATUS_SUCCESS) {
             return TRUE;
         }
 
@@ -173,21 +175,21 @@ public function toUnsignedXML()
             $root->setAttribute('InResponseTo', $this->inResponseTo);
         }
 
-        $status = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'Status');
+        $status = $this->document->createElementNS(Constants::NS_SAMLP, 'Status');
         $root->appendChild($status);
 
-        $statusCode = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'StatusCode');
+        $statusCode = $this->document->createElementNS(Constants::NS_SAMLP, 'StatusCode');
         $statusCode->setAttribute('Value', $this->status['Code']);
         $status->appendChild($statusCode);
 
         if (!is_null($this->status['SubCode'])) {
-            $subStatusCode = $this->document->createElementNS(SAML2_Constants::NS_SAMLP, 'StatusCode');
+            $subStatusCode = $this->document->createElementNS(Constants::NS_SAMLP, 'StatusCode');
             $subStatusCode->setAttribute('Value', $this->status['SubCode']);
             $statusCode->appendChild($subStatusCode);
         }
 
         if (!is_null($this->status['Message'])) {
-            SAML2_Utils::addString($status, SAML2_Constants::NS_SAMLP, 'StatusMessage', $this->status['Message']);
+            Utils::addString($status, Constants::NS_SAMLP, 'StatusMessage', $this->status['Message']);
         }
 
         return $root;
diff --git a/src/SAML2/SubjectQuery.php b/src/SAML2/SubjectQuery.php
index 110556fe4..108f538ba 100644
--- a/src/SAML2/SubjectQuery.php
+++ b/src/SAML2/SubjectQuery.php
@@ -1,5 +1,7 @@
 <?php
 
+namespace SAML2;
+
 /**
  * Base class for SAML 2 subject query messages.
  *
@@ -11,7 +13,7 @@
  *
  * @package SimpleSAMLphp
  */
-abstract class SAML2_SubjectQuery extends SAML2_Request
+abstract class SubjectQuery extends Request
 {
     /**
      * The NameId of the subject in the query.
@@ -47,7 +49,7 @@ protected function __construct($tagName, DOMElement $xml = NULL)
      */
     private function parseSubject(DOMElement $xml)
     {
-        $subject = SAML2_Utils::xpQuery($xml, './saml_assertion:Subject');
+        $subject = Utils::xpQuery($xml, './saml_assertion:Subject');
         if (empty($subject)) {
             /* No Subject node. */
             throw new Exception('Missing subject in subject query.');
@@ -56,23 +58,23 @@ private function parseSubject(DOMElement $xml)
         }
         $subject = $subject[0];
 
-        $nameId = SAML2_Utils::xpQuery($subject, './saml_assertion:NameID');
+        $nameId = Utils::xpQuery($subject, './saml_assertion:NameID');
         if (empty($nameId)) {
             throw new Exception('Missing <saml:NameID> in <saml:Subject>.');
         } elseif (count($nameId) > 1) {
             throw new Exception('More than one <saml:NameID> in <saml:Subject>.');
         }
         $nameId = $nameId[0];
-        $this->nameId = SAML2_Utils::parseNameId($nameId);
+        $this->nameId = Utils::parseNameId($nameId);
     }
 
 
     /**
      * Retrieve the NameId of the subject in the query.
      *
-     * The returned NameId is in the format used by SAML2_Utils::addNameId().
+     * The returned NameId is in the format used by \SAML2\Utils::addNameId().
      *
-     * @see SAML2_Utils::addNameId()
+     * @see \SAML2\Utils::addNameId()
      * @return array|NULL The name identifier of the assertion.
      */
     public function getNameId()
@@ -84,9 +86,9 @@ public function getNameId()
     /**
      * Set the NameId of the subject in the query.
      *
-     * The NameId must be in the format accepted by SAML2_Utils::addNameId().
+     * The NameId must be in the format accepted by \SAML2\Utils::addNameId().
      *
-     * @see SAML2_Utils::addNameId()
+     * @see \SAML2\Utils::addNameId()
      * @param array|NULL $nameId The name identifier of the assertion.
      */
     public function setNameId($nameId)
@@ -106,10 +108,10 @@ public function toUnsignedXML()
     {
         $root = parent::toUnsignedXML();
 
-        $subject = $root->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:Subject');
+        $subject = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:Subject');
         $root->appendChild($subject);
 
-        SAML2_Utils::addNameId($subject, $this->nameId);
+        Utils::addNameId($subject, $this->nameId);
 
         return $root;
     }
diff --git a/src/SAML2/Utilities/ArrayCollection.php b/src/SAML2/Utilities/ArrayCollection.php
index 79bc7c101..5e3a0b2b8 100644
--- a/src/SAML2/Utilities/ArrayCollection.php
+++ b/src/SAML2/Utilities/ArrayCollection.php
@@ -1,11 +1,15 @@
 <?php
 
+namespace SAML2\Utilities;
+
+use SAML2\Exception\RuntimeException;
+
 /**
  * Simple Array implementation of Collection.
  *
  * @SuppressWarnings(PHPMD.TooManyMethods) - it just has a large api.
  */
-class SAML2_Utilities_ArrayCollection implements SAML2_Utilities_Collection
+class ArrayCollection implements Collection
 {
     /**
      * @var array
@@ -54,7 +58,7 @@ public function remove($element)
     public function getOnlyElement()
     {
         if ($this->count() !== 1) {
-            throw new SAML2_Exception_RuntimeException(sprintf(
+            throw new RuntimeException(sprintf(
                 'SAML2_Utilities_ArrayCollection::getOnlyElement requires that the collection has exactly one element, '
                 . '"%d" elements found',
                 $this->count()
diff --git a/src/SAML2/Utilities/Certificate.php b/src/SAML2/Utilities/Certificate.php
index 35a7ca3bd..2b2bdf4de 100644
--- a/src/SAML2/Utilities/Certificate.php
+++ b/src/SAML2/Utilities/Certificate.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace SAML2\Utilities;
+
 /**
  * Collection of Utility functions specifically for certificates
  */
-class SAML2_Utilities_Certificate
+class Certificate
 {
     /**
      * The pattern that the contents of a certificate should adhere to
diff --git a/src/SAML2/Utilities/Collection.php b/src/SAML2/Utilities/Collection.php
index 1cef3db7c..a59beb4e6 100644
--- a/src/SAML2/Utilities/Collection.php
+++ b/src/SAML2/Utilities/Collection.php
@@ -1,13 +1,15 @@
 <?php
 
-interface SAML2_Utilities_Collection extends ArrayAccess, Countable, IteratorAggregate
+namespace SAML2\Utilities;
+
+interface Collection extends ArrayAccess, Countable, IteratorAggregate
 {
     /**
      * Add an element to the collection
      *
      * @param $element
      *
-     * @return $this|SAML2_Utilities_Collection
+     * @return $this|\SAML2\Utilities\Collection
      */
     public function add($element);
 
@@ -16,7 +18,7 @@ public function add($element);
      *
      * @return mixed
      *
-     * @throws SAML2_Exception_RuntimeException if the element was not the only element
+     * @throws \SAML2\Exception\RuntimeException if the element was not the only element
      */
     public function getOnlyElement();
 
@@ -46,7 +48,7 @@ public function map(Closure $function);
     /**
      * @param callable $filterFunction
      *
-     * @return SAML2_Utilities_Collection
+     * @return \SAML2\Utilities\Collection
      */
     public function filter(Closure $filterFunction);
 
diff --git a/src/SAML2/Utilities/File.php b/src/SAML2/Utilities/File.php
index debec4927..ff4de21d0 100644
--- a/src/SAML2/Utilities/File.php
+++ b/src/SAML2/Utilities/File.php
@@ -1,9 +1,14 @@
 <?php
 
+namespace SAML2\Utilities;
+
+use SAML2\Exception\InvalidArgumentException;
+use SAML2\Exception\RuntimeException;
+
 /**
  * Various File Utilities
  */
-class SAML2_Utilities_File
+class File
 {
     /**
      * @param string $file full absolute path to the file
@@ -13,11 +18,11 @@ class SAML2_Utilities_File
     public static function getFileContents($file)
     {
         if (!is_string($file)) {
-            throw SAML2_Exception_InvalidArgumentException::invalidType('string', $file);
+            throw InvalidArgumentException::invalidType('string', $file);
         }
 
         if (!is_readable($file)) {
-            throw new SAML2_Exception_RuntimeException(sprintf(
+            throw new RuntimeException(sprintf(
                 'File "%s" does not exist or is not readable',
                 $file
             ));
@@ -25,7 +30,7 @@ public static function getFileContents($file)
 
         $contents = file_get_contents($file);
         if ($contents === FALSE) {
-            throw new SAML2_Exception_RuntimeException(sprintf(
+            throw new RuntimeException(sprintf(
                 'Could not read from existing and readable file "%s"',
                 $file
             ));
diff --git a/src/SAML2/Utilities/Temporal.php b/src/SAML2/Utilities/Temporal.php
index fa659f18f..8449d2eca 100644
--- a/src/SAML2/Utilities/Temporal.php
+++ b/src/SAML2/Utilities/Temporal.php
@@ -1,6 +1,8 @@
 <?php
 
-class SAML2_Utilities_Temporal
+namespace SAML2\Utilities;
+
+class Temporal
 {
     /**
      * Getter for getting the current timestamp. Use this rather than time() calls directly as this can be mocked for
diff --git a/src/SAML2/Utils.php b/src/SAML2/Utils.php
index 37a38bc49..911234c1f 100644
--- a/src/SAML2/Utils.php
+++ b/src/SAML2/Utils.php
@@ -1,11 +1,20 @@
 <?php
 
+namespace SAML2;
+
+use SAML2\Exception\RuntimeException;
+use SAML2\XML\ds\X509Certificate;
+use SAML2\XML\ds\X509Data;
+use SAML2\XML\ds\KeyInfo;
+use SAML2\XML\md\KeyDescriptor;
+use SAML2\Compat\ContainerSingleton;
+
 /**
  * Helper functions for the SAML2 library.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_Utils
+class Utils
 {
     /**
      * Check the Signature in a XML element.
@@ -179,10 +188,10 @@ public static function xpQuery(DOMNode $node, $query)
 
         if ($xpCache === NULL || !$xpCache->document->isSameNode($doc)) {
             $xpCache = new DOMXPath($doc);
-            $xpCache->registerNamespace('soap-env', SAML2_Constants::NS_SOAP);
-            $xpCache->registerNamespace('saml_protocol', SAML2_Constants::NS_SAMLP);
-            $xpCache->registerNamespace('saml_assertion', SAML2_Constants::NS_SAML);
-            $xpCache->registerNamespace('saml_metadata', SAML2_Constants::NS_MD);
+            $xpCache->registerNamespace('soap-env', Constants::NS_SOAP);
+            $xpCache->registerNamespace('saml_protocol', Constants::NS_SAMLP);
+            $xpCache->registerNamespace('saml_assertion', Constants::NS_SAML);
+            $xpCache->registerNamespace('saml_metadata', Constants::NS_MD);
             $xpCache->registerNamespace('ds', XMLSecurityDSig::XMLDSIGNS);
             $xpCache->registerNamespace('xenc', XMLSecEnc::XMLENCNS);
         }
@@ -207,14 +216,14 @@ public static function xpQuery(DOMNode $node, $query)
     public static function copyElement(DOMElement $element, DOMElement $parent = NULL)
     {
         if ($parent === NULL) {
-            $document = SAML2_DOMDocumentFactory::create();
+            $document = DOMDocumentFactory::create();
         } else {
             $document = $parent->ownerDocument;
         }
 
         $namespaces = array();
         for ($e = $element; $e !== NULL; $e = $e->parentNode) {
-            foreach (SAML2_Utils::xpQuery($e, './namespace::*') as $ns) {
+            foreach (Utils::xpQuery($e, './namespace::*') as $ns) {
                 $prefix = $ns->localName;
                 if ($prefix === 'xml' || $prefix === 'xmlns') {
                     continue;
@@ -287,7 +296,7 @@ public static function addNameId(DOMElement $node, array $nameId)
     {
         assert('array_key_exists("Value", $nameId)');
 
-        $xml = SAML2_Utils::addString($node, SAML2_Constants::NS_SAML, 'saml:NameID', $nameId['Value']);
+        $xml = Utils::addString($node, Constants::NS_SAML, 'saml:NameID', $nameId['Value']);
 
         if (array_key_exists('NameQualifier', $nameId) && $nameId['NameQualifier'] !== NULL) {
             $xml->setAttribute('NameQualifier', $nameId['NameQualifier']);
@@ -445,7 +454,7 @@ private static function doDecryptElement(DOMElement $encryptedData, XMLSecurityK
                 }
             } catch (Exception $e) {
                 /* We failed to decrypt this key. Log it, and substitute a "random" key. */
-                SAML2_Utils::getContainer()->getLogger()->error('Failed to decrypt symmetric key: ' . $e->getMessage());
+                Utils::getContainer()->getLogger()->error('Failed to decrypt symmetric key: ' . $e->getMessage());
                 /* Create a replacement key, so that it looks like we fail in the same way as if the key was correctly padded. */
 
                 /* We base the symmetric key on the encrypted key and private key, so that we always behave the
@@ -497,8 +506,8 @@ private static function doDecryptElement(DOMElement $encryptedData, XMLSecurityK
             '</root>';
 
         try {
-            $newDoc = SAML2_DOMDocumentFactory::fromString($xml);
-        } catch (SAML2_Exception_RuntimeException $e) {
+            $newDoc = DOMDocumentFactory::fromString($xml);
+        } catch (RuntimeException $e) {
             throw new Exception('Failed to parse decrypted XML. Maybe the wrong sharedkey was used?', 0, $e);
         }
 
@@ -532,7 +541,7 @@ public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey
              * Something went wrong during decryption, but for security
              * reasons we cannot tell the user what failed.
              */
-            SAML2_Utils::getContainer()->getLogger()->error('Decryption failed: ' . $e->getMessage());
+            Utils::getContainer()->getLogger()->error('Decryption failed: ' . $e->getMessage());
             throw new Exception('Failed to decrypt XML element.', 0, $e);
         }
     }
@@ -646,22 +655,22 @@ public static function addStrings(DOMElement $parent, $namespace, $name, $locali
      * Create a KeyDescriptor with the given certificate.
      *
      * @param  string                     $x509Data The certificate, as a base64-encoded DER data.
-     * @return SAML2_XML_md_KeyDescriptor The keydescriptor.
+     * @return \SAML2\XML\md\KeyDescriptor The keydescriptor.
      */
     public static function createKeyDescriptor($x509Data)
     {
         assert('is_string($x509Data)');
 
-        $x509Certificate = new SAML2_XML_ds_X509Certificate();
+        $x509Certificate = new X509Certificate();
         $x509Certificate->certificate = $x509Data;
 
-        $x509Data = new SAML2_XML_ds_X509Data();
+        $x509Data = new X509Data();
         $x509Data->data[] = $x509Certificate;
 
-        $keyInfo = new SAML2_XML_ds_KeyInfo();
+        $keyInfo = new KeyInfo();
         $keyInfo->info[] = $x509Data;
 
-        $keyDescriptor = new SAML2_XML_md_KeyDescriptor();
+        $keyDescriptor = new KeyDescriptor();
         $keyDescriptor->KeyInfo = $keyInfo;
 
         return $keyDescriptor;
@@ -715,10 +724,10 @@ public static function xsDateTimeToTimestamp($time)
     }
 
     /**
-     * @return SAML2_Compat_Ssp_Container
+     * @return \SAML2\Compat\Ssp\Container
      */
     public static function getContainer()
     {
-        return SAML2_Compat_ContainerSingleton::getInstance();
+        return ContainerSingleton::getInstance();
     }
 }
diff --git a/src/SAML2/XML/Chunk.php b/src/SAML2/XML/Chunk.php
index f5ed763a3..98e72c26f 100644
--- a/src/SAML2/XML/Chunk.php
+++ b/src/SAML2/XML/Chunk.php
@@ -1,10 +1,15 @@
 <?php
+
+namespace SAML2\XML;
+
+use SAML2\Utils;
+use SAML2\DOMDocumentFactory;
 /**
  * Serializable class used to hold an XML element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_Chunk implements Serializable
+class Chunk implements Serializable
 {
     /**
      * The localName of the element.
@@ -37,7 +42,7 @@ public function __construct(DOMElement $xml)
         $this->localName = $xml->localName;
         $this->namespaceURI = $xml->namespaceURI;
 
-        $this->xml = SAML2_Utils::copyElement($xml);
+        $this->xml = Utils::copyElement($xml);
     }
 
     /**
@@ -59,7 +64,7 @@ public function getXML()
      */
     public function toXML(DOMElement $parent)
     {
-        return SAML2_Utils::copyElement($this->xml, $parent);
+        return Utils::copyElement($this->xml, $parent);
     }
 
     /**
@@ -76,11 +81,11 @@ public function serialize()
      * Un-serialize this XML chunk.
      *
      * @param  string          $serialized The serialized chunk.
-     * @return SAML2_XML_Chunk The chunk object represented by the serialized string.
+     * @return \SAML2\XML\Chunk The chunk object represented by the serialized string.
      */
     public function unserialize($serialized)
     {
-        $doc = SAML2_DOMDocumentFactory::fromString(unserialize($serialized));
+        $doc = DOMDocumentFactory::fromString(unserialize($serialized));
         $this->xml = $doc->documentElement;
         $this->localName = $this->xml->localName;
         $this->namespaceURI = $this->xml->namespaceURI;
diff --git a/src/SAML2/XML/ds/KeyInfo.php b/src/SAML2/XML/ds/KeyInfo.php
index 588cc9bb7..61f54e586 100644
--- a/src/SAML2/XML/ds/KeyInfo.php
+++ b/src/SAML2/XML/ds/KeyInfo.php
@@ -1,11 +1,15 @@
 <?php
 
+namespace SAML2\XML\ds;
+
+use SAML2\XML\Chunk;
+
 /**
  * Class representing a ds:KeyInfo element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_ds_KeyInfo
+class KeyInfo
 {
     /**
      * The Id attribute on this element.
@@ -18,9 +22,9 @@ class SAML2_XML_ds_KeyInfo
      * The various key information elements.
      *
      * Array with various elements describing this key.
-     * Unknown elements will be represented by SAML2_XML_Chunk.
+     * Unknown elements will be represented by \SAML2\XML\Chunk.
      *
-     * @var (SAML2_XML_Chunk|SAML2_XML_ds_KeyName|SAML2_XML_ds_X509Data)[]
+     * @var (\SAML2\XML\Chunk|\SAML2\XML\ds\KeyName|\SAML2\XML\ds\X509Data)[]
      */
     public $info = array();
 
@@ -45,18 +49,18 @@ public function __construct(DOMElement $xml = NULL)
             }
 
             if ($n->namespaceURI !== XMLSecurityDSig::XMLDSIGNS) {
-                $this->info[] = new SAML2_XML_Chunk($n);
+                $this->info[] = new Chunk($n);
                 continue;
             }
             switch ($n->localName) {
                 case 'KeyName':
-                    $this->info[] = new SAML2_XML_ds_KeyName($n);
+                    $this->info[] = new KeyName($n);
                     break;
                 case 'X509Data':
-                    $this->info[] = new SAML2_XML_ds_X509Data($n);
+                    $this->info[] = new X509Data($n);
                     break;
                 default:
-                    $this->info[] = new SAML2_XML_Chunk($n);
+                    $this->info[] = new Chunk($n);
                     break;
             }
         }
@@ -82,7 +86,7 @@ public function toXML(DOMElement $parent)
             $e->setAttribute('Id', $this->Id);
         }
 
-        /** @var SAML2_XML_Chunk|SAML2_XML_ds_KeyName|SAML2_XML_ds_X509Data $n */
+        /** @var \SAML2\XML\Chunk|\SAML2\XML\ds\KeyName|\SAML2\XML\ds\X509Data $n */
         foreach ($this->info as $n) {
             $n->toXML($e);
         }
diff --git a/src/SAML2/XML/ds/KeyName.php b/src/SAML2/XML/ds/KeyName.php
index e01f583e8..02c40d748 100644
--- a/src/SAML2/XML/ds/KeyName.php
+++ b/src/SAML2/XML/ds/KeyName.php
@@ -1,11 +1,15 @@
 <?php
 
+namespace SAML2\XML\ds;
+
+use SAML2\Utils;
+
 /**
  * Class representing a ds:KeyName element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_ds_KeyName
+class KeyName
 {
     /**
      * The key name.
@@ -38,7 +42,7 @@ public function toXML(DOMElement $parent)
     {
         assert('is_string($this->name)');
 
-        return SAML2_Utils::addString($parent, XMLSecurityDSig::XMLDSIGNS, 'ds:KeyName', $this->name);
+        return Utils::addString($parent, XMLSecurityDSig::XMLDSIGNS, 'ds:KeyName', $this->name);
     }
 
 }
diff --git a/src/SAML2/XML/ds/X509Certificate.php b/src/SAML2/XML/ds/X509Certificate.php
index 5675551c6..fcb664c41 100644
--- a/src/SAML2/XML/ds/X509Certificate.php
+++ b/src/SAML2/XML/ds/X509Certificate.php
@@ -1,11 +1,15 @@
 <?php
 
+namespace SAML2\XML\ds;
+
+use SAML2\Utils;
+
 /**
  * Class representing a ds:X509Certificate element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_ds_X509Certificate
+class X509Certificate
 {
     /**
      * The base64-encoded certificate.
@@ -38,7 +42,7 @@ public function toXML(DOMElement $parent)
     {
         assert('is_string($this->certificate)');
 
-        return SAML2_Utils::addString($parent, XMLSecurityDSig::XMLDSIGNS, 'ds:X509Certificate', $this->certificate);
+        return Utils::addString($parent, XMLSecurityDSig::XMLDSIGNS, 'ds:X509Certificate', $this->certificate);
     }
 
 }
diff --git a/src/SAML2/XML/ds/X509Data.php b/src/SAML2/XML/ds/X509Data.php
index 005dd7568..f22c9526f 100644
--- a/src/SAML2/XML/ds/X509Data.php
+++ b/src/SAML2/XML/ds/X509Data.php
@@ -1,19 +1,23 @@
 <?php
 
+namespace SAML2\XML\ds;
+
+use SAML2\XML\Chunk;
+
 /**
  * Class representing a ds:X509Data element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_ds_X509Data
+class X509Data
 {
     /**
      * The various X509 data elements.
      *
      * Array with various elements describing this certificate.
-     * Unknown elements will be represented by SAML2_XML_Chunk.
+     * Unknown elements will be represented by \SAML2\XML\Chunk.
      *
-     * @var (SAML2_XML_Chunk|SAML2_XML_ds_X509Certificate)[]
+     * @var (\SAML2\XML\Chunk|\SAML2\XML\ds\X509Certificate)[]
      */
     public $data = array();
 
@@ -34,15 +38,15 @@ public function __construct(DOMElement $xml = NULL)
             }
 
             if ($n->namespaceURI !== XMLSecurityDSig::XMLDSIGNS) {
-                $this->data[] = new SAML2_XML_Chunk($n);
+                $this->data[] = new Chunk($n);
                 continue;
             }
             switch ($n->localName) {
                 case 'X509Certificate':
-                    $this->data[] = new SAML2_XML_ds_X509Certificate($n);
+                    $this->data[] = new X509Certificate($n);
                     break;
                 default:
-                    $this->data[] = new SAML2_XML_Chunk($n);
+                    $this->data[] = new Chunk($n);
                     break;
             }
         }
@@ -63,7 +67,7 @@ public function toXML(DOMElement $parent)
         $e = $doc->createElementNS(XMLSecurityDSig::XMLDSIGNS, 'ds:X509Data');
         $parent->appendChild($e);
 
-        /** @var SAML2_XML_Chunk|SAML2_XML_ds_X509Certificate $n */
+        /** @var \SAML2\XML\Chunk|\SAML2\XML\ds\X509Certificate $n */
         foreach ($this->data as $n) {
             $n->toXML($e);
         }
diff --git a/src/SAML2/XML/md/AdditionalMetadataLocation.php b/src/SAML2/XML/md/AdditionalMetadataLocation.php
index d2bd879db..77a88f9dd 100644
--- a/src/SAML2/XML/md/AdditionalMetadataLocation.php
+++ b/src/SAML2/XML/md/AdditionalMetadataLocation.php
@@ -1,11 +1,16 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 metadata AdditionalMetadataLocation element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_AdditionalMetadataLocation
+class AdditionalMetadataLocation
 {
     /**
      * The namespace of this metadata.
@@ -52,7 +57,7 @@ public function toXML(DOMElement $parent)
         assert('is_string($this->namespace)');
         assert('is_string($this->location)');
 
-        $e = SAML2_Utils::addString($parent, SAML2_Constants::NS_MD, 'md:AdditionalMetadataLocation', $this->location);
+        $e = Utils::addString($parent, Constants::NS_MD, 'md:AdditionalMetadataLocation', $this->location);
         $e->setAttribute('namespace', $this->namespace);
 
         return $e;
diff --git a/src/SAML2/XML/md/AffiliationDescriptor.php b/src/SAML2/XML/md/AffiliationDescriptor.php
index 86cf449c7..ecf547751 100644
--- a/src/SAML2/XML/md/AffiliationDescriptor.php
+++ b/src/SAML2/XML/md/AffiliationDescriptor.php
@@ -1,11 +1,17 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\SignedElementHelper;
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 AffiliationDescriptor element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_AffiliationDescriptor extends SAML2_SignedElementHelper
+class AffiliationDescriptor extends SignedElementHelper
 {
     /**
      * The affiliationOwnerID.
@@ -56,9 +62,9 @@ class SAML2_XML_md_AffiliationDescriptor extends SAML2_SignedElementHelper
     /**
      * KeyDescriptor elements.
      *
-     * Array of SAML2_XML_md_KeyDescriptor elements.
+     * Array of \SAML2\XML\md\KeyDescriptor elements.
      *
-     * @var SAML2_XML_md_KeyDescriptor[]
+     * @var \SAML2\XML\md\KeyDescriptor[]
      */
     public $KeyDescriptor = array();
 
@@ -86,22 +92,22 @@ public function __construct(DOMElement $xml = NULL)
         }
 
         if ($xml->hasAttribute('validUntil')) {
-            $this->validUntil = SAML2_Utils::xsDateTimeToTimestamp($xml->getAttribute('validUntil'));
+            $this->validUntil = Utils::xsDateTimeToTimestamp($xml->getAttribute('validUntil'));
         }
 
         if ($xml->hasAttribute('cacheDuration')) {
             $this->cacheDuration = $xml->getAttribute('cacheDuration');
         }
 
-        $this->Extensions = SAML2_XML_md_Extensions::getList($xml);
+        $this->Extensions = Extensions::getList($xml);
 
-        $this->AffiliateMember = SAML2_Utils::extractStrings($xml, SAML2_Constants::NS_MD, 'AffiliateMember');
+        $this->AffiliateMember = Utils::extractStrings($xml, Constants::NS_MD, 'AffiliateMember');
         if (empty($this->AffiliateMember)) {
             throw new Exception('Missing AffiliateMember in AffiliationDescriptor.');
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:KeyDescriptor') as $kd) {
-            $this->KeyDescriptor[] = new SAML2_XML_md_KeyDescriptor($kd);
+        foreach (Utils::xpQuery($xml, './saml_metadata:KeyDescriptor') as $kd) {
+            $this->KeyDescriptor[] = new KeyDescriptor($kd);
         }
     }
 
@@ -122,7 +128,7 @@ public function toXML(DOMElement $parent)
         assert('!empty($this->AffiliateMember)');
         assert('is_array($this->KeyDescriptor)');
 
-        $e = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_MD, 'md:AffiliationDescriptor');
+        $e = $parent->ownerDocument->createElementNS(Constants::NS_MD, 'md:AffiliationDescriptor');
         $parent->appendChild($e);
 
         $e->setAttribute('affiliationOwnerID', $this->affiliationOwnerID);
@@ -139,9 +145,9 @@ public function toXML(DOMElement $parent)
             $e->setAttribute('cacheDuration', $this->cacheDuration);
         }
 
-        SAML2_XML_md_Extensions::addList($e, $this->Extensions);
+        Extensions::addList($e, $this->Extensions);
 
-        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:AffiliateMember', FALSE, $this->AffiliateMember);
+        Utils::addStrings($e, Constants::NS_MD, 'md:AffiliateMember', FALSE, $this->AffiliateMember);
 
         foreach ($this->KeyDescriptor as $kd) {
             $kd->toXML($e);
diff --git a/src/SAML2/XML/md/AttributeAuthorityDescriptor.php b/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
index ae1d76014..e688ac87f 100644
--- a/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
+++ b/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
@@ -1,18 +1,24 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\Utils;
+use SAML2\Constants;
+use SAML2\XML\saml\Attribute;
+
 /**
  * Class representing SAML 2 metadata AttributeAuthorityDescriptor.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_AttributeAuthorityDescriptor extends SAML2_XML_md_RoleDescriptor
+class AttributeAuthorityDescriptor extends RoleDescriptor
 {
     /**
      * List of AttributeService endpoints.
      *
      * Array with EndpointType objects.
      *
-     * @var SAML2_XML_md_EndpointType[]
+     * @var \SAML2\XML\md\EndpointType[]
      */
     public $AttributeService = array();
 
@@ -21,7 +27,7 @@ class SAML2_XML_md_AttributeAuthorityDescriptor extends SAML2_XML_md_RoleDescrip
      *
      * Array with EndpointType objects.
      *
-     * @var SAML2_XML_md_EndpointType[]
+     * @var \SAML2\XML\md\EndpointType[]
      */
     public $AssertionIDRequestService = array();
 
@@ -46,9 +52,9 @@ class SAML2_XML_md_AttributeAuthorityDescriptor extends SAML2_XML_md_RoleDescrip
     /**
      * List of supported attributes.
      *
-     * Array with SAML2_XML_saml_Attribute objects.
+     * Array with \SAML2\XML\saml\Attribute objects.
      *
-     * @var SAML2_XML_saml_Attribute[]
+     * @var \SAML2\XML\saml\Attribute[]
      */
     public $Attribute = array();
 
@@ -66,23 +72,23 @@ public function __construct(DOMElement $xml = NULL)
             return;
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AttributeService') as $ep) {
-            $this->AttributeService[] = new SAML2_XML_md_EndpointType($ep);
+        foreach (Utils::xpQuery($xml, './saml_metadata:AttributeService') as $ep) {
+            $this->AttributeService[] = new EndpointType($ep);
         }
         if (empty($this->AttributeService)) {
             throw new Exception('Must have at least one AttributeService in AttributeAuthorityDescriptor.');
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) {
-            $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($ep);
+        foreach (Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) {
+            $this->AssertionIDRequestService[] = new EndpointType($ep);
         }
 
-        $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Constants::NS_MD, 'NameIDFormat');
+        $this->NameIDFormat = Utils::extractStrings($xml, Constants::NS_MD, 'NameIDFormat');
 
-        $this->AttributeProfile = SAML2_Utils::extractStrings($xml, SAML2_Constants::NS_MD, 'AttributeProfile');
+        $this->AttributeProfile = Utils::extractStrings($xml, Constants::NS_MD, 'AttributeProfile');
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_assertion:Attribute') as $a) {
-            $this->Attribute[] = new SAML2_XML_saml_Attribute($a);
+        foreach (Utils::xpQuery($xml, './saml_assertion:Attribute') as $a) {
+            $this->Attribute[] = new Attribute($a);
         }
     }
 
@@ -111,9 +117,9 @@ public function toXML(DOMElement $parent)
             $ep->toXML($e, 'md:AssertionIDRequestService');
         }
 
-        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
+        Utils::addStrings($e, Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
 
-        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:AttributeProfile', FALSE, $this->AttributeProfile);
+        Utils::addStrings($e, Constants::NS_MD, 'md:AttributeProfile', FALSE, $this->AttributeProfile);
 
         foreach ($this->Attribute as $a) {
             $a->toXML($e);
diff --git a/src/SAML2/XML/md/AttributeConsumingService.php b/src/SAML2/XML/md/AttributeConsumingService.php
index 2d9527136..94044c803 100644
--- a/src/SAML2/XML/md/AttributeConsumingService.php
+++ b/src/SAML2/XML/md/AttributeConsumingService.php
@@ -1,11 +1,16 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 Metadata AttributeConsumingService element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_AttributeConsumingService
+class AttributeConsumingService
 {
     /**
      * The index of this AttributeConsumingService.
@@ -44,7 +49,7 @@ class SAML2_XML_md_AttributeConsumingService
      *
      * This is an array of SAML_RequestedAttributeType elements.
      *
-     * @var SAML2_XML_md_RequestedAttribute[]
+     * @var \SAML2\XML\md\RequestedAttribute[]
      */
     public $RequestedAttribute = array();
 
@@ -65,17 +70,17 @@ public function __construct(DOMElement $xml = NULL)
         }
         $this->index = (int) $xml->getAttribute('index');
 
-        $this->isDefault = SAML2_Utils::parseBoolean($xml, 'isDefault', NULL);
+        $this->isDefault = Utils::parseBoolean($xml, 'isDefault', NULL);
 
-        $this->ServiceName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Constants::NS_MD, 'ServiceName');
+        $this->ServiceName = Utils::extractLocalizedStrings($xml, Constants::NS_MD, 'ServiceName');
         if (empty($this->ServiceName)) {
             throw new Exception('Missing ServiceName in AttributeConsumingService.');
         }
 
-        $this->ServiceDescription = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Constants::NS_MD, 'ServiceDescription');
+        $this->ServiceDescription = Utils::extractLocalizedStrings($xml, Constants::NS_MD, 'ServiceDescription');
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:RequestedAttribute') as $ra) {
-            $this->RequestedAttribute[] = new SAML2_XML_md_RequestedAttribute($ra);
+        foreach (Utils::xpQuery($xml, './saml_metadata:RequestedAttribute') as $ra) {
+            $this->RequestedAttribute[] = new RequestedAttribute($ra);
         }
     }
 
@@ -95,7 +100,7 @@ public function toXML(DOMElement $parent)
 
         $doc = $parent->ownerDocument;
 
-        $e = $doc->createElementNS(SAML2_Constants::NS_MD, 'md:AttributeConsumingService');
+        $e = $doc->createElementNS(Constants::NS_MD, 'md:AttributeConsumingService');
         $parent->appendChild($e);
 
         $e->setAttribute('index', (string) $this->index);
@@ -106,8 +111,8 @@ public function toXML(DOMElement $parent)
             $e->setAttribute('isDefault', 'false');
         }
 
-        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:ServiceName', TRUE, $this->ServiceName);
-        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:ServiceDescription', TRUE, $this->ServiceDescription);
+        Utils::addStrings($e, Constants::NS_MD, 'md:ServiceName', TRUE, $this->ServiceName);
+        Utils::addStrings($e, Constants::NS_MD, 'md:ServiceDescription', TRUE, $this->ServiceDescription);
 
         foreach ($this->RequestedAttribute as $ra) {
             $ra->toXML($e);
diff --git a/src/SAML2/XML/md/AuthnAuthorityDescriptor.php b/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
index 2645bc290..4b2920790 100644
--- a/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
+++ b/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
@@ -1,18 +1,23 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 metadata AuthnAuthorityDescriptor.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_AuthnAuthorityDescriptor extends SAML2_XML_md_RoleDescriptor
+class AuthnAuthorityDescriptor extends RoleDescriptor
 {
     /**
      * List of AuthnQueryService endpoints.
      *
      * Array with EndpointType objects.
      *
-     * @var SAML2_XML_md_EndpointType[]
+     * @var \SAML2\XML\md\EndpointType[]
      */
     public $AuthnQueryService = array();
 
@@ -21,7 +26,7 @@ class SAML2_XML_md_AuthnAuthorityDescriptor extends SAML2_XML_md_RoleDescriptor
      *
      * Array with EndpointType objects.
      *
-     * @var SAML2_XML_md_EndpointType[]
+     * @var \SAML2\XML\md\EndpointType[]
      */
     public $AssertionIDRequestService = array();
 
@@ -48,18 +53,18 @@ public function __construct(DOMElement $xml = NULL)
             return;
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AuthnQueryService') as $ep) {
-            $this->AuthnQueryService[] = new SAML2_XML_md_EndpointType($ep);
+        foreach (Utils::xpQuery($xml, './saml_metadata:AuthnQueryService') as $ep) {
+            $this->AuthnQueryService[] = new EndpointType($ep);
         }
         if (empty($this->AuthnQueryService)) {
             throw new Exception('Must have at least one AuthnQueryService in AuthnAuthorityDescriptor.');
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) {
-            $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($ep);
+        foreach (Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) {
+            $this->AssertionIDRequestService[] = new EndpointType($ep);
         }
 
-        $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Constants::NS_MD, 'NameIDFormat');
+        $this->NameIDFormat = Utils::extractStrings($xml, Constants::NS_MD, 'NameIDFormat');
     }
 
     /**
@@ -85,7 +90,7 @@ public function toXML(DOMElement $parent)
             $ep->toXML($e, 'md:AssertionIDRequestService');
         }
 
-        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
+        Utils::addStrings($e, Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
 
         return $e;
     }
diff --git a/src/SAML2/XML/md/ContactPerson.php b/src/SAML2/XML/md/ContactPerson.php
index b4ade615f..1c17515e6 100644
--- a/src/SAML2/XML/md/ContactPerson.php
+++ b/src/SAML2/XML/md/ContactPerson.php
@@ -1,11 +1,16 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 ContactPerson.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_ContactPerson
+class ContactPerson
 {
     /**
      * The contact type.
@@ -75,7 +80,7 @@ public function __construct(DOMElement $xml = NULL)
         }
         $this->contactType = $xml->getAttribute('contactType');
 
-        $this->Extensions = SAML2_XML_md_Extensions::getList($xml);
+        $this->Extensions = Extensions::getList($xml);
 
         $this->Company = self::getStringElement($xml, 'Company');
         $this->GivenName = self::getStringElement($xml, 'GivenName');
@@ -95,7 +100,7 @@ private static function getStringElements(DOMElement $parent, $name)
     {
         assert('is_string($name)');
 
-        $e = SAML2_Utils::xpQuery($parent, './saml_metadata:' . $name);
+        $e = Utils::xpQuery($parent, './saml_metadata:' . $name);
 
         $ret = array();
         foreach ($e as $i) {
@@ -146,27 +151,27 @@ public function toXML(DOMElement $parent)
 
         $doc = $parent->ownerDocument;
 
-        $e = $doc->createElementNS(SAML2_Constants::NS_MD, 'md:ContactPerson');
+        $e = $doc->createElementNS(Constants::NS_MD, 'md:ContactPerson');
         $parent->appendChild($e);
 
         $e->setAttribute('contactType', $this->contactType);
 
-        SAML2_XML_md_Extensions::addList($e, $this->Extensions);
+        Extensions::addList($e, $this->Extensions);
 
         if (isset($this->Company)) {
-            SAML2_Utils::addString($e, SAML2_Constants::NS_MD, 'md:Company', $this->Company);
+            Utils::addString($e, Constants::NS_MD, 'md:Company', $this->Company);
         }
         if (isset($this->GivenName)) {
-            SAML2_Utils::addString($e, SAML2_Constants::NS_MD, 'md:GivenName', $this->GivenName);
+            Utils::addString($e, Constants::NS_MD, 'md:GivenName', $this->GivenName);
         }
         if (isset($this->SurName)) {
-            SAML2_Utils::addString($e, SAML2_Constants::NS_MD, 'md:SurName', $this->SurName);
+            Utils::addString($e, Constants::NS_MD, 'md:SurName', $this->SurName);
         }
         if (!empty($this->EmailAddress)) {
-            SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:EmailAddress', FALSE, $this->EmailAddress);
+            Utils::addStrings($e, Constants::NS_MD, 'md:EmailAddress', FALSE, $this->EmailAddress);
         }
         if (!empty($this->TelephoneNumber)) {
-            SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:TelephoneNumber', FALSE, $this->TelephoneNumber);
+            Utils::addStrings($e, Constants::NS_MD, 'md:TelephoneNumber', FALSE, $this->TelephoneNumber);
         }
 
         return $e;
diff --git a/src/SAML2/XML/md/EndpointType.php b/src/SAML2/XML/md/EndpointType.php
index 74578cb9b..3b5c6f557 100644
--- a/src/SAML2/XML/md/EndpointType.php
+++ b/src/SAML2/XML/md/EndpointType.php
@@ -1,11 +1,15 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 EndpointType.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_EndpointType
+class EndpointType
 {
     /**
      * The binding for this endpoint.
@@ -167,7 +171,7 @@ public function toXML(DOMElement $parent, $name)
         assert('is_string($this->Location)');
         assert('is_null($this->ResponseLocation) || is_string($this->ResponseLocation)');
 
-        $e = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_MD, $name);
+        $e = $parent->ownerDocument->createElementNS(Constants::NS_MD, $name);
         $parent->appendChild($e);
 
         $e->setAttribute('Binding', $this->Binding);
diff --git a/src/SAML2/XML/md/EntitiesDescriptor.php b/src/SAML2/XML/md/EntitiesDescriptor.php
index e4d91ce80..c47cc02fe 100644
--- a/src/SAML2/XML/md/EntitiesDescriptor.php
+++ b/src/SAML2/XML/md/EntitiesDescriptor.php
@@ -1,11 +1,18 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\SignedElementHelper;
+use SAML2\Utils;
+use SAML2\DOMDocumentFactory;
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 EntitiesDescriptor element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_EntitiesDescriptor extends SAML2_SignedElementHelper
+class EntitiesDescriptor extends SignedElementHelper
 {
     /**
      * The ID of this element.
@@ -47,7 +54,7 @@ class SAML2_XML_md_EntitiesDescriptor extends SAML2_SignedElementHelper
     /**
      * Child EntityDescriptor and EntitiesDescriptor elements.
      *
-     * @var (SAML2_XML_md_EntityDescriptor|SAML2_XML_md_EntitiesDescriptor)[]
+     * @var (\SAML2\XML\md\EntityDescriptor|\SAML2\XML\md\EntitiesDescriptor)[]
      */
     public $children = array();
 
@@ -68,7 +75,7 @@ public function __construct(DOMElement $xml = NULL)
             $this->ID = $xml->getAttribute('ID');
         }
         if ($xml->hasAttribute('validUntil')) {
-            $this->validUntil = SAML2_Utils::xsDateTimeToTimestamp($xml->getAttribute('validUntil'));
+            $this->validUntil = Utils::xsDateTimeToTimestamp($xml->getAttribute('validUntil'));
         }
         if ($xml->hasAttribute('cacheDuration')) {
             $this->cacheDuration = $xml->getAttribute('cacheDuration');
@@ -77,13 +84,13 @@ public function __construct(DOMElement $xml = NULL)
             $this->Name = $xml->getAttribute('Name');
         }
 
-        $this->Extensions = SAML2_XML_md_Extensions::getList($xml);
+        $this->Extensions = Extensions::getList($xml);
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:EntityDescriptor|./saml_metadata:EntitiesDescriptor') as $node) {
+        foreach (Utils::xpQuery($xml, './saml_metadata:EntityDescriptor|./saml_metadata:EntitiesDescriptor') as $node) {
             if ($node->localName === 'EntityDescriptor') {
-                $this->children[] = new SAML2_XML_md_EntityDescriptor($node);
+                $this->children[] = new EntityDescriptor($node);
             } else {
-                $this->children[] = new SAML2_XML_md_EntitiesDescriptor($node);
+                $this->children[] = new EntitiesDescriptor($node);
             }
         }
     }
@@ -104,11 +111,11 @@ public function toXML(DOMElement $parent = NULL)
         assert('is_array($this->children)');
 
         if ($parent === NULL) {
-            $doc = SAML2_DOMDocumentFactory::create();
-            $e = $doc->createElementNS(SAML2_Constants::NS_MD, 'md:EntitiesDescriptor');
+            $doc = DOMDocumentFactory::create();
+            $e = $doc->createElementNS(Constants::NS_MD, 'md:EntitiesDescriptor');
             $doc->appendChild($e);
         } else {
-            $e = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_MD, 'md:EntitiesDescriptor');
+            $e = $parent->ownerDocument->createElementNS(Constants::NS_MD, 'md:EntitiesDescriptor');
             $parent->appendChild($e);
         }
 
@@ -128,9 +135,9 @@ public function toXML(DOMElement $parent = NULL)
             $e->setAttribute('Name', $this->Name);
         }
 
-        SAML2_XML_md_Extensions::addList($e, $this->Extensions);
+        Extensions::addList($e, $this->Extensions);
 
-        /** @var SAML2_XML_md_EntityDescriptor|SAML2_XML_md_EntitiesDescriptor $node */
+        /** @var \SAML2\XML\md\EntityDescriptor|\SAML2\XML\md\EntitiesDescriptor $node */
         foreach ($this->children as $node) {
             $node->toXML($e);
         }
diff --git a/src/SAML2/XML/md/EntityDescriptor.php b/src/SAML2/XML/md/EntityDescriptor.php
index 1e6709f81..2adf20240 100644
--- a/src/SAML2/XML/md/EntityDescriptor.php
+++ b/src/SAML2/XML/md/EntityDescriptor.php
@@ -1,11 +1,18 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\SignedElementHelper;
+use SAML2\Utils;
+use SAML2\Constants;
+use SAML2\DOMDocumentFactory;
+
 /**
  * Class representing SAML 2 EntityDescriptor element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_EntityDescriptor extends SAML2_SignedElementHelper
+class EntityDescriptor extends SignedElementHelper
 {
     /**
      * The entityID this EntityDescriptor represents.
@@ -47,37 +54,37 @@ class SAML2_XML_md_EntityDescriptor extends SAML2_SignedElementHelper
     /**
      * Array with all roles for this entity.
      *
-     * Array of SAML2_XML_md_RoleDescriptor objects (and subclasses of RoleDescriptor).
+     * Array of \SAML2\XML\md\RoleDescriptor objects (and subclasses of RoleDescriptor).
      *
-     * @var (SAML2_XML_md_UnknownRoleDescriptor|SAML2_XML_md_IDPSSODescriptor|SAML2_XML_md_SPSSODescriptor|SAML2_XML_md_AuthnAuthorityDescriptor|SAML2_XML_md_AttributeAuthorityDescriptor|SAML2_XML_md_PDPDescriptor)[]
+     * @var (\SAML2\XML\md\UnknownRoleDescriptor|\SAML2\XML\md\IDPSSODescriptor|\SAML2\XML\md\SPSSODescriptor|\SAML2\XML\md\AuthnAuthorityDescriptor|\SAML2\XML\md\AttributeAuthorityDescriptor|\SAML2\XML\md\PDPDescriptor)[]
      */
     public $RoleDescriptor = array();
 
     /**
      * AffiliationDescriptor of this entity.
      *
-     * @var SAML2_XML_md_AffiliationDescriptor|NULL
+     * @var \SAML2\XML\md\AffiliationDescriptor|NULL
      */
     public $AffiliationDescriptor = NULL;
 
     /**
      * Organization of this entity.
      *
-     * @var SAML2_XML_md_Organization|NULL
+     * @var \SAML2\XML\md\Organization|NULL
      */
     public $Organization = NULL;
 
     /**
      * ContactPerson elements for this entity.
      *
-     * @var SAML2_XML_md_ContactPerson[]
+     * @var \SAML2\XML\md\ContactPerson[]
      */
     public $ContactPerson = array();
 
     /**
      * AdditionalMetadataLocation elements for this entity.
      *
-     * @var SAML2_XML_md_AdditionalMetadataLocation[]
+     * @var \SAML2\XML\md\AdditionalMetadataLocation[]
      */
     public $AdditionalMetadataLocation = array();
 
@@ -104,50 +111,50 @@ public function __construct(DOMElement $xml = NULL)
             $this->ID = $xml->getAttribute('ID');
         }
         if ($xml->hasAttribute('validUntil')) {
-            $this->validUntil = SAML2_Utils::xsDateTimeToTimestamp($xml->getAttribute('validUntil'));
+            $this->validUntil = Utils::xsDateTimeToTimestamp($xml->getAttribute('validUntil'));
         }
         if ($xml->hasAttribute('cacheDuration')) {
             $this->cacheDuration = $xml->getAttribute('cacheDuration');
         }
 
-        $this->Extensions = SAML2_XML_md_Extensions::getList($xml);
+        $this->Extensions = Extensions::getList($xml);
 
         for ($node = $xml->firstChild; $node !== NULL; $node = $node->nextSibling) {
             if (!($node instanceof DOMElement)) {
                 continue;
             }
 
-            if ($node->namespaceURI !== SAML2_Constants::NS_MD) {
+            if ($node->namespaceURI !== Constants::NS_MD) {
                 continue;
             }
 
             switch ($node->localName) {
                 case 'RoleDescriptor':
-                    $this->RoleDescriptor[] = new SAML2_XML_md_UnknownRoleDescriptor($node);
+                    $this->RoleDescriptor[] = new UnknownRoleDescriptor($node);
                     break;
                 case 'IDPSSODescriptor':
-                    $this->RoleDescriptor[] = new SAML2_XML_md_IDPSSODescriptor($node);
+                    $this->RoleDescriptor[] = new IDPSSODescriptor($node);
                     break;
                 case 'SPSSODescriptor':
-                    $this->RoleDescriptor[] = new SAML2_XML_md_SPSSODescriptor($node);
+                    $this->RoleDescriptor[] = new SPSSODescriptor($node);
                     break;
                 case 'AuthnAuthorityDescriptor':
-                    $this->RoleDescriptor[] = new SAML2_XML_md_AuthnAuthorityDescriptor($node);
+                    $this->RoleDescriptor[] = new AuthnAuthorityDescriptor($node);
                     break;
                 case 'AttributeAuthorityDescriptor':
-                    $this->RoleDescriptor[] = new SAML2_XML_md_AttributeAuthorityDescriptor($node);
+                    $this->RoleDescriptor[] = new AttributeAuthorityDescriptor($node);
                     break;
                 case 'PDPDescriptor':
-                    $this->RoleDescriptor[] = new SAML2_XML_md_PDPDescriptor($node);
+                    $this->RoleDescriptor[] = new PDPDescriptor($node);
                     break;
             }
         }
 
-        $affiliationDescriptor = SAML2_Utils::xpQuery($xml, './saml_metadata:AffiliationDescriptor');
+        $affiliationDescriptor = Utils::xpQuery($xml, './saml_metadata:AffiliationDescriptor');
         if (count($affiliationDescriptor) > 1) {
             throw new Exception('More than one AffiliationDescriptor in the entity.');
         } elseif (!empty($affiliationDescriptor)) {
-            $this->AffiliationDescriptor = new SAML2_XML_md_AffiliationDescriptor($affiliationDescriptor[0]);
+            $this->AffiliationDescriptor = new AffiliationDescriptor($affiliationDescriptor[0]);
         }
 
         if (empty($this->RoleDescriptor) && is_null($this->AffiliationDescriptor)) {
@@ -156,19 +163,19 @@ public function __construct(DOMElement $xml = NULL)
             throw new Exception('AffiliationDescriptor cannot be combined with other RoleDescriptor elements in EntityDescriptor.');
         }
 
-        $organization = SAML2_Utils::xpQuery($xml, './saml_metadata:Organization');
+        $organization = Utils::xpQuery($xml, './saml_metadata:Organization');
         if (count($organization) > 1) {
             throw new Exception('More than one Organization in the entity.');
         } elseif (!empty($organization)) {
-            $this->Organization = new SAML2_XML_md_Organization($organization[0]);
+            $this->Organization = new Organization($organization[0]);
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:ContactPerson') as $cp) {
-            $this->ContactPerson[] = new SAML2_XML_md_ContactPerson($cp);
+        foreach (Utils::xpQuery($xml, './saml_metadata:ContactPerson') as $cp) {
+            $this->ContactPerson[] = new ContactPerson($cp);
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AdditionalMetadataLocation') as $aml) {
-            $this->AdditionalMetadataLocation[] = new SAML2_XML_md_AdditionalMetadataLocation($aml);
+        foreach (Utils::xpQuery($xml, './saml_metadata:AdditionalMetadataLocation') as $aml) {
+            $this->AdditionalMetadataLocation[] = new AdditionalMetadataLocation($aml);
         }
     }
 
@@ -192,11 +199,11 @@ public function toXML(DOMElement $parent = NULL)
         assert('is_array($this->AdditionalMetadataLocation)');
 
         if ($parent === NULL) {
-            $doc = SAML2_DOMDocumentFactory::create();
-            $e = $doc->createElementNS(SAML2_Constants::NS_MD, 'md:EntityDescriptor');
+            $doc = DOMDocumentFactory::create();
+            $e = $doc->createElementNS(Constants::NS_MD, 'md:EntityDescriptor');
             $doc->appendChild($e);
         } else {
-            $e = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_MD, 'md:EntityDescriptor');
+            $e = $parent->ownerDocument->createElementNS(Constants::NS_MD, 'md:EntityDescriptor');
             $parent->appendChild($e);
         }
 
@@ -214,9 +221,9 @@ public function toXML(DOMElement $parent = NULL)
             $e->setAttribute('cacheDuration', $this->cacheDuration);
         }
 
-        SAML2_XML_md_Extensions::addList($e, $this->Extensions);
+        Extensions::addList($e, $this->Extensions);
 
-        /** @var SAML2_XML_md_UnknownRoleDescriptor|SAML2_XML_md_IDPSSODescriptor|SAML2_XML_md_SPSSODescriptor|SAML2_XML_md_AuthnAuthorityDescriptor|SAML2_XML_md_AttributeAuthorityDescriptor|SAML2_XML_md_PDPDescriptor $n */
+        /** @var \SAML2\XML\md\UnknownRoleDescriptor|\SAML2\XML\md\IDPSSODescriptor|\SAML2\XML\md\SPSSODescriptor|\SAML2\XML\md\AuthnAuthorityDescriptor|\SAML2\XML\md\AttributeAuthorityDescriptor|\SAML2\XML\md\PDPDescriptor $n */
         foreach ($this->RoleDescriptor as $n) {
             $n->toXML($e);
         }
diff --git a/src/SAML2/XML/md/Extensions.php b/src/SAML2/XML/md/Extensions.php
index 2b1aee81c..8e1706853 100644
--- a/src/SAML2/XML/md/Extensions.php
+++ b/src/SAML2/XML/md/Extensions.php
@@ -1,36 +1,49 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\Utils;
+use SAML2\XML\shibmd\Scope;
+use SAML2\XML\mdattr\EntityAttributes;
+use SAML2\XML\mdrpi\Common;
+use SAML2\XML\mdrpi\RegistrationInfo;
+use SAML2\XML\mdrpi\PublicationInfo;
+use SAML2\XML\mdui\UIInfo;
+use SAML2\XML\mdui\DiscoHints;
+use SAML2\XML\Chunk;
+use SAML2\Constants;
+
 /**
  * Class for handling SAML2 metadata extensions.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_Extensions
+class Extensions
 {
     /**
      * Get a list of Extensions in the given element.
      *
      * @param  DOMElement $parent The element that may contain the md:Extensions element.
-     * @return SAML2_XML_Chunk[]  Array of extensions.
+     * @return \SAML2\XML\Chunk[]  Array of extensions.
      */
     public static function getList(DOMElement $parent)
     {
         $ret = array();
-        foreach (SAML2_Utils::xpQuery($parent, './saml_metadata:Extensions/*') as $node) {
-            if ($node->namespaceURI === SAML2_XML_shibmd_Scope::NS && $node->localName === 'Scope') {
-                $ret[] = new SAML2_XML_shibmd_Scope($node);
-            } elseif ($node->namespaceURI === SAML2_XML_mdattr_EntityAttributes::NS && $node->localName === 'EntityAttributes') {
-                $ret[] = new SAML2_XML_mdattr_EntityAttributes($node);
-            } elseif ($node->namespaceURI === SAML2_XML_mdrpi_Common::NS_MDRPI && $node->localName === 'RegistrationInfo') {
-                $ret[] = new SAML2_XML_mdrpi_RegistrationInfo($node);
-            } elseif ($node->namespaceURI === SAML2_XML_mdrpi_Common::NS_MDRPI && $node->localName === 'PublicationInfo') {
-                $ret[] = new SAML2_XML_mdrpi_PublicationInfo($node);
-            } elseif ($node->namespaceURI === SAML2_XML_mdui_UIInfo::NS && $node->localName === 'UIInfo') {
-                $ret[] = new SAML2_XML_mdui_UIInfo($node);
-            } elseif ($node->namespaceURI === SAML2_XML_mdui_DiscoHints::NS && $node->localName === 'DiscoHints') {
-                $ret[] = new SAML2_XML_mdui_DiscoHints($node);
+        foreach (Utils::xpQuery($parent, './saml_metadata:Extensions/*') as $node) {
+            if ($node->namespaceURI === Scope::NS && $node->localName === 'Scope') {
+                $ret[] = new Scope($node);
+            } elseif ($node->namespaceURI === EntityAttributes::NS && $node->localName === 'EntityAttributes') {
+                $ret[] = new EntityAttributes($node);
+            } elseif ($node->namespaceURI === Common::NS_MDRPI && $node->localName === 'RegistrationInfo') {
+                $ret[] = new RegistrationInfo($node);
+            } elseif ($node->namespaceURI === Common::NS_MDRPI && $node->localName === 'PublicationInfo') {
+                $ret[] = new PublicationInfo($node);
+            } elseif ($node->namespaceURI === UIInfo::NS && $node->localName === 'UIInfo') {
+                $ret[] = new UIInfo($node);
+            } elseif ($node->namespaceURI === DiscoHints::NS && $node->localName === 'DiscoHints') {
+                $ret[] = new DiscoHints($node);
             } else {
-                $ret[] = new SAML2_XML_Chunk($node);
+                $ret[] = new Chunk($node);
             }
         }
 
@@ -41,7 +54,7 @@ public static function getList(DOMElement $parent)
      * Add a list of Extensions to the given element.
      *
      * @param DOMElement        $parent     The element we should add the extensions to.
-     * @param SAML2_XML_Chunk[] $extensions List of extension objects.
+     * @param \SAML2\XML\Chunk[] $extensions List of extension objects.
      */
     public static function addList(DOMElement $parent, array $extensions)
     {
@@ -49,7 +62,7 @@ public static function addList(DOMElement $parent, array $extensions)
             return;
         }
 
-        $extElement = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_MD, 'md:Extensions');
+        $extElement = $parent->ownerDocument->createElementNS(Constants::NS_MD, 'md:Extensions');
         $parent->appendChild($extElement);
 
         foreach ($extensions as $ext) {
diff --git a/src/SAML2/XML/md/IDPSSODescriptor.php b/src/SAML2/XML/md/IDPSSODescriptor.php
index 119afe601..dda70df8e 100644
--- a/src/SAML2/XML/md/IDPSSODescriptor.php
+++ b/src/SAML2/XML/md/IDPSSODescriptor.php
@@ -1,11 +1,17 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\Utils;
+use SAML2\Constants;
+use SAML2\XML\saml\Attribute;
+
 /**
  * Class representing SAML 2 IDPSSODescriptor.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_IDPSSODescriptor extends SAML2_XML_md_SSODescriptorType
+class IDPSSODescriptor extends SSODescriptorType
 {
     /**
      * Whether AuthnRequests sent to this IdP should be signed.
@@ -19,7 +25,7 @@ class SAML2_XML_md_IDPSSODescriptor extends SAML2_XML_md_SSODescriptorType
      *
      * Array with EndpointType objects.
      *
-     * @var SAML2_XML_md_EndpointType[]
+     * @var \SAML2\XML\md\EndpointType[]
      */
     public $SingleSignOnService = array();
 
@@ -28,7 +34,7 @@ class SAML2_XML_md_IDPSSODescriptor extends SAML2_XML_md_SSODescriptorType
      *
      * Array with EndpointType objects.
      *
-     * @var SAML2_XML_md_EndpointType[]
+     * @var \SAML2\XML\md\EndpointType[]
      */
     public $NameIDMappingService = array();
 
@@ -37,7 +43,7 @@ class SAML2_XML_md_IDPSSODescriptor extends SAML2_XML_md_SSODescriptorType
      *
      * Array with EndpointType objects.
      *
-     * @var SAML2_XML_md_EndpointType[]
+     * @var \SAML2\XML\md\EndpointType[]
      */
     public $AssertionIDRequestService = array();
 
@@ -53,9 +59,9 @@ class SAML2_XML_md_IDPSSODescriptor extends SAML2_XML_md_SSODescriptorType
     /**
      * List of supported attributes.
      *
-     * Array with SAML2_XML_saml_Attribute objects.
+     * Array with \SAML2\XML\saml\Attribute objects.
      *
-     * @var SAML2_XML_saml_Attribute[]
+     * @var \SAML2\XML\saml\Attribute[]
      */
     public $Attribute = array();
 
@@ -72,24 +78,24 @@ public function __construct(DOMElement $xml = NULL)
             return;
         }
 
-        $this->WantAuthnRequestsSigned = SAML2_Utils::parseBoolean($xml, 'WantAuthnRequestsSigned', NULL);
+        $this->WantAuthnRequestsSigned = Utils::parseBoolean($xml, 'WantAuthnRequestsSigned', NULL);
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:SingleSignOnService') as $ep) {
-            $this->SingleSignOnService[] = new SAML2_XML_md_EndpointType($ep);
+        foreach (Utils::xpQuery($xml, './saml_metadata:SingleSignOnService') as $ep) {
+            $this->SingleSignOnService[] = new EndpointType($ep);
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:NameIDMappingService') as $ep) {
-            $this->NameIDMappingService[] = new SAML2_XML_md_EndpointType($ep);
+        foreach (Utils::xpQuery($xml, './saml_metadata:NameIDMappingService') as $ep) {
+            $this->NameIDMappingService[] = new EndpointType($ep);
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) {
-            $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($ep);
+        foreach (Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) {
+            $this->AssertionIDRequestService[] = new EndpointType($ep);
         }
 
-        $this->AttributeProfile = SAML2_Utils::extractStrings($xml, SAML2_Constants::NS_MD, 'AttributeProfile');
+        $this->AttributeProfile = Utils::extractStrings($xml, Constants::NS_MD, 'AttributeProfile');
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_assertion:Attribute') as $a) {
-            $this->Attribute[] = new SAML2_XML_saml_Attribute($a);
+        foreach (Utils::xpQuery($xml, './saml_assertion:Attribute') as $a) {
+            $this->Attribute[] = new Attribute($a);
         }
     }
 
@@ -128,7 +134,7 @@ public function toXML(DOMElement $parent)
             $ep->toXML($e, 'md:AssertionIDRequestService');
         }
 
-        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:AttributeProfile', FALSE, $this->AttributeProfile);
+        Utils::addStrings($e, Constants::NS_MD, 'md:AttributeProfile', FALSE, $this->AttributeProfile);
 
         foreach ($this->Attribute as $a) {
             $a->toXML($e);
diff --git a/src/SAML2/XML/md/IndexedEndpointType.php b/src/SAML2/XML/md/IndexedEndpointType.php
index 2e5c89173..e781eeabe 100644
--- a/src/SAML2/XML/md/IndexedEndpointType.php
+++ b/src/SAML2/XML/md/IndexedEndpointType.php
@@ -1,11 +1,15 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\Utils;
+
 /**
  * Class representing SAML 2 IndexedEndpointType.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_IndexedEndpointType extends SAML2_XML_md_EndpointType
+class IndexedEndpointType extends EndpointType
 {
     /**
      * The index for this endpoint.
@@ -40,7 +44,7 @@ public function __construct(DOMElement $xml = NULL)
         }
         $this->index = (int) $xml->getAttribute('index');
 
-        $this->isDefault = SAML2_Utils::parseBoolean($xml, 'isDefault', NULL);
+        $this->isDefault = Utils::parseBoolean($xml, 'isDefault', NULL);
     }
 
     /**
diff --git a/src/SAML2/XML/md/KeyDescriptor.php b/src/SAML2/XML/md/KeyDescriptor.php
index d68fb5086..95873cbad 100644
--- a/src/SAML2/XML/md/KeyDescriptor.php
+++ b/src/SAML2/XML/md/KeyDescriptor.php
@@ -1,11 +1,18 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\Utils;
+use SAML2\XML\ds\KeyInfo;
+use SAML2\XML\Chunk;
+use SAML2\Constants;
+
 /**
  * Class representing a KeyDescriptor element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_KeyDescriptor
+class KeyDescriptor
 {
     /**
      * What this key can be used for.
@@ -19,16 +26,16 @@ class SAML2_XML_md_KeyDescriptor
     /**
      * The KeyInfo for this key.
      *
-     * @var SAML2_XML_ds_KeyInfo
+     * @var \SAML2\XML\ds\KeyInfo
      */
     public $KeyInfo;
 
     /**
      * Supported EncryptionMethods.
      *
-     * Array of SAML2_XML_Chunk objects.
+     * Array of \SAML2\XML\Chunk objects.
      *
-     * @var SAML2_XML_Chunk[]
+     * @var \SAML2\XML\Chunk[]
      */
     public $EncryptionMethod = array();
 
@@ -48,16 +55,16 @@ public function __construct(DOMElement $xml = NULL)
             $this->use = $xml->getAttribute('use');
         }
 
-        $keyInfo = SAML2_Utils::xpQuery($xml, './ds:KeyInfo');
+        $keyInfo = Utils::xpQuery($xml, './ds:KeyInfo');
         if (count($keyInfo) > 1) {
             throw new Exception('More than one ds:KeyInfo in the KeyDescriptor.');
         } elseif (empty($keyInfo)) {
             throw new Exception('No ds:KeyInfo in the KeyDescriptor.');
         }
-        $this->KeyInfo = new SAML2_XML_ds_KeyInfo($keyInfo[0]);
+        $this->KeyInfo = new KeyInfo($keyInfo[0]);
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:EncryptionMethod') as $em) {
-            $this->EncryptionMethod[] = new SAML2_XML_Chunk($em);
+        foreach (Utils::xpQuery($xml, './saml_metadata:EncryptionMethod') as $em) {
+            $this->EncryptionMethod[] = new Chunk($em);
         }
 
     }
@@ -76,7 +83,7 @@ public function toXML(DOMElement $parent)
 
         $doc = $parent->ownerDocument;
 
-        $e = $doc->createElementNS(SAML2_Constants::NS_MD, 'md:KeyDescriptor');
+        $e = $doc->createElementNS(Constants::NS_MD, 'md:KeyDescriptor');
         $parent->appendChild($e);
 
         if (isset($this->use)) {
diff --git a/src/SAML2/XML/md/Organization.php b/src/SAML2/XML/md/Organization.php
index a9dc7177d..67f183ab5 100644
--- a/src/SAML2/XML/md/Organization.php
+++ b/src/SAML2/XML/md/Organization.php
@@ -1,11 +1,16 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 Organization element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_Organization
+class Organization
 {
     /**
      * Extensions on this element.
@@ -48,19 +53,19 @@ public function __construct(DOMElement $xml = NULL)
             return;
         }
 
-        $this->Extensions = SAML2_XML_md_Extensions::getList($xml);
+        $this->Extensions = Extensions::getList($xml);
 
-        $this->OrganizationName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Constants::NS_MD, 'OrganizationName');
+        $this->OrganizationName = Utils::extractLocalizedStrings($xml, Constants::NS_MD, 'OrganizationName');
         if (empty($this->OrganizationName)) {
             $this->OrganizationName = array('invalid' => '');
         }
 
-        $this->OrganizationDisplayName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Constants::NS_MD, 'OrganizationDisplayName');
+        $this->OrganizationDisplayName = Utils::extractLocalizedStrings($xml, Constants::NS_MD, 'OrganizationDisplayName');
         if (empty($this->OrganizationDisplayName)) {
             $this->OrganizationDisplayName = array('invalid' => '');
         }
 
-        $this->OrganizationURL = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Constants::NS_MD, 'OrganizationURL');
+        $this->OrganizationURL = Utils::extractLocalizedStrings($xml, Constants::NS_MD, 'OrganizationURL');
         if (empty($this->OrganizationURL)) {
             $this->OrganizationURL = array('invalid' => '');
         }
@@ -84,14 +89,14 @@ public function toXML(DOMElement $parent)
 
         $doc = $parent->ownerDocument;
 
-        $e = $doc->createElementNS(SAML2_Constants::NS_MD, 'md:Organization');
+        $e = $doc->createElementNS(Constants::NS_MD, 'md:Organization');
         $parent->appendChild($e);
 
-        SAML2_XML_md_Extensions::addList($e, $this->Extensions);
+        Extensions::addList($e, $this->Extensions);
 
-        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:OrganizationName', TRUE, $this->OrganizationName);
-        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:OrganizationDisplayName', TRUE, $this->OrganizationDisplayName);
-        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:OrganizationURL', TRUE, $this->OrganizationURL);
+        Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationName', TRUE, $this->OrganizationName);
+        Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationDisplayName', TRUE, $this->OrganizationDisplayName);
+        Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationURL', TRUE, $this->OrganizationURL);
 
         return $e;
     }
diff --git a/src/SAML2/XML/md/PDPDescriptor.php b/src/SAML2/XML/md/PDPDescriptor.php
index 5627bf434..72bd27c8c 100644
--- a/src/SAML2/XML/md/PDPDescriptor.php
+++ b/src/SAML2/XML/md/PDPDescriptor.php
@@ -1,18 +1,23 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 metadata PDPDescriptor.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_PDPDescriptor extends SAML2_XML_md_RoleDescriptor
+class PDPDescriptor extends RoleDescriptor
 {
     /**
      * List of AuthzService endpoints.
      *
      * Array with EndpointType objects.
      *
-     * @var SAML2_XML_md_EndpointType[]
+     * @var \SAML2\XML\md\EndpointType[]
      */
     public $AuthzService = array();
 
@@ -21,7 +26,7 @@ class SAML2_XML_md_PDPDescriptor extends SAML2_XML_md_RoleDescriptor
      *
      * Array with EndpointType objects.
      *
-     * @var SAML2_XML_md_EndpointType[]
+     * @var \SAML2\XML\md\EndpointType[]
      */
     public $AssertionIDRequestService = array();
 
@@ -48,18 +53,18 @@ public function __construct(DOMElement $xml = NULL)
             return;
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AuthzService') as $ep) {
-            $this->AuthzService[] = new SAML2_XML_md_EndpointType($ep);
+        foreach (Utils::xpQuery($xml, './saml_metadata:AuthzService') as $ep) {
+            $this->AuthzService[] = new EndpointType($ep);
         }
         if (empty($this->AuthzService)) {
             throw new Exception('Must have at least one AuthzService in PDPDescriptor.');
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) {
-            $this->AssertionIDRequestService[] = new SAML2_XML_md_EndpointType($ep);
+        foreach (Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) {
+            $this->AssertionIDRequestService[] = new EndpointType($ep);
         }
 
-        $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Constants::NS_MD, 'NameIDFormat');
+        $this->NameIDFormat = Utils::extractStrings($xml, Constants::NS_MD, 'NameIDFormat');
     }
 
     /**
@@ -85,7 +90,7 @@ public function toXML(DOMElement $parent)
             $ep->toXML($e, 'md:AssertionIDRequestService');
         }
 
-        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
+        Utils::addStrings($e, Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
 
         return $e;
     }
diff --git a/src/SAML2/XML/md/RequestedAttribute.php b/src/SAML2/XML/md/RequestedAttribute.php
index 5e10acf87..af8a2f958 100644
--- a/src/SAML2/XML/md/RequestedAttribute.php
+++ b/src/SAML2/XML/md/RequestedAttribute.php
@@ -1,11 +1,17 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\XML\saml\Attribute;
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 metadata RequestedAttribute.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_RequestedAttribute extends SAML2_XML_saml_Attribute
+class RequestedAttribute extends Attribute
 {
     /**
      * Whether this attribute is required.
@@ -27,7 +33,7 @@ public function __construct(DOMElement $xml = NULL)
             return;
         }
 
-        $this->isRequired = SAML2_Utils::parseBoolean($xml, 'isRequired', NULL);
+        $this->isRequired = Utils::parseBoolean($xml, 'isRequired', NULL);
     }
 
     /**
@@ -40,7 +46,7 @@ public function toXML(DOMElement $parent)
     {
         assert('is_bool($this->isRequired) || is_null($this->isRequired)');
 
-        $e = $this->toXMLInternal($parent, SAML2_Constants::NS_MD, 'md:RequestedAttribute');
+        $e = $this->toXMLInternal($parent, Constants::NS_MD, 'md:RequestedAttribute');
 
         if ($this->isRequired === TRUE) {
             $e->setAttribute('isRequired', 'true');
diff --git a/src/SAML2/XML/md/RoleDescriptor.php b/src/SAML2/XML/md/RoleDescriptor.php
index 5163c1cfb..e0b0ff589 100644
--- a/src/SAML2/XML/md/RoleDescriptor.php
+++ b/src/SAML2/XML/md/RoleDescriptor.php
@@ -1,11 +1,17 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\SignedElementHelper;
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 RoleDescriptor element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_RoleDescriptor extends SAML2_SignedElementHelper
+class RoleDescriptor extends SignedElementHelper
 {
     /**
      * The name of this descriptor element.
@@ -61,25 +67,25 @@ class SAML2_XML_md_RoleDescriptor extends SAML2_SignedElementHelper
     /**
      * KeyDescriptor elements.
      *
-     * Array of SAML2_XML_md_KeyDescriptor elements.
+     * Array of \SAML2\XML\md\KeyDescriptor elements.
      *
-     * @var SAML2_XML_md_KeyDescriptor[]
+     * @var \SAML2\XML\md\KeyDescriptor[]
      */
     public $KeyDescriptor = array();
 
     /**
      * Organization of this role.
      *
-     * @var SAML2_XML_md_Organization|NULL
+     * @var \SAML2\XML\md\Organization|NULL
      */
     public $Organization = NULL;
 
     /**
      * ContactPerson elements for this role.
      *
-     * Array of SAML2_XML_md_ContactPerson objects.
+     * Array of \SAML2\XML\md\ContactPerson objects.
      *
-     * @var SAML2_XML_md_ContactPerson[]
+     * @var \SAML2\XML\md\ContactPerson[]
      */
     public $ContactPerson = array();
 
@@ -105,7 +111,7 @@ protected function __construct($elementName, DOMElement $xml = NULL)
             $this->ID = $xml->getAttribute('ID');
         }
         if ($xml->hasAttribute('validUntil')) {
-            $this->validUntil = SAML2_Utils::xsDateTimeToTimestamp($xml->getAttribute('validUntil'));
+            $this->validUntil = Utils::xsDateTimeToTimestamp($xml->getAttribute('validUntil'));
         }
         if ($xml->hasAttribute('cacheDuration')) {
             $this->cacheDuration = $xml->getAttribute('cacheDuration');
@@ -120,21 +126,21 @@ protected function __construct($elementName, DOMElement $xml = NULL)
             $this->errorURL = $xml->getAttribute('errorURL');
         }
 
-        $this->Extensions = SAML2_XML_md_Extensions::getList($xml);
+        $this->Extensions = Extensions::getList($xml);
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:KeyDescriptor') as $kd) {
-            $this->KeyDescriptor[] = new SAML2_XML_md_KeyDescriptor($kd);
+        foreach (Utils::xpQuery($xml, './saml_metadata:KeyDescriptor') as $kd) {
+            $this->KeyDescriptor[] = new KeyDescriptor($kd);
         }
 
-        $organization = SAML2_Utils::xpQuery($xml, './saml_metadata:Organization');
+        $organization = Utils::xpQuery($xml, './saml_metadata:Organization');
         if (count($organization) > 1) {
             throw new Exception('More than one Organization in the entity.');
         } elseif (!empty($organization)) {
-            $this->Organization = new SAML2_XML_md_Organization($organization[0]);
+            $this->Organization = new Organization($organization[0]);
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:ContactPerson') as $cp) {
-            $this->contactPersons[] = new SAML2_XML_md_ContactPerson($cp);
+        foreach (Utils::xpQuery($xml, './saml_metadata:ContactPerson') as $cp) {
+            $this->contactPersons[] = new ContactPerson($cp);
         }
     }
 
@@ -156,7 +162,7 @@ protected function toXML(DOMElement $parent)
         assert('is_null($this->Organization) || $this->Organization instanceof SAML2_XML_md_Organization');
         assert('is_array($this->ContactPerson)');
 
-        $e = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_MD, $this->elementName);
+        $e = $parent->ownerDocument->createElementNS(Constants::NS_MD, $this->elementName);
         $parent->appendChild($e);
 
         if (isset($this->ID)) {
@@ -177,7 +183,7 @@ protected function toXML(DOMElement $parent)
             $e->setAttribute('errorURL', $this->errorURL);
         }
 
-        SAML2_XML_md_Extensions::addList($e, $this->Extensions);
+        Extensions::addList($e, $this->Extensions);
 
         foreach ($this->KeyDescriptor as $kd) {
             $kd->toXML($e);
diff --git a/src/SAML2/XML/md/SPSSODescriptor.php b/src/SAML2/XML/md/SPSSODescriptor.php
index 2472a0784..1be2af64d 100644
--- a/src/SAML2/XML/md/SPSSODescriptor.php
+++ b/src/SAML2/XML/md/SPSSODescriptor.php
@@ -1,11 +1,15 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\Utils;
+
 /**
  * Class representing SAML 2 SPSSODescriptor.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_SPSSODescriptor extends SAML2_XML_md_SSODescriptorType
+class SPSSODescriptor extends SSODescriptorType
 {
     /**
      * Whether this SP signs authentication requests.
@@ -26,16 +30,16 @@ class SAML2_XML_md_SPSSODescriptor extends SAML2_XML_md_SSODescriptorType
      *
      * Array with IndexedEndpointType objects.
      *
-     * @var SAML2_XML_md_IndexedEndpointType[]
+     * @var \SAML2\XML\md\IndexedEndpointType[]
      */
     public $AssertionConsumerService = array();
 
     /**
      * List of AttributeConsumingService descriptors for this SP.
      *
-     * Array with SAML2_XML_md_AttributeConsumingService objects.
+     * Array with \SAML2\XML\md\AttributeConsumingService objects.
      *
-     * @var SAML2_XML_md_AttributeConsumingService[]
+     * @var \SAML2\XML\md\AttributeConsumingService[]
      */
     public $AttributeConsumingService = array();
 
@@ -52,15 +56,15 @@ public function __construct(DOMElement $xml = NULL)
             return;
         }
 
-        $this->AuthnRequestsSigned = SAML2_Utils::parseBoolean($xml, 'AuthnRequestsSigned', NULL);
-        $this->WantAssertionsSigned = SAML2_Utils::parseBoolean($xml, 'WantAssertionsSigned', NULL);
+        $this->AuthnRequestsSigned = Utils::parseBoolean($xml, 'AuthnRequestsSigned', NULL);
+        $this->WantAssertionsSigned = Utils::parseBoolean($xml, 'WantAssertionsSigned', NULL);
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AssertionConsumerService') as $ep) {
-            $this->AssertionConsumerService[] = new SAML2_XML_md_IndexedEndpointType($ep);
+        foreach (Utils::xpQuery($xml, './saml_metadata:AssertionConsumerService') as $ep) {
+            $this->AssertionConsumerService[] = new IndexedEndpointType($ep);
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:AttributeConsumingService') as $acs) {
-            $this->AttributeConsumingService[] = new SAML2_XML_md_AttributeConsumingService($acs);
+        foreach (Utils::xpQuery($xml, './saml_metadata:AttributeConsumingService') as $acs) {
+            $this->AttributeConsumingService[] = new AttributeConsumingService($acs);
         }
     }
 
diff --git a/src/SAML2/XML/md/SSODescriptorType.php b/src/SAML2/XML/md/SSODescriptorType.php
index 0b6d8021a..9138f80ef 100644
--- a/src/SAML2/XML/md/SSODescriptorType.php
+++ b/src/SAML2/XML/md/SSODescriptorType.php
@@ -1,18 +1,23 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 SSODescriptorType.
  *
  * @package SimpleSAMLphp
  */
-abstract class SAML2_XML_md_SSODescriptorType extends SAML2_XML_md_RoleDescriptor
+abstract class SSODescriptorType extends RoleDescriptor
 {
     /**
      * List of ArtifactResolutionService endpoints.
      *
      * Array with IndexedEndpointType objects.
      *
-     * @var SAML2_XML_md_IndexedEndpointType[]
+     * @var \SAML2\XML\md\IndexedEndpointType[]
      */
     public $ArtifactResolutionService = array();
 
@@ -21,7 +26,7 @@ abstract class SAML2_XML_md_SSODescriptorType extends SAML2_XML_md_RoleDescripto
      *
      * Array with EndpointType objects.
      *
-     * @var SAML2_XML_md_EndpointType[]
+     * @var \SAML2\XML\md\EndpointType[]
      */
     public $SingleLogoutService = array();
 
@@ -30,7 +35,7 @@ abstract class SAML2_XML_md_SSODescriptorType extends SAML2_XML_md_RoleDescripto
      *
      * Array with EndpointType objects.
      *
-     * @var SAML2_XML_md_EndpointType[]
+     * @var \SAML2\XML\md\EndpointType[]
      */
     public $ManageNameIDService = array();
 
@@ -59,19 +64,19 @@ protected function __construct($elementName, DOMElement $xml = NULL)
             return;
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:ArtifactResolutionService') as $ep) {
-            $this->ArtifactResolutionService[] = new SAML2_XML_md_IndexedEndpointType($ep);
+        foreach (Utils::xpQuery($xml, './saml_metadata:ArtifactResolutionService') as $ep) {
+            $this->ArtifactResolutionService[] = new IndexedEndpointType($ep);
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:SingleLogoutService') as $ep) {
-            $this->SingleLogoutService[] = new SAML2_XML_md_EndpointType($ep);
+        foreach (Utils::xpQuery($xml, './saml_metadata:SingleLogoutService') as $ep) {
+            $this->SingleLogoutService[] = new EndpointType($ep);
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:ManageNameIDService') as $ep) {
-            $this->ManageNameIDService[] = new SAML2_XML_md_EndpointType($ep);
+        foreach (Utils::xpQuery($xml, './saml_metadata:ManageNameIDService') as $ep) {
+            $this->ManageNameIDService[] = new EndpointType($ep);
         }
 
-        $this->NameIDFormat = SAML2_Utils::extractStrings($xml, SAML2_Constants::NS_MD, 'NameIDFormat');
+        $this->NameIDFormat = Utils::extractStrings($xml, Constants::NS_MD, 'NameIDFormat');
     }
 
     /**
@@ -101,7 +106,7 @@ protected function toXML(DOMElement $parent)
             $ep->toXML($e, 'md:ManageNameIDService');
         }
 
-        SAML2_Utils::addStrings($e, SAML2_Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
+        Utils::addStrings($e, Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
 
         return $e;
     }
diff --git a/src/SAML2/XML/md/UnknownRoleDescriptor.php b/src/SAML2/XML/md/UnknownRoleDescriptor.php
index 07c745110..663eb8e9d 100644
--- a/src/SAML2/XML/md/UnknownRoleDescriptor.php
+++ b/src/SAML2/XML/md/UnknownRoleDescriptor.php
@@ -1,16 +1,20 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\XML\Chunk;
+
 /**
  * Class representing unknown RoleDescriptors.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_md_UnknownRoleDescriptor extends SAML2_XML_md_RoleDescriptor
+class UnknownRoleDescriptor extends RoleDescriptor
 {
     /**
      * This RoleDescriptor as XML
      *
-     * @var SAML2_XML_Chunk
+     * @var \SAML2\XML\Chunk
      */
     private $xml;
 
@@ -23,7 +27,7 @@ public function __construct(DOMElement $xml)
     {
         parent::__construct('md:RoleDescriptor', $xml);
 
-        $this->xml = new SAML2_XML_Chunk($xml);
+        $this->xml = new Chunk($xml);
     }
 
     /**
diff --git a/src/SAML2/XML/mdattr/EntityAttributes.php b/src/SAML2/XML/mdattr/EntityAttributes.php
index 6b776f790..b5762b388 100644
--- a/src/SAML2/XML/mdattr/EntityAttributes.php
+++ b/src/SAML2/XML/mdattr/EntityAttributes.php
@@ -1,12 +1,18 @@
 <?php
 
+namespace SAML2\XML\mdattr;
+
+use SAML2\Utils;
+use SAML2\XML\saml\Attribute;
+use SAML2\XML\Chunk;
+
 /**
  * Class for handling the EntityAttributes metadata extension.
  *
  * @link: http://docs.oasis-open.org/security/saml/Post2.0/sstc-metadata-attr-cs-01.pdf
  * @package SimpleSAMLphp
  */
-class SAML2_XML_mdattr_EntityAttributes
+class EntityAttributes
 {
     /**
      * The namespace used for the EntityAttributes extension.
@@ -16,9 +22,9 @@ class SAML2_XML_mdattr_EntityAttributes
     /**
      * Array with child elements.
      *
-     * The elements can be SAML2_XML_saml_Attribute or SAML2_XML_Chunk elements.
+     * The elements can be \SAML2\XML\saml\Attribute or \SAML2\XML\Chunk elements.
      *
-     * @var (SAML2_XML_saml_Attribute|SAML2_XML_Chunk)[]
+     * @var (\SAML2\XML\saml\Attribute|\SAML2\XML\Chunk)[]
      */
     public $children;
 
@@ -33,11 +39,11 @@ public function __construct(DOMElement $xml = NULL)
             return;
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_assertion:Attribute|./saml_assertion:Assertion') as $node) {
+        foreach (Utils::xpQuery($xml, './saml_assertion:Attribute|./saml_assertion:Assertion') as $node) {
             if ($node->localName === 'Attribute') {
-                $this->children[] = new SAML2_XML_saml_Attribute($node);
+                $this->children[] = new Attribute($node);
             } else {
-                $this->children[] = new SAML2_XML_Chunk($node);
+                $this->children[] = new Chunk($node);
             }
         }
 
@@ -55,10 +61,10 @@ public function toXML(DOMElement $parent)
 
         $doc = $parent->ownerDocument;
 
-        $e = $doc->createElementNS(SAML2_XML_mdattr_EntityAttributes::NS, 'mdattr:EntityAttributes');
+        $e = $doc->createElementNS(EntityAttributes::NS, 'mdattr:EntityAttributes');
         $parent->appendChild($e);
 
-        /** @var SAML2_XML_saml_Attribute|SAML2_XML_Chunk $child */
+        /** @var \SAML2\XML\saml\Attribute|\SAML2\XML\Chunk $child */
         foreach ($this->children as $child) {
             $child->toXML($e);
         }
diff --git a/src/SAML2/XML/mdrpi/Common.php b/src/SAML2/XML/mdrpi/Common.php
index 4f81b0304..98fc43e84 100644
--- a/src/SAML2/XML/mdrpi/Common.php
+++ b/src/SAML2/XML/mdrpi/Common.php
@@ -1,12 +1,14 @@
 <?php
 
+namespace SAML2\XML\mdrpi;
+
 /**
  * Common definitions for the mdrpi metadata extension.
  *
  * @link: http://docs.oasis-open.org/security/saml/Post2.0/saml-metadata-rpi/v1.0/saml-metadata-rpi-v1.0.pdf
  * @package SimpleSAMLphp
  */
-class SAML2_XML_mdrpi_Common
+class Common
 {
     const NS_MDRPI = 'urn:oasis:names:tc:SAML:metadata:rpi';
 
diff --git a/src/SAML2/XML/mdrpi/PublicationInfo.php b/src/SAML2/XML/mdrpi/PublicationInfo.php
index aa21be1f4..38f137ba9 100644
--- a/src/SAML2/XML/mdrpi/PublicationInfo.php
+++ b/src/SAML2/XML/mdrpi/PublicationInfo.php
@@ -1,12 +1,16 @@
 <?php
 
+namespace SAML2\XML\mdrpi;
+
+use SAML2\Utils;
+
 /**
  * Class for handling the mdrpi:PublicationInfo element.
  *
  * @link: http://docs.oasis-open.org/security/saml/Post2.0/saml-metadata-rpi/v1.0/saml-metadata-rpi-v1.0.pdf
  * @package SimpleSAMLphp
  */
-class SAML2_XML_mdrpi_PublicationInfo
+class PublicationInfo
 {
     /**
      * The identifier of the metadata publisher.
@@ -56,14 +60,14 @@ public function __construct(DOMElement $xml = NULL)
         $this->publisher = $xml->getAttribute('publisher');
 
         if ($xml->hasAttribute('creationInstant')) {
-            $this->creationInstant = SAML2_Utils::xsDateTimeToTimestamp($xml->getAttribute('creationInstant'));
+            $this->creationInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('creationInstant'));
         }
 
         if ($xml->hasAttribute('publicationId')) {
             $this->publicationId = $xml->getAttribute('publicationId');
         }
 
-        $this->UsagePolicy = SAML2_Utils::extractLocalizedStrings($xml, SAML2_XML_mdrpi_Common::NS_MDRPI, 'UsagePolicy');
+        $this->UsagePolicy = Utils::extractLocalizedStrings($xml, Common::NS_MDRPI, 'UsagePolicy');
     }
 
     /**
@@ -81,7 +85,7 @@ public function toXML(DOMElement $parent)
 
         $doc = $parent->ownerDocument;
 
-        $e = $doc->createElementNS(SAML2_XML_mdrpi_Common::NS_MDRPI, 'mdrpi:PublicationInfo');
+        $e = $doc->createElementNS(Common::NS_MDRPI, 'mdrpi:PublicationInfo');
         $parent->appendChild($e);
 
         $e->setAttribute('publisher', $this->publisher);
@@ -94,7 +98,7 @@ public function toXML(DOMElement $parent)
             $e->setAttribute('publicationId', $this->publicationId);
         }
 
-        SAML2_Utils::addStrings($e, SAML2_XML_mdrpi_Common::NS_MDRPI, 'mdrpi:UsagePolicy', TRUE, $this->UsagePolicy);
+        Utils::addStrings($e, Common::NS_MDRPI, 'mdrpi:UsagePolicy', TRUE, $this->UsagePolicy);
 
         return $e;
     }
diff --git a/src/SAML2/XML/mdrpi/RegistrationInfo.php b/src/SAML2/XML/mdrpi/RegistrationInfo.php
index 338fa0642..1701195f6 100644
--- a/src/SAML2/XML/mdrpi/RegistrationInfo.php
+++ b/src/SAML2/XML/mdrpi/RegistrationInfo.php
@@ -1,12 +1,16 @@
 <?php
 
+namespace SAML2\XML\mdrpi;
+
+use SAML2\Utils;
+
 /**
  * Class for handling the mdrpi:RegistrationInfo element.
  *
  * @link: http://docs.oasis-open.org/security/saml/Post2.0/saml-metadata-rpi/v1.0/saml-metadata-rpi-v1.0.pdf
  * @package SimpleSAMLphp
  */
-class SAML2_XML_mdrpi_RegistrationInfo
+class RegistrationInfo
 {
     /**
      * The identifier of the metadata registration authority.
@@ -49,10 +53,10 @@ public function __construct(DOMElement $xml = NULL)
         $this->registrationAuthority = $xml->getAttribute('registrationAuthority');
 
         if ($xml->hasAttribute('registrationInstant')) {
-            $this->registrationInstant = SAML2_Utils::xsDateTimeToTimestamp($xml->getAttribute('registrationInstant'));
+            $this->registrationInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('registrationInstant'));
         }
 
-        $this->RegistrationPolicy = SAML2_Utils::extractLocalizedStrings($xml, SAML2_XML_mdrpi_Common::NS_MDRPI, 'RegistrationPolicy');
+        $this->RegistrationPolicy = Utils::extractLocalizedStrings($xml, Common::NS_MDRPI, 'RegistrationPolicy');
     }
 
     /**
@@ -73,7 +77,7 @@ public function toXML(DOMElement $parent)
 
         $doc = $parent->ownerDocument;
 
-        $e = $doc->createElementNS(SAML2_XML_mdrpi_Common::NS_MDRPI, 'mdrpi:RegistrationInfo');
+        $e = $doc->createElementNS(Common::NS_MDRPI, 'mdrpi:RegistrationInfo');
         $parent->appendChild($e);
 
         $e->setAttribute('registrationAuthority', $this->registrationAuthority);
@@ -82,7 +86,7 @@ public function toXML(DOMElement $parent)
             $e->setAttribute('registrationInstant', gmdate('Y-m-d\TH:i:s\Z', $this->registrationInstant));
         }
 
-        SAML2_Utils::addStrings($e, SAML2_XML_mdrpi_Common::NS_MDRPI, 'mdrpi:RegistrationPolicy', TRUE, $this->RegistrationPolicy);
+        Utils::addStrings($e, Common::NS_MDRPI, 'mdrpi:RegistrationPolicy', TRUE, $this->RegistrationPolicy);
 
         return $e;
     }
diff --git a/src/SAML2/XML/mdui/DiscoHints.php b/src/SAML2/XML/mdui/DiscoHints.php
index da35da1dc..823da041b 100644
--- a/src/SAML2/XML/mdui/DiscoHints.php
+++ b/src/SAML2/XML/mdui/DiscoHints.php
@@ -1,12 +1,17 @@
 <?php
 
+namespace SAML2\XML\mdui;
+
+use SAML2\Utils;
+use SAML2\XML\Chunk;
+
 /**
  * Class for handling the metadata extensions for login and discovery user interface
  *
  * @link: http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-metadata-ui/v1.0/sstc-saml-metadata-ui-v1.0.pdf
  * @package SimpleSAMLphp
  */
-class SAML2_XML_mdui_DiscoHints
+class DiscoHints
 {
     /**
      * The namespace used for the DiscoHints extension.
@@ -16,9 +21,9 @@ class SAML2_XML_mdui_DiscoHints
     /**
      * Array with child elements.
      *
-     * The elements can be any of the other SAML2_XML_mdui_* elements.
+     * The elements can be any of the other \SAML2\XML\mdui\* elements.
      *
-     * @var SAML2_XML_Chunk[]
+     * @var \SAML2\XML\Chunk[]
      */
     public $children = array();
 
@@ -54,12 +59,12 @@ public function __construct(DOMElement $xml = NULL)
             return;
         }
 
-        $this->IPHint =          SAML2_Utils::extractStrings($xml, self::NS, 'IPHint');
-        $this->DomainHint =      SAML2_Utils::extractStrings($xml, self::NS, 'DomainHint');
-        $this->GeolocationHint = SAML2_Utils::extractStrings($xml, self::NS, 'GeolocationHint');
+        $this->IPHint =          Utils::extractStrings($xml, self::NS, 'IPHint');
+        $this->DomainHint =      Utils::extractStrings($xml, self::NS, 'DomainHint');
+        $this->GeolocationHint = Utils::extractStrings($xml, self::NS, 'GeolocationHint');
 
-        foreach (SAML2_Utils::xpQuery($xml, "./*[namespace-uri()!='".self::NS."']") as $node) {
-            $this->children[] = new SAML2_XML_Chunk($node);
+        foreach (Utils::xpQuery($xml, "./*[namespace-uri()!='".self::NS."']") as $node) {
+            $this->children[] = new Chunk($node);
         }
     }
 
@@ -91,9 +96,9 @@ public function toXML(DOMElement $parent)
                 }
             }
 
-            SAML2_Utils::addStrings($e, self::NS, 'mdui:IPHint', FALSE, $this->IPHint);
-            SAML2_Utils::addStrings($e, self::NS, 'mdui:DomainHint', FALSE, $this->DomainHint);
-            SAML2_Utils::addStrings($e, self::NS, 'mdui:GeolocationHint', FALSE, $this->GeolocationHint);
+            Utils::addStrings($e, self::NS, 'mdui:IPHint', FALSE, $this->IPHint);
+            Utils::addStrings($e, self::NS, 'mdui:DomainHint', FALSE, $this->DomainHint);
+            Utils::addStrings($e, self::NS, 'mdui:GeolocationHint', FALSE, $this->GeolocationHint);
 
             return $e;
         }
diff --git a/src/SAML2/XML/mdui/Keywords.php b/src/SAML2/XML/mdui/Keywords.php
index ee1c89d57..1044479b1 100644
--- a/src/SAML2/XML/mdui/Keywords.php
+++ b/src/SAML2/XML/mdui/Keywords.php
@@ -1,12 +1,14 @@
 <?php
 
+namespace SAML2\XML\mdui;
+
 /**
  * Class for handling the Keywords metadata extensions for login and discovery user interface
  *
  * @link: http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-metadata-ui/v1.0/sstc-saml-metadata-ui-v1.0.pdf
  * @package SimpleSAMLphp
  */
-class SAML2_XML_mdui_Keywords
+class Keywords
 {
     /**
      * The keywords of this item.
@@ -61,7 +63,7 @@ public function toXML(DOMElement $parent)
 
         $doc = $parent->ownerDocument;
 
-        $e = $doc->createElementNS(SAML2_XML_mdui_UIInfo::NS, 'mdui:Keywords');
+        $e = $doc->createElementNS(UIInfo::NS, 'mdui:Keywords');
         $e->setAttribute('xml:lang', $this->lang);
         $value = '';
         foreach ($this->Keywords as $keyword) {
diff --git a/src/SAML2/XML/mdui/Logo.php b/src/SAML2/XML/mdui/Logo.php
index f876251b1..57b773468 100644
--- a/src/SAML2/XML/mdui/Logo.php
+++ b/src/SAML2/XML/mdui/Logo.php
@@ -1,12 +1,14 @@
 <?php
 
+namespace SAML2\XML\mdui;
+
 /**
  * Class for handling the Logo metadata extensions for login and discovery user interface
  *
  * @link: http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-metadata-ui/v1.0/sstc-saml-metadata-ui-v1.0.pdf
  * @package SimpleSAMLphp
  */
-class SAML2_XML_mdui_Logo
+class Logo
 {
     /**
      * The url of this logo.
@@ -77,7 +79,7 @@ public function toXML(DOMElement $parent)
 
         $doc = $parent->ownerDocument;
 
-        $e = $doc->createElementNS(SAML2_XML_mdui_UIInfo::NS, 'mdui:Logo');
+        $e = $doc->createElementNS(UIInfo::NS, 'mdui:Logo');
         $e->appendChild($doc->createTextNode($this->url));
         $e->setAttribute('width', (int) $this->width);
         $e->setAttribute('height', (int) $this->height);
diff --git a/src/SAML2/XML/mdui/UIInfo.php b/src/SAML2/XML/mdui/UIInfo.php
index a94b374ea..a2bc6a9de 100644
--- a/src/SAML2/XML/mdui/UIInfo.php
+++ b/src/SAML2/XML/mdui/UIInfo.php
@@ -1,12 +1,17 @@
 <?php
 
+namespace SAML2\XML\mdui;
+
+use SAML2\Utils;
+use SAML2\XML\Chunk;
+
 /**
  * Class for handling the metadata extensions for login and discovery user interface
  *
  * @link: http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-metadata-ui/v1.0/sstc-saml-metadata-ui-v1.0.pdf
  * @package SimpleSAMLphp
  */
-class SAML2_XML_mdui_UIInfo
+class UIInfo
 {
     /**
      * The namespace used for the UIInfo extension.
@@ -16,7 +21,7 @@ class SAML2_XML_mdui_UIInfo
     /**
      * Array with child elements.
      *
-     * The elements can be any of the other SAML2_XML_mdui_* elements.
+     * The elements can be any of the other \SAML2\XML\mdui\* elements.
      *
      * @var array
      */
@@ -75,23 +80,23 @@ public function __construct(DOMElement $xml = NULL)
             return;
         }
 
-        $this->DisplayName         = SAML2_Utils::extractLocalizedStrings($xml, self::NS, 'DisplayName');
-        $this->Description         = SAML2_Utils::extractLocalizedStrings($xml, self::NS, 'Description');
-        $this->InformationURL      = SAML2_Utils::extractLocalizedStrings($xml, self::NS, 'InformationURL');
-        $this->PrivacyStatementURL = SAML2_Utils::extractLocalizedStrings($xml, self::NS, 'PrivacyStatementURL');
+        $this->DisplayName         = Utils::extractLocalizedStrings($xml, self::NS, 'DisplayName');
+        $this->Description         = Utils::extractLocalizedStrings($xml, self::NS, 'Description');
+        $this->InformationURL      = Utils::extractLocalizedStrings($xml, self::NS, 'InformationURL');
+        $this->PrivacyStatementURL = Utils::extractLocalizedStrings($xml, self::NS, 'PrivacyStatementURL');
 
-        foreach (SAML2_Utils::xpQuery($xml, './*') as $node) {
+        foreach (Utils::xpQuery($xml, './*') as $node) {
             if ($node->namespaceURI === self::NS) {
                 switch ($node->localName) {
                     case 'Keywords':
-                        $this->Keywords[] = new SAML2_XML_mdui_Keywords($node);
+                        $this->Keywords[] = new Keywords($node);
                         break;
                     case 'Logo':
-                        $this->Logo[] = new SAML2_XML_mdui_Logo($node);
+                        $this->Logo[] = new Logo($node);
                         break;
                 }
             } else {
-                $this->children[] = new SAML2_XML_Chunk($node);
+                $this->children[] = new Chunk($node);
             }
         }
     }
@@ -124,10 +129,10 @@ public function toXML(DOMElement $parent)
             $e = $doc->createElementNS(self::NS, 'mdui:UIInfo');
             $parent->appendChild($e);
 
-            SAML2_Utils::addStrings($e, self::NS, 'mdui:DisplayName', TRUE, $this->DisplayName);
-            SAML2_Utils::addStrings($e, self::NS, 'mdui:Description', TRUE, $this->Description);
-            SAML2_Utils::addStrings($e, self::NS, 'mdui:InformationURL', TRUE, $this->InformationURL);
-            SAML2_Utils::addStrings($e, self::NS, 'mdui:PrivacyStatementURL', TRUE, $this->PrivacyStatementURL);
+            Utils::addStrings($e, self::NS, 'mdui:DisplayName', TRUE, $this->DisplayName);
+            Utils::addStrings($e, self::NS, 'mdui:Description', TRUE, $this->Description);
+            Utils::addStrings($e, self::NS, 'mdui:InformationURL', TRUE, $this->InformationURL);
+            Utils::addStrings($e, self::NS, 'mdui:PrivacyStatementURL', TRUE, $this->PrivacyStatementURL);
 
             if (!empty($this->Keywords)) {
                 foreach ($this->Keywords as $child) {
diff --git a/src/SAML2/XML/saml/Attribute.php b/src/SAML2/XML/saml/Attribute.php
index 2b7f7d421..0323c69b7 100644
--- a/src/SAML2/XML/saml/Attribute.php
+++ b/src/SAML2/XML/saml/Attribute.php
@@ -1,11 +1,16 @@
 <?php
 
+namespace SAML2\XML\saml;
+
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 Attribute.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_saml_Attribute
+class Attribute
 {
     /**
      * The Name of this attribute.
@@ -31,9 +36,9 @@ class SAML2_XML_saml_Attribute
     /**
      * List of attribute values.
      *
-     * Array of SAML2_XML_saml_AttributeValue elements.
+     * Array of \SAML2\XML\saml\AttributeValue elements.
      *
-     * @var SAML2_XML_saml_AttributeValue[]
+     * @var \SAML2\XML\saml\AttributeValue[]
      */
     public $AttributeValue = array();
 
@@ -62,8 +67,8 @@ public function __construct(DOMElement $xml = NULL)
             $this->FriendlyName = $xml->getAttribute('FriendlyName');
         }
 
-        foreach (SAML2_Utils::xpQuery($xml, './saml_assertion:AttributeValue') as $av) {
-            $this->AttributeValue[] = new SAML2_XML_saml_AttributeValue($av);
+        foreach (Utils::xpQuery($xml, './saml_assertion:AttributeValue') as $av) {
+            $this->AttributeValue[] = new AttributeValue($av);
         }
     }
 
@@ -113,7 +118,7 @@ protected function toXMLInternal(DOMElement $parent, $namespace, $name)
      */
     public function toXML(DOMElement $parent)
     {
-        return $this->toXMLInternal($parent, SAML2_Constants::NS_SAML, 'saml:Attribute');
+        return $this->toXMLInternal($parent, Constants::NS_SAML, 'saml:Attribute');
     }
 
 }
diff --git a/src/SAML2/XML/saml/AttributeValue.php b/src/SAML2/XML/saml/AttributeValue.php
index 022fc4a5e..37021e399 100644
--- a/src/SAML2/XML/saml/AttributeValue.php
+++ b/src/SAML2/XML/saml/AttributeValue.php
@@ -1,11 +1,17 @@
 <?php
 
+namespace SAML2\XML\saml;
+
+use SAML2\DOMDocumentFactory;
+use SAML2\Constants;
+use SAML2\Utils;
+
 /**
  * Serializable class representing an AttributeValue.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_saml_AttributeValue implements Serializable
+class AttributeValue implements Serializable
 {
     /**
      * The raw DOMElement representing this value.
@@ -27,27 +33,27 @@ public function __construct($value)
         assert('is_string($value) || $value instanceof DOMElement');
 
         if (is_string($value)) {
-            $doc = SAML2_DOMDocumentFactory::create();
-            $this->element = $doc->createElementNS(SAML2_Constants::NS_SAML, 'saml:AttributeValue');
-            $this->element->setAttributeNS(SAML2_Constants::NS_XSI, 'xsi:type', 'xs:string');
+            $doc = DOMDocumentFactory::create();
+            $this->element = $doc->createElementNS(Constants::NS_SAML, 'saml:AttributeValue');
+            $this->element->setAttributeNS(Constants::NS_XSI, 'xsi:type', 'xs:string');
             $this->element->appendChild($doc->createTextNode($value));
 
             /* Make sure that the xs-namespace is available in the AttributeValue (for xs:string). */
-            $this->element->setAttributeNS(SAML2_Constants::NS_XS, 'xs:tmp', 'tmp');
-            $this->element->removeAttributeNS(SAML2_Constants::NS_XS, 'tmp');
+            $this->element->setAttributeNS(Constants::NS_XS, 'xs:tmp', 'tmp');
+            $this->element->removeAttributeNS(Constants::NS_XS, 'tmp');
 
             return;
         }
 
-        if ($value->namespaceURI === SAML2_Constants::NS_SAML && $value->localName === 'AttributeValue') {
-            $this->element = SAML2_Utils::copyElement($value);
+        if ($value->namespaceURI === Constants::NS_SAML && $value->localName === 'AttributeValue') {
+            $this->element = Utils::copyElement($value);
 
             return;
         }
 
-        $doc = SAML2_DOMDocumentFactory::create();
-        $this->element = $doc->createElementNS(SAML2_Constants::NS_SAML, 'saml:AttributeValue');
-        SAML2_Utils::copyElement($value, $this->element);
+        $doc = DOMDocumentFactory::create();
+        $this->element = $doc->createElementNS(Constants::NS_SAML, 'saml:AttributeValue');
+        Utils::copyElement($value, $this->element);
     }
 
     /**
@@ -61,7 +67,7 @@ public function toXML(DOMElement $parent)
         assert('$this->element instanceof DOMElement');
         assert('$this->element->namespaceURI === SAML2_Constants::NS_SAML && $this->element->localName === "AttributeValue"');
 
-        $v = SAML2_Utils::copyElement($this->element, $parent);
+        $v = Utils::copyElement($this->element, $parent);
 
         return $v;
     }
@@ -114,7 +120,7 @@ public function serialize()
      */
     public function unserialize($serialized)
     {
-        $doc = SAML2_DOMDocumentFactory::fromString(unserialize($serialized));
+        $doc = DOMDocumentFactory::fromString(unserialize($serialized));
         $this->element = $doc->documentElement;
     }
 }
diff --git a/src/SAML2/XML/saml/NameID.php b/src/SAML2/XML/saml/NameID.php
index 8142a0433..45be3916a 100644
--- a/src/SAML2/XML/saml/NameID.php
+++ b/src/SAML2/XML/saml/NameID.php
@@ -1,11 +1,16 @@
 <?php
 
+namespace SAML2\XML\saml;
+
+use SAML2\DOMDocumentFactory;
+use SAML2\Constants;
+
 /**
  * Class representing the saml:NameID element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_saml_NameID
+class NameID
 {
     /**
      * The NameQualifier or the NameID.
@@ -87,12 +92,12 @@ public function toXML(DOMElement $parent = NULL)
         assert('is_string($this->value)');
 
         if ($parent === NULL) {
-            $parent = SAML2_DOMDocumentFactory::create();
+            $parent = DOMDocumentFactory::create();
             $doc = $parent;
         } else {
             $doc = $parent->ownerDocument;
         }
-        $e = $doc->createElementNS(SAML2_Constants::NS_SAML, 'saml:NameID');
+        $e = $doc->createElementNS(Constants::NS_SAML, 'saml:NameID');
         $parent->appendChild($e);
 
         if ($this->NameQualifier !== NULL) {
diff --git a/src/SAML2/XML/saml/SubjectConfirmation.php b/src/SAML2/XML/saml/SubjectConfirmation.php
index da4bccc6f..81f5c8fa4 100644
--- a/src/SAML2/XML/saml/SubjectConfirmation.php
+++ b/src/SAML2/XML/saml/SubjectConfirmation.php
@@ -1,11 +1,16 @@
 <?php
 
+namespace SAML2\XML\saml;
+
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 SubjectConfirmation element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_saml_SubjectConfirmation
+class SubjectConfirmation
 {
     /**
      * The method we can use to verify this Subject.
@@ -17,14 +22,14 @@ class SAML2_XML_saml_SubjectConfirmation
     /**
      * The NameID of the entity that can use this element to verify the Subject.
      *
-     * @var SAML2_XML_saml_NameID|NULL
+     * @var \SAML2\XML\saml\NameID|NULL
      */
     public $NameID;
 
     /**
      * SubjectConfirmationData element with extra data for verification of the Subject.
      *
-     * @var SAML2_XML_saml_SubjectConfirmationData|NULL
+     * @var \SAML2\XML\saml\SubjectConfirmationData|NULL
      */
     public $SubjectConfirmationData;
 
@@ -45,18 +50,18 @@ public function __construct(DOMElement $xml = NULL)
         }
         $this->Method = $xml->getAttribute('Method');
 
-        $nid = SAML2_Utils::xpQuery($xml, './saml_assertion:NameID');
+        $nid = Utils::xpQuery($xml, './saml_assertion:NameID');
         if (count($nid) > 1) {
             throw new Exception('More than one NameID in a SubjectConfirmation element.');
         } elseif (!empty($nid)) {
-            $this->NameID = new SAML2_XML_saml_NameID($nid[0]);
+            $this->NameID = new NameID($nid[0]);
         }
 
-        $scd = SAML2_Utils::xpQuery($xml, './saml_assertion:SubjectConfirmationData');
+        $scd = Utils::xpQuery($xml, './saml_assertion:SubjectConfirmationData');
         if (count($scd) > 1) {
             throw new Exception('More than one SubjectConfirmationData child in a SubjectConfirmation element.');
         } elseif (!empty($scd)) {
-            $this->SubjectConfirmationData = new SAML2_XML_saml_SubjectConfirmationData($scd[0]);
+            $this->SubjectConfirmationData = new SubjectConfirmationData($scd[0]);
         }
     }
 
@@ -72,7 +77,7 @@ public function toXML(DOMElement $parent)
         assert('is_null($this->NameID) || $this->NameID instanceof SAML2_XML_saml_NameID');
         assert('is_null($this->SubjectConfirmationData) || $this->SubjectConfirmationData instanceof SAML2_XML_saml_SubjectConfirmationData');
 
-        $e = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:SubjectConfirmation');
+        $e = $parent->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:SubjectConfirmation');
         $parent->appendChild($e);
 
         $e->setAttribute('Method', $this->Method);
diff --git a/src/SAML2/XML/saml/SubjectConfirmationData.php b/src/SAML2/XML/saml/SubjectConfirmationData.php
index 24ceb4dd3..f9bcf23a9 100644
--- a/src/SAML2/XML/saml/SubjectConfirmationData.php
+++ b/src/SAML2/XML/saml/SubjectConfirmationData.php
@@ -1,11 +1,18 @@
 <?php
 
+namespace SAML2\XML\saml;
+
+use SAML2\Utils;
+use SAML2\XML\Chunk;
+use SAML2\XML\ds\KeyInfo;
+use SAML2\Constants;
+
 /**
  * Class representing SAML 2 SubjectConfirmationData element.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_saml_SubjectConfirmationData
+class SubjectConfirmationData
 {
     /**
      * The time before this element is valid, as an unix timestamp.
@@ -46,9 +53,9 @@ class SAML2_XML_saml_SubjectConfirmationData
      * The various key information elements.
      *
      * Array with various elements describing this key.
-     * Unknown elements will be represented by SAML2_XML_Chunk.
+     * Unknown elements will be represented by \SAML2\XML\Chunk.
      *
-     * @var (SAML2_XML_ds_KeyInfo|SAML2_XML_Chunk)[]
+     * @var (\SAML2\XML\ds\KeyInfo|\SAML2\XML\Chunk)[]
      */
     public $info = array();
 
@@ -64,10 +71,10 @@ public function __construct(DOMElement $xml = NULL)
         }
 
         if ($xml->hasAttribute('NotBefore')) {
-            $this->NotBefore = SAML2_Utils::xsDateTimeToTimestamp($xml->getAttribute('NotBefore'));
+            $this->NotBefore = Utils::xsDateTimeToTimestamp($xml->getAttribute('NotBefore'));
         }
         if ($xml->hasAttribute('NotOnOrAfter')) {
-            $this->NotOnOrAfter = SAML2_Utils::xsDateTimeToTimestamp($xml->getAttribute('NotOnOrAfter'));
+            $this->NotOnOrAfter = Utils::xsDateTimeToTimestamp($xml->getAttribute('NotOnOrAfter'));
         }
         if ($xml->hasAttribute('Recipient')) {
             $this->Recipient = $xml->getAttribute('Recipient');
@@ -83,15 +90,15 @@ public function __construct(DOMElement $xml = NULL)
                 continue;
             }
             if ($n->namespaceURI !== XMLSecurityDSig::XMLDSIGNS) {
-                $this->info[] = new SAML2_XML_Chunk($n);
+                $this->info[] = new Chunk($n);
                 continue;
             }
             switch ($n->localName) {
                 case 'KeyInfo':
-                    $this->info[] = new SAML2_XML_ds_KeyInfo($n);
+                    $this->info[] = new KeyInfo($n);
                     break;
                 default:
-                    $this->info[] = new SAML2_XML_Chunk($n);
+                    $this->info[] = new Chunk($n);
                     break;
             }
         }
@@ -111,7 +118,7 @@ public function toXML(DOMElement $parent)
         assert('is_null($this->InResponseTo) || is_string($this->InResponseTo)');
         assert('is_null($this->Address) || is_string($this->Address)');
 
-        $e = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_SAML, 'saml:SubjectConfirmationData');
+        $e = $parent->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:SubjectConfirmationData');
         $parent->appendChild($e);
 
         if (isset($this->NotBefore)) {
@@ -129,7 +136,7 @@ public function toXML(DOMElement $parent)
         if (isset($this->Address)) {
             $e->setAttribute('Address', $this->Address);
         }
-        /** @var SAML2_XML_ds_KeyInfo|SAML2_XML_Chunk $n */
+        /** @var \SAML2\XML\ds\KeyInfo|\SAML2\XML\Chunk $n */
         foreach ($this->info as $n) {
             $n->toXML($e);
         }
diff --git a/src/SAML2/XML/samlp/Extensions.php b/src/SAML2/XML/samlp/Extensions.php
index 9f01f90d4..ff1e7d9c5 100644
--- a/src/SAML2/XML/samlp/Extensions.php
+++ b/src/SAML2/XML/samlp/Extensions.php
@@ -1,11 +1,17 @@
 <?php
 
+namespace SAML2\XML\samlp;
+
+use SAML2\Utils;
+use SAML2\XML\Chunk;
+use SAML2\Constants;
+
 /**
  * Class for handling SAML2 extensions.
  *
  * @package SimpleSAMLphp
  */
-class SAML2_XML_samlp_Extensions
+class Extensions
 {
     /**
      * Get a list of Extensions in the given element.
@@ -16,8 +22,8 @@ class SAML2_XML_samlp_Extensions
     public static function getList(DOMElement $parent)
     {
         $ret = array();
-        foreach (SAML2_Utils::xpQuery($parent, './saml_protocol:Extensions/*') as $node) {
-            $ret[] = new SAML2_XML_Chunk($node);
+        foreach (Utils::xpQuery($parent, './saml_protocol:Extensions/*') as $node) {
+            $ret[] = new Chunk($node);
         }
 
         return $ret;
@@ -27,7 +33,7 @@ public static function getList(DOMElement $parent)
      * Add a list of Extensions to the given element.
      *
      * @param DOMElement        $parent     The element we should add the extensions to.
-     * @param SAML2_XML_Chunk[] $extensions List of extension objects.
+     * @param \SAML2\XML\Chunk[] $extensions List of extension objects.
      */
     public static function addList(DOMElement $parent, array $extensions)
     {
@@ -35,7 +41,7 @@ public static function addList(DOMElement $parent, array $extensions)
             return;
         }
 
-        $extElement = $parent->ownerDocument->createElementNS(SAML2_Constants::NS_SAMLP, 'samlp:Extensions');
+        $extElement = $parent->ownerDocument->createElementNS(Constants::NS_SAMLP, 'samlp:Extensions');
         $parent->appendChild($extElement);
 
         foreach ($extensions as $ext) {
diff --git a/src/SAML2/XML/shibmd/Scope.php b/src/SAML2/XML/shibmd/Scope.php
index 9c50ec5af..25b680137 100644
--- a/src/SAML2/XML/shibmd/Scope.php
+++ b/src/SAML2/XML/shibmd/Scope.php
@@ -1,12 +1,16 @@
 <?php
 
+namespace SAML2\XML\shibmd;
+
+use SAML2\Utils;
+
 /**
  * Class which represents the Scope element found in Shibboleth metadata.
  *
  * @link https://wiki.shibboleth.net/confluence/display/SHIB/ShibbolethMetadataProfile
  * @package SimpleSAMLphp
  */
-class SAML2_XML_shibmd_Scope
+class Scope
 {
     /**
      * The namespace used for the Scope extension element.
@@ -39,7 +43,7 @@ public function __construct(DOMElement $xml = NULL)
         }
 
         $this->scope = $xml->textContent;
-        $this->regexp = SAML2_Utils::parseBoolean($xml, 'regexp', NULL);
+        $this->regexp = Utils::parseBoolean($xml, 'regexp', NULL);
     }
 
     /**
@@ -55,7 +59,7 @@ public function toXML(DOMElement $parent)
 
         $doc = $parent->ownerDocument;
 
-        $e = $doc->createElementNS(SAML2_XML_shibmd_Scope::NS, 'shibmd:Scope');
+        $e = $doc->createElementNS(Scope::NS, 'shibmd:Scope');
         $parent->appendChild($e);
 
         $e->appendChild($doc->createTextNode($this->scope));
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php
index d6e033e94..6d388d71b 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php
@@ -1,5 +1,10 @@
 <?php
 
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\ControlledTimeTest;
+use SAML2\Assertion\Validation\Result;
+
 use \Mockery as m;
 
 /**
@@ -8,7 +13,7 @@
  *
  * @runTestsInSeparateProcesses
  */
-class SAML2_Assertion_Validation_ConstraintValidator_NotBeforeTest extends SAML2_ControlledTimeTest
+class NotBeforeTest extends ControlledTimeTest
 {
     /**
      * @var \Mockery\MockInterface
@@ -34,8 +39,8 @@ public function timestamp_in_the_future_beyond_graceperiod_is_not_valid()
     {
         $this->assertion->shouldReceive('getNotBefore')->andReturn($this->currentTime + 61);
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_NotBefore();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new NotBefore();
+        $result    = new Result();
 
         $validator->validate($this->assertion, $result);
 
@@ -51,8 +56,8 @@ public function time_within_graceperiod_is_valid()
     {
         $this->assertion->shouldReceive('getNotBefore')->andReturn($this->currentTime + 60);
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_NotBefore();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new NotBefore();
+        $result    = new Result();
 
         $validator->validate($this->assertion, $result);
 
@@ -67,8 +72,8 @@ public function current_time_is_valid()
     {
         $this->assertion->shouldReceive('getNotBefore')->andReturn($this->currentTime);
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_NotBefore();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new NotBefore();
+        $result    = new Result();
 
         $validator->validate($this->assertion, $result);
 
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php
index 1c8e3dfe7..69f50e7ff 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php
@@ -1,5 +1,10 @@
 <?php
 
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\ControlledTimeTest;
+use SAML2\Assertion\Validation\Result;
+
 use \Mockery as m;
 
 /**
@@ -8,7 +13,7 @@
  *
  * @runTestsInSeparateProcesses
  */
-class SAML2_Assertion_Validation_ConstraintValidator_NotOnOrAfterTest extends SAML2_ControlledTimeTest
+class NotOnOrAfterTest extends ControlledTimeTest
 {
     /**
      * @var \Mockery\MockInterface
@@ -29,8 +34,8 @@ public function timestamp_in_the_past_before_graceperiod_is_not_valid()
     {
         $this->assertion->shouldReceive('getNotOnOrAfter')->andReturn($this->currentTime - 60);
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_NotOnOrAfter();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new NotOnOrAfter();
+        $result    = new Result();
 
         $validator->validate($this->assertion, $result);
 
@@ -46,8 +51,8 @@ public function time_within_graceperiod_is_valid()
     {
         $this->assertion->shouldReceive('getNotOnOrAfter')->andReturn($this->currentTime - 59);
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_NotOnOrAfter();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new NotOnOrAfter();
+        $result    = new Result();
 
         $validator->validate($this->assertion, $result);
 
@@ -62,8 +67,8 @@ public function current_time_is_valid()
     {
         $this->assertion->shouldReceive('getNotOnOrAfter')->andReturn($this->currentTime);
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_NotOnOrAfter();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new NotOnOrAfter();
+        $result    = new Result();
 
         $validator->validate($this->assertion, $result);
 
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php
index 3a332236c..04fb073de 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php
@@ -1,5 +1,10 @@
 <?php
 
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\ControlledTimeTest;
+use SAML2\Assertion\Validation\Result;
+
 use \Mockery as m;
 
 /**
@@ -8,7 +13,7 @@
  *
  * @runTestsInSeparateProcesses
  */
-class SAML2_Assertion_Validation_ConstraintValidator_SessionNotOnOrAfterTest extends SAML2_ControlledTimeTest
+class SessionNotOnOrAfterTest extends ControlledTimeTest
 {
     /**
      * @var \Mockery\MockInterface
@@ -29,8 +34,8 @@ public function timestamp_in_the_past_before_graceperiod_is_not_valid()
     {
         $this->assertion->shouldReceive('getSessionNotOnOrAfter')->andReturn($this->currentTime - 60);
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SessionNotOnOrAfter();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new SessionNotOnOrAfter();
+        $result    = new Result();
 
         $validator->validate($this->assertion, $result);
 
@@ -46,8 +51,8 @@ public function time_within_graceperiod_is_valid()
     {
         $this->assertion->shouldReceive('getSessionNotOnOrAfter')->andReturn($this->currentTime - 59);
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SessionNotOnOrAfter();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new SessionNotOnOrAfter();
+        $result    = new Result();
 
         $validator->validate($this->assertion, $result);
 
@@ -62,8 +67,8 @@ public function current_time_is_valid()
     {
         $this->assertion->shouldReceive('getSessionNotOnOrAfter')->andReturn($this->currentTime);
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SessionNotOnOrAfter();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new SessionNotOnOrAfter();
+        $result    = new Result();
 
         $validator->validate($this->assertion, $result);
 
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
index fa4e73638..ad8c92b31 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
@@ -1,12 +1,16 @@
 <?php
 
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\Assertion\Validation\Result;
+
 use \Mockery as m;
 
 /**
  * Because we're mocking a static call, we have to run it in separate processes so as to no contaminate the other
  * tests.
  */
-class SAML2_Assertion_Validation_ConstraintValidator_SpIsValidAudienceTest extends \PHPUnit_Framework_TestCase
+class SpIsValidAudienceTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @var \Mockery\MockInterface
@@ -34,9 +38,9 @@ public function when_no_valid_adiences_are_given_the_assertion_is_valid()
         $this->assertion->shouldReceive('getValidAudiences')->andReturn(null);
         $this->serviceProvider->shouldReceive('getEntityId')->andReturn('entityId');
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SpIsValidAudience();
+        $validator = new SpIsValidAudience();
         $validator->setServiceProvider($this->serviceProvider);
-        $result    = new SAML2_Assertion_Validation_Result();
+        $result    = new Result();
 
         $validator->validate($this->assertion, $result);
 
@@ -52,9 +56,9 @@ public function if_the_sp_entity_id_is_not_in_the_valid_audiences_the_assertion_
         $this->assertion->shouldReceive('getValidAudiences')->andReturn(array('someEntityId'));
         $this->serviceProvider->shouldReceive('getEntityId')->andReturn('anotherEntityId');
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SpIsValidAudience();
+        $validator = new SpIsValidAudience();
         $validator->setServiceProvider($this->serviceProvider);
-        $result    = new SAML2_Assertion_Validation_Result();
+        $result    = new Result();
 
         $validator->validate($this->assertion, $result);
 
@@ -71,9 +75,9 @@ public function the_assertion_is_valid_when_the_current_sp_entity_id_is_a_valid_
         $this->assertion->shouldReceive('getValidAudiences')->andReturn(array('foo', 'bar', 'validEntityId', 'baz'));
         $this->serviceProvider->shouldReceive('getEntityId')->andReturn('validEntityId');
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SpIsValidAudience();
+        $validator = new SpIsValidAudience();
         $validator->setServiceProvider($this->serviceProvider);
-        $result    = new SAML2_Assertion_Validation_Result();
+        $result    = new Result();
 
         $validator->validate($this->assertion, $result);
 
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
index 8088ffd85..5951ae3e9 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
@@ -1,8 +1,13 @@
 <?php
 
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\Constants;
+use SAML2\Assertion\Validation\Result;
+
 use \Mockery as m;
 
-class SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationTest extends \PHPUnit_Framework_TestCase
+class SubjectConfirmationTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @var \Mockery\MockInterface
@@ -20,10 +25,10 @@ public function setUp()
      */
     public function a_subject_confirmation_with_bearer_method_is_valid()
     {
-        $this->subjectConfirmation->Method = SAML2_Constants::CM_BEARER;
+        $this->subjectConfirmation->Method = Constants::CM_BEARER;
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationMethod();
-        $result = new SAML2_Assertion_Validation_Result();
+        $validator = new SubjectConfirmationMethod();
+        $result = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
@@ -36,10 +41,10 @@ public function a_subject_confirmation_with_bearer_method_is_valid()
      */
     public function a_subject_confirmation_with_holder_of_key_method_is_not_valid()
     {
-        $this->subjectConfirmation->Method = SAML2_Constants::CM_HOK;
+        $this->subjectConfirmation->Method = Constants::CM_HOK;
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationMethod();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new SubjectConfirmationMethod();
+        $result    = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php
index bd2439b1b..5890d65ed 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php
@@ -1,5 +1,10 @@
 <?php
 
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\ControlledTimeTest;
+use SAML2\Assertion\Validation\Result;
+
 use \Mockery as m;
 
 /**
@@ -8,7 +13,7 @@
  *
  * @runTestsInSeparateProcesses
  */
-class SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationNotBeforeTest extends SAML2_ControlledTimeTest
+class SubjectConfirmationNotBeforeTest extends ControlledTimeTest
 {
     /**
      * @var \Mockery\MockInterface
@@ -36,8 +41,8 @@ public function timestamp_in_the_future_beyond_graceperiod_is_not_valid()
     {
         $this->subjectConfirmation->SubjectConfirmationData->NotBefore = $this->currentTime + 61;
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationNotBefore();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new SubjectConfirmationNotBefore();
+        $result    = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
@@ -53,8 +58,8 @@ public function time_within_graceperiod_is_valid()
     {
         $this->subjectConfirmation->SubjectConfirmationData->NotBefore = $this->currentTime + 60;
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationNotBefore();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new SubjectConfirmationNotBefore();
+        $result    = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
@@ -69,8 +74,8 @@ public function current_time_is_valid()
     {
         $this->subjectConfirmation->SubjectConfirmationData->NotBefore = $this->currentTime;
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationNotBefore();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new SubjectConfirmationNotBefore();
+        $result    = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php
index 58a0ab7fd..8078906de 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php
@@ -1,5 +1,10 @@
 <?php
 
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\ControlledTimeTest;
+use SAML2\Assertion\Validation\Result;
+
 use \Mockery as m;
 
 /**
@@ -8,7 +13,7 @@
  *
  * @runTestsInSeparateProcesses
  */
-class SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationNotOnOrAfterTest extends SAML2_ControlledTimeTest
+class SubjectConfirmationNotOnOrAfterTest extends ControlledTimeTest
 {
     /**
      * @var \Mockery\MockInterface
@@ -36,8 +41,8 @@ public function timestamp_in_the_past_before_graceperiod_is_not_valid()
     {
         $this->subjectConfirmationData->NotOnOrAfter = $this->currentTime - 60;
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationNotOnOrAfter();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new SubjectConfirmationNotOnOrAfter();
+        $result    = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
@@ -53,8 +58,8 @@ public function time_within_graceperiod_is_valid()
     {
         $this->subjectConfirmationData->NotOnOrAfter = $this->currentTime - 59;
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationNotOnOrAfter();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new SubjectConfirmationNotOnOrAfter();
+        $result    = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
@@ -69,8 +74,8 @@ public function current_time_is_valid()
     {
         $this->subjectConfirmationData->NotOnOrAfter = $this->currentTime;
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationNotBefore();
-        $result    = new SAML2_Assertion_Validation_Result();
+        $validator = new SubjectConfirmationNotBefore();
+        $result    = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMathchesTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMathchesTest.php
index 4371641f6..50afeb662 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMathchesTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMathchesTest.php
@@ -1,8 +1,13 @@
 <?php
 
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\Configuration\Destination;
+use SAML2\Assertion\Validation\Result;
+
 use \Mockery as m;
 
-class SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationRecipientMatchesTest extends
+class SubjectConfirmationRecipientMatchesTest extends
     \PHPUnit_Framework_TestCase
 {
     /**
@@ -31,10 +36,10 @@ public function when_the_subject_confirmation_recipient_differs_from_the_destina
     {
         $this->subjectConfirmation->SubjectConfirmationData->Recipient = 'someDestination';
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationRecipientMatches(
-            new SAML2_Configuration_Destination('anotherDestination')
+        $validator = new SubjectConfirmationRecipientMatches(
+            new Destination('anotherDestination')
         );
-        $result = new SAML2_Assertion_Validation_Result();
+        $result = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
@@ -50,10 +55,10 @@ public function when_the_subject_confirmation_recipient_equals_the_destination_t
     {
         $this->subjectConfirmation->SubjectConfirmationData->Recipient = 'theSameDestination';
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationRecipientMatches(
-            new SAML2_Configuration_Destination('theSameDestination')
+        $validator = new SubjectConfirmationRecipientMatches(
+            new Destination('theSameDestination')
         );
-        $result = new SAML2_Assertion_Validation_Result();
+        $result = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
index 44b92b729..7e8790ee4 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
@@ -1,8 +1,12 @@
 <?php
 
+namespace SAML2\Assertion\Validation\ConstraintValidator;
+
+use SAML2\Assertion\Validation\Result;
+
 use \Mockery as m;
 
-class SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationResponseToMatchesTest extends
+class SubjectConfirmationResponseToMatchesTest extends
     \PHPUnit_Framework_TestCase
 {
     /**
@@ -38,10 +42,10 @@ public function when_the_response_responseto_is_null_the_subject_confirmation_is
         $this->response->shouldReceive('getInResponseTo')->andReturnNull();
         $this->subjectConfirmationData->InResponseTo = 'someValue';
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationResponseToMatches(
+        $validator = new SubjectConfirmationResponseToMatches(
             $this->response
         );
-        $result    = new SAML2_Assertion_Validation_Result();
+        $result    = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
@@ -57,10 +61,10 @@ public function when_the_subjectconfirmation_responseto_is_null_the_subjectconfi
         $this->response->shouldReceive('getInResponseTo')->andReturn('someValue');
         $this->subjectConfirmationData->InResponseTo = null;
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationResponseToMatches(
+        $validator = new SubjectConfirmationResponseToMatches(
             $this->response
         );
-        $result    = new SAML2_Assertion_Validation_Result();
+        $result    = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
@@ -76,10 +80,10 @@ public function when_the_subjectconfirmation_and_response_responseto_are_null_th
         $this->response->shouldReceive('getInResponseTo')->andReturnNull();
         $this->subjectConfirmationData->InResponseTo = null;
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationResponseToMatches(
+        $validator = new SubjectConfirmationResponseToMatches(
             $this->response
         );
-        $result    = new SAML2_Assertion_Validation_Result();
+        $result    = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
@@ -95,10 +99,10 @@ public function when_the_subjectconfirmation_and_response_responseto_are_equal_t
         $this->response->shouldReceive('getInResponseTo')->andReturn('theSameValue');
         $this->subjectConfirmationData->InResponseTo = 'theSameValue';
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationResponseToMatches(
+        $validator = new SubjectConfirmationResponseToMatches(
             $this->response
         );
-        $result    = new SAML2_Assertion_Validation_Result();
+        $result    = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
@@ -114,10 +118,10 @@ public function when_the_subjectconfirmation_and_response_responseto_differ_the_
         $this->response->shouldReceive('getInResponseTo')->andReturn('someValue');
         $this->subjectConfirmationData->InResponseTo = 'anotherValue';
 
-        $validator = new SAML2_Assertion_Validation_ConstraintValidator_SubjectConfirmationResponseToMatches(
+        $validator = new SubjectConfirmationResponseToMatches(
             $this->response
         );
-        $result    = new SAML2_Assertion_Validation_Result();
+        $result    = new Result();
 
         $validator->validate($this->subjectConfirmation, $result);
 
diff --git a/tests/SAML2/AssertionTest.php b/tests/SAML2/AssertionTest.php
index e65a0e17c..d7bb152a2 100644
--- a/tests/SAML2/AssertionTest.php
+++ b/tests/SAML2/AssertionTest.php
@@ -1,14 +1,18 @@
 <?php
 
+namespace SAML2;
+
+use SAML2\XML\Chunk;
+
 /**
- * Class SAML2_AssertionTest
+ * Class \SAML2\AssertionTest
  */
-class SAML2_AssertionTest extends \PHPUnit_Framework_TestCase
+class AssertionTest extends \PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
         // Create an assertion
-        $assertion = new \SAML2_Assertion();
+        $assertion = new \Assertion();
         $assertion->setIssuer('testIssuer');
         $assertion->setValidAudiences(array('audience1', 'audience2'));
         $assertion->setAuthnContext('someAuthnContext');
@@ -17,12 +21,12 @@ public function testMarshalling()
         $assertionElement = $assertion->toXML();
 
         // Test for an Issuer
-        $issuerElements = \SAML2_Utils::xpQuery($assertionElement, './saml_assertion:Issuer');
+        $issuerElements = \Utils::xpQuery($assertionElement, './saml_assertion:Issuer');
         $this->assertCount(1, $issuerElements);
         $this->assertEquals('testIssuer', $issuerElements[0]->textContent);
 
         // Test for an AudienceRestriction
-        $audienceElements = \SAML2_Utils::xpQuery(
+        $audienceElements = \Utils::xpQuery(
             $assertionElement,
             './saml_assertion:Conditions/saml_assertion:AudienceRestriction/saml_assertion:Audience'
         );
@@ -31,7 +35,7 @@ public function testMarshalling()
         $this->assertEquals('audience2', $audienceElements[1]->textContent);
 
         // Test for an Authentication Context
-        $authnContextElements = \SAML2_Utils::xpQuery(
+        $authnContextElements = \Utils::xpQuery(
             $assertionElement,
             './saml_assertion:AuthnStatement/saml_assertion:AuthnContext/saml_assertion:AuthnContextClassRef'
         );
@@ -65,8 +69,8 @@ public function testUnmarshalling()
   </saml:AuthnStatement>
 </saml:Assertion>
 XML;
-        $document  = SAML2_DOMDocumentFactory::fromString($xml);
-        $assertion = new \SAML2_Assertion($document->firstChild);
+        $document  = DOMDocumentFactory::fromString($xml);
+        $assertion = new \Assertion($document->firstChild);
 
         // Test for valid audiences
         $assertionValidAudiences = $assertion->getValidAudiences();
@@ -104,9 +108,9 @@ public function testAuthnContextDeclAndClassRef()
 XML;
 
         // Try with unmarshalling
-        $document = SAML2_DOMDocumentFactory::fromString($xml);
+        $document = DOMDocumentFactory::fromString($xml);
 
-        $assertion = new \SAML2_Assertion($document->documentElement);
+        $assertion = new \Assertion($document->documentElement);
         $authnContextDecl = $assertion->getAuthnContextDecl();
         $this->assertNotEmpty($authnContextDecl);
         $this->assertEquals('AuthnContextDecl', $authnContextDecl->localName);
@@ -136,9 +140,9 @@ public function testAuthnContextDeclRefAndClassRef()
 </saml:Assertion>
 XML;
 
-        $document = SAML2_DOMDocumentFactory::fromString($xml);
+        $document = DOMDocumentFactory::fromString($xml);
 
-        $assertion = new \SAML2_Assertion($document->documentElement);
+        $assertion = new \Assertion($document->documentElement);
         $this->assertEquals('/relative/path/to/document.xml', $assertion->getAuthnContextDeclRef());
         $this->assertEquals('someAuthnContext', $assertion->getAuthnContextClassRef());
     }
@@ -150,24 +154,24 @@ public function testAuthnContextDeclAndRefConstraint()
 </samlac:AuthenticationContextDeclaration>
 XML;
 
-        $document  = SAML2_DOMDocumentFactory::fromString($xml);
-        $assertion = new \SAML2_Assertion();
+        $document  = DOMDocumentFactory::fromString($xml);
+        $assertion = new \Assertion();
 
         $e = null;
         try {
-            $assertion->setAuthnContextDecl(new SAML2_XML_Chunk($document->documentElement));
+            $assertion->setAuthnContextDecl(new Chunk($document->documentElement));
             $assertion->setAuthnContextDeclRef('/relative/path/to/document.xml');
         }
         catch (Exception $e) {}
         $this->assertNotEmpty($e);
 
         // Try again in reverse order for good measure.
-        $assertion = new \SAML2_Assertion();
+        $assertion = new \Assertion();
 
         $e = null;
         try {
             $assertion->setAuthnContextDeclRef('/relative/path/to/document.xml');
-            $assertion->setAuthnContextDecl(new SAML2_XML_Chunk($document->documentElement));
+            $assertion->setAuthnContextDecl(new Chunk($document->documentElement));
         }
         catch (Exception $e) {}
         $this->assertNotEmpty($e);
@@ -193,11 +197,11 @@ public function testAuthnContextDeclAndRefConstraint()
 </saml:Assertion>
 XML;
 
-        $document = SAML2_DOMDocumentFactory::fromString($xml);
+        $document = DOMDocumentFactory::fromString($xml);
 
         $e = null;
         try {
-            new \SAML2_Assertion($document->documentElement);
+            new \Assertion($document->documentElement);
         }
         catch (Exception $e) {}
         $this->assertNotEmpty($e);
@@ -206,7 +210,7 @@ public function testAuthnContextDeclAndRefConstraint()
     public function testMustHaveClassRefOrDeclOrDeclRef()
     {
         // Unmarshall an assertion
-        $document = SAML2_DOMDocumentFactory::fromString(<<<XML
+        $document = DOMDocumentFactory::fromString(<<<XML
 <saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
                 ID="_593e33ddf86449ce4d4c22b60ac48e067d98a0b2bf"
                 Version="2.0"
@@ -224,7 +228,7 @@ public function testMustHaveClassRefOrDeclOrDeclRef()
         );
         $e = null;
         try {
-            $assertion = new \SAML2_Assertion($document->firstChild);
+            $assertion = new \Assertion($document->firstChild);
         }
         catch (Exception $e) {
         }
@@ -241,7 +245,7 @@ public function testNoAuthnContextDeclRefFallback()
         $authnContextDeclRef = 'relative/url/to/authcontext.xml';
 
         // Unmarshall an assertion
-        $document = SAML2_DOMDocumentFactory::fromString(<<<XML
+        $document = DOMDocumentFactory::fromString(<<<XML
 <saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
                 xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
                 ID="_593e33ddf86449ce4d4c22b60ac48e067d98a0b2bf"
@@ -257,7 +261,7 @@ public function testNoAuthnContextDeclRefFallback()
 </saml:Assertion>
 XML
         );
-        $assertion = new \SAML2_Assertion($document->firstChild);
+        $assertion = new \Assertion($document->firstChild);
         $this->assertEmpty($assertion->getAuthnContextClassRef());
         $this->assertEquals($authnContextDeclRef, $assertion->getAuthnContextDeclRef());
     }
@@ -321,7 +325,7 @@ public function testHasEncryptedAttributes()
     </saml:Assertion>
 XML
         );
-        $assertion = new \SAML2_Assertion($document->firstChild);
+        $assertion = new \Assertion($document->firstChild);
         $this->assertTrue($assertion->hasEncryptedAttributes());
     }
 }
diff --git a/tests/SAML2/AttributeQueryTest.php b/tests/SAML2/AttributeQueryTest.php
index 2866cf0f3..d10cea7be 100644
--- a/tests/SAML2/AttributeQueryTest.php
+++ b/tests/SAML2/AttributeQueryTest.php
@@ -1,13 +1,15 @@
 <?php
 
+namespace SAML2;
+
 /**
- * Class SAML2_AttributeQueryTest
+ * Class \SAML2\AttributeQueryTest
  */
-class SAML2_AttributeQueryTest extends \PHPUnit_Framework_TestCase
+class AttributeQueryTest extends \PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
-        $attributeQuery = new SAML2_AttributeQuery();
+        $attributeQuery = new AttributeQuery();
         $attributeQuery->setNameID(array('Value' => 'NameIDValue'));
         $attributeQuery->setAttributes(
             array(
@@ -26,27 +28,27 @@ public function testMarshalling()
         $attributeQueryElement = $attributeQuery->toUnsignedXML();
 
         // Test Attribute Names
-        $attributes = SAML2_Utils::xpQuery($attributeQueryElement, './saml_assertion:Attribute');
+        $attributes = Utils::xpQuery($attributeQueryElement, './saml_assertion:Attribute');
         $this->assertCount(3, $attributes);
         $this->assertEquals('test1', $attributes[0]->getAttribute('Name'));
         $this->assertEquals('test2', $attributes[1]->getAttribute('Name'));
         $this->assertEquals('test3', $attributes[2]->getAttribute('Name'));
 
         // Test Attribute Values for Attribute 1
-        $av1 = SAML2_Utils::xpQuery($attributes[0], './saml_assertion:AttributeValue');
+        $av1 = Utils::xpQuery($attributes[0], './saml_assertion:AttributeValue');
         $this->assertCount(2, $av1);
         $this->assertEquals('test1_attrv1', $av1[0]->textContent);
         $this->assertEquals('test1_attrv2', $av1[1]->textContent);
 
         // Test Attribute Values for Attribute 2
-        $av2 = SAML2_Utils::xpQuery($attributes[1], './saml_assertion:AttributeValue');
+        $av2 = Utils::xpQuery($attributes[1], './saml_assertion:AttributeValue');
         $this->assertCount(3, $av2);
         $this->assertEquals('test2_attrv1', $av2[0]->textContent);
         $this->assertEquals('test2_attrv2', $av2[1]->textContent);
         $this->assertEquals('test2_attrv3', $av2[2]->textContent);
 
         // Test Attribute Values for Attribute 3
-        $av3 = SAML2_Utils::xpQuery($attributes[2], './saml_assertion:AttributeValue');
+        $av3 = Utils::xpQuery($attributes[2], './saml_assertion:AttributeValue');
         $this->assertCount(0, $av3);
     }
 }
diff --git a/tests/SAML2/AuthnRequestTest.php b/tests/SAML2/AuthnRequestTest.php
index d1ba3a1aa..c44091368 100644
--- a/tests/SAML2/AuthnRequestTest.php
+++ b/tests/SAML2/AuthnRequestTest.php
@@ -1,13 +1,15 @@
 <?php
 
+namespace SAML2;
+
 /**
- * Class SAML2_AuthnRequestTest
+ * Class \SAML2\AuthnRequestTest
  */
-class SAML2_AuthnRequestTest extends PHPUnit_Framework_TestCase
+class AuthnRequestTest extends PHPUnit_Framework_TestCase
 {
     public function testUnmarshalling()
     {
-        $authnRequest = new SAML2_AuthnRequest();
+        $authnRequest = new AuthnRequest();
         $authnRequest->setRequestedAuthnContext(array(
             'AuthnContextClassRef' => array(
                 'accr1',
@@ -18,7 +20,7 @@ public function testUnmarshalling()
 
         $authnRequestElement = $authnRequest->toUnsignedXML();
 
-        $requestedAuthnContextElements = SAML2_Utils::xpQuery(
+        $requestedAuthnContextElements = Utils::xpQuery(
             $authnRequestElement,
             './saml_protocol:RequestedAuthnContext'
         );
@@ -27,7 +29,7 @@ public function testUnmarshalling()
         $requestedAuthnConextElement = $requestedAuthnContextElements[0];
         $this->assertEquals('better', $requestedAuthnConextElement->getAttribute("Comparison"));
 
-        $authnContextClassRefElements = SAML2_Utils::xpQuery(
+        $authnContextClassRefElements = Utils::xpQuery(
             $requestedAuthnConextElement,
             './saml_assertion:AuthnContextClassRef'
         );
@@ -54,9 +56,9 @@ public function testMarshallingOfSimpleRequest()
 AUTHNREQUEST
         );
 
-        $authnRequest = new SAML2_AuthnRequest($document->documentElement);
+        $authnRequest = new AuthnRequest($document->documentElement);
 
-        $expectedIssueInstant = SAML2_Utils::xsDateTimeToTimestamp('2004-12-05T09:21:59Z');
+        $expectedIssueInstant = Utils::xsDateTimeToTimestamp('2004-12-05T09:21:59Z');
         $this->assertEquals($expectedIssueInstant, $authnRequest->getIssueInstant());
         $this->assertEquals('https://idp.example.org/SAML2/SSO/Artifact', $authnRequest->getDestination());
         $this->assertEquals('urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact', $authnRequest->getProtocolBinding());
@@ -97,8 +99,8 @@ public function testExtensionOrdering()
 </samlp:AuthnRequest>
 AUTHNREQUEST;
 
-        $document     = SAML2_DOMDocumentFactory::fromString($xml);
-        $authnRequest = new SAML2_AuthnRequest($document->documentElement);
+        $document     = DOMDocumentFactory::fromString($xml);
+        $authnRequest = new AuthnRequest($document->documentElement);
 
         $this->assertXmlStringEqualsXmlString($document->C14N(), $authnRequest->toUnsignedXML()->C14N());
     }
@@ -122,7 +124,7 @@ public function testThatTheSubjectIsCorrectlyRead()
 </samlp:AuthnRequest>
 AUTHNREQUEST
 );
-        $authnRequest = new SAML2_AuthnRequest($document->documentElement);
+        $authnRequest = new AuthnRequest($document->documentElement);
 
         $expectedNameId = array(
             'Value'  => "user@example.org",
@@ -133,8 +135,8 @@ public function testThatTheSubjectIsCorrectlyRead()
 
     public function testThatTheSubjectCanBeSetBySettingTheNameId()
     {
-        $request = new SAML2_AuthnRequest();
-        $request->setNameId(array('Value' => 'user@example.org', 'Format' => SAML2_Constants::NAMEID_UNSPECIFIED));
+        $request = new AuthnRequest();
+        $request->setNameId(array('Value' => 'user@example.org', 'Format' => Constants::NAMEID_UNSPECIFIED));
 
         $requestAsXML = $request->toUnsignedXML()->ownerDocument->saveXML();
         $expected = '<saml:Subject><saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">user@example.org</saml:NameID></saml:Subject>';
@@ -175,12 +177,12 @@ public function testThatAnEncryptedNameIdCanBeDecrypted()
 AUTHNREQUEST
         );
 
-        $authnRequest = new SAML2_AuthnRequest($document->documentElement);
+        $authnRequest = new AuthnRequest($document->documentElement);
 
-        $key = SAML2_CertificatesMock::getPrivateKey();
+        $key = CertificatesMock::getPrivateKey();
         $authnRequest->decryptNameId($key);
 
-        $expectedNameId = array('Value' => md5('Arthur Dent'), 'Format' => SAML2_Constants::NAMEID_ENCRYPTED);
+        $expectedNameId = array('Value' => md5('Arthur Dent'), 'Format' => Constants::NAMEID_ENCRYPTED);
 
         $this->assertEquals($expectedNameId, $authnRequest->getNameId());
     }
@@ -193,16 +195,16 @@ public function testThatAnEncryptedNameIdCanBeDecrypted()
     public function testThatAnEncryptedNameIdResultsInTheCorrectXmlStructure()
     {
         // the NameID we're going to encrypt
-        $nameId = array('Value' => md5('Arthur Dent'), 'Format' => SAML2_Constants::NAMEID_ENCRYPTED);
+        $nameId = array('Value' => md5('Arthur Dent'), 'Format' => Constants::NAMEID_ENCRYPTED);
 
         // basic AuthnRequest
-        $request = new SAML2_AuthnRequest();
+        $request = new AuthnRequest();
         $request->setIssuer('https://gateway.stepup.org/saml20/sp/metadata');
         $request->setDestination('https://tiqr.stepup.org/idp/profile/saml2/Redirect/SSO');
         $request->setNameId($nameId);
 
         // encrypt the NameID
-        $key = SAML2_CertificatesMock::getPublicKey();
+        $key = CertificatesMock::getPublicKey();
         $request->encryptNameId($key);
 
         $expectedStructureDocument = new DOMDocument();
@@ -250,7 +252,7 @@ public function testThatAnEncryptedNameIdResultsInTheCorrectXmlStructure()
     public function testIDPlistAttributes()
     {
         // basic AuthnRequest
-        $request = new SAML2_AuthnRequest();
+        $request = new AuthnRequest();
         $request->setIssuer('https://gateway.example.org/saml20/sp/metadata');
         $request->setDestination('https://tiqr.example.org/idp/profile/saml2/Redirect/SSO');
         $request->setIDPList(array(
diff --git a/tests/SAML2/Certificate/FingerprintLoaderTest.php b/tests/SAML2/Certificate/FingerprintLoaderTest.php
index 6e898edd7..83f9efaf6 100644
--- a/tests/SAML2/Certificate/FingerprintLoaderTest.php
+++ b/tests/SAML2/Certificate/FingerprintLoaderTest.php
@@ -1,9 +1,14 @@
 <?php
 
-class SAML2_Certificate_FingerprintLoaderTest extends PHPUnit_Framework_TestCase
+namespace SAML2\Certificate;
+
+use SAML2\Configuration\ArrayAdapter;
+use SAML2\Certificate\Stub\ImplementsToString;
+
+class FingerprintLoaderTest extends PHPUnit_Framework_TestCase
 {
     /**
-     * @var SAML2_Certificate_FingerprintLoader
+     * @var \SAML2\Certificate\FingerprintLoader
      */
     private $fingerprintLoader;
 
@@ -14,7 +19,7 @@ class SAML2_Certificate_FingerprintLoaderTest extends PHPUnit_Framework_TestCase
 
     public function setUp()
     {
-        $this->fingerprintLoader = new SAML2_Certificate_FingerprintLoader();
+        $this->fingerprintLoader = new FingerprintLoader();
         $this->configurationMock = \Mockery::mock('SAML2_Configuration_CertificateProvider');
     }
 
@@ -23,7 +28,7 @@ public function setUp()
      * @test
      *
      * @dataProvider invalidConfigurationProvider
-     * @expectedException SAML2_Exception_InvalidArgumentException
+     * @expectedException \SAML2\Exception\InvalidArgumentException
      */
     public function it_does_not_accept_invalid_configuration_values($configurationValue)
     {
@@ -40,7 +45,7 @@ public function it_does_not_accept_invalid_configuration_values($configurationVa
      * @test
      *
      * @dataProvider invalidConfigurationProvider
-     * @expectedException SAML2_Exception_InvalidArgumentException
+     * @expectedException \SAML2\Exception\InvalidArgumentException
      */
     public function it_correctly_parses_arrays_and_traversables($configurationValue)
     {
@@ -60,7 +65,7 @@ public function invalidConfigurationProvider()
             'string'                             => array(''),
             'null value'                         => array(null),
             'non traversable'                    => array(new \StdClass()),
-            'traversable with non string values' => array(new SAML2_Configuration_ArrayAdapter(array('a', 1, null))),
+            'traversable with non string values' => array(new ArrayAdapter(array('a', 1, null))),
             'array with non string value'        => array(array('b', true, false))
         );
     }
@@ -74,15 +79,15 @@ public function validConfigurationProvider()
             'mixed array'       => array(
                 array(
                     'a',
-                    new SAML2_Certificate_Stub_ImplementsToString('b'),
+                    new ImplementsToString('b'),
                     'c',
                 )
             ),
             'mixed traversable' => array(
-                new SAML2_Configuration_ArrayAdapter(array(
+                new ArrayAdapter(array(
                     'a',
                     'b',
-                    new SAML2_Certificate_Stub_ImplementsToString('c')
+                    new ImplementsToString('c')
                 ))
             ),
         );
diff --git a/tests/SAML2/Certificate/FingerprintTest.php b/tests/SAML2/Certificate/FingerprintTest.php
index bb73aea64..777c7412a 100644
--- a/tests/SAML2/Certificate/FingerprintTest.php
+++ b/tests/SAML2/Certificate/FingerprintTest.php
@@ -1,9 +1,11 @@
 <?php
 
-class SAML2_Certificate_FingerprintTest extends PHPUnit_Framework_TestCase
+namespace SAML2\Certificate;
+
+class FingerprintTest extends PHPUnit_Framework_TestCase
 {
     /**
-     * @var SAML2_Certificate_Fingerprint
+     * @var \SAML2\Certificate\Fingerprint
      */
     private $fingerprint;
 
@@ -11,10 +13,10 @@ class SAML2_Certificate_FingerprintTest extends PHPUnit_Framework_TestCase
      * @group certificate
      * @test
      *
-     * @expectedException SAML2_Exception_InvalidArgumentException
+     * @expectedException \SAML2\Exception\InvalidArgumentException
      */
     public function fails_on_invalid_fingerprint_data()
     {
-        $this->fingerprint = new SAML2_Certificate_Fingerprint(NULL);
+        $this->fingerprint = new Fingerprint(NULL);
     }
 }
diff --git a/tests/SAML2/Certificate/KeyLoaderTest.php b/tests/SAML2/Certificate/KeyLoaderTest.php
index ef8601596..d54402b5f 100644
--- a/tests/SAML2/Certificate/KeyLoaderTest.php
+++ b/tests/SAML2/Certificate/KeyLoaderTest.php
@@ -1,9 +1,13 @@
 <?php
 
-class SAML2_Certificate_KeyLoaderTest extends \PHPUnit_Framework_TestCase
+namespace SAML2\Certificate;
+
+use SAML2\Utilities\Certificate;
+
+class KeyLoaderTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var SAML2_Certificate_KeyLoader
+     * @var \SAML2\Certificate\KeyLoader
      */
     private $keyLoader;
 
@@ -21,7 +25,7 @@ class SAML2_Certificate_KeyLoaderTest extends \PHPUnit_Framework_TestCase
 
     public function setUp()
     {
-        $this->keyLoader = new SAML2_Certificate_KeyLoader();
+        $this->keyLoader = new KeyLoader();
         $this->configurationMock = \Mockery::mock('SAML2_Configuration_CertificateProvider');
     }
 
@@ -32,23 +36,23 @@ public function setUp()
      */
     public function load_keys_checks_for_usage_of_key()
     {
-        $signing = array(SAML2_Certificate_Key::USAGE_SIGNING => true);
-        $encryption = array(SAML2_Certificate_Key::USAGE_ENCRYPTION => true);
+        $signing = array(Key::USAGE_SIGNING => true);
+        $encryption = array(Key::USAGE_ENCRYPTION => true);
 
         $keys = array($signing, $encryption);
 
-        $this->keyLoader->loadKeys($keys, SAML2_Certificate_Key::USAGE_SIGNING);
+        $this->keyLoader->loadKeys($keys, Key::USAGE_SIGNING);
         $loadedKeys = $this->keyLoader->getKeys();
 
         $this->assertCount(1, $loadedKeys, 'Amount of keys that have been loaded does not match the expected amount');
-        $this->assertTrue($loadedKeys->get(0)->canBeUsedFor(SAML2_Certificate_Key::USAGE_SIGNING));
+        $this->assertTrue($loadedKeys->get(0)->canBeUsedFor(Key::USAGE_SIGNING));
     }
 
     /**
      * @group certificate
      *
      * @test
-     * @expectedException SAML2_Exception_InvalidArgumentException
+     * @expectedException \SAML2\Exception\InvalidArgumentException
      */
     public function certificate_data_with_invalid_format_throws_an_exception()
     {
@@ -77,7 +81,7 @@ public function certificate_data_is_loaded_as_key()
      * @group certificate
      *
      * @test
-     * @expectedException SAML2_Certificate_Exception_InvalidCertificateStructureException
+     * @expectedException \SAML2\Certificate\Exception\InvalidCertificateStructureException
      */
     public function loading_a_file_with_the_wrong_format_throws_an_exception()
     {
@@ -98,7 +102,7 @@ public function loading_a_certificate_from_file_creates_a_key()
         $loadedKeys = $this->keyLoader->getKeys();
         $loadedKey = $loadedKeys->get(0);
         $fileContents = file_get_contents($file);
-        preg_match(SAML2_Utilities_Certificate::CERTIFICATE_PATTERN, $fileContents, $matches);
+        preg_match(Certificate::CERTIFICATE_PATTERN, $fileContents, $matches);
         $expected = preg_replace('~\s+~', '', $matches[1]);
 
         $this->assertTrue($this->keyLoader->hasKeys());
@@ -110,7 +114,7 @@ public function loading_a_certificate_from_file_creates_a_key()
      * @group certificate
      *
      * @test
-     * @expectedException SAML2_Certificate_Exception_NoKeysFoundException
+     * @expectedException \SAML2\Certificate\Exception\NoKeysFoundException
      */
     public function loading_a_required_certificate_from_an_empty_configuration_throws_an_exception()
     {
@@ -158,7 +162,7 @@ public function loading_a_certificate_file_from_configuration_creates_key()
      * @group certificate
      *
      * @test
-     * @expectedException SAML2_Certificate_Exception_InvalidCertificateStructureException
+     * @expectedException \SAML2\Certificate\Exception\InvalidCertificateStructureException
      */
     public function loading_an_invalid_certificate_file_from_configuration_throws_exception()
     {
diff --git a/tests/SAML2/Certificate/KeyTest.php b/tests/SAML2/Certificate/KeyTest.php
index 6fa42087e..9f8afc76b 100644
--- a/tests/SAML2/Certificate/KeyTest.php
+++ b/tests/SAML2/Certificate/KeyTest.php
@@ -1,16 +1,18 @@
 <?php
 
-class SAML2_Certificate_KeyTest extends \PHPUnit_Framework_TestCase
+namespace SAML2\Certificate;
+
+class KeyTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @group certificate
      *
      * @test
-     * @expectedException SAML2_Certificate_Exception_InvalidKeyUsageException
+     * @expectedException \SAML2\Certificate\Exception\InvalidKeyUsageException
      */
     public function invalid_key_usage_should_throw_an_exception()
     {
-        $key = new SAML2_Certificate_Key(array(SAML2_Certificate_Key::USAGE_SIGNING => true));
+        $key = new Key(array(Key::USAGE_SIGNING => true));
 
         $key->canBeUsedFor('foo');
     }
@@ -22,12 +24,12 @@ public function invalid_key_usage_should_throw_an_exception()
      */
     public function assert_that_key_usage_check_works_correctly()
     {
-        $key = new SAML2_Certificate_Key(array(SAML2_Certificate_Key::USAGE_SIGNING => true));
+        $key = new Key(array(Key::USAGE_SIGNING => true));
 
-        $this->assertTrue($key->canBeUsedFor(SAML2_Certificate_Key::USAGE_SIGNING));
-        $this->assertFalse($key->canBeUsedFor(SAML2_Certificate_Key::USAGE_ENCRYPTION));
+        $this->assertTrue($key->canBeUsedFor(Key::USAGE_SIGNING));
+        $this->assertFalse($key->canBeUsedFor(Key::USAGE_ENCRYPTION));
 
-        $key[SAML2_Certificate_Key::USAGE_ENCRYPTION] = false;
-        $this->assertFalse($key->canBeUsedFor(SAML2_Certificate_Key::USAGE_ENCRYPTION));
+        $key[Key::USAGE_ENCRYPTION] = false;
+        $this->assertFalse($key->canBeUsedFor(Key::USAGE_ENCRYPTION));
     }
 }
diff --git a/tests/SAML2/Certificate/PrivateKeyLoaderTest.php b/tests/SAML2/Certificate/PrivateKeyLoaderTest.php
index cce0e2b46..68d6da9e6 100644
--- a/tests/SAML2/Certificate/PrivateKeyLoaderTest.php
+++ b/tests/SAML2/Certificate/PrivateKeyLoaderTest.php
@@ -1,15 +1,19 @@
 <?php
 
-class SAML2_Certificate_PrivateKeyLoaderTest extends \PHPUnit_Framework_TestCase
+namespace SAML2\Certificate;
+
+use SAML2\Configuration\PrivateKey;
+
+class PrivateKeyLoaderTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var SAML2_Certificate_PrivateKeyLoader
+     * @var \SAML2\Certificate\PrivateKeyLoader
      */
     private $privateKeyLoader;
 
     public function setUp()
     {
-        $this->privateKeyLoader = new SAML2_Certificate_PrivateKeyLoader();
+        $this->privateKeyLoader = new PrivateKeyLoader();
     }
 
     /**
@@ -17,10 +21,10 @@ public function setUp()
      * @test
      * @dataProvider privateKeyTestProvider
      *
-     * @param SAML2_Configuration_PrivateKey $configuredKey
+     * @param \SAML2\Configuration\PrivateKey $configuredKey
      */
     public function loading_a_configured_private_key_returns_a_certificate_private_key(
-        SAML2_Configuration_PrivateKey $configuredKey
+        PrivateKey $configuredKey
     ) {
         $resultingKey = $this->privateKeyLoader->loadPrivateKey($configuredKey);
 
@@ -38,15 +42,15 @@ public function privateKeyTestProvider()
     {
         return array(
             'no passphrase'   => array(
-                new SAML2_Configuration_PrivateKey(
+                new PrivateKey(
                     dirname(__FILE__) . '/File/a_fake_private_key_file.pem',
-                    SAML2_Configuration_PrivateKey::NAME_DEFAULT
+                    PrivateKey::NAME_DEFAULT
                 )
             ),
             'with passphrase' => array(
-                new SAML2_Configuration_PrivateKey(
+                new PrivateKey(
                     dirname(__FILE__) . '/File/a_fake_private_key_file.pem',
-                    SAML2_Configuration_PrivateKey::NAME_DEFAULT,
+                    PrivateKey::NAME_DEFAULT,
                     'foo bar baz'
                 )
             ),
diff --git a/tests/SAML2/Certificate/Stub/ImplementsToString.php b/tests/SAML2/Certificate/Stub/ImplementsToString.php
index a26cddde6..13f450a04 100644
--- a/tests/SAML2/Certificate/Stub/ImplementsToString.php
+++ b/tests/SAML2/Certificate/Stub/ImplementsToString.php
@@ -1,6 +1,8 @@
 <?php
 
-class SAML2_Certificate_Stub_ImplementsToString
+namespace SAML2\Certificate\Stub;
+
+class ImplementsToString
 {
     /**
      * @var string
diff --git a/tests/SAML2/Certificate/X509Test.php b/tests/SAML2/Certificate/X509Test.php
index 9cc54c4fe..4b2e7d4a3 100644
--- a/tests/SAML2/Certificate/X509Test.php
+++ b/tests/SAML2/Certificate/X509Test.php
@@ -1,6 +1,8 @@
 <?php
 
-class SAML2_Certificate_X509Test extends PHPUnit_Framework_TestCase
+namespace SAML2\Certificate;
+
+class X509Test extends PHPUnit_Framework_TestCase
 {
     /**
      * @group certificate
@@ -13,10 +15,10 @@ public function x509_certificate_contents_must_be_stripped_of_whitespace()
             'X509Certificate' => ' Should   No Longer  Have Whitespaces'
         );
 
-        $viaConstructor                = new SAML2_Certificate_X509($toTest);
-        $viaSetting                    = new SAML2_Certificate_X509(array());
+        $viaConstructor                = new X509($toTest);
+        $viaSetting                    = new X509(array());
         $viaSetting['X509Certificate'] = $toTest['X509Certificate'];
-        $viaFactory                    = SAML2_Certificate_X509::createFromCertificateData($toTest['X509Certificate']);
+        $viaFactory                    = X509::createFromCertificateData($toTest['X509Certificate']);
 
         $this->assertEquals($viaConstructor['X509Certificate'], 'ShouldNoLongerHaveWhitespaces');
         $this->assertEquals($viaSetting['X509Certificate'], 'ShouldNoLongerHaveWhitespaces');
diff --git a/tests/SAML2/CertificatesMock.php b/tests/SAML2/CertificatesMock.php
index ce762c9ee..b4ce49715 100644
--- a/tests/SAML2/CertificatesMock.php
+++ b/tests/SAML2/CertificatesMock.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace SAML2;
+
 /**
- * Class SAML2_CertificatesMock
+ * Class \SAML2\CertificatesMock
  */
-class SAML2_CertificatesMock
+class CertificatesMock
 {
     const PUBLIC_KEY_PEM = '-----BEGIN CERTIFICATE-----
 MIICgTCCAeoCCQCbOlrWDdX7FTANBgkqhkiG9w0BAQUFADCBhDELMAkGA1UEBhMC
diff --git a/tests/SAML2/Configuration/ArrayAdapterTest.php b/tests/SAML2/Configuration/ArrayAdapterTest.php
index a819902e8..39a6cbaa8 100644
--- a/tests/SAML2/Configuration/ArrayAdapterTest.php
+++ b/tests/SAML2/Configuration/ArrayAdapterTest.php
@@ -1,6 +1,8 @@
 <?php
 
-class SAML2_Configuration_ArrayAdapterTest extends PHPUnit_Framework_TestCase
+namespace SAML2\Configuration;
+
+class ArrayAdapterTest extends PHPUnit_Framework_TestCase
 {
     /**
      * @group configuration
@@ -8,7 +10,7 @@ class SAML2_Configuration_ArrayAdapterTest extends PHPUnit_Framework_TestCase
      */
     public function set_configuration_can_be_queried()
     {
-        $configuration = new SAML2_Configuration_ArrayAdapter(array('foo' => 'bar'));
+        $configuration = new ArrayAdapter(array('foo' => 'bar'));
 
         $this->assertTrue($configuration->has('foo'));
         $this->assertFalse($configuration->has('quux'));
@@ -23,7 +25,7 @@ public function default_values_are_returned_for_unavailable_configuration()
     {
         $configuration = array('foo' => 'bar');
 
-        $arrayAdapter = new SAML2_Configuration_ArrayAdapter($configuration);
+        $arrayAdapter = new ArrayAdapter($configuration);
 
         $this->assertNull($arrayAdapter->get('quuz'));
         $this->assertFalse($arrayAdapter->get('quux', false));
diff --git a/tests/SAML2/Configuration/DestinationTest.php b/tests/SAML2/Configuration/DestinationTest.php
index 647859207..da660be84 100644
--- a/tests/SAML2/Configuration/DestinationTest.php
+++ b/tests/SAML2/Configuration/DestinationTest.php
@@ -1,6 +1,8 @@
 <?php
 
-class SAML2_Configuration_DestinationTest extends \PHPUnit_Framework_TestCase
+namespace SAML2\Configuration;
+
+class DestinationTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @group configuration
@@ -8,8 +10,8 @@ class SAML2_Configuration_DestinationTest extends \PHPUnit_Framework_TestCase
      */
     public function two_destinations_with_the_same_value_are_equal()
     {
-        $destinationOne = new SAML2_Configuration_Destination('a');
-        $destinationTwo = new SAML2_Configuration_Destination('a');
+        $destinationOne = new Destination('a');
+        $destinationTwo = new Destination('a');
 
         $this->assertTrue($destinationOne->equals($destinationTwo));
     }
@@ -20,8 +22,8 @@ public function two_destinations_with_the_same_value_are_equal()
      */
     public function two_destinations_with_the_different_values_are_not_equal()
     {
-        $destinationOne = new SAML2_Configuration_Destination('a');
-        $destinationTwo = new SAML2_Configuration_Destination('a');
+        $destinationOne = new Destination('a');
+        $destinationTwo = new Destination('a');
 
         $this->assertTrue($destinationOne->equals($destinationTwo));
     }
@@ -30,11 +32,11 @@ public function two_destinations_with_the_different_values_are_not_equal()
      * @group configuration
      * @test
      * @dataProvider nonStringValueProvider
-     * @expectedException SAML2_Exception_InvalidArgumentException
+     * @expectedException \SAML2\Exception\InvalidArgumentException
      */
     public function a_destination_cannot_be_created_with_a_non_string_value($value)
     {
-        $destination = new SAML2_Configuration_Destination($value);
+        $destination = new Destination($value);
     }
 
     /**
diff --git a/tests/SAML2/ControlledTimeTest.php b/tests/SAML2/ControlledTimeTest.php
index 302f56fd7..d1d351032 100644
--- a/tests/SAML2/ControlledTimeTest.php
+++ b/tests/SAML2/ControlledTimeTest.php
@@ -1,5 +1,7 @@
 <?php
 
+namespace SAML2;
+
 use \Mockery as m;
 
 /**
@@ -8,7 +10,7 @@
  *
  * @runTestsInSeparateProcesses
  */
-abstract class SAML2_ControlledTimeTest extends \PHPUnit_Framework_TestCase
+abstract class ControlledTimeTest extends \PHPUnit_Framework_TestCase
 {
     protected $currentTime = 1;
 
diff --git a/tests/SAML2/DOMDocumentFactoryTest.php b/tests/SAML2/DOMDocumentFactoryTest.php
index e0ae7dd02..ddf5c857a 100644
--- a/tests/SAML2/DOMDocumentFactoryTest.php
+++ b/tests/SAML2/DOMDocumentFactoryTest.php
@@ -1,26 +1,28 @@
 <?php
 
-class SAML2_DOMDocumentFactoryTest extends PHPUnit_Framework_TestCase
+namespace SAML2;
+
+class DOMDocumentFactoryTest extends PHPUnit_Framework_TestCase
 {
     /**
      * @param mixed $argument
      *
      * @group domdocument
      * @dataProvider nonStringProvider
-     * @expectedException SAML2_Exception_InvalidArgumentException
+     * @expectedException \SAML2\Exception\InvalidArgumentException
      */
     public function testOnlyAStringIsAcceptedByFronString($argument)
     {
-        SAML2_DOMDocumentFactory::fromString($argument);
+        DOMDocumentFactory::fromString($argument);
     }
 
     /**
      * @group domdocument
-     * @expectedException SAML2_Exception_RuntimeException
+     * @expectedException \SAML2\Exception\RuntimeException
      */
     public function testNotXmlStringRaisesAnException()
     {
-        SAML2_DOMDocumentFactory::fromString('this is not xml');
+        DOMDocumentFactory::fromString('this is not xml');
     }
 
     /**
@@ -30,7 +32,7 @@ public function testXmlStringIsCorrectlyLoaded()
     {
         $xml = '<root/>';
 
-        $document = SAML2_DOMDocumentFactory::fromString($xml);
+        $document = DOMDocumentFactory::fromString($xml);
 
         $this->assertXmlStringEqualsXmlString($xml, $document->saveXML());
     }
@@ -40,34 +42,34 @@ public function testXmlStringIsCorrectlyLoaded()
      *
      * @group        domdocument
      * @dataProvider nonStringProvider
-     * @expectedException SAML2_Exception_InvalidArgumentException
+     * @expectedException \SAML2\Exception\InvalidArgumentException
      */
     public function testOnlyAStringIsAcceptedByFromFile($argument)
     {
-        SAML2_DOMDocumentFactory::fromString($argument);
+        DOMDocumentFactory::fromString($argument);
     }
 
     /**
      * @group        domdocument
      * @dataProvider nonStringProvider
-     * @expectedException SAML2_Exception_InvalidArgumentException
+     * @expectedException \SAML2\Exception\InvalidArgumentException
      */
     public function testFileThatDoesNotExistIsNotAccepted()
     {
         $filename = 'DoesNotExist.ext';
 
-        SAML2_DOMDocumentFactory::fromFile($filename);
+        DOMDocumentFactory::fromFile($filename);
     }
 
     /**
      * @group domdocument
-     * @expectedException SAML2_Exception_RuntimeException
+     * @expectedException \SAML2\Exception\RuntimeException
      */
     public function testFileThatDoesNotContainXMLCannotBeLoaded()
     {
         $file = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'domdocument_invalid_xml.xml';
 
-        SAML2_DOMDocumentFactory::fromFile($file);
+        DOMDocumentFactory::fromFile($file);
     }
 
     /**
@@ -77,52 +79,52 @@ public function testFileWithValidXMLCanBeLoaded()
     {
         $file = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'domdocument_valid_xml.xml';
 
-        $document = SAML2_DOMDocumentFactory::fromFile($file);
+        $document = DOMDocumentFactory::fromFile($file);
 
         $this->assertXmlStringEqualsXmlFile($file, $document->saveXML());
     }
 
     /**
      * @group                    domdocument
-     * @expectedException        SAML2_Exception_RuntimeException
+     * @expectedException        \SAML2\Exception\RuntimeException
      * @expectedExceptionMessage Dangerous XML detected, DOCTYPE nodes are not allowed in the XML body
      */
     public function testFileThatContainsDocTypeIsNotAccepted()
     {
         $file = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'domdocument_doctype.xml';
-        SAML2_DOMDocumentFactory::fromFile($file);
+        DOMDocumentFactory::fromFile($file);
     }
 
     /**
      * @group                    domdocument
-     * @expectedException        SAML2_Exception_RuntimeException
+     * @expectedException        \SAML2\Exception\RuntimeException
      * @expectedExceptionMessage Dangerous XML detected, DOCTYPE nodes are not allowed in the XML body
      */
     public function testStringThatContainsDocTypeIsNotAccepted()
     {
         $xml = '<!DOCTYPE foo [<!ELEMENT foo ANY > <!ENTITY xxe SYSTEM "file:///dev/random" >]><foo />';
-        SAML2_DOMDocumentFactory::fromString($xml);
+        DOMDocumentFactory::fromString($xml);
     }
 
     /**
      * @group                    domdocument
-     * @expectedException        SAML2_Exception_RuntimeException
+     * @expectedException        \SAML2\Exception\RuntimeException
      * @expectedExceptionMessage does not have content
      */
     public function testEmptyFileIsNotValid()
     {
         $file = realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'domdocument_empty.xml';
-        SAML2_DOMDocumentFactory::fromFile($file);
+        DOMDocumentFactory::fromFile($file);
     }
 
     /**
      * @group                    domdocument
-     * @expectedException        SAML2_Exception_InvalidArgumentException
+     * @expectedException        \SAML2\Exception\InvalidArgumentException
      * @expectedExceptionMessage Invalid Argument type: "non-empty string" expected, "string" given
      */
     public function testEmptyStringIsNotValid()
     {
-        SAML2_DOMDocumentFactory::fromString("");
+        DOMDocumentFactory::fromString("");
     }
 
     /**
diff --git a/tests/SAML2/LogoutRequestTest.php b/tests/SAML2/LogoutRequestTest.php
index 5b3d7fd49..bebccea39 100644
--- a/tests/SAML2/LogoutRequestTest.php
+++ b/tests/SAML2/LogoutRequestTest.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace SAML2;
+
 /**
- * Class SAML2_LogoutRequestTest
+ * Class \SAML2\LogoutRequestTest
  */
-class SAML2_LogoutRequestTest extends \PHPUnit_Framework_TestCase
+class LogoutRequestTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @var DOMElement
@@ -38,35 +40,35 @@ public function setUp()
   <samlp:SessionIndex>SomeSessionIndex2</samlp:SessionIndex>
 </samlp:LogoutRequest>
 XML;
-        $document = SAML2_DOMDocumentFactory::fromString($xml);
+        $document = DOMDocumentFactory::fromString($xml);
         $this->logoutRequestElement = $document->firstChild;
     }
 
     public function testMarshalling()
     {
-        $logoutRequest = new SAML2_LogoutRequest();
+        $logoutRequest = new LogoutRequest();
         $logoutRequest->setNameID(array('Value' => 'NameIDValue'));
         $logoutRequest->setSessionIndex('SessionIndexValue');
 
         $logoutRequestElement = $logoutRequest->toUnsignedXML();
         $this->assertEquals('LogoutRequest', $logoutRequestElement->localName);
-        $this->assertEquals(SAML2_Constants::NS_SAMLP, $logoutRequestElement->namespaceURI);
+        $this->assertEquals(Constants::NS_SAMLP, $logoutRequestElement->namespaceURI);
 
-        $nameIdElements = SAML2_Utils::xpQuery($logoutRequestElement, './saml_assertion:NameID');
+        $nameIdElements = Utils::xpQuery($logoutRequestElement, './saml_assertion:NameID');
         $this->assertCount(1, $nameIdElements);
         $nameIdElements = $nameIdElements[0];
         $this->assertEquals('NameIDValue', $nameIdElements->textContent);
 
-        $sessionIndexElements = SAML2_Utils::xpQuery($logoutRequestElement, './saml_protocol:SessionIndex');
+        $sessionIndexElements = Utils::xpQuery($logoutRequestElement, './saml_protocol:SessionIndex');
         $this->assertCount(1, $sessionIndexElements);
         $this->assertEquals('SessionIndexValue', $sessionIndexElements[0]->textContent);
 
-        $logoutRequest = new SAML2_LogoutRequest();
+        $logoutRequest = new LogoutRequest();
         $logoutRequest->setNameID(array('Value' => 'NameIDValue'));
         $logoutRequest->setSessionIndexes(array('SessionIndexValue1', 'SessionIndexValue2'));
         $logoutRequestElement = $logoutRequest->toUnsignedXML();
 
-        $sessionIndexElements = SAML2_Utils::xpQuery($logoutRequestElement, './saml_protocol:SessionIndex');
+        $sessionIndexElements = Utils::xpQuery($logoutRequestElement, './saml_protocol:SessionIndex');
         $this->assertCount(2, $sessionIndexElements);
         $this->assertEquals('SessionIndexValue1', $sessionIndexElements[0]->textContent);
         $this->assertEquals('SessionIndexValue2', $sessionIndexElements[1]->textContent);
@@ -74,7 +76,7 @@ public function testMarshalling()
 
     public function testUnmarshalling()
     {
-        $logoutRequest = new SAML2_LogoutRequest($this->logoutRequestElement);
+        $logoutRequest = new LogoutRequest($this->logoutRequestElement);
         $this->assertEquals('TheIssuer', $logoutRequest->getIssuer());
         $this->assertTrue($logoutRequest->isNameIdEncrypted());
 
@@ -83,7 +85,7 @@ public function testUnmarshalling()
         $this->assertEquals('SomeSessionIndex1', $sessionIndexElements[0]);
         $this->assertEquals('SomeSessionIndex2', $sessionIndexElements[1]);
 
-        $logoutRequest->decryptNameId(SAML2_CertificatesMock::getPrivateKey());
+        $logoutRequest->decryptNameId(CertificatesMock::getPrivateKey());
 
         $nameId = $logoutRequest->getNameId();
         $this->assertEquals('TheNameIDValue', $nameId['Value']);
@@ -91,23 +93,23 @@ public function testUnmarshalling()
 
     public function testEncryptedNameId()
     {
-        $logoutRequest = new SAML2_LogoutRequest();
+        $logoutRequest = new LogoutRequest();
         $logoutRequest->setNameID(array('Value' => 'NameIDValue'));
-        $logoutRequest->encryptNameId(SAML2_CertificatesMock::getPublicKey());
+        $logoutRequest->encryptNameId(CertificatesMock::getPublicKey());
 
         $logoutRequestElement = $logoutRequest->toUnsignedXML();
         $this->assertCount(
             1,
-            SAML2_Utils::xpQuery($logoutRequestElement, './saml_assertion:EncryptedID/xenc:EncryptedData')
+            Utils::xpQuery($logoutRequestElement, './saml_assertion:EncryptedID/xenc:EncryptedData')
         );
     }
 
     public function testDecryptingNameId()
     {
-        $logoutRequest = new SAML2_LogoutRequest($this->logoutRequestElement);
+        $logoutRequest = new LogoutRequest($this->logoutRequestElement);
         $this->assertTrue($logoutRequest->isNameIdEncrypted());
 
-        $logoutRequest->decryptNameId(SAML2_CertificatesMock::getPrivateKey());
+        $logoutRequest->decryptNameId(CertificatesMock::getPrivateKey());
         $nameId = $logoutRequest->getNameId();
         $this->assertEquals('TheNameIDValue', $nameId['Value']);
     }
diff --git a/tests/SAML2/Response/SignatureValidationTest.php b/tests/SAML2/Response/SignatureValidationTest.php
index 9daeb1902..c1fcd7156 100644
--- a/tests/SAML2/Response/SignatureValidationTest.php
+++ b/tests/SAML2/Response/SignatureValidationTest.php
@@ -1,27 +1,37 @@
 <?php
 
+namespace SAML2\Response;
+
+use SAML2\Utilities\Certificate;
+use SAML2\CertificatesMock;
+use SAML2\Configuration\IdentityProvider;
+use SAML2\Configuration\ServiceProvider;
+use SAML2\Configuration\Destination;
+use SAML2\Response;
+use SAML2\Assertion;
+
 /**
  * Test that ensures that either the response or the assertion(s) or both must be signed.
  */
-class SAML2_Response_SignatureValidationTest extends PHPUnit_Framework_TestCase
+class SignatureValidationTest extends PHPUnit_Framework_TestCase
 {
     /**
-     * @var SAML2_Configuration_IdentityProvider
+     * @var \SAML2\Configuration\IdentityProvider
      */
     private $identityProviderConfiguration;
 
     /**
-     * @var SAML2_Configuration_ServiceProvider
+     * @var \SAML2\Configuration\ServiceProvider
      */
     private $serviceProviderConfiguration;
 
     /**
-     * @var Mockery\MockInterface Mock of SAML2_Assertion_ProcessorBuilder
+     * @var Mockery\MockInterface Mock of \SAML2\Assertion\ProcessorBuilder
      */
     private $assertionProcessorBuilder;
 
     /**
-     * @var Mockery\MockInterface Mock of SAML2_Assertion_Processor
+     * @var Mockery\MockInterface Mock of \SAML2\Assertion\Processor
      */
     private $assertionProcessor;
 
@@ -43,13 +53,13 @@ public function setUp()
             ->once()
             ->andReturn($this->assertionProcessor);
 
-        $pattern = SAML2_Utilities_Certificate::CERTIFICATE_PATTERN;
-        preg_match($pattern, SAML2_CertificatesMock::PUBLIC_KEY_PEM, $matches);
+        $pattern = Certificate::CERTIFICATE_PATTERN;
+        preg_match($pattern, CertificatesMock::PUBLIC_KEY_PEM, $matches);
 
         $this->identityProviderConfiguration
-            = new SAML2_Configuration_IdentityProvider(array('certificateData' => $matches[1]));
+            = new IdentityProvider(array('certificateData' => $matches[1]));
         $this->serviceProviderConfiguration
-            = new SAML2_Configuration_ServiceProvider(array('entityId' => 'urn:mace:feide.no:services:no.feide.moodle'));
+            = new ServiceProvider(array('entityId' => 'urn:mace:feide.no:services:no.feide.moodle'));
     }
 
     /**
@@ -68,12 +78,12 @@ public function testThatAnUnsignedResponseWithASignedAssertionCanBeProcessed()
     {
         $this->assertionProcessor->shouldReceive('processAssertions')->once();
 
-        $processor = new SAML2_Response_Processor(new \Psr\Log\NullLogger());
+        $processor = new Processor(new \Psr\Log\NullLogger());
 
         $processor->process(
             $this->serviceProviderConfiguration,
             $this->identityProviderConfiguration,
-            new SAML2_Configuration_Destination($this->currentDestination),
+            new Destination($this->currentDestination),
             $this->getUnsignedResponseWithSignedAssertion()
         );
     }
@@ -85,12 +95,12 @@ public function testThatAnSignedResponseWithAnUnsignedAssertionCanBeProcessed()
     {
         $this->assertionProcessor->shouldReceive('processAssertions')->once();
 
-        $processor = new SAML2_Response_Processor(new \Psr\Log\NullLogger());
+        $processor = new Processor(new \Psr\Log\NullLogger());
 
         $processor->process(
             $this->serviceProviderConfiguration,
             $this->identityProviderConfiguration,
-            new SAML2_Configuration_Destination($this->currentDestination),
+            new Destination($this->currentDestination),
             $this->getSignedResponseWithUnsignedAssertion()
         );
     }
@@ -102,18 +112,18 @@ public function testThatASignedResponseWithASignedAssertionIsValid()
     {
         $this->assertionProcessor->shouldReceive('processAssertions')->once();
 
-        $processor = new SAML2_Response_Processor(new \Psr\Log\NullLogger());
+        $processor = new Processor(new \Psr\Log\NullLogger());
 
         $processor->process(
             $this->serviceProviderConfiguration,
             $this->identityProviderConfiguration,
-            new SAML2_Configuration_Destination($this->currentDestination),
+            new Destination($this->currentDestination),
             $this->getSignedResponseWithSignedAssertion()
         );
     }
 
     /**
-     * @expectedException SAML2_Response_Exception_UnsignedResponseException
+     * @expectedException \SAML2\Response\Exception\UnsignedResponseException
      * @runInSeparateProcess
      */
     public function testThatAnUnsignedResponseWithNoSignedAssertionsThrowsAnException()
@@ -121,45 +131,45 @@ public function testThatAnUnsignedResponseWithNoSignedAssertionsThrowsAnExceptio
         // here the processAssertions may not be called as it should fail with an exception due to having no signature
         $this->assertionProcessor->shouldReceive('processAssertions')->never();
 
-        $processor = new SAML2_Response_Processor(new \Psr\Log\NullLogger());
+        $processor = new Processor(new \Psr\Log\NullLogger());
 
         $processor->process(
-            new SAML2_Configuration_ServiceProvider(array()),
-            new SAML2_Configuration_IdentityProvider(array()),
-            new SAML2_Configuration_Destination($this->currentDestination),
+            new ServiceProvider(array()),
+            new IdentityProvider(array()),
+            new Destination($this->currentDestination),
             $this->getUnsignedResponseWithUnsignedAssertion()
         );
     }
 
     /**
-     * @return SAML2_Response
+     * @return \SAML2\Response
      */
     private function getSignedResponseWithUnsignedAssertion()
     {
         $doc = new DOMDocument();
         $doc->load(__DIR__ . '/response.xml');
-        $response = new SAML2_Response($doc->firstChild);
-        $response->setSignatureKey(SAML2_CertificatesMock::getPrivateKey());
-        $response->setCertificates(array(SAML2_CertificatesMock::PUBLIC_KEY_PEM));
+        $response = new Response($doc->firstChild);
+        $response->setSignatureKey(CertificatesMock::getPrivateKey());
+        $response->setCertificates(array(CertificatesMock::PUBLIC_KEY_PEM));
 
         // convert to signed response
-        return new SAML2_Response($response->toSignedXML());
+        return new Response($response->toSignedXML());
     }
 
     /**
-     * @return SAML2_Response
+     * @return \SAML2\Response
      */
     private function getUnsignedResponseWithSignedAssertion()
     {
         $doc = new DOMDocument();
         $doc->load(__DIR__ . '/response.xml');
-        $response = new SAML2_Response($doc->firstChild);
+        $response = new Response($doc->firstChild);
 
         $assertions = $response->getAssertions();
         $assertion = $assertions[0];
-        $assertion->setSignatureKey(SAML2_CertificatesMock::getPrivateKey());
-        $assertion->setCertificates(array(SAML2_CertificatesMock::PUBLIC_KEY_PEM));
-        $signedAssertion = new SAML2_Assertion($assertion->toXML());
+        $assertion->setSignatureKey(CertificatesMock::getPrivateKey());
+        $assertion->setCertificates(array(CertificatesMock::PUBLIC_KEY_PEM));
+        $signedAssertion = new Assertion($assertion->toXML());
 
         $response->setAssertions(array($signedAssertion));
 
@@ -167,31 +177,31 @@ private function getUnsignedResponseWithSignedAssertion()
     }
 
     /**
-     * @return SAML2_Response
+     * @return \SAML2\Response
      */
     private function getSignedResponseWithSignedAssertion()
     {
         $doc = new DOMDocument();
         $doc->load(__DIR__ . '/response.xml');
-        $response = new SAML2_Response($doc->firstChild);
-        $response->setSignatureKey(SAML2_CertificatesMock::getPrivateKey());
-        $response->setCertificates(array(SAML2_CertificatesMock::PUBLIC_KEY_PEM));
+        $response = new Response($doc->firstChild);
+        $response->setSignatureKey(CertificatesMock::getPrivateKey());
+        $response->setCertificates(array(CertificatesMock::PUBLIC_KEY_PEM));
 
         $assertions = $response->getAssertions();
         $assertion  = $assertions[0];
-        $assertion->setSignatureKey(SAML2_CertificatesMock::getPrivateKey());
-        $assertion->setCertificates(array(SAML2_CertificatesMock::PUBLIC_KEY_PEM));
+        $assertion->setSignatureKey(CertificatesMock::getPrivateKey());
+        $assertion->setCertificates(array(CertificatesMock::PUBLIC_KEY_PEM));
 
-        return new SAML2_Response($response->toSignedXML());
+        return new Response($response->toSignedXML());
     }
 
     /**
-     * @return SAML2_Response
+     * @return \SAML2\Response
      */
     private function getUnsignedResponseWithUnsignedAssertion()
     {
         $doc = new DOMDocument();
         $doc->load(__DIR__ . '/response.xml');
-        return new SAML2_Response($doc->firstChild);
+        return new Response($doc->firstChild);
     }
 }
diff --git a/tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php b/tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
index 60b91f12c..f9d614115 100644
--- a/tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
+++ b/tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
@@ -1,6 +1,11 @@
 <?php
 
-class SAML2_Response_Validation_ConstraintValidator_DestinationMatchesTest extends \PHPUnit_Framework_TestCase
+namespace SAML2\Response\Validation\ConstraintValidator;
+
+use SAML2\Configuration\Destination;
+use SAML2\Response\Validation\Result;
+
+class DestinationMatchesTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @var \Mockery\MockInterface
@@ -18,10 +23,10 @@ public function setUp()
      */
     public function a_response_is_valid_when_the_destinations_match()
     {
-        $expectedDestination = new SAML2_Configuration_Destination('VALID DESTINATION');
+        $expectedDestination = new Destination('VALID DESTINATION');
         $this->response->shouldReceive('getDestination')->once()->andReturn('VALID DESTINATION');
-        $validator = new SAML2_Response_Validation_ConstraintValidator_DestinationMatches($expectedDestination);
-        $result    = new SAML2_Response_Validation_Result();
+        $validator = new DestinationMatches($expectedDestination);
+        $result    = new Result();
 
         $validator->validate($this->response, $result);
 
@@ -35,10 +40,10 @@ public function a_response_is_valid_when_the_destinations_match()
     public function a_response_is_not_valid_when_the_destinations_are_not_equal()
     {
         $this->response->shouldReceive('getDestination')->once()->andReturn('FOO');
-        $validator = new SAML2_Response_Validation_ConstraintValidator_DestinationMatches(
-            new SAML2_Configuration_Destination('BAR')
+        $validator = new DestinationMatches(
+            new Destination('BAR')
         );
-        $result = new SAML2_Response_Validation_Result();
+        $result = new Result();
 
         $validator->validate($this->response, $result);
         $errors = $result->getErrors();
diff --git a/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php b/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
index 855d278cc..faf7a34a9 100644
--- a/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
+++ b/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
@@ -1,6 +1,11 @@
 <?php
 
-class SAML2_Response_Validation_ConstraintValidator_IsSuccessfulTest extends \PHPUnit_Framework_TestCase
+namespace SAML2\Response\Validation\ConstraintValidator;
+
+use SAML2\Response\Validation\Result;
+use SAML2\Constants;
+
+class IsSuccessfulTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @var \Mockery\MockInterface
@@ -20,8 +25,8 @@ public function validating_a_successful_response_gives_a_valid_validation_result
     {
         $this->response->shouldReceive('isSuccess')->once()->andReturn(true);
 
-        $validator = new SAML2_Response_Validation_ConstraintValidator_IsSuccessful();
-        $result    = new SAML2_Response_Validation_Result();
+        $validator = new IsSuccessful();
+        $result    = new Result();
 
         $validator->validate($this->response, $result);
 
@@ -36,14 +41,14 @@ public function an_unsuccessful_response_is_not_valid_and_generates_a_proper_err
     {
         $responseStatus = array(
             'Code'    => 'foo',
-            'SubCode' => SAML2_Constants::STATUS_PREFIX . 'bar',
+            'SubCode' => Constants::STATUS_PREFIX . 'bar',
             'Message' => 'this is a test message'
         );
         $this->response->shouldReceive('isSuccess')->once()->andReturn(false);
         $this->response->shouldReceive('getStatus')->once()->andReturn($responseStatus);
 
-        $validator = new SAML2_Response_Validation_ConstraintValidator_IsSuccessful();
-        $result    = new SAML2_Response_Validation_Result();
+        $validator = new IsSuccessful();
+        $result    = new Result();
 
         $validator->validate($this->response, $result);
         $errors = $result->getErrors();
diff --git a/tests/SAML2/Response/Validation/ResultTest.php b/tests/SAML2/Response/Validation/ResultTest.php
index 3ca725108..aa3796130 100644
--- a/tests/SAML2/Response/Validation/ResultTest.php
+++ b/tests/SAML2/Response/Validation/ResultTest.php
@@ -1,6 +1,8 @@
 <?php
 
-class SAML2_Response_Validation_ResultTest extends \PHPUnit_Framework_TestCase
+namespace SAML2\Response\Validation;
+
+class ResultTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @group response-validation
@@ -9,7 +11,7 @@ class SAML2_Response_Validation_ResultTest extends \PHPUnit_Framework_TestCase
     public function added_errors_can_be_retrieved()
     {
         $error = 'This would be an error message';
-        $result = new SAML2_Response_Validation_Result();
+        $result = new Result();
 
         $result->addError($error);
         $errors = $result->getErrors();
@@ -22,11 +24,11 @@ public function added_errors_can_be_retrieved()
      * @group response-validation
      * @test
      *
-     * @expectedException SAML2_Exception_InvalidArgumentException
+     * @expectedException \SAML2\Exception\InvalidArgumentException
      */
     public function an_exception_is_thrown_when_trying_to_add_an_invalid_error()
     {
-        $result = new SAML2_Response_Validation_Result();
+        $result = new Result();
 
         $result->addError(123);
     }
@@ -37,7 +39,7 @@ public function an_exception_is_thrown_when_trying_to_add_an_invalid_error()
      */
     public function the_result_correctly_reports_whether_or_not_it_is_valid()
     {
-        $result = new SAML2_Response_Validation_Result();
+        $result = new Result();
 
         $this->assertTrue($result->isValid());
         $this->assertCount(0, $result->getErrors());
diff --git a/tests/SAML2/Response/XmlSignatureWrappingTest.php b/tests/SAML2/Response/XmlSignatureWrappingTest.php
index 7cdd889fd..085d8dc1d 100644
--- a/tests/SAML2/Response/XmlSignatureWrappingTest.php
+++ b/tests/SAML2/Response/XmlSignatureWrappingTest.php
@@ -1,25 +1,34 @@
 <?php
 
-class SAML2_Response_XmlSignatureWrappingTest extends PHPUnit_Framework_TestCase
+namespace SAML2\Response;
+
+use SAML2\Signature\Validator;
+use SAML2\Utilities\Certificate;
+use SAML2\CertificatesMock;
+use SAML2\Configuration\IdentityProvider;
+use SAML2\DOMDocumentFactory;
+use SAML2\Assertion;
+
+class XmlSignatureWrappingTest extends PHPUnit_Framework_TestCase
 {
     /**
-     * @var SAML2_Signature_Validator
+     * @var \SAML2\Signature\Validator
      */
     private $signatureValidator;
 
     /**
-     * @var SAML2_Configuration_IdentityProvider
+     * @var \SAML2\Configuration\IdentityProvider
      */
     private $identityProviderConfiguration;
 
     public function setUp()
     {
-        $this->signatureValidator = new SAML2_Signature_Validator(new \Psr\Log\NullLogger());
+        $this->signatureValidator = new Validator(new \Psr\Log\NullLogger());
 
-        $pattern = SAML2_Utilities_Certificate::CERTIFICATE_PATTERN;
-        preg_match($pattern, SAML2_CertificatesMock::PUBLIC_KEY_PEM, $matches);
+        $pattern = Certificate::CERTIFICATE_PATTERN;
+        preg_match($pattern, CertificatesMock::PUBLIC_KEY_PEM, $matches);
 
-        $this->identityProviderConfiguration = new SAML2_Configuration_IdentityProvider(
+        $this->identityProviderConfiguration = new IdentityProvider(
             array('certificateData' => $matches[1])
         );
     }
@@ -48,16 +57,16 @@ public function testThatASignatureReferencingAnotherAssertionIsNotValid()
 
     private function getSignedAssertionWithSignatureThatReferencesAnotherAssertion()
     {
-        $doc = SAML2_DOMDocumentFactory::fromFile(__DIR__ . '/signedAssertionWithInvalidReferencedId.xml');
-        $assertion = new SAML2_Assertion($doc->firstChild);
+        $doc = DOMDocumentFactory::fromFile(__DIR__ . '/signedAssertionWithInvalidReferencedId.xml');
+        $assertion = new Assertion($doc->firstChild);
 
         return $assertion;
     }
 
     private function getSignedAssertionWithEmbeddedAssertionReferencedInSignature()
     {
-        $document = SAML2_DOMDocumentFactory::fromFile(__DIR__ . '/signedAssertionReferencedEmbeddedAssertion.xml');
-        $assertion = new SAML2_Assertion($document->firstChild);
+        $document = DOMDocumentFactory::fromFile(__DIR__ . '/signedAssertionReferencedEmbeddedAssertion.xml');
+        $assertion = new Assertion($document->firstChild);
 
         return $assertion;
     }
diff --git a/tests/SAML2/ResponseTest.php b/tests/SAML2/ResponseTest.php
index 3c65cda41..9aae81df9 100644
--- a/tests/SAML2/ResponseTest.php
+++ b/tests/SAML2/ResponseTest.php
@@ -1,21 +1,23 @@
 <?php
 
+namespace SAML2;
+
 /**
- * Class SAML2_ResponseTest
+ * Class \SAML2\ResponseTest
  */
-class SAML2_ResponseTest extends PHPUnit_Framework_TestCase
+class ResponseTest extends PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
-        $response = new SAML2_Response();
-        $response->setConsent(SAML2_Constants::CONSENT_EXPLICIT);
+        $response = new Response();
+        $response->setConsent(Constants::CONSENT_EXPLICIT);
         $response->setIssuer('SomeIssuer');
         $responseElement = $response->toUnsignedXML();
 
         $this->assertTrue($responseElement->hasAttribute('Consent'));
-        $this->assertEquals($responseElement->getAttribute('Consent'), SAML2_Constants::CONSENT_EXPLICIT);
+        $this->assertEquals($responseElement->getAttribute('Consent'), Constants::CONSENT_EXPLICIT);
 
-        $issuerElements = SAML2_Utils::xpQuery($responseElement, './saml_assertion:Issuer');
+        $issuerElements = Utils::xpQuery($responseElement, './saml_assertion:Issuer');
         $this->assertCount(1, $issuerElements);
         $this->assertEquals('SomeIssuer', $issuerElements[0]->textContent);
     }
@@ -103,8 +105,8 @@ public function testLoop()
 </samlp:Response>
 XML;
 
-        $fixtureResponseDom = SAML2_DOMDocumentFactory::fromString($xml);
-        $request            = new SAML2_Response($fixtureResponseDom->firstChild);
+        $fixtureResponseDom = DOMDocumentFactory::fromString($xml);
+        $request            = new Response($fixtureResponseDom->firstChild);
 
         $requestXml = $requestDocument = $request->toUnsignedXML()->ownerDocument->C14N();
         $fixtureXml = $fixtureResponseDom->C14N();
diff --git a/tests/SAML2/Signature/FingerprintValidatorTest.php b/tests/SAML2/Signature/FingerprintValidatorTest.php
index a0fe41ef3..df491650a 100644
--- a/tests/SAML2/Signature/FingerprintValidatorTest.php
+++ b/tests/SAML2/Signature/FingerprintValidatorTest.php
@@ -1,6 +1,17 @@
 <?php
 
-class SAML2_Signature_FingerprintValidatorTest extends \PHPUnit_Framework_TestCase
+namespace SAML2\Signature;
+
+use SAML2\SimpleTestLogger;
+use SAML2\Certificate\FingerprintLoader;
+use SAML2\Utilities\Certificate;
+use SAML2\CertificatesMock;
+use SAML2\Certificate\X509;
+use SAML2\Configuration\IdentityProvider;
+use SAML2\DOMDocumentFactory;
+use SAML2\Response;
+
+class FingerprintValidatorTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @var \Mockery\MockInterface
@@ -26,9 +37,9 @@ public function it_cannot_validate_when_no_fingerprint_is_configured()
     {
         $this->mockConfiguration->shouldReceive('getCertificateFingerprints')->once()->andReturn(null);
 
-        $validator = new SAML2_Signature_FingerprintValidator(
-            new SAML2_SimpleTestLogger(),
-            new SAML2_Certificate_FingerprintLoader()
+        $validator = new FingerprintValidator(
+            new SimpleTestLogger(),
+            new FingerprintLoader()
         );
 
         $this->assertFalse($validator->canValidate($this->mockSignedElement, $this->mockConfiguration));
@@ -43,9 +54,9 @@ public function it_cannot_validate_when_no_certificates_are_found()
         $this->mockConfiguration->shouldReceive('getCertificateFingerprints')->once()->andReturn(array());
         $this->mockSignedElement->shouldReceive('getCertificates')->once()->andReturn(array());
 
-        $validator = new SAML2_Signature_FingerprintValidator(
-            new SAML2_SimpleTestLogger(),
-            new SAML2_Certificate_FingerprintLoader()
+        $validator = new FingerprintValidator(
+            new SimpleTestLogger(),
+            new FingerprintLoader()
         );
 
         $this->assertFalse($validator->canValidate($this->mockSignedElement, $this->mockConfiguration));
@@ -57,26 +68,26 @@ public function it_cannot_validate_when_no_certificates_are_found()
      */
     public function signed_message_with_valid_signature_is_validated_correctly()
     {
-        $pattern = SAML2_Utilities_Certificate::CERTIFICATE_PATTERN;
-        preg_match($pattern, SAML2_CertificatesMock::PUBLIC_KEY_PEM, $matches);
-        $certdata = SAML2_Certificate_X509::createFromCertificateData($matches[1]);
+        $pattern = Certificate::CERTIFICATE_PATTERN;
+        preg_match($pattern, CertificatesMock::PUBLIC_KEY_PEM, $matches);
+        $certdata = X509::createFromCertificateData($matches[1]);
         $fingerprint = $certdata->getFingerprint();
         $fingerprint_retry = $certdata->getFingerprint();
         $this->assertTrue($fingerprint->equals($fingerprint_retry), 'Cached fingerprint does not match original');
 
-        $config    = new SAML2_Configuration_IdentityProvider(array('certificateFingerprints' => array($fingerprint->getRaw())));
-        $validator = new SAML2_Signature_FingerprintValidator(
-            new SAML2_SimpleTestLogger(),
-            new SAML2_Certificate_FingerprintLoader()
+        $config    = new IdentityProvider(array('certificateFingerprints' => array($fingerprint->getRaw())));
+        $validator = new FingerprintValidator(
+            new SimpleTestLogger(),
+            new FingerprintLoader()
         );
 
-        $doc = SAML2_DOMDocumentFactory::fromFile(__DIR__ . '/response.xml');
-        $response = new SAML2_Response($doc->firstChild);
-        $response->setSignatureKey(SAML2_CertificatesMock::getPrivateKey());
-        $response->setCertificates(array(SAML2_CertificatesMock::PUBLIC_KEY_PEM));
+        $doc = DOMDocumentFactory::fromFile(__DIR__ . '/response.xml');
+        $response = new Response($doc->firstChild);
+        $response->setSignatureKey(CertificatesMock::getPrivateKey());
+        $response->setCertificates(array(CertificatesMock::PUBLIC_KEY_PEM));
 
         // convert to signed response
-        $response = new SAML2_Response($response->toSignedXML());
+        $response = new Response($response->toSignedXML());
 
         $this->assertTrue($validator->canValidate($response, $config), 'Cannot validate the element');
         $this->assertTrue($validator->hasValidSignature($response, $config), 'The signature is not valid');
diff --git a/tests/SAML2/Signature/MockChainedValidator.php b/tests/SAML2/Signature/MockChainedValidator.php
index 8e632a88a..93de58649 100644
--- a/tests/SAML2/Signature/MockChainedValidator.php
+++ b/tests/SAML2/Signature/MockChainedValidator.php
@@ -1,10 +1,15 @@
 <?php
 
+namespace SAML2\Signature;
+
+use SAML2\SignedElement;
+use SAML2\Configuration\CertificateProvider;
+
 /**
  * MockChainedValidator, to be able to test the validatorchain without having to use
  * actual validators
  */
-class SAML2_Signature_MockChainedValidator extends SAML2_Signature_AbstractChainedValidator
+class MockChainedValidator extends AbstractChainedValidator
 {
     /**
      * @var boolean
@@ -31,15 +36,15 @@ public function __construct($canValidate, $isValid)
     }
 
     public function canValidate(
-        SAML2_SignedElement $signedElement,
-        SAML2_Configuration_CertificateProvider $configuration
+        SignedElement $signedElement,
+        CertificateProvider $configuration
     ) {
         return $this->canValidate;
     }
 
     public function hasValidSignature(
-        SAML2_SignedElement $signedElement,
-        SAML2_Configuration_CertificateProvider $configuration
+        SignedElement $signedElement,
+        CertificateProvider $configuration
     ) {
         return $this->isValid;
     }
diff --git a/tests/SAML2/Signature/PublicKeyValidatorTest.php b/tests/SAML2/Signature/PublicKeyValidatorTest.php
index 286971bb7..c0cb78e43 100644
--- a/tests/SAML2/Signature/PublicKeyValidatorTest.php
+++ b/tests/SAML2/Signature/PublicKeyValidatorTest.php
@@ -1,6 +1,18 @@
 <?php
 
-class SAML2_Signature_PublicKeyValidatorTest extends \PHPUnit_Framework_TestCase
+namespace SAML2\Signature;
+
+use SAML2\Certificate\KeyCollection;
+use SAML2\Certificate\Key;
+use SAML2\SimpleTestLogger;
+use SAML2\Utilities\Certificate;
+use SAML2\CertificatesMock;
+use SAML2\Configuration\IdentityProvider;
+use SAML2\Certificate\KeyLoader;
+use SAML2\DOMDocumentFactory;
+use SAML2\Response;
+
+class PublicKeyValidatorTest extends \PHPUnit_Framework_TestCase
 {
     private $mockSignedElement;
     private $mockConfiguration;
@@ -17,8 +29,8 @@ public function setUp()
      */
     public function it_cannot_validate_if_no_keys_can_be_loaded()
     {
-        $keyloaderMock = $this->prepareKeyLoader(new SAML2_Certificate_KeyCollection());
-        $validator = new SAML2_Signature_PublicKeyValidator(new \Psr\Log\NullLogger(), $keyloaderMock);
+        $keyloaderMock = $this->prepareKeyLoader(new KeyCollection());
+        $validator = new PublicKeyValidator(new \Psr\Log\NullLogger(), $keyloaderMock);
 
         $this->assertFalse($validator->canValidate($this->mockSignedElement, $this->mockConfiguration));
     }
@@ -29,8 +41,8 @@ public function it_cannot_validate_if_no_keys_can_be_loaded()
      */
     public function it_will_validate_when_keys_can_be_loaded()
     {
-        $keyloaderMock = $this->prepareKeyLoader(new SAML2_Certificate_KeyCollection(array(1, 2)));
-        $validator = new SAML2_Signature_PublicKeyValidator(new \Psr\Log\NullLogger(), $keyloaderMock);
+        $keyloaderMock = $this->prepareKeyLoader(new KeyCollection(array(1, 2)));
+        $validator = new PublicKeyValidator(new \Psr\Log\NullLogger(), $keyloaderMock);
 
         $this->assertTrue($validator->canValidate($this->mockSignedElement, $this->mockConfiguration));
     }
@@ -41,14 +53,14 @@ public function it_will_validate_when_keys_can_be_loaded()
      */
     public function non_X509_keys_are_not_used_for_validation()
     {
-        $controlledCollection = new SAML2_Certificate_KeyCollection(array(
-            new SAML2_Certificate_Key(array('type' => 'not_X509')),
-            new SAML2_Certificate_Key(array('type' => 'again_not_X509'))
+        $controlledCollection = new KeyCollection(array(
+            new Key(array('type' => 'not_X509')),
+            new Key(array('type' => 'again_not_X509'))
         ));
 
         $keyloaderMock = $this->prepareKeyLoader($controlledCollection);
-        $logger = new SAML2_SimpleTestLogger();
-        $validator = new SAML2_Signature_PublicKeyValidator($logger, $keyloaderMock);
+        $logger = new SimpleTestLogger();
+        $validator = new PublicKeyValidator($logger, $keyloaderMock);
 
         $this->assertTrue($validator->canValidate($this->mockSignedElement, $this->mockConfiguration));
         $this->assertFalse($validator->hasValidSignature($this->mockSignedElement, $this->mockConfiguration));
@@ -63,19 +75,19 @@ public function non_X509_keys_are_not_used_for_validation()
      */
     public function signed_message_with_valid_signature_is_validated_correctly()
     {
-        $pattern = SAML2_Utilities_Certificate::CERTIFICATE_PATTERN;
-        preg_match($pattern, SAML2_CertificatesMock::PUBLIC_KEY_PEM, $matches);
+        $pattern = Certificate::CERTIFICATE_PATTERN;
+        preg_match($pattern, CertificatesMock::PUBLIC_KEY_PEM, $matches);
 
-        $config = new SAML2_Configuration_IdentityProvider(array('certificateData' => $matches[1]));
-        $validator = new SAML2_Signature_PublicKeyValidator(new SAML2_SimpleTestLogger(), new SAML2_Certificate_KeyLoader());
+        $config = new IdentityProvider(array('certificateData' => $matches[1]));
+        $validator = new PublicKeyValidator(new SimpleTestLogger(), new KeyLoader());
 
-        $doc = SAML2_DOMDocumentFactory::fromFile(__DIR__ . '/response.xml');
-        $response = new SAML2_Response($doc->firstChild);
-        $response->setSignatureKey(SAML2_CertificatesMock::getPrivateKey());
-        $response->setCertificates(array(SAML2_CertificatesMock::PUBLIC_KEY_PEM));
+        $doc = DOMDocumentFactory::fromFile(__DIR__ . '/response.xml');
+        $response = new Response($doc->firstChild);
+        $response->setSignatureKey(CertificatesMock::getPrivateKey());
+        $response->setCertificates(array(CertificatesMock::PUBLIC_KEY_PEM));
 
         // convert to signed response
-        $response = new SAML2_Response($response->toSignedXML());
+        $response = new Response($response->toSignedXML());
 
         $this->assertTrue($validator->canValidate($response, $config), 'Cannot validate the element');
         $this->assertTrue($validator->hasValidSignature($response, $config), 'The signature is not valid');
diff --git a/tests/SAML2/Signature/ValidatorChainTest.php b/tests/SAML2/Signature/ValidatorChainTest.php
index ca212c78b..c05ff9afe 100644
--- a/tests/SAML2/Signature/ValidatorChainTest.php
+++ b/tests/SAML2/Signature/ValidatorChainTest.php
@@ -1,29 +1,34 @@
 <?php
 
-class SAML2_Signature_ValidatorChainTest extends \PHPUnit_Framework_TestCase
+namespace SAML2\Signature;
+
+use SAML2\Response;
+use SAML2\Configuration\IdentityProvider;
+
+class ValidatorChainTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var SAML2_Signature_ValidatorChain
+     * @var \SAML2\Signature\ValidatorChain
      */
     private $chain;
 
     public function setUp()
     {
-        $this->chain = new SAML2_Signature_ValidatorChain(new \Psr\Log\NullLogger(), array());
+        $this->chain = new ValidatorChain(new \Psr\Log\NullLogger(), array());
     }
 
     /**
      * @group signature
      *
      * @test
-     * @expectedException SAML2_Signature_MissingConfigurationException
+     * @expectedException \SAML2\Signature\MissingConfigurationException
      */
     public function if_no_validators_can_validate_an_exception_is_thrown()
     {
-        $this->chain->appendValidator(new SAML2_Signature_MockChainedValidator(false, true));
-        $this->chain->appendValidator(new SAML2_Signature_MockChainedValidator(false, true));
+        $this->chain->appendValidator(new MockChainedValidator(false, true));
+        $this->chain->appendValidator(new MockChainedValidator(false, true));
 
-        $this->chain->hasValidSignature(new SAML2_Response(), new SAML2_Configuration_IdentityProvider(array()));
+        $this->chain->hasValidSignature(new Response(), new IdentityProvider(array()));
     }
 
     /**
@@ -33,13 +38,13 @@ public function if_no_validators_can_validate_an_exception_is_thrown()
      */
     public function all_registered_validators_should_be_tried()
     {
-        $this->chain->appendValidator(new SAML2_Signature_MockChainedValidator(false, true));
-        $this->chain->appendValidator(new SAML2_Signature_MockChainedValidator(false, true));
-        $this->chain->appendValidator(new SAML2_Signature_MockChainedValidator(true, false));
+        $this->chain->appendValidator(new MockChainedValidator(false, true));
+        $this->chain->appendValidator(new MockChainedValidator(false, true));
+        $this->chain->appendValidator(new MockChainedValidator(true, false));
 
         $validationResult = $this->chain->hasValidSignature(
-            new SAML2_Response(),
-            new SAML2_Configuration_IdentityProvider(array())
+            new Response(),
+            new IdentityProvider(array())
         );
         $this->assertFalse($validationResult, 'The validation result is not what is expected');
     }
@@ -51,13 +56,13 @@ public function all_registered_validators_should_be_tried()
      */
     public function it_uses_the_result_of_the_first_validator_that_can_validate()
     {
-        $this->chain->appendValidator(new SAML2_Signature_MockChainedValidator(false, true));
-        $this->chain->appendValidator(new SAML2_Signature_MockChainedValidator(true, false));
-        $this->chain->appendValidator(new SAML2_Signature_MockChainedValidator(false, true));
+        $this->chain->appendValidator(new MockChainedValidator(false, true));
+        $this->chain->appendValidator(new MockChainedValidator(true, false));
+        $this->chain->appendValidator(new MockChainedValidator(false, true));
 
         $validationResult = $this->chain->hasValidSignature(
-            new SAML2_Response(),
-            new SAML2_Configuration_IdentityProvider(array())
+            new Response(),
+            new IdentityProvider(array())
         );
         $this->assertFalse($validationResult, 'The validation result is not what is expected');
     }
diff --git a/tests/SAML2/SignedElementHelperMock.php b/tests/SAML2/SignedElementHelperMock.php
index efed758a9..806ef435a 100644
--- a/tests/SAML2/SignedElementHelperMock.php
+++ b/tests/SAML2/SignedElementHelperMock.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace SAML2;
+
 /**
- * Class SAML2_SignedElementHelperMock
+ * Class \SAML2\SignedElementHelperMock
  */
-class SAML2_SignedElementHelperMock extends SAML2_SignedElementHelper
+class SignedElementHelperMock extends SignedElementHelper
 {
     /**
      * @param DOMElement $xml
@@ -18,7 +20,7 @@ public function __construct(DOMElement $xml = NULL)
      */
     public function toSignedXML()
     {
-        $doc = SAML2_DOMDocumentFactory::create();
+        $doc = DOMDocumentFactory::create();
         $root = $doc->createElement('root');
         $doc->appendChild($root);
 
diff --git a/tests/SAML2/SignedElementHelperTest.php b/tests/SAML2/SignedElementHelperTest.php
index 8e7a3380c..6fa41f53d 100644
--- a/tests/SAML2/SignedElementHelperTest.php
+++ b/tests/SAML2/SignedElementHelperTest.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace SAML2;
+
 /**
- * Class SAML2_SignedElementHelperTest
+ * Class \SAML2\SignedElementHelperTest
  */
-class SAML2_SignedElementHelperTest extends \PHPUnit_Framework_TestCase
+class SignedElementHelperTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @var \DOMElement
@@ -15,9 +17,9 @@ class SAML2_SignedElementHelperTest extends \PHPUnit_Framework_TestCase
      */
     public function setUp()
     {
-        $mock = new SAML2_SignedElementHelperMock();
-        $mock->setSignatureKey(SAML2_CertificatesMock::getPrivateKey());
-        $mock->setCertificates(array(SAML2_CertificatesMock::PUBLIC_KEY_PEM));
+        $mock = new SignedElementHelperMock();
+        $mock->setSignatureKey(CertificatesMock::getPrivateKey());
+        $mock->setCertificates(array(CertificatesMock::PUBLIC_KEY_PEM));
         $this->signedMockElement = $mock->toSignedXML();
     }
 
@@ -29,10 +31,10 @@ public function setUp()
      */
     public function testValidateWithoutModification()
     {
-        $signedMockElementCopy = SAML2_Utils::copyElement($this->signedMockElement);
+        $signedMockElementCopy = Utils::copyElement($this->signedMockElement);
         $signedMockElementCopy->ownerDocument->appendChild($signedMockElementCopy);
-        $tmp = new SAML2_SignedElementHelperMock($signedMockElementCopy);
-        $this->assertTrue($tmp->validate(SAML2_CertificatesMock::getPublicKey()));
+        $tmp = new SignedElementHelperMock($signedMockElementCopy);
+        $this->assertTrue($tmp->validate(CertificatesMock::getPublicKey()));
     }
 
     /**
@@ -41,17 +43,17 @@ public function testValidateWithoutModification()
     public function testValidateWithReferenceTampering()
     {
         // Test modification of reference.
-        $signedMockElementCopy = SAML2_Utils::copyElement($this->signedMockElement);
+        $signedMockElementCopy = Utils::copyElement($this->signedMockElement);
         $signedMockElementCopy->ownerDocument->appendChild($signedMockElementCopy);
-        $digestValueElements = SAML2_Utils::xpQuery(
+        $digestValueElements = Utils::xpQuery(
             $signedMockElementCopy,
             '/root/ds:Signature/ds:SignedInfo/ds:Reference/ds:DigestValue'
         );
         $this->assertCount(1, $digestValueElements);
         $digestValueElements[0]->firstChild->data = 'invalid';
-        $tmp = new SAML2_SignedElementHelperMock($signedMockElementCopy);
+        $tmp = new SignedElementHelperMock($signedMockElementCopy);
         $this->assertFalse(
-            $tmp->validate(SAML2_CertificatesMock::getPublicKey()),
+            $tmp->validate(CertificatesMock::getPublicKey()),
             'When the DigestValue has been tampered with, a signature should no longer be valid'
         );
     }
@@ -62,15 +64,15 @@ public function testValidateWithReferenceTampering()
     public function testValidateWithValueTampering()
     {
         // Test modification of SignatureValue.
-        $signedMockElementCopy = SAML2_Utils::copyElement($this->signedMockElement);
+        $signedMockElementCopy = Utils::copyElement($this->signedMockElement);
         $signedMockElementCopy->ownerDocument->appendChild($signedMockElementCopy);
-        $digestValueElements = SAML2_Utils::xpQuery($signedMockElementCopy, '/root/ds:Signature/ds:SignatureValue');
+        $digestValueElements = Utils::xpQuery($signedMockElementCopy, '/root/ds:Signature/ds:SignatureValue');
         $this->assertCount(1, $digestValueElements);
         $digestValueElements[0]->firstChild->data = 'invalid';
-        $tmp = new SAML2_SignedElementHelperMock($signedMockElementCopy);
+        $tmp = new SignedElementHelperMock($signedMockElementCopy);
 
         $this->setExpectedException('Exception', 'Unable to validate Signature');
-        $tmp->validate(SAML2_CertificatesMock::getPublicKey());
+        $tmp->validate(CertificatesMock::getPublicKey());
     }
 
     /**
@@ -78,12 +80,12 @@ public function testValidateWithValueTampering()
      */
     public function testGetValidatingCertificates()
     {
-        $certData = XMLSecurityDSig::staticGet509XCerts(SAML2_CertificatesMock::PUBLIC_KEY_PEM);
+        $certData = XMLSecurityDSig::staticGet509XCerts(CertificatesMock::PUBLIC_KEY_PEM);
         $certData = $certData[0];
 
-        $signedMockElementCopy = SAML2_Utils::copyElement($this->signedMockElement);
+        $signedMockElementCopy = Utils::copyElement($this->signedMockElement);
         $signedMockElementCopy->ownerDocument->appendChild($signedMockElementCopy);
-        $tmp = new SAML2_SignedElementHelperMock($signedMockElementCopy);
+        $tmp = new SignedElementHelperMock($signedMockElementCopy);
         $certs = $tmp->getValidatingCertificates();
         $this->assertCount(1, $certs);
         $this->assertEquals($certData, $certs[0]);
@@ -106,11 +108,11 @@ public function testGetValidatingCertificates()
 r+X+X2Al/n6aDn7qAxXbl0RZuB+saxn+yFR6HFKggwkR1L2pimCuD0gTr6LlrNgf
 edF1YfJgq35hcMMLY9RE/0C0bCI=
 -----END CERTIFICATE-----';
-        $mock = new SAML2_SignedElementHelperMock();
-        $mock->setSignatureKey(SAML2_CertificatesMock::getPrivateKey());
-        $mock->setCertificates(array($tmpCert, SAML2_CertificatesMock::PUBLIC_KEY_PEM));
+        $mock = new SignedElementHelperMock();
+        $mock->setSignatureKey(CertificatesMock::getPrivateKey());
+        $mock->setCertificates(array($tmpCert, CertificatesMock::PUBLIC_KEY_PEM));
         $this->signedMockElement = $mock->toSignedXML();
-        $tmp = new SAML2_SignedElementHelperMock($this->signedMockElement);
+        $tmp = new SignedElementHelperMock($this->signedMockElement);
         $certs = $tmp->getValidatingCertificates();
         $this->assertCount(1, $certs);
         $this->assertEquals($certData, $certs[0]);
diff --git a/tests/SAML2/SimpleTestLogger.php b/tests/SAML2/SimpleTestLogger.php
index a8b83e75e..48979689b 100644
--- a/tests/SAML2/SimpleTestLogger.php
+++ b/tests/SAML2/SimpleTestLogger.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace SAML2;
+
 /**
  * A very simple in-memory logger that allows querying the log for existence of messages
  */
-class SAML2_SimpleTestLogger extends \Psr\Log\AbstractLogger
+class SimpleTestLogger extends \Psr\Log\AbstractLogger
 {
     /**
      * @var array
diff --git a/tests/SAML2/StatusResponseTest.php b/tests/SAML2/StatusResponseTest.php
index 2947417a9..800d41026 100644
--- a/tests/SAML2/StatusResponseTest.php
+++ b/tests/SAML2/StatusResponseTest.php
@@ -1,13 +1,15 @@
 <?php
 
+namespace SAML2;
+
 /**
- * Class SAML2_StatusResponseTest
+ * Class \SAML2\StatusResponseTest
  */
-class SAML2_StatusResponseTest extends PHPUnit_Framework_TestCase
+class StatusResponseTest extends PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
-        $response = new SAML2_Response();
+        $response = new Response();
         $response->setStatus(array(
             'Code' => 'OurStatusCode',
             'SubCode' => 'OurSubStatusCode',
@@ -16,18 +18,18 @@ public function testMarshalling()
 
         $responseElement = $response->toUnsignedXML();
 
-        $statusElements = SAML2_Utils::xpQuery($responseElement, './saml_protocol:Status');
+        $statusElements = Utils::xpQuery($responseElement, './saml_protocol:Status');
         $this->assertCount(1, $statusElements);
 
-        $statusCodeElements = SAML2_Utils::xpQuery($statusElements[0], './saml_protocol:StatusCode');
+        $statusCodeElements = Utils::xpQuery($statusElements[0], './saml_protocol:StatusCode');
         $this->assertCount(1, $statusCodeElements);
         $this->assertEquals('OurStatusCode', $statusCodeElements[0]->getAttribute("Value"));
 
-        $nestedStatusCodeElements = SAML2_Utils::xpQuery($statusCodeElements[0], './saml_protocol:StatusCode');
+        $nestedStatusCodeElements = Utils::xpQuery($statusCodeElements[0], './saml_protocol:StatusCode');
         $this->assertCount(1, $nestedStatusCodeElements);
         $this->assertEquals('OurSubStatusCode', $nestedStatusCodeElements[0]->getAttribute("Value"));
 
-        $statusMessageElements = SAML2_Utils::xpQuery($statusElements[0], './saml_protocol:StatusMessage');
+        $statusMessageElements = Utils::xpQuery($statusElements[0], './saml_protocol:StatusMessage');
         $this->assertCount(1, $statusMessageElements);
         $this->assertEquals('OurMessageText', $statusMessageElements[0]->textContent);
     }
diff --git a/tests/SAML2/Utilities/FileTest.php b/tests/SAML2/Utilities/FileTest.php
index 7ab9fdbb6..be04f7944 100644
--- a/tests/SAML2/Utilities/FileTest.php
+++ b/tests/SAML2/Utilities/FileTest.php
@@ -1,27 +1,29 @@
 <?php
 
-class SAML2_Utilities_FileTest extends \PHPUnit_Framework_TestCase
+namespace SAML2\Utilities;
+
+class FileTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @group utilities
      * @test
      *
-     * @expectedException SAML2_Exception_RuntimeException
+     * @expectedException \SAML2\Exception\RuntimeException
      */
     public function when_loading_a_non_existant_file_an_exception_is_thrown()
     {
-        SAML2_Utilities_File::getFileContents('/foo/bar/baz/quux');
+        File::getFileContents('/foo/bar/baz/quux');
     }
 
    /**
      * @group utilities
      * @test
      *
-     * @expectedException SAML2_Exception_InvalidArgumentException
+     * @expectedException \SAML2\Exception\InvalidArgumentException
      */
     public function passing_nonstring_filename_throws_exception()
     {
-        SAML2_Utilities_File::getFileContents(NULL);
+        File::getFileContents(NULL);
     }
 
     /**
@@ -30,7 +32,7 @@ public function passing_nonstring_filename_throws_exception()
      */
     public function an_existing_readable_file_can_be_loaded()
     {
-        $contents = SAML2_Utilities_File::getFileContents(__DIR__ . '/File/can_be_loaded.txt');
+        $contents = File::getFileContents(__DIR__ . '/File/can_be_loaded.txt');
 
         $this->assertEquals("Yes we can!\n", $contents, 'The contents of the loaded file differ from what was expected');
     }
diff --git a/tests/SAML2/UtilsTest.php b/tests/SAML2/UtilsTest.php
index 74c545382..4cc2aeb54 100644
--- a/tests/SAML2/UtilsTest.php
+++ b/tests/SAML2/UtilsTest.php
@@ -1,16 +1,18 @@
 <?php
 
+namespace SAML2;
+
 /**
- * Class SAML2_UtilsTest
+ * Class \SAML2\UtilsTest
  */
-class SAML2_UtilsTest extends PHPUnit_Framework_TestCase
+class UtilsTest extends PHPUnit_Framework_TestCase
 {
     /**
      * Test querying a SAML XML document.
      */
     public function testXpQuery()
     {
-        $aq = new SAML2_AttributeQuery();
+        $aq = new AttributeQuery();
         $aq->setNameID(array(
             'Value' => 'NameIDValue',
             'Format' => 'SomeNameIDFormat',
@@ -20,7 +22,7 @@ public function testXpQuery()
 
         $xml = $aq->toUnsignedXML();
 
-        $nameID = SAML2_Utils::xpQuery($xml, './saml_assertion:Subject/saml_assertion:NameID');
+        $nameID = Utils::xpQuery($xml, './saml_assertion:Subject/saml_assertion:NameID');
         $this->assertTrue(count($nameID) === 1);
         $this->assertEquals('SomeNameIDFormat', $nameID[0]->getAttribute("Format"));
         $this->assertEquals('OurNameQualifier', $nameID[0]->getAttribute("NameQualifier"));
@@ -33,9 +35,9 @@ public function testXpQuery()
      */
     public function testAddString()
     {
-        $document = SAML2_DOMDocumentFactory::fromString('<root/>');
+        $document = DOMDocumentFactory::fromString('<root/>');
 
-        SAML2_Utils::addString(
+        Utils::addString(
             $document->firstChild,
             'testns',
             'ns:somenode',
@@ -47,7 +49,7 @@ public function testAddString()
         );
 
         $document->loadXML('<ns:root xmlns:ns="testns"/>');
-        SAML2_Utils::addString(
+        Utils::addString(
             $document->firstChild,
             'testns',
             'ns:somenode',
@@ -64,8 +66,8 @@ public function testAddString()
      */
     public function testGetAddStrings()
     {
-        $document = SAML2_DOMDocumentFactory::fromString('<root/>');
-        SAML2_Utils::addStrings(
+        $document = DOMDocumentFactory::fromString('<root/>');
+        Utils::addStrings(
             $document->firstChild,
             'testns',
             'ns:somenode',
@@ -81,7 +83,7 @@ public function testGetAddStrings()
         );
 
         $document->loadXML('<ns:root xmlns:ns="testns"/>');
-        SAML2_Utils::addStrings(
+        Utils::addStrings(
             $document->firstChild,
             'testns',
             'ns:somenode',
@@ -97,7 +99,7 @@ public function testGetAddStrings()
         );
 
         $document->loadXML('<root/>');
-        SAML2_Utils::addStrings(
+        Utils::addStrings(
             $document->firstChild,
             'testns',
             'ns:somenode',
@@ -113,7 +115,7 @@ public function testGetAddStrings()
         );
 
         $document->loadXML('<ns:root xmlns:ns="testns"/>');
-        SAML2_Utils::addStrings(
+        Utils::addStrings(
             $document->firstChild,
             'testns',
             'ns:somenode',
@@ -134,16 +136,16 @@ public function testGetAddStrings()
      */
     public function testExtractString()
     {
-        $document = SAML2_DOMDocumentFactory::fromString(
-            '<root xmlns="' . SAML2_Constants::NS_MD . '">'.
+        $document = DOMDocumentFactory::fromString(
+            '<root xmlns="' . Constants::NS_MD . '">'.
             '<somenode>value1</somenode>'.
             '<somenode>value2</somenode>'.
             '</root>'
         );
 
-        $stringValues = SAML2_Utils::extractStrings(
+        $stringValues = Utils::extractStrings(
             $document->firstChild,
-            SAML2_Constants::NS_MD,
+            Constants::NS_MD,
             'somenode'
         );
 
@@ -157,16 +159,16 @@ public function testExtractString()
      */
     public function testExtractLocalizedString()
     {
-        $document = SAML2_DOMDocumentFactory::fromString(
-            '<root xmlns="' . SAML2_Constants::NS_MD . '">'.
+        $document = DOMDocumentFactory::fromString(
+            '<root xmlns="' . Constants::NS_MD . '">'.
             '<somenode xml:lang="en">value (en)</somenode>'.
             '<somenode xml:lang="no">value (no)</somenode>'.
             '</root>'
         );
 
-        $localizedStringValues = SAML2_Utils::extractLocalizedStrings(
+        $localizedStringValues = Utils::extractLocalizedStrings(
             $document->firstChild,
-            SAML2_Constants::NS_MD,
+            Constants::NS_MD,
             'somenode'
         );
 
@@ -183,7 +185,7 @@ public function testExtractLocalizedString()
     public function testXsDateTimeToTimestamp($shouldPass, $time, $expectedTs = null)
     {
         try {
-            $ts = SAML2_Utils::xsDateTimeToTimestamp($time);
+            $ts = Utils::xsDateTimeToTimestamp($time);
             $this->assertTrue($shouldPass);
             $this->assertEquals($expectedTs, $ts);
         } catch (Exception $e) {
diff --git a/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php b/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
index 255797993..6615a5655 100644
--- a/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
+++ b/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
@@ -1,20 +1,26 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\DOMDocumentFactory;
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
- * Class SAML2_XML_md_AdditionalMetadataLocationTest
+ * Class \SAML2\XML\md\AdditionalMetadataLocationTest
  */
-class SAML2_XML_md_AdditionalMetadataLocationTest extends PHPUnit_Framework_TestCase
+class AdditionalMetadataLocationTest extends PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
-        $document = SAML2_DOMDocumentFactory::fromString('<root/>');
+        $document = DOMDocumentFactory::fromString('<root/>');
 
-        $additionalMetadataLocation = new SAML2_XML_md_AdditionalMetadataLocation();
+        $additionalMetadataLocation = new AdditionalMetadataLocation();
         $additionalMetadataLocation->namespace = 'NamespaceAttribute';
         $additionalMetadataLocation->location = 'TheLocation';
         $additionalMetadataLocationElement = $additionalMetadataLocation->toXML($document->firstChild);
 
-        $additionalMetadataLocationElements = SAML2_Utils::xpQuery(
+        $additionalMetadataLocationElements = Utils::xpQuery(
             $additionalMetadataLocationElement,
             '/root/saml_metadata:AdditionalMetadataLocation'
         );
@@ -27,19 +33,19 @@ public function testMarshalling()
 
     public function testUnmarshalling()
     {
-        $document = SAML2_DOMDocumentFactory::fromString(
-            '<md:AdditionalMetadataLocation xmlns:md="' . SAML2_Constants::NS_MD . '"'.
+        $document = DOMDocumentFactory::fromString(
+            '<md:AdditionalMetadataLocation xmlns:md="' . Constants::NS_MD . '"'.
             ' namespace="TheNamespaceAttribute">LocationText</md:AdditionalMetadataLocation>'
         );
-        $additionalMetadataLocation = new SAML2_XML_md_AdditionalMetadataLocation($document->firstChild);
+        $additionalMetadataLocation = new AdditionalMetadataLocation($document->firstChild);
         $this->assertEquals('TheNamespaceAttribute', $additionalMetadataLocation->namespace);
         $this->assertEquals('LocationText', $additionalMetadataLocation->location);
 
         $document->loadXML(
-            '<md:AdditionalMetadataLocation xmlns:md="' . SAML2_Constants::NS_MD . '"'.
+            '<md:AdditionalMetadataLocation xmlns:md="' . Constants::NS_MD . '"'.
             '>LocationText</md:AdditionalMetadataLocation>'
         );
         $this->setExpectedException('Exception', 'Missing namespace attribute on AdditionalMetadataLocation element.');
-        new SAML2_XML_md_AdditionalMetadataLocation($document->firstChild);
+        new AdditionalMetadataLocation($document->firstChild);
     }
 }
diff --git a/tests/SAML2/XML/md/AffiliationDescriptorTest.php b/tests/SAML2/XML/md/AffiliationDescriptorTest.php
index 73bcad0c2..1a58c3f39 100644
--- a/tests/SAML2/XML/md/AffiliationDescriptorTest.php
+++ b/tests/SAML2/XML/md/AffiliationDescriptorTest.php
@@ -1,12 +1,18 @@
 <?php
 
-class SAML2_XML_md_AffiliationDescriptorTest extends PHPUnit_Framework_TestCase
+namespace SAML2\XML\md;
+
+use SAML2\DOMDocumentFactory;
+use SAML2\Utils;
+use SAML2\Constants;
+
+class AffiliationDescriptorTest extends PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
-        $document = SAML2_DOMDocumentFactory::fromString('<root />');
+        $document = DOMDocumentFactory::fromString('<root />');
 
-        $affiliationDescriptorElement = new SAML2_XML_md_AffiliationDescriptor();
+        $affiliationDescriptorElement = new AffiliationDescriptor();
         $affiliationDescriptorElement->affiliationOwnerID = 'TheOwner';
         $affiliationDescriptorElement->ID = 'TheID';
         $affiliationDescriptorElement->validUntil = 1234567890;
@@ -18,7 +24,7 @@ public function testMarshalling()
 
         $affiliationDescriptorElement = $affiliationDescriptorElement->toXML($document->firstChild);
 
-        $affiliationDescriptorElements = SAML2_Utils::xpQuery(
+        $affiliationDescriptorElements = Utils::xpQuery(
             $affiliationDescriptorElement,
             '/root/saml_metadata:AffiliationDescriptor'
         );
@@ -30,7 +36,7 @@ public function testMarshalling()
         $this->assertEquals('2009-02-13T23:31:30Z', $affiliationDescriptorElement->getAttribute("validUntil"));
         $this->assertEquals('PT5000S', $affiliationDescriptorElement->getAttribute("cacheDuration"));
 
-        $affiliateMembers = SAML2_Utils::xpQuery($affiliationDescriptorElement, './saml_metadata:AffiliateMember');
+        $affiliateMembers = Utils::xpQuery($affiliationDescriptorElement, './saml_metadata:AffiliateMember');
         $this->assertCount(2, $affiliateMembers);
         $this->assertEquals('Member1', $affiliateMembers[0]->textContent);
         $this->assertEquals('Member2', $affiliateMembers[1]->textContent);
@@ -38,8 +44,8 @@ public function testMarshalling()
 
     public function testUnmarshalling()
     {
-        $mdNamespace = SAML2_Constants::NS_MD;
-        $document = SAML2_DOMDocumentFactory::fromString(<<<XML
+        $mdNamespace = Constants::NS_MD;
+        $document = DOMDocumentFactory::fromString(<<<XML
 <md:AffiliationDescriptor xmlns:md="{$mdNamespace}" affiliationOwnerID="TheOwner" ID="TheID" validUntil="2009-02-13T23:31:30Z" cacheDuration="PT5000S">
     <md:AffiliateMember>Member</md:AffiliateMember>
     <md:AffiliateMember>OtherMember</md:AffiliateMember>
@@ -47,7 +53,7 @@ public function testUnmarshalling()
 XML
         );
 
-        $affiliateDescriptor = new SAML2_XML_md_AffiliationDescriptor($document->firstChild);
+        $affiliateDescriptor = new AffiliationDescriptor($document->firstChild);
         $this->assertEquals('TheOwner', $affiliateDescriptor->affiliationOwnerID);
         $this->assertEquals('TheID', $affiliateDescriptor->ID);
         $this->assertEquals(1234567890, $affiliateDescriptor->validUntil);
@@ -59,21 +65,21 @@ public function testUnmarshalling()
 
     public function testUnmarshallingWithoutMembers()
     {
-        $mdNamespace = SAML2_Constants::NS_MD;
-        $document = SAML2_DOMDocumentFactory::fromString(
+        $mdNamespace = Constants::NS_MD;
+        $document = DOMDocumentFactory::fromString(
 <<<XML
 <md:AffiliationDescriptor xmlns:md="{$mdNamespace}" affiliationOwnerID="TheOwner" ID="TheID" validUntil="2009-02-13T23:31:30Z" cacheDuration="PT5000S">
 </md:AffiliationDescriptor>
 XML
         );
         $this->setExpectedException('Exception', 'Missing AffiliateMember in AffiliationDescriptor.');
-        new SAML2_XML_md_AffiliationDescriptor($document->firstChild);
+        new AffiliationDescriptor($document->firstChild);
     }
 
     public function testUnmarshallingWithoutOwner()
     {
-        $mdNamespace = SAML2_Constants::NS_MD;
-        $document = SAML2_DOMDocumentFactory::fromString(
+        $mdNamespace = Constants::NS_MD;
+        $document = DOMDocumentFactory::fromString(
             <<<XML
     <md:AffiliationDescriptor xmlns:md="{$mdNamespace}" ID="TheID" validUntil="2009-02-13T23:31:30Z" cacheDuration="PT5000S">
     <md:AffiliateMember>Member</md:AffiliateMember>
@@ -83,7 +89,7 @@ public function testUnmarshallingWithoutOwner()
         );
 
         $this->setExpectedException('Exception', 'Missing affiliationOwnerID on AffiliationDescriptor.');
-        new SAML2_XML_md_AffiliationDescriptor($document->firstChild);
+        new AffiliationDescriptor($document->firstChild);
     }
 
 
diff --git a/tests/SAML2/XML/md/EndpointTypeTest.php b/tests/SAML2/XML/md/EndpointTypeTest.php
index 209e0421c..4af9e7e35 100644
--- a/tests/SAML2/XML/md/EndpointTypeTest.php
+++ b/tests/SAML2/XML/md/EndpointTypeTest.php
@@ -1,20 +1,26 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\DOMDocumentFactory;
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
- * Class SAML2_XML_md_EndpointType
+ * Class \SAML2\XML\md\EndpointType
  */
-class SAML2_XML_md_EndpointTypeTest extends PHPUnit_Framework_TestCase
+class EndpointTypeTest extends PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
-        $endpointType = new SAML2_XML_md_EndpointType();
+        $endpointType = new EndpointType();
         $endpointType->Binding = 'TestBinding';
         $endpointType->Location = 'TestLocation';
 
-        $document = SAML2_DOMDocumentFactory::fromString('<root />');
+        $document = DOMDocumentFactory::fromString('<root />');
         $endpointTypeElement = $endpointType->toXML($document->firstChild, 'md:Test');
 
-        $endpointTypeElements = SAML2_Utils::xpQuery($endpointTypeElement, '/root/saml_metadata:Test');
+        $endpointTypeElements = Utils::xpQuery($endpointTypeElement, '/root/saml_metadata:Test');
         $this->assertCount(1, $endpointTypeElements);
         $endpointTypeElement = $endpointTypeElements[0];
 
@@ -27,7 +33,7 @@ public function testMarshalling()
         $document->loadXML('<root />');
         $endpointTypeElement = $endpointType->toXML($document->firstChild, 'md:Test');
 
-        $endpointTypeElement = SAML2_Utils::xpQuery($endpointTypeElement, '/root/saml_metadata:Test');
+        $endpointTypeElement = Utils::xpQuery($endpointTypeElement, '/root/saml_metadata:Test');
         $this->assertCount(1, $endpointTypeElement);
         $endpointTypeElement = $endpointTypeElement[0];
 
@@ -36,13 +42,13 @@ public function testMarshalling()
 
     public function testUnmarshalling()
     {
-        $mdNamespace = SAML2_Constants::NS_MD;
-        $document = SAML2_DOMDocumentFactory::fromString(
+        $mdNamespace = Constants::NS_MD;
+        $document = DOMDocumentFactory::fromString(
 <<<XML
 <md:Test xmlns:md="{$mdNamespace}" Binding="urn:something" Location="https://whatever/" xmlns:test="urn:test" test:attr="value" />
 XML
         );
-        $endpointType = new SAML2_XML_md_EndpointType($document->firstChild);
+        $endpointType = new EndpointType($document->firstChild);
         $this->assertEquals(TRUE, $endpointType->hasAttributeNS('urn:test', 'attr'));
         $this->assertEquals('value', $endpointType->getAttributeNS('urn:test', 'attr'));
         $this->assertEquals(FALSE, $endpointType->hasAttributeNS('urn:test', 'invalid'));
@@ -57,7 +63,7 @@ public function testUnmarshalling()
 
         $document->loadXML('<root />');
         $endpointTypeElement = $endpointType->toXML($document->firstChild, 'md:Test');
-        $endpointTypeElements = SAML2_Utils::xpQuery($endpointTypeElement, '/root/saml_metadata:Test');
+        $endpointTypeElements = Utils::xpQuery($endpointTypeElement, '/root/saml_metadata:Test');
         $this->assertCount(1, $endpointTypeElements);
         $endpointTypeElement = $endpointTypeElements[0];
 
diff --git a/tests/SAML2/XML/md/EntityDescriptorTest.php b/tests/SAML2/XML/md/EntityDescriptorTest.php
index 41715a13a..7d86e09eb 100755
--- a/tests/SAML2/XML/md/EntityDescriptorTest.php
+++ b/tests/SAML2/XML/md/EntityDescriptorTest.php
@@ -1,13 +1,17 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\DOMDocumentFactory;
+
 /**
- * Class SAML2_XML_md_EntityDescriptorTest
+ * Class \SAML2\XML\md\EntityDescriptorTest
  */
-class SAML2_XML_md_EntityDescriptorTest extends \PHPUnit_Framework_TestCase
+class EntityDescriptorTest extends \PHPUnit_Framework_TestCase
 {
     public function testMissingAffiliationId()
     {
-        $document = SAML2_DOMDocumentFactory::fromString(
+        $document = DOMDocumentFactory::fromString(
         <<<XML
 <EntityDescriptor entityID="theEntityID" xmlns="urn:oasis:names:tc:SAML:2.0:metadata">
     <AffiliationDescriptor>
@@ -17,12 +21,12 @@ public function testMissingAffiliationId()
 XML
         );
         $this->setExpectedException('Exception', 'Missing affiliationOwnerID on AffiliationDescriptor.');
-        new SAML2_XML_md_EntityDescriptor($document->firstChild);
+        new EntityDescriptor($document->firstChild);
     }
 
     public function testMissingEntityId()
     {
-        $document = SAML2_DOMDocumentFactory::fromString(
+        $document = DOMDocumentFactory::fromString(
         <<<XML
 <EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata">
     <AffiliationDescriptor affiliationOwnerID="asdf">
@@ -32,12 +36,12 @@ public function testMissingEntityId()
 XML
         );
         $this->setExpectedException('Exception', 'Missing required attribute entityID on EntityDescriptor.');
-        new SAML2_XML_md_EntityDescriptor($document->firstChild);
+        new EntityDescriptor($document->firstChild);
     }
 
     public function testMissingAffiliateMember()
     {
-        $document = SAML2_DOMDocumentFactory::fromString(
+        $document = DOMDocumentFactory::fromString(
         <<<XML
 <EntityDescriptor entityID="theEntityID" xmlns="urn:oasis:names:tc:SAML:2.0:metadata">
     <AffiliationDescriptor affiliationOwnerID="asdf">
@@ -46,24 +50,24 @@ public function testMissingAffiliateMember()
 XML
         );
         $this->setExpectedException('Exception', 'Missing AffiliateMember in AffiliationDescriptor.');
-        new SAML2_XML_md_EntityDescriptor($document->firstChild);
+        new EntityDescriptor($document->firstChild);
     }
 
     public function testMissingDescriptor()
     {
-        $document = SAML2_DOMDocumentFactory::fromString(
+        $document = DOMDocumentFactory::fromString(
         <<<XML
 <EntityDescriptor entityID="theEntityID" xmlns="urn:oasis:names:tc:SAML:2.0:metadata">
 </EntityDescriptor>
 XML
         );
         $this->setExpectedException('Exception', 'Must have either one of the RoleDescriptors or an AffiliationDescriptor in EntityDescriptor.');
-        new SAML2_XML_md_EntityDescriptor($document->firstChild);
+        new EntityDescriptor($document->firstChild);
     }
 
     public function testInvalidValidUntil()
     {
-        $document = SAML2_DOMDocumentFactory::fromString(
+        $document = DOMDocumentFactory::fromString(
         <<<XML
 <EntityDescriptor validUntil="asdf" entityID="theEntityID" xmlns="urn:oasis:names:tc:SAML:2.0:metadata">
     <AffiliationDescriptor affiliationOwnerID="asd">
@@ -73,12 +77,12 @@ public function testInvalidValidUntil()
 XML
         );
         $this->setExpectedException('Exception', 'Invalid SAML2 timestamp passed to xsDateTimeToTimestamp: asdf');
-        new SAML2_XML_md_EntityDescriptor($document->firstChild);
+        new EntityDescriptor($document->firstChild);
     }
 
     public function testUnmarshalling()
     {
-        $document = SAML2_DOMDocumentFactory::fromString(
+        $document = DOMDocumentFactory::fromString(
         <<<XML
 <EntityDescriptor entityID="theEntityID" xmlns="urn:oasis:names:tc:SAML:2.0:metadata">
     <AffiliationDescriptor affiliationOwnerID="asdf" ID="theAffiliationDescriptorID" validUntil="2010-02-01T12:34:56Z" cacheDuration="PT9000S" >
@@ -88,15 +92,15 @@ public function testUnmarshalling()
 </EntityDescriptor>
 XML
         );
-        $entityDescriptor = new SAML2_XML_md_EntityDescriptor($document->firstChild);
+        $entityDescriptor = new EntityDescriptor($document->firstChild);
 
-        $this->assertTrue($entityDescriptor instanceof SAML2_XML_md_EntityDescriptor);
+        $this->assertTrue($entityDescriptor instanceof EntityDescriptor);
         $this->assertEquals('theEntityID', $entityDescriptor->entityID);
 
         $this->assertTrue(empty($entityDescriptor->RoleDescriptor));
 
         $affiliationDescriptor = $entityDescriptor->AffiliationDescriptor;
-        $this->assertTrue($affiliationDescriptor instanceof SAML2_XML_md_AffiliationDescriptor);
+        $this->assertTrue($affiliationDescriptor instanceof AffiliationDescriptor);
         $this->assertEquals('asdf', $affiliationDescriptor->affiliationOwnerID);
         $this->assertEquals('theAffiliationDescriptorID', $affiliationDescriptor->ID);
         $this->assertEquals(1265027696, $affiliationDescriptor->validUntil);
@@ -108,7 +112,7 @@ public function testUnmarshalling()
 
     public function testUnmarshalling2()
     {
-        $document = SAML2_DOMDocumentFactory::fromString(<<<XML
+        $document = DOMDocumentFactory::fromString(<<<XML
 <EntityDescriptor entityID="theEntityID" ID="theID" validUntil="2010-01-01T12:34:56Z" cacheDuration="PT5000S" xmlns="urn:oasis:names:tc:SAML:2.0:metadata">
 
     <AttributeAuthorityDescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
@@ -126,19 +130,19 @@ public function testUnmarshalling2()
 </EntityDescriptor>
 XML
         );
-        $entityDescriptor = new SAML2_XML_md_EntityDescriptor($document->firstChild);
+        $entityDescriptor = new EntityDescriptor($document->firstChild);
 
-        $this->assertTrue($entityDescriptor instanceof SAML2_XML_md_EntityDescriptor);
+        $this->assertTrue($entityDescriptor instanceof EntityDescriptor);
         $this->assertEquals('theEntityID', $entityDescriptor->entityID);
         $this->assertEquals('theID', $entityDescriptor->ID);
         $this->assertEquals(1262349296, $entityDescriptor->validUntil);
         $this->assertEquals('PT5000S', $entityDescriptor->cacheDuration);
 
         $this->assertCount(1, $entityDescriptor->RoleDescriptor);
-        $this->assertTrue($entityDescriptor->RoleDescriptor[0] instanceof SAML2_XML_md_AttributeAuthorityDescriptor);
+        $this->assertTrue($entityDescriptor->RoleDescriptor[0] instanceof AttributeAuthorityDescriptor);
 
         $o = $entityDescriptor->Organization;
-        $this->assertTrue($o instanceof SAML2_XML_md_Organization);
+        $this->assertTrue($o instanceof Organization);
         $this->assertCount(2, $o->OrganizationName);
         $this->assertEquals('orgNameTest (no)', $o->OrganizationName["no"]);
         $this->assertEquals('orgNameTest (en)', $o->OrganizationName["en"]);
diff --git a/tests/SAML2/XML/md/IndexedEndpointTypeTest.php b/tests/SAML2/XML/md/IndexedEndpointTypeTest.php
index 79141a8ce..1f3404dbe 100644
--- a/tests/SAML2/XML/md/IndexedEndpointTypeTest.php
+++ b/tests/SAML2/XML/md/IndexedEndpointTypeTest.php
@@ -1,22 +1,27 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\DOMDocumentFactory;
+use SAML2\Utils;
+
 /**
- * Class SAML2_XML_md_IndexedEndpointTypeTest
+ * Class \SAML2\XML\md\IndexedEndpointTypeTest
  */
-class SAML2_XML_md_IndexedEndpointTypeTest extends \PHPUnit_Framework_TestCase
+class IndexedEndpointTypeTest extends \PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
-        $indexedEndpointType = new SAML2_XML_md_IndexedEndpointType();
+        $indexedEndpointType = new IndexedEndpointType();
         $indexedEndpointType->Binding = 'TestBinding';
         $indexedEndpointType->Location = 'TestLocation';
         $indexedEndpointType->index = 42;
         $indexedEndpointType->isDefault = FALSE;
 
-        $document = SAML2_DOMDocumentFactory::fromString('<root />');
+        $document = DOMDocumentFactory::fromString('<root />');
         $indexedEndpointTypeElement = $indexedEndpointType->toXML($document->firstChild, 'md:Test');
 
-        $indexedEndpointElements = SAML2_Utils::xpQuery($indexedEndpointTypeElement, '/root/saml_metadata:Test');
+        $indexedEndpointElements = Utils::xpQuery($indexedEndpointTypeElement, '/root/saml_metadata:Test');
         $this->assertCount(1, $indexedEndpointElements);
         $indexedEndpointElement = $indexedEndpointElements[0];
 
@@ -28,14 +33,14 @@ public function testMarshalling()
         $indexedEndpointType->isDefault = TRUE;
         $document->loadXML('<root />');
         $indexedEndpointTypeElement = $indexedEndpointType->toXML($document->firstChild, 'md:Test');
-        $indexedEndpointTypeElement = SAML2_Utils::xpQuery($indexedEndpointTypeElement, '/root/saml_metadata:Test');
+        $indexedEndpointTypeElement = Utils::xpQuery($indexedEndpointTypeElement, '/root/saml_metadata:Test');
         $this->assertCount(1, $indexedEndpointTypeElement);
         $this->assertEquals('true', $indexedEndpointTypeElement[0]->getAttribute('isDefault'));
 
         $indexedEndpointType->isDefault = NULL;
         $document->loadXML('<root />');
         $indexedEndpointTypeElement = $indexedEndpointType->toXML($document->firstChild, 'md:Test');
-        $indexedEndpointTypeElement = SAML2_Utils::xpQuery($indexedEndpointTypeElement, '/root/saml_metadata:Test');
+        $indexedEndpointTypeElement = Utils::xpQuery($indexedEndpointTypeElement, '/root/saml_metadata:Test');
         $this->assertCount(1, $indexedEndpointTypeElement);
         $this->assertTrue(!$indexedEndpointTypeElement[0]->hasAttribute('isDefault'));
     }
diff --git a/tests/SAML2/XML/md/RoleDescriptorMock.php b/tests/SAML2/XML/md/RoleDescriptorMock.php
index f0e66e21b..bf3ac40b3 100644
--- a/tests/SAML2/XML/md/RoleDescriptorMock.php
+++ b/tests/SAML2/XML/md/RoleDescriptorMock.php
@@ -1,14 +1,18 @@
 <?php
 
+namespace SAML2\XML\md;
 
-class SAML2_XML_md_RoleDescriptorMock extends SAML2_XML_md_RoleDescriptor {
+use SAML2\Constants;
+
+
+class RoleDescriptorMock extends RoleDescriptor {
     public function __construct(DOMElement $xml = NULL) {
         parent::__construct('md:RoleDescriptor', $xml);
     }
 
     public function toXML(DOMElement $parent) {
         $xml = parent::toXML($parent);
-        $xml->setAttributeNS(SAML2_Constants::NS_XSI, 'xsi:type', 'myns:MyElement');
+        $xml->setAttributeNS(Constants::NS_XSI, 'xsi:type', 'myns:MyElement');
         $xml->setAttributeNS('http://example.org/mynsdefinition', 'myns:tmp', 'tmp');
         $xml->removeAttributeNS('http://example.org/mynsdefinition', 'tmp');
         return $xml;
diff --git a/tests/SAML2/XML/md/RoleDescriptorTest.php b/tests/SAML2/XML/md/RoleDescriptorTest.php
index ff4153fdd..c201c7a5c 100644
--- a/tests/SAML2/XML/md/RoleDescriptorTest.php
+++ b/tests/SAML2/XML/md/RoleDescriptorTest.php
@@ -1,12 +1,18 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\DOMDocumentFactory;
+use SAML2\Utils;
+use SAML2\Constants;
+
 require 'RoleDescriptorMock.php';
 
-class SAML2_XML_md_RoleDescriptorTest extends \PHPUnit_Framework_TestCase
+class RoleDescriptorTest extends \PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
-        $roleDescriptor = new SAML2_XML_md_RoleDescriptorMock();
+        $roleDescriptor = new RoleDescriptorMock();
         $roleDescriptor->ID = 'SomeID';
         $roleDescriptor->validUntil = 1234567890;
         $roleDescriptor->cacheDuration = 'PT5000S';
@@ -16,10 +22,10 @@ public function testMarshalling()
         );
         $roleDescriptor->errorURL = 'https://example.org/error';
 
-        $document = SAML2_DOMDocumentFactory::fromString('<root />');
+        $document = DOMDocumentFactory::fromString('<root />');
         $roleDescriptorElement = $roleDescriptor->toXML($document->firstChild);
 
-        $roleDescriptorElement = SAML2_Utils::xpQuery($roleDescriptorElement, '/root/md:RoleDescriptor');
+        $roleDescriptorElement = Utils::xpQuery($roleDescriptorElement, '/root/md:RoleDescriptor');
         $this->assertCount(1, $roleDescriptorElement);
         $roleDescriptorElement = $roleDescriptorElement[0];
 
@@ -27,7 +33,7 @@ public function testMarshalling()
         $this->assertEquals('2009-02-13T23:31:30Z', $roleDescriptorElement->getAttribute("validUntil"));
         $this->assertEquals('PT5000S', $roleDescriptorElement->getAttribute("cacheDuration"));
         $this->assertEquals('protocol1 protocol2', $roleDescriptorElement->getAttribute("protocolSupportEnumeration"));
-        $this->assertEquals('myns:MyElement', $roleDescriptorElement->getAttributeNS(SAML2_Constants::NS_XSI, "type"));
+        $this->assertEquals('myns:MyElement', $roleDescriptorElement->getAttributeNS(Constants::NS_XSI, "type"));
         $this->assertEquals('http://example.org/mynsdefinition', $roleDescriptorElement->lookupNamespaceURI("myns"));
     }
 }
diff --git a/tests/SAML2/XML/mdrpi/PublicationInfoTest.php b/tests/SAML2/XML/mdrpi/PublicationInfoTest.php
index 5044abd5b..d58c83c67 100644
--- a/tests/SAML2/XML/mdrpi/PublicationInfoTest.php
+++ b/tests/SAML2/XML/mdrpi/PublicationInfoTest.php
@@ -1,13 +1,18 @@
 <?php
 
+namespace SAML2\XML\mdrpi;
+
+use SAML2\DOMDocumentFactory;
+use SAML2\Utils;
+
 /**
- * Class SAML2_XML_mdrpi_PublicationInfoTest
+ * Class \SAML2\XML\mdrpi\PublicationInfoTest
  */
-class SAML2_XML_mdrpi_PublicationInfoTest extends \PHPUnit_Framework_TestCase
+class PublicationInfoTest extends \PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
-        $publicationInfo = new SAML2_XML_mdrpi_PublicationInfo();
+        $publicationInfo = new PublicationInfo();
         $publicationInfo->publisher = 'TestPublisher';
         $publicationInfo->creationInstant = 1234567890;
         $publicationInfo->publicationId = 'PublicationIdValue';
@@ -16,10 +21,10 @@ public function testMarshalling()
             'no' => 'http://NorwegianUsagePolicy',
         );
 
-        $document = SAML2_DOMDocumentFactory::fromString('<root />');
+        $document = DOMDocumentFactory::fromString('<root />');
         $xml = $publicationInfo->toXML($document->firstChild);
 
-        $publicationInfoElements = SAML2_Utils::xpQuery(
+        $publicationInfoElements = Utils::xpQuery(
             $xml,
             '/root/*[local-name()=\'PublicationInfo\' and namespace-uri()=\'urn:oasis:names:tc:SAML:metadata:rpi\']'
         );
@@ -30,7 +35,7 @@ public function testMarshalling()
         $this->assertEquals('2009-02-13T23:31:30Z', $publicationInfoElement->getAttribute("creationInstant"));
         $this->assertEquals('PublicationIdValue', $publicationInfoElement->getAttribute("publicationId"));
 
-        $usagePolicyElements = SAML2_Utils::xpQuery(
+        $usagePolicyElements = Utils::xpQuery(
             $publicationInfoElement,
             './*[local-name()=\'UsagePolicy\' and namespace-uri()=\'urn:oasis:names:tc:SAML:metadata:rpi\']'
         );
@@ -44,7 +49,7 @@ public function testMarshalling()
 
     public function testUnmarshalling()
     {
-        $document = SAML2_DOMDocumentFactory::fromString(<<<XML
+        $document = DOMDocumentFactory::fromString(<<<XML
 <mdrpi:PublicationInfo xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi"
                        publisher="SomePublisher"
                        creationInstant="2011-01-01T00:00:00Z"
@@ -55,7 +60,7 @@ public function testUnmarshalling()
 XML
         );
 
-        $publicationInfo = new SAML2_XML_mdrpi_PublicationInfo($document->firstChild);
+        $publicationInfo = new PublicationInfo($document->firstChild);
 
         $this->assertEquals('SomePublisher', $publicationInfo->publisher);
         $this->assertEquals(1293840000, $publicationInfo->creationInstant);
diff --git a/tests/SAML2/XML/saml/AttributeTest.php b/tests/SAML2/XML/saml/AttributeTest.php
index f1cf2eaad..17378e60d 100644
--- a/tests/SAML2/XML/saml/AttributeTest.php
+++ b/tests/SAML2/XML/saml/AttributeTest.php
@@ -1,25 +1,33 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\XML\saml\Attribute;
+use SAML2\XML\saml\AttributeValue;
+use SAML2\DOMDocumentFactory;
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
- * Class SAML2_XML_md_AttributeTest
+ * Class \SAML2\XML\md\AttributeTest
  */
-class SAML2_XML_md_AttributeTest extends \PHPUnit_Framework_TestCase
+class AttributeTest extends \PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
-        $attribute = new SAML2_XML_saml_Attribute();
+        $attribute = new Attribute();
         $attribute->Name = 'TheName';
         $attribute->NameFormat = 'TheNameFormat';
         $attribute->FriendlyName = 'TheFriendlyName';
         $attribute->AttributeValue = array(
-            new SAML2_XML_saml_AttributeValue('FirstValue'),
-            new SAML2_XML_saml_AttributeValue('SecondValue'),
+            new AttributeValue('FirstValue'),
+            new AttributeValue('SecondValue'),
         );
 
-        $document = SAML2_DOMDocumentFactory::fromString('<root />');
+        $document = DOMDocumentFactory::fromString('<root />');
         $attributeElement = $attribute->toXML($document->firstChild);
 
-        $attributeElements = SAML2_Utils::xpQuery($attributeElement, '/root/saml_assertion:Attribute');
+        $attributeElements = Utils::xpQuery($attributeElement, '/root/saml_assertion:Attribute');
         $this->assertCount(1, $attributeElements);
         $attributeElement = $attributeElements[0];
 
@@ -30,8 +38,8 @@ public function testMarshalling()
 
     public function testUnmarshalling()
     {
-        $samlNamespace = SAML2_Constants::NS_SAML;
-        $document = SAML2_DOMDocumentFactory::fromString(<<<XML
+        $samlNamespace = Constants::NS_SAML;
+        $document = DOMDocumentFactory::fromString(<<<XML
 <saml:Attribute xmlns:saml="{$samlNamespace}" Name="TheName" NameFormat="TheNameFormat" FriendlyName="TheFriendlyName">
     <saml:AttributeValue>FirstValue</saml:AttributeValue>
     <saml:AttributeValue>SecondValue</saml:AttributeValue>
@@ -39,7 +47,7 @@ public function testUnmarshalling()
 XML
         );
 
-        $attribute = new SAML2_XML_saml_Attribute($document->firstChild);
+        $attribute = new Attribute($document->firstChild);
         $this->assertEquals('TheName', $attribute->Name);
         $this->assertEquals('TheNameFormat', $attribute->NameFormat);
         $this->assertEquals('TheFriendlyName', $attribute->FriendlyName);
@@ -51,8 +59,8 @@ public function testUnmarshalling()
 
     public function testUnmarshallingFailure()
     {
-        $samlNamespace = SAML2_Constants::NS_SAML;
-        $document = SAML2_DOMDocumentFactory::fromString(<<<XML
+        $samlNamespace = Constants::NS_SAML;
+        $document = DOMDocumentFactory::fromString(<<<XML
 <saml:Attribute xmlns:saml="{$samlNamespace}" NameFormat="TheNameFormat" FriendlyName="TheFriendlyName">
     <saml:AttributeValue>FirstValue</saml:AttributeValue>
     <saml:AttributeValue>SecondValue</saml:AttributeValue>
@@ -60,6 +68,6 @@ public function testUnmarshallingFailure()
 XML
         );
         $this->setExpectedException('Exception', 'Missing Name on Attribute.');
-        new SAML2_XML_saml_Attribute($document->firstChild);
+        new Attribute($document->firstChild);
     }
 }
diff --git a/tests/SAML2/XML/saml/NameIDTest.php b/tests/SAML2/XML/saml/NameIDTest.php
index 64dcc14fa..d29cca258 100644
--- a/tests/SAML2/XML/saml/NameIDTest.php
+++ b/tests/SAML2/XML/saml/NameIDTest.php
@@ -1,13 +1,20 @@
 <?php
 
+namespace SAML2\XML\md;
+
+use SAML2\XML\saml\NameID;
+use SAML2\Utils;
+use SAML2\Constants;
+use SAML2\DOMDocumentFactory;
+
 /**
- * Class SAML2_XML_md_NameIDTest
+ * Class \SAML2\XML\md\NameIDTest
  */
-class SAML2_XML_md_NameIDTest extends \PHPUnit_Framework_TestCase
+class NameIDTest extends \PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
-        $nameId = new SAML2_XML_saml_NameID();
+        $nameId = new NameID();
         $nameId->NameQualifier = 'TheNameQualifier';
         $nameId->SPNameQualifier = 'TheSPNameQualifier';
         $nameId->Format = 'TheFormat';
@@ -15,7 +22,7 @@ public function testMarshalling()
         $nameId->value = 'TheNameIDValue';
         $nameIdElement = $nameId->toXML();
 
-        $nameIdElements = SAML2_Utils::xpQuery($nameIdElement, '/saml_assertion:NameID');
+        $nameIdElements = Utils::xpQuery($nameIdElement, '/saml_assertion:NameID');
         $this->assertCount(1, $nameIdElements);
         $nameIdElement = $nameIdElements[0];
 
@@ -28,13 +35,13 @@ public function testMarshalling()
 
     public function testUnmarshalling()
     {
-        $samlNamespace = SAML2_Constants::NS_SAML;
-        $document = SAML2_DOMDocumentFactory::fromString(<<<XML
+        $samlNamespace = Constants::NS_SAML;
+        $document = DOMDocumentFactory::fromString(<<<XML
 <saml:NameID xmlns:saml="{$samlNamespace}" NameQualifier="TheNameQualifier" SPNameQualifier="TheSPNameQualifier" Format="TheFormat" SPProvidedID="TheSPProvidedID">TheNameIDValue</saml:NameID>
 XML
         );
 
-        $nameId = new SAML2_XML_saml_NameID($document->firstChild);
+        $nameId = new NameID($document->firstChild);
         $this->assertEquals('TheNameQualifier', $nameId->NameQualifier);
         $this->assertEquals('TheSPNameQualifier', $nameId->SPNameQualifier);
         $this->assertEquals('TheFormat', $nameId->Format);
diff --git a/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php b/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php
index 2a8f15e53..8eb8daf03 100644
--- a/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php
+++ b/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php
@@ -1,23 +1,29 @@
 <?php
 
+namespace SAML2\XML\saml;
+
+use SAML2\DOMDocumentFactory;
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
- * Class SAML2_XML_saml_SubjectConfirmationDataTest
+ * Class \SAML2\XML\saml\SubjectConfirmationDataTest
  */
-class SAML2_XML_saml_SubjectConfirmationDataTest extends \PHPUnit_Framework_TestCase
+class SubjectConfirmationDataTest extends \PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
-        $subjectConfirmationData = new SAML2_XML_saml_SubjectConfirmationData();
+        $subjectConfirmationData = new SubjectConfirmationData();
         $subjectConfirmationData->NotBefore = 987654321;
         $subjectConfirmationData->NotOnOrAfter = 1234567890;
         $subjectConfirmationData->Recipient = 'https://sp.example.org/asdf';
         $subjectConfirmationData->InResponseTo = 'SomeRequestID';
         $subjectConfirmationData->Address = '127.0.0.1';
 
-        $document = SAML2_DOMDocumentFactory::fromString('<root />');
+        $document = DOMDocumentFactory::fromString('<root />');
         $subjectConfirmationDataElement = $subjectConfirmationData->toXML($document->firstChild);
 
-        $subjectConfirmationDataElements = SAML2_Utils::xpQuery(
+        $subjectConfirmationDataElements = Utils::xpQuery(
             $subjectConfirmationDataElement,
             '//saml_assertion:SubjectConfirmationData'
         );
@@ -33,8 +39,8 @@ public function testMarshalling()
 
     public function testUnmarshalling()
     {
-        $samlNamespace = SAML2_Constants::NS_SAML;
-        $document = SAML2_DOMDocumentFactory::fromString(<<<XML
+        $samlNamespace = Constants::NS_SAML;
+        $document = DOMDocumentFactory::fromString(<<<XML
 <saml:SubjectConfirmationData
     xmlns:saml="{$samlNamespace}"
     NotBefore="2001-04-19T04:25:21Z"
@@ -46,7 +52,7 @@ public function testUnmarshalling()
 XML
         );
 
-        $subjectConfirmationData = new SAML2_XML_saml_SubjectConfirmationData($document->firstChild);
+        $subjectConfirmationData = new SubjectConfirmationData($document->firstChild);
         $this->assertEquals(987654321, $subjectConfirmationData->NotBefore);
         $this->assertEquals(1234567890, $subjectConfirmationData->NotOnOrAfter);
         $this->assertEquals('https://sp.example.org/asdf', $subjectConfirmationData->Recipient);
diff --git a/tests/SAML2/XML/saml/SubjectConfirmationTest.php b/tests/SAML2/XML/saml/SubjectConfirmationTest.php
index 0f65d3957..a4ebd9f9e 100644
--- a/tests/SAML2/XML/saml/SubjectConfirmationTest.php
+++ b/tests/SAML2/XML/saml/SubjectConfirmationTest.php
@@ -1,33 +1,39 @@
 <?php
 
+namespace SAML2\XML\saml;
+
+use SAML2\DOMDocumentFactory;
+use SAML2\Utils;
+use SAML2\Constants;
+
 /**
- * Class SAML2_XML_saml_SubjectConfirmationTest
+ * Class \SAML2\XML\saml\SubjectConfirmationTest
  */
-class SAML2_XML_saml_SubjectConfirmationTest extends \PHPUnit_Framework_TestCase
+class SubjectConfirmationTest extends \PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
-        $subjectConfirmation = new SAML2_XML_saml_SubjectConfirmation();
+        $subjectConfirmation = new SubjectConfirmation();
         $subjectConfirmation->Method = 'SomeMethod';
-        $subjectConfirmation->NameID = new SAML2_XML_saml_NameID();
+        $subjectConfirmation->NameID = new NameID();
         $subjectConfirmation->NameID->value = 'SomeNameIDValue';
-        $subjectConfirmation->SubjectConfirmationData = new SAML2_XML_saml_SubjectConfirmationData();
+        $subjectConfirmation->SubjectConfirmationData = new SubjectConfirmationData();
 
-        $document = SAML2_DOMDocumentFactory::fromString('<root />');
+        $document = DOMDocumentFactory::fromString('<root />');
         $subjectConfirmationElement = $subjectConfirmation->toXML($document->firstChild);
-        $subjectConfirmationElements = SAML2_Utils::xpQuery($subjectConfirmationElement, '//saml_assertion:SubjectConfirmation');
+        $subjectConfirmationElements = Utils::xpQuery($subjectConfirmationElement, '//saml_assertion:SubjectConfirmation');
         $this->assertCount(1, $subjectConfirmationElements);
         $subjectConfirmationElement = $subjectConfirmationElements[0];
 
         $this->assertEquals('SomeMethod', $subjectConfirmationElement->getAttribute("Method"));
-        $this->assertCount(1, SAML2_Utils::xpQuery($subjectConfirmationElement, "./saml_assertion:NameID"));
-        $this->assertCount(1, SAML2_Utils::xpQuery($subjectConfirmationElement, "./saml_assertion:SubjectConfirmationData"));
+        $this->assertCount(1, Utils::xpQuery($subjectConfirmationElement, "./saml_assertion:NameID"));
+        $this->assertCount(1, Utils::xpQuery($subjectConfirmationElement, "./saml_assertion:SubjectConfirmationData"));
     }
 
     public function testUnmarshalling()
     {
-        $samlNamespace = SAML2_Constants::NS_SAML;
-        $document = SAML2_DOMDocumentFactory::fromString(
+        $samlNamespace = Constants::NS_SAML;
+        $document = DOMDocumentFactory::fromString(
 <<<XML
 <saml:SubjectConfirmation xmlns:saml="{$samlNamespace}" Method="SomeMethod">
   <saml:NameID>SomeNameIDValue</saml:NameID>
@@ -36,10 +42,10 @@ public function testUnmarshalling()
 XML
         );
 
-        $subjectConfirmation = new SAML2_XML_saml_SubjectConfirmation($document->firstChild);
+        $subjectConfirmation = new SubjectConfirmation($document->firstChild);
         $this->assertEquals('SomeMethod', $subjectConfirmation->Method);
-        $this->assertTrue($subjectConfirmation->NameID instanceof SAML2_XML_saml_NameID);
+        $this->assertTrue($subjectConfirmation->NameID instanceof NameID);
         $this->assertEquals('SomeNameIDValue', $subjectConfirmation->NameID->value);
-        $this->assertTrue($subjectConfirmation->SubjectConfirmationData instanceof SAML2_XML_saml_SubjectConfirmationData);
+        $this->assertTrue($subjectConfirmation->SubjectConfirmationData instanceof SubjectConfirmationData);
     }
 }

From 19446b96fbacac9f92bfd42d2201bf7b5645418b Mon Sep 17 00:00:00 2001
From: Charles Bell <cb8@users.noreply.github.com>
Date: Sun, 29 Nov 2015 19:40:47 +0100
Subject: [PATCH 05/17] Remove composer.lock

---
 .gitignore    |    7 +-
 composer.lock | 1520 -------------------------------------------------
 2 files changed, 4 insertions(+), 1523 deletions(-)
 delete mode 100644 composer.lock

diff --git a/.gitignore b/.gitignore
index 817b396a5..2e5e3bbf6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
+/build/
+/cache.properties
+/composer.lock
+/composer.phar
 /vendor/
-build
-cache.properties
-composer.phar
diff --git a/composer.lock b/composer.lock
deleted file mode 100644
index 51e14ebbb..000000000
--- a/composer.lock
+++ /dev/null
@@ -1,1520 +0,0 @@
-{
-    "_readme": [
-        "This file locks the dependencies of your project to a known state",
-        "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
-        "This file is @generated automatically"
-    ],
-    "hash": "7eef7fe4ad07e291e4923d53eba0a847",
-    "packages": [
-        {
-            "name": "psr/log",
-            "version": "1.0.0",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/php-fig/log.git",
-                "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b",
-                "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b",
-                "shasum": ""
-            },
-            "type": "library",
-            "autoload": {
-                "psr-0": {
-                    "Psr\\Log\\": ""
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "PHP-FIG",
-                    "homepage": "http://www.php-fig.org/"
-                }
-            ],
-            "description": "Common interface for logging libraries",
-            "keywords": [
-                "log",
-                "psr",
-                "psr-3"
-            ],
-            "time": "2012-12-21 11:40:51"
-        },
-        {
-            "name": "robrichards/xmlseclibs",
-            "version": "1.3.2",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/robrichards/xmlseclibs.git",
-                "reference": "5e3c8a03990b9a97d1ea714bcba391d2f58e5b2d"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/robrichards/xmlseclibs/zipball/5e3c8a03990b9a97d1ea714bcba391d2f58e5b2d",
-                "reference": "5e3c8a03990b9a97d1ea714bcba391d2f58e5b2d",
-                "shasum": ""
-            },
-            "suggest": {
-                "ext/mcrypt": "MCrypt extension",
-                "ext/openssl": "OpenSSL extension"
-            },
-            "type": "library",
-            "autoload": {
-                "files": [
-                    "xmlseclibs.php"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "description": "A PHP library for XML Security",
-            "homepage": "https://github.com/robrichards/xmlseclibs",
-            "keywords": [
-                "security",
-                "signature",
-                "xml",
-                "xmldsig"
-            ],
-            "time": "2015-05-21 19:26:03"
-        }
-    ],
-    "packages-dev": [
-        {
-            "name": "guzzle/guzzle",
-            "version": "v3.9.2",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/guzzle/guzzle3.git",
-                "reference": "54991459675c1a2924122afbb0e5609ade581155"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/54991459675c1a2924122afbb0e5609ade581155",
-                "reference": "54991459675c1a2924122afbb0e5609ade581155",
-                "shasum": ""
-            },
-            "require": {
-                "ext-curl": "*",
-                "php": ">=5.3.3",
-                "symfony/event-dispatcher": "~2.1"
-            },
-            "replace": {
-                "guzzle/batch": "self.version",
-                "guzzle/cache": "self.version",
-                "guzzle/common": "self.version",
-                "guzzle/http": "self.version",
-                "guzzle/inflection": "self.version",
-                "guzzle/iterator": "self.version",
-                "guzzle/log": "self.version",
-                "guzzle/parser": "self.version",
-                "guzzle/plugin": "self.version",
-                "guzzle/plugin-async": "self.version",
-                "guzzle/plugin-backoff": "self.version",
-                "guzzle/plugin-cache": "self.version",
-                "guzzle/plugin-cookie": "self.version",
-                "guzzle/plugin-curlauth": "self.version",
-                "guzzle/plugin-error-response": "self.version",
-                "guzzle/plugin-history": "self.version",
-                "guzzle/plugin-log": "self.version",
-                "guzzle/plugin-md5": "self.version",
-                "guzzle/plugin-mock": "self.version",
-                "guzzle/plugin-oauth": "self.version",
-                "guzzle/service": "self.version",
-                "guzzle/stream": "self.version"
-            },
-            "require-dev": {
-                "doctrine/cache": "~1.3",
-                "monolog/monolog": "~1.0",
-                "phpunit/phpunit": "3.7.*",
-                "psr/log": "~1.0",
-                "symfony/class-loader": "~2.1",
-                "zendframework/zend-cache": "2.*,<2.3",
-                "zendframework/zend-log": "2.*,<2.3"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "3.9-dev"
-                }
-            },
-            "autoload": {
-                "psr-0": {
-                    "Guzzle": "src/",
-                    "Guzzle\\Tests": "tests/"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Michael Dowling",
-                    "email": "mtdowling@gmail.com",
-                    "homepage": "https://github.com/mtdowling"
-                },
-                {
-                    "name": "Guzzle Community",
-                    "homepage": "https://github.com/guzzle/guzzle/contributors"
-                }
-            ],
-            "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
-            "homepage": "http://guzzlephp.org/",
-            "keywords": [
-                "client",
-                "curl",
-                "framework",
-                "http",
-                "http client",
-                "rest",
-                "web service"
-            ],
-            "time": "2014-08-11 04:32:36"
-        },
-        {
-            "name": "mockery/mockery",
-            "version": "0.9.2",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/padraic/mockery.git",
-                "reference": "95a4855380dc70176c51807c678fb3bd6198529a"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/padraic/mockery/zipball/95a4855380dc70176c51807c678fb3bd6198529a",
-                "reference": "95a4855380dc70176c51807c678fb3bd6198529a",
-                "shasum": ""
-            },
-            "require": {
-                "lib-pcre": ">=7.0",
-                "php": ">=5.3.2"
-            },
-            "require-dev": {
-                "hamcrest/hamcrest-php": "~1.1",
-                "phpunit/phpunit": "~4.0",
-                "satooshi/php-coveralls": "~0.7@dev"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "0.9.x-dev"
-                }
-            },
-            "autoload": {
-                "psr-0": {
-                    "Mockery": "library/"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "P\u00e1draic Brady",
-                    "email": "padraic.brady@gmail.com",
-                    "homepage": "http://blog.astrumfutura.com"
-                },
-                {
-                    "name": "Dave Marshall",
-                    "email": "dave.marshall@atstsolutions.co.uk",
-                    "homepage": "http://davedevelopment.co.uk"
-                }
-            ],
-            "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succint API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.",
-            "homepage": "http://github.com/padraic/mockery",
-            "keywords": [
-                "BDD",
-                "TDD",
-                "library",
-                "mock",
-                "mock objects",
-                "mockery",
-                "stub",
-                "test",
-                "test double",
-                "testing"
-            ],
-            "time": "2014-09-03 10:11:10"
-        },
-        {
-            "name": "pdepend/pdepend",
-            "version": "1.1.3",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/pdepend/pdepend.git",
-                "reference": "1537f19d62d7b30c13ac173270106df7c6b9c459"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/pdepend/pdepend/zipball/1537f19d62d7b30c13ac173270106df7c6b9c459",
-                "reference": "1537f19d62d7b30c13ac173270106df7c6b9c459",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.2.3"
-            },
-            "bin": [
-                "src/bin/pdepend"
-            ],
-            "type": "library",
-            "autoload": {
-                "psr-0": {
-                    "PHP_": "src/main/php/"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "description": "Official version of pdepend to be handled with Composer",
-            "time": "2013-12-04 17:46:00"
-        },
-        {
-            "name": "phpmd/phpmd",
-            "version": "1.5.1",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/phpmd/phpmd.git",
-                "reference": "f2d47500f4c5f80ee442d95829c62c2ece2bbeb6"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/phpmd/phpmd/zipball/f2d47500f4c5f80ee442d95829c62c2ece2bbeb6",
-                "reference": "f2d47500f4c5f80ee442d95829c62c2ece2bbeb6",
-                "shasum": ""
-            },
-            "require": {
-                "pdepend/pdepend": "1.1.*",
-                "php": ">=5.3.0"
-            },
-            "require-dev": {
-                "phpunit/phpunit": "3.*@stable",
-                "squizlabs/php_codesniffer": "@stable"
-            },
-            "bin": [
-                "src/bin/phpmd"
-            ],
-            "type": "library",
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                "../../pdepend/pdepend/src/main/php",
-                "src/main/php"
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "description": "Official version of PHPMD handled with Composer.",
-            "time": "2014-09-16 14:26:49"
-        },
-        {
-            "name": "phpunit/php-code-coverage",
-            "version": "1.2.18",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
-                "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b",
-                "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3",
-                "phpunit/php-file-iterator": ">=1.3.0@stable",
-                "phpunit/php-text-template": ">=1.2.0@stable",
-                "phpunit/php-token-stream": ">=1.1.3,<1.3.0"
-            },
-            "require-dev": {
-                "phpunit/phpunit": "3.7.*@dev"
-            },
-            "suggest": {
-                "ext-dom": "*",
-                "ext-xdebug": ">=2.0.5"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "1.2.x-dev"
-                }
-            },
-            "autoload": {
-                "classmap": [
-                    "PHP/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                ""
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sb@sebastian-bergmann.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
-            "homepage": "https://github.com/sebastianbergmann/php-code-coverage",
-            "keywords": [
-                "coverage",
-                "testing",
-                "xunit"
-            ],
-            "time": "2014-09-02 10:13:14"
-        },
-        {
-            "name": "phpunit/php-file-iterator",
-            "version": "1.3.4",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
-                "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb",
-                "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3"
-            },
-            "type": "library",
-            "autoload": {
-                "classmap": [
-                    "File/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                ""
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sb@sebastian-bergmann.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "FilterIterator implementation that filters files based on a list of suffixes.",
-            "homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
-            "keywords": [
-                "filesystem",
-                "iterator"
-            ],
-            "time": "2013-10-10 15:34:57"
-        },
-        {
-            "name": "phpunit/php-text-template",
-            "version": "1.2.0",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/php-text-template.git",
-                "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
-                "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3"
-            },
-            "type": "library",
-            "autoload": {
-                "classmap": [
-                    "Text/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                ""
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sb@sebastian-bergmann.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "Simple template engine.",
-            "homepage": "https://github.com/sebastianbergmann/php-text-template/",
-            "keywords": [
-                "template"
-            ],
-            "time": "2014-01-30 17:20:04"
-        },
-        {
-            "name": "phpunit/php-timer",
-            "version": "1.0.5",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/php-timer.git",
-                "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
-                "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3"
-            },
-            "type": "library",
-            "autoload": {
-                "classmap": [
-                    "PHP/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                ""
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sb@sebastian-bergmann.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "Utility class for timing",
-            "homepage": "https://github.com/sebastianbergmann/php-timer/",
-            "keywords": [
-                "timer"
-            ],
-            "time": "2013-08-02 07:42:54"
-        },
-        {
-            "name": "phpunit/php-token-stream",
-            "version": "1.2.2",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/php-token-stream.git",
-                "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32",
-                "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32",
-                "shasum": ""
-            },
-            "require": {
-                "ext-tokenizer": "*",
-                "php": ">=5.3.3"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "1.2-dev"
-                }
-            },
-            "autoload": {
-                "classmap": [
-                    "PHP/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                ""
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sb@sebastian-bergmann.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "Wrapper around PHP's tokenizer extension.",
-            "homepage": "https://github.com/sebastianbergmann/php-token-stream/",
-            "keywords": [
-                "tokenizer"
-            ],
-            "time": "2014-03-03 05:10:30"
-        },
-        {
-            "name": "phpunit/phpunit",
-            "version": "3.7.38",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/phpunit.git",
-                "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/38709dc22d519a3d1be46849868aa2ddf822bcf6",
-                "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6",
-                "shasum": ""
-            },
-            "require": {
-                "ext-ctype": "*",
-                "ext-dom": "*",
-                "ext-json": "*",
-                "ext-pcre": "*",
-                "ext-reflection": "*",
-                "ext-spl": "*",
-                "php": ">=5.3.3",
-                "phpunit/php-code-coverage": "~1.2",
-                "phpunit/php-file-iterator": "~1.3",
-                "phpunit/php-text-template": "~1.1",
-                "phpunit/php-timer": "~1.0",
-                "phpunit/phpunit-mock-objects": "~1.2",
-                "symfony/yaml": "~2.0"
-            },
-            "require-dev": {
-                "pear-pear.php.net/pear": "1.9.4"
-            },
-            "suggest": {
-                "phpunit/php-invoker": "~1.1"
-            },
-            "bin": [
-                "composer/bin/phpunit"
-            ],
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "3.7.x-dev"
-                }
-            },
-            "autoload": {
-                "classmap": [
-                    "PHPUnit/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                "",
-                "../../symfony/yaml/"
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sebastian@phpunit.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "The PHP Unit Testing framework.",
-            "homepage": "http://www.phpunit.de/",
-            "keywords": [
-                "phpunit",
-                "testing",
-                "xunit"
-            ],
-            "time": "2014-10-17 09:04:17"
-        },
-        {
-            "name": "phpunit/phpunit-mock-objects",
-            "version": "1.2.3",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
-                "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875",
-                "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3",
-                "phpunit/php-text-template": ">=1.1.1@stable"
-            },
-            "suggest": {
-                "ext-soap": "*"
-            },
-            "type": "library",
-            "autoload": {
-                "classmap": [
-                    "PHPUnit/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "include-path": [
-                ""
-            ],
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sb@sebastian-bergmann.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "Mock Object library for PHPUnit",
-            "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
-            "keywords": [
-                "mock",
-                "xunit"
-            ],
-            "time": "2013-01-13 10:24:48"
-        },
-        {
-            "name": "satooshi/php-coveralls",
-            "version": "v0.6.1",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/satooshi/php-coveralls.git",
-                "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/dd0df95bd37a7cf5c5c50304dfe260ffe4b50760",
-                "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760",
-                "shasum": ""
-            },
-            "require": {
-                "ext-curl": "*",
-                "ext-json": "*",
-                "ext-simplexml": "*",
-                "guzzle/guzzle": ">=3.0",
-                "php": ">=5.3",
-                "psr/log": "1.0.0",
-                "symfony/config": ">=2.0",
-                "symfony/console": ">=2.0",
-                "symfony/stopwatch": ">=2.2",
-                "symfony/yaml": ">=2.0"
-            },
-            "require-dev": {
-                "apigen/apigen": "2.8.*@stable",
-                "pdepend/pdepend": "dev-master",
-                "phpmd/phpmd": "dev-master",
-                "phpunit/php-invoker": ">=1.1.0,<1.2.0",
-                "phpunit/phpunit": "3.7.*@stable",
-                "sebastian/finder-facade": "dev-master",
-                "sebastian/phpcpd": "1.4.*@stable",
-                "squizlabs/php_codesniffer": "1.4.*@stable",
-                "theseer/fdomdocument": "dev-master"
-            },
-            "bin": [
-                "composer/bin/coveralls"
-            ],
-            "type": "library",
-            "autoload": {
-                "psr-0": {
-                    "Contrib\\Component": "src/",
-                    "Contrib\\Bundle": "src/"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Kitamura Satoshi",
-                    "email": "with.no.parachute@gmail.com",
-                    "homepage": "https://www.facebook.com/satooshi.jp"
-                }
-            ],
-            "description": "PHP client library for Coveralls API",
-            "homepage": "https://github.com/satooshi/php-coveralls",
-            "keywords": [
-                "ci",
-                "coverage",
-                "github",
-                "test"
-            ],
-            "time": "2013-05-04 08:07:33"
-        },
-        {
-            "name": "sebastian/finder-facade",
-            "version": "1.1.0",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/finder-facade.git",
-                "reference": "1e396fda3449fce9df032749fa4fa2619e0347e0"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/finder-facade/zipball/1e396fda3449fce9df032749fa4fa2619e0347e0",
-                "reference": "1e396fda3449fce9df032749fa4fa2619e0347e0",
-                "shasum": ""
-            },
-            "require": {
-                "symfony/finder": ">=2.2.0",
-                "theseer/fdomdocument": ">=1.3.1"
-            },
-            "type": "library",
-            "autoload": {
-                "classmap": [
-                    "src/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sebastian@phpunit.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "FinderFacade is a convenience wrapper for Symfony's Finder component.",
-            "homepage": "https://github.com/sebastianbergmann/finder-facade",
-            "time": "2013-05-28 06:10:03"
-        },
-        {
-            "name": "sebastian/phpcpd",
-            "version": "1.4.3",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/phpcpd.git",
-                "reference": "090575dbd6486bff545a7426f98e988c8c597c1b"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpcpd/zipball/090575dbd6486bff545a7426f98e988c8c597c1b",
-                "reference": "090575dbd6486bff545a7426f98e988c8c597c1b",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3",
-                "phpunit/php-timer": ">=1.0.4,<1.1.0",
-                "sebastian/finder-facade": "~1.1",
-                "sebastian/version": ">=1.0.0",
-                "symfony/finder": ">=2.1.2",
-                "theseer/fdomdocument": "~1.4",
-                "zetacomponents/base": ">=1.8",
-                "zetacomponents/console-tools": ">=1.6"
-            },
-            "bin": [
-                "composer/bin/phpcpd"
-            ],
-            "type": "library",
-            "autoload": {
-                "classmap": [
-                    "src/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sebastian@phpunit.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "Copy/Paste Detector (CPD) for PHP code.",
-            "homepage": "https://github.com/sebastianbergmann/phpcpd",
-            "time": "2013-07-30 14:37:42"
-        },
-        {
-            "name": "sebastian/version",
-            "version": "1.0.3",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/version.git",
-                "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43",
-                "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43",
-                "shasum": ""
-            },
-            "type": "library",
-            "autoload": {
-                "classmap": [
-                    "src/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sebastian@phpunit.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "Library that helps with managing the version number of Git-hosted PHP projects",
-            "homepage": "https://github.com/sebastianbergmann/version",
-            "time": "2014-03-07 15:35:33"
-        },
-        {
-            "name": "sensiolabs/security-checker",
-            "version": "v1.3.4",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sensiolabs/security-checker.git",
-                "reference": "da1f9d19c80eac2b6ae8043bb92b7c7a16d00713"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sensiolabs/security-checker/zipball/da1f9d19c80eac2b6ae8043bb92b7c7a16d00713",
-                "reference": "da1f9d19c80eac2b6ae8043bb92b7c7a16d00713",
-                "shasum": ""
-            },
-            "require": {
-                "ext-curl": "*",
-                "symfony/console": "~2.0"
-            },
-            "bin": [
-                "security-checker"
-            ],
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "1.3-dev"
-                }
-            },
-            "autoload": {
-                "psr-0": {
-                    "SensioLabs\\Security": ""
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Fabien Potencier",
-                    "email": "fabien.potencier@gmail.com"
-                }
-            ],
-            "description": "A security checker for your composer.lock",
-            "time": "2014-07-08 18:12:35"
-        },
-        {
-            "name": "squizlabs/php_codesniffer",
-            "version": "1.5.5",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
-                "reference": "5d973e59cf58a0c847f298de84374c96b42b17b3"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5d973e59cf58a0c847f298de84374c96b42b17b3",
-                "reference": "5d973e59cf58a0c847f298de84374c96b42b17b3",
-                "shasum": ""
-            },
-            "require": {
-                "ext-tokenizer": "*",
-                "php": ">=5.1.2"
-            },
-            "suggest": {
-                "phpunit/php-timer": "dev-master"
-            },
-            "bin": [
-                "scripts/phpcs"
-            ],
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-phpcs-fixer": "2.0.x-dev"
-                }
-            },
-            "autoload": {
-                "classmap": [
-                    "CodeSniffer.php",
-                    "CodeSniffer/CLI.php",
-                    "CodeSniffer/Exception.php",
-                    "CodeSniffer/File.php",
-                    "CodeSniffer/Report.php",
-                    "CodeSniffer/Reporting.php",
-                    "CodeSniffer/Sniff.php",
-                    "CodeSniffer/Tokens.php",
-                    "CodeSniffer/Reports/",
-                    "CodeSniffer/CommentParser/",
-                    "CodeSniffer/Tokenizers/",
-                    "CodeSniffer/DocGenerators/",
-                    "CodeSniffer/Standards/AbstractPatternSniff.php",
-                    "CodeSniffer/Standards/AbstractScopeSniff.php",
-                    "CodeSniffer/Standards/AbstractVariableSniff.php",
-                    "CodeSniffer/Standards/IncorrectPatternException.php",
-                    "CodeSniffer/Standards/Generic/Sniffs/",
-                    "CodeSniffer/Standards/MySource/Sniffs/",
-                    "CodeSniffer/Standards/PEAR/Sniffs/",
-                    "CodeSniffer/Standards/PSR1/Sniffs/",
-                    "CodeSniffer/Standards/PSR2/Sniffs/",
-                    "CodeSniffer/Standards/Squiz/Sniffs/",
-                    "CodeSniffer/Standards/Zend/Sniffs/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Greg Sherwood",
-                    "role": "lead"
-                }
-            ],
-            "description": "PHP_CodeSniffer tokenises PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
-            "homepage": "http://www.squizlabs.com/php-codesniffer",
-            "keywords": [
-                "phpcs",
-                "standards"
-            ],
-            "time": "2014-09-25 03:33:46"
-        },
-        {
-            "name": "symfony/config",
-            "version": "v2.5.7",
-            "target-dir": "Symfony/Component/Config",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/symfony/Config.git",
-                "reference": "7b11dceebaaf877b75bc1aedfd831a2ddc326de9"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/symfony/Config/zipball/7b11dceebaaf877b75bc1aedfd831a2ddc326de9",
-                "reference": "7b11dceebaaf877b75bc1aedfd831a2ddc326de9",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3",
-                "symfony/filesystem": "~2.3"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "2.5-dev"
-                }
-            },
-            "autoload": {
-                "psr-0": {
-                    "Symfony\\Component\\Config\\": ""
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Symfony Community",
-                    "homepage": "http://symfony.com/contributors"
-                },
-                {
-                    "name": "Fabien Potencier",
-                    "email": "fabien@symfony.com"
-                }
-            ],
-            "description": "Symfony Config Component",
-            "homepage": "http://symfony.com",
-            "time": "2014-11-20 13:22:25"
-        },
-        {
-            "name": "symfony/console",
-            "version": "v2.5.7",
-            "target-dir": "Symfony/Component/Console",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/symfony/Console.git",
-                "reference": "61b13c27c9258e97009249d4ef193c964bf346b7"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/symfony/Console/zipball/61b13c27c9258e97009249d4ef193c964bf346b7",
-                "reference": "61b13c27c9258e97009249d4ef193c964bf346b7",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3"
-            },
-            "require-dev": {
-                "psr/log": "~1.0",
-                "symfony/event-dispatcher": "~2.1"
-            },
-            "suggest": {
-                "psr/log": "For using the console logger",
-                "symfony/event-dispatcher": ""
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "2.5-dev"
-                }
-            },
-            "autoload": {
-                "psr-0": {
-                    "Symfony\\Component\\Console\\": ""
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Symfony Community",
-                    "homepage": "http://symfony.com/contributors"
-                },
-                {
-                    "name": "Fabien Potencier",
-                    "email": "fabien@symfony.com"
-                }
-            ],
-            "description": "Symfony Console Component",
-            "homepage": "http://symfony.com",
-            "time": "2014-11-20 13:22:25"
-        },
-        {
-            "name": "symfony/event-dispatcher",
-            "version": "v2.5.7",
-            "target-dir": "Symfony/Component/EventDispatcher",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/symfony/EventDispatcher.git",
-                "reference": "bb6fc12085cd195dceaf48016087b12b632df497"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/bb6fc12085cd195dceaf48016087b12b632df497",
-                "reference": "bb6fc12085cd195dceaf48016087b12b632df497",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3"
-            },
-            "require-dev": {
-                "psr/log": "~1.0",
-                "symfony/config": "~2.0",
-                "symfony/dependency-injection": "~2.0,<2.6.0",
-                "symfony/stopwatch": "~2.2"
-            },
-            "suggest": {
-                "symfony/dependency-injection": "",
-                "symfony/http-kernel": ""
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "2.5-dev"
-                }
-            },
-            "autoload": {
-                "psr-0": {
-                    "Symfony\\Component\\EventDispatcher\\": ""
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Symfony Community",
-                    "homepage": "http://symfony.com/contributors"
-                },
-                {
-                    "name": "Fabien Potencier",
-                    "email": "fabien@symfony.com"
-                }
-            ],
-            "description": "Symfony EventDispatcher Component",
-            "homepage": "http://symfony.com",
-            "time": "2014-10-30 20:17:55"
-        },
-        {
-            "name": "symfony/filesystem",
-            "version": "v2.5.7",
-            "target-dir": "Symfony/Component/Filesystem",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/symfony/Filesystem.git",
-                "reference": "3c3e382bd869b3ec10008a3d9ef455b1cc2868db"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/symfony/Filesystem/zipball/3c3e382bd869b3ec10008a3d9ef455b1cc2868db",
-                "reference": "3c3e382bd869b3ec10008a3d9ef455b1cc2868db",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "2.5-dev"
-                }
-            },
-            "autoload": {
-                "psr-0": {
-                    "Symfony\\Component\\Filesystem\\": ""
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Symfony Community",
-                    "homepage": "http://symfony.com/contributors"
-                },
-                {
-                    "name": "Fabien Potencier",
-                    "email": "fabien@symfony.com"
-                }
-            ],
-            "description": "Symfony Filesystem Component",
-            "homepage": "http://symfony.com",
-            "time": "2014-11-16 17:28:00"
-        },
-        {
-            "name": "symfony/finder",
-            "version": "v2.5.7",
-            "target-dir": "Symfony/Component/Finder",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/symfony/Finder.git",
-                "reference": "743aabbf4958663ef626e10ae3a6c7b17a0fa3bd"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/symfony/Finder/zipball/743aabbf4958663ef626e10ae3a6c7b17a0fa3bd",
-                "reference": "743aabbf4958663ef626e10ae3a6c7b17a0fa3bd",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "2.5-dev"
-                }
-            },
-            "autoload": {
-                "psr-0": {
-                    "Symfony\\Component\\Finder\\": ""
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Symfony Community",
-                    "homepage": "http://symfony.com/contributors"
-                },
-                {
-                    "name": "Fabien Potencier",
-                    "email": "fabien@symfony.com"
-                }
-            ],
-            "description": "Symfony Finder Component",
-            "homepage": "http://symfony.com",
-            "time": "2014-10-26 07:41:27"
-        },
-        {
-            "name": "symfony/stopwatch",
-            "version": "v2.5.7",
-            "target-dir": "Symfony/Component/Stopwatch",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/symfony/Stopwatch.git",
-                "reference": "9f8a33a24f2378c0ec5f372a8d50b2d43069c050"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/9f8a33a24f2378c0ec5f372a8d50b2d43069c050",
-                "reference": "9f8a33a24f2378c0ec5f372a8d50b2d43069c050",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "2.5-dev"
-                }
-            },
-            "autoload": {
-                "psr-0": {
-                    "Symfony\\Component\\Stopwatch\\": ""
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Symfony Community",
-                    "homepage": "http://symfony.com/contributors"
-                },
-                {
-                    "name": "Fabien Potencier",
-                    "email": "fabien@symfony.com"
-                }
-            ],
-            "description": "Symfony Stopwatch Component",
-            "homepage": "http://symfony.com",
-            "time": "2014-09-22 09:14:18"
-        },
-        {
-            "name": "symfony/yaml",
-            "version": "v2.5.7",
-            "target-dir": "Symfony/Component/Yaml",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/symfony/Yaml.git",
-                "reference": "900d38bc8f74a50343ce65dd1c1e9819658ee56b"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/symfony/Yaml/zipball/900d38bc8f74a50343ce65dd1c1e9819658ee56b",
-                "reference": "900d38bc8f74a50343ce65dd1c1e9819658ee56b",
-                "shasum": ""
-            },
-            "require": {
-                "php": ">=5.3.3"
-            },
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "2.5-dev"
-                }
-            },
-            "autoload": {
-                "psr-0": {
-                    "Symfony\\Component\\Yaml\\": ""
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "MIT"
-            ],
-            "authors": [
-                {
-                    "name": "Symfony Community",
-                    "homepage": "http://symfony.com/contributors"
-                },
-                {
-                    "name": "Fabien Potencier",
-                    "email": "fabien@symfony.com"
-                }
-            ],
-            "description": "Symfony Yaml Component",
-            "homepage": "http://symfony.com",
-            "time": "2014-11-20 13:22:25"
-        },
-        {
-            "name": "theseer/fdomdocument",
-            "version": "1.6.0",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/theseer/fDOMDocument.git",
-                "reference": "d08cf070350f884c63fc9078d27893c2ab6c7cef"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/theseer/fDOMDocument/zipball/d08cf070350f884c63fc9078d27893c2ab6c7cef",
-                "reference": "d08cf070350f884c63fc9078d27893c2ab6c7cef",
-                "shasum": ""
-            },
-            "require": {
-                "ext-dom": "*",
-                "lib-libxml": "*",
-                "php": ">=5.3.3"
-            },
-            "type": "library",
-            "autoload": {
-                "classmap": [
-                    "src/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Arne Blankerts",
-                    "email": "arne@blankerts.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "The classes contained within this repository extend the standard DOM to use exceptions at all occasions of errors instead of PHP warnings or notices. They also add various custom methods and shortcuts for convenience and to simplify the usage of DOM.",
-            "homepage": "https://github.com/theseer/fDOMDocument",
-            "time": "2014-09-13 10:57:19"
-        },
-        {
-            "name": "zetacomponents/base",
-            "version": "1.9",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/zetacomponents/Base.git",
-                "reference": "f20df24e8de3e48b6b69b2503f917e457281e687"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/zetacomponents/Base/zipball/f20df24e8de3e48b6b69b2503f917e457281e687",
-                "reference": "f20df24e8de3e48b6b69b2503f917e457281e687",
-                "shasum": ""
-            },
-            "require-dev": {
-                "zetacomponents/unit-test": "*"
-            },
-            "type": "library",
-            "autoload": {
-                "classmap": [
-                    "src"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "Apache-2.0"
-            ],
-            "authors": [
-                {
-                    "name": "Sergey Alexeev"
-                },
-                {
-                    "name": "Sebastian Bergmann"
-                },
-                {
-                    "name": "Jan Borsodi"
-                },
-                {
-                    "name": "Raymond Bosman"
-                },
-                {
-                    "name": "Frederik Holljen"
-                },
-                {
-                    "name": "Kore Nordmann"
-                },
-                {
-                    "name": "Derick Rethans"
-                },
-                {
-                    "name": "Vadym Savchuk"
-                },
-                {
-                    "name": "Tobias Schlitt"
-                },
-                {
-                    "name": "Alexandru Stanoi"
-                }
-            ],
-            "description": "The Base package provides the basic infrastructure that all packages rely on. Therefore every component relies on this package.",
-            "homepage": "https://github.com/zetacomponents",
-            "time": "2014-09-19 03:28:34"
-        },
-        {
-            "name": "zetacomponents/console-tools",
-            "version": "1.7",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/zetacomponents/ConsoleTools.git",
-                "reference": "30d67e9d04f458ac8cae4c49e50f81061460ff2c"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/zetacomponents/ConsoleTools/zipball/30d67e9d04f458ac8cae4c49e50f81061460ff2c",
-                "reference": "30d67e9d04f458ac8cae4c49e50f81061460ff2c",
-                "shasum": ""
-            },
-            "require": {
-                "zetacomponents/base": "~1.8"
-            },
-            "require-dev": {
-                "zetacomponents/unit-test": "*"
-            },
-            "type": "library",
-            "autoload": {
-                "classmap": [
-                    "src"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "Apache-2.0"
-            ],
-            "authors": [
-                {
-                    "name": "Sergey Alexeev"
-                },
-                {
-                    "name": "Sebastian Bergmann"
-                },
-                {
-                    "name": "Jan Borsodi"
-                },
-                {
-                    "name": "Raymond Bosman"
-                },
-                {
-                    "name": "Frederik Holljen"
-                },
-                {
-                    "name": "Kore Nordmann"
-                },
-                {
-                    "name": "Derick Rethans"
-                },
-                {
-                    "name": "Vadym Savchuk"
-                },
-                {
-                    "name": "Tobias Schlitt"
-                },
-                {
-                    "name": "Alexandru Stanoi"
-                }
-            ],
-            "description": "A set of classes to do different actions with the console (also called shell). It can render a progress bar, tables and a status bar and contains a class for parsing command line options.",
-            "homepage": "https://github.com/zetacomponents",
-            "time": "2014-09-27 19:26:09"
-        }
-    ],
-    "aliases": [],
-    "minimum-stability": "stable",
-    "stability-flags": [],
-    "prefer-stable": false,
-    "platform": {
-        "php": ">=5.3.3",
-        "ext-openssl": "*",
-        "ext-dom": "*",
-        "ext-mcrypt": "*"
-    },
-    "platform-dev": []
-}

From 87bc3bcb88e5c6df262bc134dc485b9458b3e7f3 Mon Sep 17 00:00:00 2001
From: Charles Bell <cb8@users.noreply.github.com>
Date: Sun, 29 Nov 2015 19:43:44 +0100
Subject: [PATCH 06/17] Configure autoloader to use namespaces

---
 composer.json      | 4 ++--
 tests/autoload.php | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/composer.json b/composer.json
index b2283ab18..bbcb70014 100644
--- a/composer.json
+++ b/composer.json
@@ -27,12 +27,12 @@
     },
     "autoload": {
         "psr-0": {
-            "SAML2_": "src/"
+            "SAML2\\": "src/"
         }
     },
     "autoload-dev": {
         "psr-0": {
-            "SAML2_": "tests/"
+            "SAML2\\": "tests/"
         }
     }
 }
diff --git a/tests/autoload.php b/tests/autoload.php
index 871269336..3dad8fedc 100644
--- a/tests/autoload.php
+++ b/tests/autoload.php
@@ -4,4 +4,4 @@
 require __DIR__ . '/../vendor/autoload.php';
 
 // And set the Mock container as the Container to use.
-SAML2_Compat_ContainerSingleton::setContainer(new SAML2_Compat_MockContainer());
+\SAML2\Compat\ContainerSingleton::setContainer(new \SAML2\Compat\MockContainer());

From 76f6babfebca6d501773931dd2cd3ebf7f6c9609 Mon Sep 17 00:00:00 2001
From: Charles Bell <cb8@users.noreply.github.com>
Date: Sun, 29 Nov 2015 20:18:06 +0100
Subject: [PATCH 07/17] Update XMLSecLibs

---
 composer.json                                    | 2 +-
 src/SAML2/Assertion.php                          | 2 ++
 src/SAML2/AuthnRequest.php                       | 2 ++
 src/SAML2/Certificate/PrivateKeyLoader.php       | 1 +
 src/SAML2/Configuration/ServiceProvider.php      | 2 ++
 src/SAML2/EncryptedAssertion.php                 | 3 +++
 src/SAML2/HTTPArtifact.php                       | 1 +
 src/SAML2/HTTPRedirect.php                       | 2 ++
 src/SAML2/LogoutRequest.php                      | 3 +++
 src/SAML2/Message.php                            | 1 +
 src/SAML2/SOAPClient.php                         | 1 +
 src/SAML2/Signature/AbstractChainedValidator.php | 1 +
 src/SAML2/SignedElement.php                      | 2 ++
 src/SAML2/SignedElementHelper.php                | 2 ++
 src/SAML2/Utils.php                              | 3 +++
 src/SAML2/XML/ds/KeyInfo.php                     | 1 +
 src/SAML2/XML/ds/KeyName.php                     | 1 +
 src/SAML2/XML/ds/X509Certificate.php             | 1 +
 src/SAML2/XML/ds/X509Data.php                    | 1 +
 src/SAML2/XML/saml/SubjectConfirmationData.php   | 1 +
 tests/SAML2/CertificatesMock.php                 | 2 ++
 tests/SAML2/SignedElementHelperTest.php          | 2 ++
 22 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/composer.json b/composer.json
index bbcb70014..52c61da71 100644
--- a/composer.json
+++ b/composer.json
@@ -13,7 +13,7 @@
         "ext-openssl": "*",
         "ext-dom": "*",
 
-        "robrichards/xmlseclibs": "^1.3",
+        "robrichards/xmlseclibs": "^2.0",
         "psr/log": "~1.0"
     },
     "require-dev": {
diff --git a/src/SAML2/Assertion.php b/src/SAML2/Assertion.php
index eba3afaa4..7cca7b9ca 100644
--- a/src/SAML2/Assertion.php
+++ b/src/SAML2/Assertion.php
@@ -2,6 +2,8 @@
 
 namespace SAML2;
 
+use RobRichards\XMLSecLibs\XMLSecEnc;
+use RobRichards\XMLSecLibs\XMLSecurityKey;
 use SAML2\Utilities\Temporal;
 use SAML2\XML\saml\SubjectConfirmation;
 use SAML2\XML\Chunk;
diff --git a/src/SAML2/AuthnRequest.php b/src/SAML2/AuthnRequest.php
index aa8a8782d..3b137a4d2 100644
--- a/src/SAML2/AuthnRequest.php
+++ b/src/SAML2/AuthnRequest.php
@@ -2,6 +2,8 @@
 
 namespace SAML2;
 
+use RobRichards\XMLSecLibs\XMLSecEnc;
+use RobRichards\XMLSecLibs\XMLSecurityKey;
 use SAML2\XML\saml\SubjectConfirmation;
 
 /**
diff --git a/src/SAML2/Certificate/PrivateKeyLoader.php b/src/SAML2/Certificate/PrivateKeyLoader.php
index 7493deb7e..711875669 100644
--- a/src/SAML2/Certificate/PrivateKeyLoader.php
+++ b/src/SAML2/Certificate/PrivateKeyLoader.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\Certificate;
 
+use RobRichards\XMLSecLibs\XMLSecurityKey;
 use SAML2\Configuration\PrivateKey;
 use SAML2\Utilities\File;
 use SAML2\Configuration\DecryptionProvider;
diff --git a/src/SAML2/Configuration/ServiceProvider.php b/src/SAML2/Configuration/ServiceProvider.php
index bd6e0c0ba..b565d8ace 100644
--- a/src/SAML2/Configuration/ServiceProvider.php
+++ b/src/SAML2/Configuration/ServiceProvider.php
@@ -2,6 +2,8 @@
 
 namespace SAML2\Configuration;
 
+use RobRichards\XMLSecLibs\XMLSecurityKey;
+
 /**
  * Basic Configuration Wrapper
  */
diff --git a/src/SAML2/EncryptedAssertion.php b/src/SAML2/EncryptedAssertion.php
index 388983b6b..51da22e75 100644
--- a/src/SAML2/EncryptedAssertion.php
+++ b/src/SAML2/EncryptedAssertion.php
@@ -2,6 +2,9 @@
 
 namespace SAML2;
 
+use RobRichards\XMLSecLibs\XMLSecEnc;
+use RobRichards\XMLSecLibs\XMLSecurityKey;
+
 /**
  * Class handling encrypted assertions.
  *
diff --git a/src/SAML2/HTTPArtifact.php b/src/SAML2/HTTPArtifact.php
index ec48dfdee..aeaadbdcf 100644
--- a/src/SAML2/HTTPArtifact.php
+++ b/src/SAML2/HTTPArtifact.php
@@ -2,6 +2,7 @@
 
 namespace SAML2;
 
+use RobRichards\XMLSecLibs\XMLSecurityKey;
 use SAML2\Utilities\Temporal;
 
 /**
diff --git a/src/SAML2/HTTPRedirect.php b/src/SAML2/HTTPRedirect.php
index 0b95d32f6..d7e52b8ae 100644
--- a/src/SAML2/HTTPRedirect.php
+++ b/src/SAML2/HTTPRedirect.php
@@ -2,6 +2,8 @@
 
 namespace SAML2;
 
+use RobRichards\XMLSecLibs\XMLSecurityKey;
+
 /**
  * Class which implements the HTTP-Redirect binding.
  *
diff --git a/src/SAML2/LogoutRequest.php b/src/SAML2/LogoutRequest.php
index 78ac261c3..ae0f001f8 100644
--- a/src/SAML2/LogoutRequest.php
+++ b/src/SAML2/LogoutRequest.php
@@ -2,6 +2,9 @@
 
 namespace SAML2;
 
+use RobRichards\XMLSecLibs\XMLSecEnc;
+use RobRichards\XMLSecLibs\XMLSecurityKey;
+
 /**
  * Class for SAML 2 logout request messages.
  *
diff --git a/src/SAML2/Message.php b/src/SAML2/Message.php
index 9f9e55df2..aa7751123 100644
--- a/src/SAML2/Message.php
+++ b/src/SAML2/Message.php
@@ -2,6 +2,7 @@
 
 namespace SAML2;
 
+use RobRichards\XMLSecLibs\XMLSecurityKey;
 use SAML2\Utilities\Temporal;
 use SAML2\XML\samlp\Extensions;
 
diff --git a/src/SAML2/SOAPClient.php b/src/SAML2/SOAPClient.php
index 90d231b95..3a1713107 100644
--- a/src/SAML2/SOAPClient.php
+++ b/src/SAML2/SOAPClient.php
@@ -2,6 +2,7 @@
 
 namespace SAML2;
 
+use RobRichards\XMLSecLibs\XMLSecurityKey;
 use SAML2\Exception\RuntimeException;
 
 /**
diff --git a/src/SAML2/Signature/AbstractChainedValidator.php b/src/SAML2/Signature/AbstractChainedValidator.php
index 1524d92c6..b921c01ab 100644
--- a/src/SAML2/Signature/AbstractChainedValidator.php
+++ b/src/SAML2/Signature/AbstractChainedValidator.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\Signature;
 
+use RobRichards\XMLSecLibs\XMLSecurityKey;
 use SAML2\SignedElement;
 
 abstract class AbstractChainedValidator implements ChainedValidator
diff --git a/src/SAML2/SignedElement.php b/src/SAML2/SignedElement.php
index 8928d32f0..a7fa26046 100644
--- a/src/SAML2/SignedElement.php
+++ b/src/SAML2/SignedElement.php
@@ -2,6 +2,8 @@
 
 namespace SAML2;
 
+use RobRichards\XMLSecLibs\XMLSecurityKey;
+
 /**
  * Interface to a SAML 2 element which may be signed.
  *
diff --git a/src/SAML2/SignedElementHelper.php b/src/SAML2/SignedElementHelper.php
index 72434438a..ea7c8ce38 100644
--- a/src/SAML2/SignedElementHelper.php
+++ b/src/SAML2/SignedElementHelper.php
@@ -2,6 +2,8 @@
 
 namespace SAML2;
 
+use RobRichards\XMLSecLibs\XMLSecurityKey;
+
 /**
  * Helper class for processing signed elements.
  *
diff --git a/src/SAML2/Utils.php b/src/SAML2/Utils.php
index 911234c1f..604d0167a 100644
--- a/src/SAML2/Utils.php
+++ b/src/SAML2/Utils.php
@@ -2,6 +2,9 @@
 
 namespace SAML2;
 
+use RobRichards\XMLSecLibs\XMLSecEnc;
+use RobRichards\XMLSecLibs\XMLSecurityDSig;
+use RobRichards\XMLSecLibs\XMLSecurityKey;
 use SAML2\Exception\RuntimeException;
 use SAML2\XML\ds\X509Certificate;
 use SAML2\XML\ds\X509Data;
diff --git a/src/SAML2/XML/ds/KeyInfo.php b/src/SAML2/XML/ds/KeyInfo.php
index 61f54e586..4ca502904 100644
--- a/src/SAML2/XML/ds/KeyInfo.php
+++ b/src/SAML2/XML/ds/KeyInfo.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\XML\ds;
 
+use RobRichards\XMLSecLibs\XMLSecurityDSig;
 use SAML2\XML\Chunk;
 
 /**
diff --git a/src/SAML2/XML/ds/KeyName.php b/src/SAML2/XML/ds/KeyName.php
index 02c40d748..856bd561a 100644
--- a/src/SAML2/XML/ds/KeyName.php
+++ b/src/SAML2/XML/ds/KeyName.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\XML\ds;
 
+use RobRichards\XMLSecLibs\XMLSecurityDSig;
 use SAML2\Utils;
 
 /**
diff --git a/src/SAML2/XML/ds/X509Certificate.php b/src/SAML2/XML/ds/X509Certificate.php
index fcb664c41..77bc15e59 100644
--- a/src/SAML2/XML/ds/X509Certificate.php
+++ b/src/SAML2/XML/ds/X509Certificate.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\XML\ds;
 
+use RobRichards\XMLSecLibs\XMLSecurityDSig;
 use SAML2\Utils;
 
 /**
diff --git a/src/SAML2/XML/ds/X509Data.php b/src/SAML2/XML/ds/X509Data.php
index f22c9526f..9ce186b52 100644
--- a/src/SAML2/XML/ds/X509Data.php
+++ b/src/SAML2/XML/ds/X509Data.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\XML\ds;
 
+use RobRichards\XMLSecLibs\XMLSecurityDSig;
 use SAML2\XML\Chunk;
 
 /**
diff --git a/src/SAML2/XML/saml/SubjectConfirmationData.php b/src/SAML2/XML/saml/SubjectConfirmationData.php
index f9bcf23a9..73849258c 100644
--- a/src/SAML2/XML/saml/SubjectConfirmationData.php
+++ b/src/SAML2/XML/saml/SubjectConfirmationData.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\XML\saml;
 
+use RobRichards\XMLSecLibs\XMLSecurityDSig;
 use SAML2\Utils;
 use SAML2\XML\Chunk;
 use SAML2\XML\ds\KeyInfo;
diff --git a/tests/SAML2/CertificatesMock.php b/tests/SAML2/CertificatesMock.php
index b4ce49715..0e5730004 100644
--- a/tests/SAML2/CertificatesMock.php
+++ b/tests/SAML2/CertificatesMock.php
@@ -2,6 +2,8 @@
 
 namespace SAML2;
 
+use RobRichards\XMLSecLibs\XMLSecurityKey;
+
 /**
  * Class \SAML2\CertificatesMock
  */
diff --git a/tests/SAML2/SignedElementHelperTest.php b/tests/SAML2/SignedElementHelperTest.php
index 6fa41f53d..90c9c6e0a 100644
--- a/tests/SAML2/SignedElementHelperTest.php
+++ b/tests/SAML2/SignedElementHelperTest.php
@@ -2,6 +2,8 @@
 
 namespace SAML2;
 
+use RobRichards\XMLSecLibs\XMLSecurityDSig;
+
 /**
  * Class \SAML2\SignedElementHelperTest
  */

From 4ffccff8c984c85de339b7d5bf5ec6bc782f46a6 Mon Sep 17 00:00:00 2001
From: Charles Bell <cb8@users.noreply.github.com>
Date: Sun, 29 Nov 2015 21:08:30 +0100
Subject: [PATCH 08/17] Fix wrong PHP namespaces

---
 src/SAML2/ArtifactResolve.php                 |   4 +-
 src/SAML2/ArtifactResponse.php                |  12 +-
 src/SAML2/Assertion.php                       | 136 ++++++++---------
 src/SAML2/Assertion/Decrypter.php             |   2 +-
 .../NameIdDecryptionTransformer.php           |   2 +-
 src/SAML2/AttributeQuery.php                  |  10 +-
 src/SAML2/AuthnRequest.php                    |  46 +++---
 src/SAML2/Binding.php                         |   8 +-
 .../InvalidCertificateStructureException.php  |   2 +-
 .../Exception/InvalidKeyUsageException.php    |   2 +-
 .../Exception/NoKeysFoundException.php        |   2 +-
 .../Certificate/FingerprintCollection.php     |   2 +-
 src/SAML2/Certificate/Key.php                 |   4 +-
 src/SAML2/Certificate/KeyCollection.php       |   2 +-
 src/SAML2/Certificate/PrivateKeyLoader.php    |   8 +-
 src/SAML2/DOMDocumentFactory.php              |  12 +-
 src/SAML2/EncryptedAssertion.php              |  22 +--
 .../Exception/InvalidArgumentException.php    |   2 +-
 src/SAML2/Exception/RuntimeException.php      |   2 +-
 .../Exception/UnparseableXmlException.php     |   2 +-
 src/SAML2/HTTPArtifact.php                    |  14 +-
 src/SAML2/HTTPPost.php                        |   4 +-
 src/SAML2/HTTPRedirect.php                    |  18 +--
 src/SAML2/LogoutRequest.php                   |  18 +--
 src/SAML2/LogoutResponse.php                  |   4 +-
 src/SAML2/Message.php                         |  40 ++---
 src/SAML2/Response.php                        |   6 +-
 .../Exception/UnsignedResponseException.php   |   2 +-
 src/SAML2/SOAP.php                            |   4 +-
 src/SAML2/SOAPClient.php                      |  20 +--
 .../Signature/AbstractChainedValidator.php    |   4 +-
 .../MissingConfigurationException.php         |   2 +-
 src/SAML2/SignedElementHelper.php             |  22 +--
 src/SAML2/StatusResponse.php                  |  12 +-
 src/SAML2/SubjectQuery.php                    |  20 +--
 src/SAML2/Utilities/ArrayCollection.php       |   8 +-
 src/SAML2/Utilities/Collection.php            |   6 +-
 src/SAML2/Utils.php                           | 144 +++++++++---------
 src/SAML2/XML/Chunk.php                       |  22 +--
 src/SAML2/XML/ds/KeyInfo.php                  |  12 +-
 src/SAML2/XML/ds/KeyName.php                  |  10 +-
 src/SAML2/XML/ds/X509Certificate.php          |  10 +-
 src/SAML2/XML/ds/X509Data.php                 |  12 +-
 .../XML/md/AdditionalMetadataLocation.php     |  14 +-
 src/SAML2/XML/md/AffiliationDescriptor.php    |  16 +-
 .../XML/md/AttributeAuthorityDescriptor.php   |  14 +-
 .../XML/md/AttributeConsumingService.php      |  18 +--
 src/SAML2/XML/md/AuthnAuthorityDescriptor.php |  14 +-
 src/SAML2/XML/md/ContactPerson.php            |  30 ++--
 src/SAML2/XML/md/EndpointType.php             |  20 +--
 src/SAML2/XML/md/EntitiesDescriptor.php       |  10 +-
 src/SAML2/XML/md/EntityDescriptor.php         |  28 ++--
 src/SAML2/XML/md/Extensions.php               |   8 +-
 src/SAML2/XML/md/IDPSSODescriptor.php         |  10 +-
 src/SAML2/XML/md/IndexedEndpointType.php      |  14 +-
 src/SAML2/XML/md/KeyDescriptor.php            |  18 +--
 src/SAML2/XML/md/Organization.php             |  10 +-
 src/SAML2/XML/md/PDPDescriptor.php            |  14 +-
 src/SAML2/XML/md/RequestedAttribute.php       |  10 +-
 src/SAML2/XML/md/RoleDescriptor.php           |  18 +--
 src/SAML2/XML/md/SPSSODescriptor.php          |   8 +-
 src/SAML2/XML/md/SSODescriptorType.php        |  10 +-
 src/SAML2/XML/md/UnknownRoleDescriptor.php    |   8 +-
 src/SAML2/XML/mdattr/EntityAttributes.php     |  10 +-
 src/SAML2/XML/mdrpi/PublicationInfo.php       |  14 +-
 src/SAML2/XML/mdrpi/RegistrationInfo.php      |  16 +-
 src/SAML2/XML/mdui/DiscoHints.php             |  10 +-
 src/SAML2/XML/mdui/Keywords.php               |  20 +--
 src/SAML2/XML/mdui/Logo.php                   |  18 +--
 src/SAML2/XML/mdui/UIInfo.php                 |  10 +-
 src/SAML2/XML/saml/Attribute.php              |  20 +--
 src/SAML2/XML/saml/AttributeValue.php         |  24 +--
 src/SAML2/XML/saml/NameID.php                 |  10 +-
 src/SAML2/XML/saml/SubjectConfirmation.php    |  22 +--
 .../XML/saml/SubjectConfirmationData.php      |  12 +-
 src/SAML2/XML/samlp/Extensions.php            |   8 +-
 src/SAML2/XML/shibmd/Scope.php                |  10 +-
 .../ConstraintValidator/NotBeforeTest.php     |   2 +-
 .../ConstraintValidator/NotOnOrAfterTest.php  |   2 +-
 .../SessionNotOnOrAfterTest.php               |   2 +-
 .../SpIsValidAudienceTest.php                 |   4 +-
 .../SubjectConfirmationMethodTest.php         |   2 +-
 .../SubjectConfirmationNotBeforeTest.php      |   4 +-
 .../SubjectConfirmationNotOnOrAfterTest.php   |   4 +-
 ...bjectConfirmationRecipientMathchesTest.php |   4 +-
 ...bjectConfirmationResponseToMatchesTest.php |   6 +-
 tests/SAML2/AssertionTest.php                 |  38 ++---
 tests/SAML2/AuthnRequestTest.php              |  12 +-
 .../Certificate/FingerprintLoaderTest.php     |   6 +-
 tests/SAML2/Certificate/FingerprintTest.php   |   2 +-
 tests/SAML2/Certificate/KeyLoaderTest.php     |   2 +-
 .../Certificate/PrivateKeyLoaderTest.php      |   2 +-
 tests/SAML2/Certificate/X509Test.php          |   2 +-
 .../SAML2/Configuration/ArrayAdapterTest.php  |   2 +-
 tests/SAML2/ControlledTimeTest.php            |   2 +-
 tests/SAML2/DOMDocumentFactoryTest.php        |   4 +-
 tests/SAML2/LogoutRequestTest.php             |   2 +-
 .../Response/SignatureValidationTest.php      |  20 +--
 .../DestinationMatchesTest.php                |   2 +-
 .../ConstraintValidator/IsSuccessfulTest.php  |   2 +-
 .../Response/XmlSignatureWrappingTest.php     |   2 +-
 tests/SAML2/ResponseTest.php                  |   2 +-
 .../Signature/FingerprintValidatorTest.php    |   4 +-
 .../Signature/PublicKeyValidatorTest.php      |   6 +-
 tests/SAML2/SignedElementHelperMock.php       |   6 +-
 tests/SAML2/StatusResponseTest.php            |   2 +-
 tests/SAML2/UtilsTest.php                     |   4 +-
 .../XML/md/AdditionalMetadataLocationTest.php |   2 +-
 .../XML/md/AffiliationDescriptorTest.php      |   2 +-
 tests/SAML2/XML/md/EndpointTypeTest.php       |   2 +-
 tests/SAML2/XML/md/RoleDescriptorMock.php     |   4 +-
 111 files changed, 678 insertions(+), 678 deletions(-)

diff --git a/src/SAML2/ArtifactResolve.php b/src/SAML2/ArtifactResolve.php
index cc8422645..eb69ddc20 100644
--- a/src/SAML2/ArtifactResolve.php
+++ b/src/SAML2/ArtifactResolve.php
@@ -13,7 +13,7 @@ class ArtifactResolve extends Request
 {
     private $artifact;
 
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct('ArtifactResolve', $xml);
 
@@ -48,7 +48,7 @@ public function setArtifact($artifact)
     /**
      * Convert the response message to an XML element.
      *
-     * @return DOMElement This response.
+     * @return \DOMElement This response.
      */
     public function toUnsignedXML()
     {
diff --git a/src/SAML2/ArtifactResponse.php b/src/SAML2/ArtifactResponse.php
index 2af6b18ba..bb3e1d8ab 100644
--- a/src/SAML2/ArtifactResponse.php
+++ b/src/SAML2/ArtifactResponse.php
@@ -11,15 +11,15 @@
 class ArtifactResponse extends StatusResponse
 {
     /**
-     * The DOMElement with the message the artifact refers
+     * The \DOMElement with the message the artifact refers
      * to, or NULL if we don't refer to any artifact.
      *
-     * @var DOMElement|NULL
+     * @var \DOMElement|NULL
      */
     private $any;
 
 
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct('ArtifactResponse', $xml);
 
@@ -31,7 +31,7 @@ public function __construct(DOMElement $xml = NULL)
             $status = $status[0];
 
             for ($any = $status->nextSibling; $any !== NULL; $any = $any->nextSibling) {
-                if ($any instanceof DOMElement) {
+                if ($any instanceof \DOMElement) {
                     $this->any = $any;
                     break;
                 }
@@ -41,7 +41,7 @@ public function __construct(DOMElement $xml = NULL)
 
     }
 
-    public function setAny(DOMElement $any = NULL)
+    public function setAny(\DOMElement $any = NULL)
     {
         $this->any = $any;
     }
@@ -54,7 +54,7 @@ public function getAny()
     /**
      * Convert the response message to an XML element.
      *
-     * @return DOMElement This response.
+     * @return \DOMElement This response.
      */
     public function toUnsignedXML()
     {
diff --git a/src/SAML2/Assertion.php b/src/SAML2/Assertion.php
index 7cca7b9ca..383e770e2 100644
--- a/src/SAML2/Assertion.php
+++ b/src/SAML2/Assertion.php
@@ -50,7 +50,7 @@ class Assertion implements SignedElement
      *
      * If this is not NULL, the NameId needs decryption before it can be accessed.
      *
-     * @var DOMElement|NULL
+     * @var \DOMElement|NULL
      */
     private $encryptedNameId;
 
@@ -59,7 +59,7 @@ class Assertion implements SignedElement
      *
      * If this is not NULL, these Attributes need decryption before they can be accessed.
      *
-     * @var DOMElement[]|NULL
+     * @var \DOMElement[]|NULL
      */
     private $encryptedAttributes;
 
@@ -154,7 +154,7 @@ class Assertion implements SignedElement
     /**
      * The attributes, as an associative array.
      *
-     * @var DOMElement[]
+     * @var \DOMElement[]
      */
     private $attributes;
 
@@ -214,10 +214,10 @@ class Assertion implements SignedElement
     /**
      * Constructor for SAML 2 assertions.
      *
-     * @param DOMElement|NULL $xml The input assertion.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The input assertion.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         $this->id = Utils::getContainer()->generateId();
         $this->issueInstant = Temporal::getTime();
@@ -234,20 +234,20 @@ public function __construct(DOMElement $xml = NULL)
         }
 
         if (!$xml->hasAttribute('ID')) {
-            throw new Exception('Missing ID attribute on SAML assertion.');
+            throw new \Exception('Missing ID attribute on SAML assertion.');
         }
         $this->id = $xml->getAttribute('ID');
 
         if ($xml->getAttribute('Version') !== '2.0') {
             /* Currently a very strict check. */
-            throw new Exception('Unsupported version: ' . $xml->getAttribute('Version'));
+            throw new \Exception('Unsupported version: ' . $xml->getAttribute('Version'));
         }
 
         $this->issueInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('IssueInstant'));
 
         $issuer = Utils::xpQuery($xml, './saml_assertion:Issuer');
         if (empty($issuer)) {
-            throw new Exception('Missing <saml:Issuer> in assertion.');
+            throw new \Exception('Missing <saml:Issuer> in assertion.');
         }
         $this->issuer = trim($issuer[0]->textContent);
 
@@ -262,10 +262,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Parse subject in assertion.
      *
-     * @param DOMElement $xml The assertion XML element.
-     * @throws Exception
+     * @param \DOMElement $xml The assertion XML element.
+     * @throws \Exception
      */
-    private function parseSubject(DOMElement $xml)
+    private function parseSubject(\DOMElement $xml)
     {
         $subject = Utils::xpQuery($xml, './saml_assertion:Subject');
         if (empty($subject)) {
@@ -273,7 +273,7 @@ private function parseSubject(DOMElement $xml)
 
             return;
         } elseif (count($subject) > 1) {
-            throw new Exception('More than one <saml:Subject> in <saml:Assertion>.');
+            throw new \Exception('More than one <saml:Subject> in <saml:Assertion>.');
         }
         $subject = $subject[0];
 
@@ -282,9 +282,9 @@ private function parseSubject(DOMElement $xml)
             './saml_assertion:NameID | ./saml_assertion:EncryptedID/xenc:EncryptedData'
         );
         if (empty($nameId)) {
-            throw new Exception('Missing <saml:NameID> or <saml:EncryptedID> in <saml:Subject>.');
+            throw new \Exception('Missing <saml:NameID> or <saml:EncryptedID> in <saml:Subject>.');
         } elseif (count($nameId) > 1) {
-            throw new Exception('More than one <saml:NameID> or <saml:EncryptedD> in <saml:Subject>.');
+            throw new \Exception('More than one <saml:NameID> or <saml:EncryptedD> in <saml:Subject>.');
         }
         $nameId = $nameId[0];
         if ($nameId->localName === 'EncryptedData') {
@@ -296,7 +296,7 @@ private function parseSubject(DOMElement $xml)
 
         $subjectConfirmation = Utils::xpQuery($subject, './saml_assertion:SubjectConfirmation');
         if (empty($subjectConfirmation)) {
-            throw new Exception('Missing <saml:SubjectConfirmation> in <saml:Subject>.');
+            throw new \Exception('Missing <saml:SubjectConfirmation> in <saml:Subject>.');
         }
 
         foreach ($subjectConfirmation as $sc) {
@@ -307,10 +307,10 @@ private function parseSubject(DOMElement $xml)
     /**
      * Parse conditions in assertion.
      *
-     * @param DOMElement $xml The assertion XML element.
-     * @throws Exception
+     * @param \DOMElement $xml The assertion XML element.
+     * @throws \Exception
      */
-    private function parseConditions(DOMElement $xml)
+    private function parseConditions(\DOMElement $xml)
     {
         $conditions = Utils::xpQuery($xml, './saml_assertion:Conditions');
         if (empty($conditions)) {
@@ -318,7 +318,7 @@ private function parseConditions(DOMElement $xml)
 
             return;
         } elseif (count($conditions) > 1) {
-            throw new Exception('More than one <saml:Conditions> in <saml:Assertion>.');
+            throw new \Exception('More than one <saml:Conditions> in <saml:Assertion>.');
         }
         $conditions = $conditions[0];
 
@@ -336,11 +336,11 @@ private function parseConditions(DOMElement $xml)
         }
 
         for ($node = $conditions->firstChild; $node !== NULL; $node = $node->nextSibling) {
-            if ($node instanceof DOMText) {
+            if ($node instanceof \DOMText) {
                 continue;
             }
             if ($node->namespaceURI !== Constants::NS_SAML) {
-                throw new Exception('Unknown namespace of condition: ' . var_export($node->namespaceURI, TRUE));
+                throw new \Exception('Unknown namespace of condition: ' . var_export($node->namespaceURI, TRUE));
             }
             switch ($node->localName) {
                 case 'AudienceRestriction':
@@ -364,7 +364,7 @@ private function parseConditions(DOMElement $xml)
                     /* Currently ignored. */
                     break;
                 default:
-                    throw new Exception('Unknown condition: ' . var_export($node->localName, TRUE));
+                    throw new \Exception('Unknown condition: ' . var_export($node->localName, TRUE));
             }
         }
 
@@ -373,10 +373,10 @@ private function parseConditions(DOMElement $xml)
     /**
      * Parse AuthnStatement in assertion.
      *
-     * @param DOMElement $xml The assertion XML element.
-     * @throws Exception
+     * @param \DOMElement $xml The assertion XML element.
+     * @throws \Exception
      */
-    private function parseAuthnStatement(DOMElement $xml)
+    private function parseAuthnStatement(\DOMElement $xml)
     {
         $authnStatements = Utils::xpQuery($xml, './saml_assertion:AuthnStatement');
         if (empty($authnStatements)) {
@@ -384,12 +384,12 @@ private function parseAuthnStatement(DOMElement $xml)
 
             return;
         } elseif (count($authnStatements) > 1) {
-            throw new Exception('More that one <saml:AuthnStatement> in <saml:Assertion> not supported.');
+            throw new \Exception('More that one <saml:AuthnStatement> in <saml:Assertion> not supported.');
         }
         $authnStatement = $authnStatements[0];
 
         if (!$authnStatement->hasAttribute('AuthnInstant')) {
-            throw new Exception('Missing required AuthnInstant attribute on <saml:AuthnStatement>.');
+            throw new \Exception('Missing required AuthnInstant attribute on <saml:AuthnStatement>.');
         }
         $this->authnInstant = Utils::xsDateTimeToTimestamp($authnStatement->getAttribute('AuthnInstant'));
 
@@ -407,24 +407,24 @@ private function parseAuthnStatement(DOMElement $xml)
     /**
      * Parse AuthnContext in AuthnStatement.
      *
-     * @param DOMElement $authnStatementEl
-     * @throws Exception
+     * @param \DOMElement $authnStatementEl
+     * @throws \Exception
      */
-    private function parseAuthnContext(DOMElement $authnStatementEl)
+    private function parseAuthnContext(\DOMElement $authnStatementEl)
     {
         // Get the AuthnContext element
         $authnContexts = Utils::xpQuery($authnStatementEl, './saml_assertion:AuthnContext');
         if (count($authnContexts) > 1) {
-            throw new Exception('More than one <saml:AuthnContext> in <saml:AuthnStatement>.');
+            throw new \Exception('More than one <saml:AuthnContext> in <saml:AuthnStatement>.');
         } elseif (empty($authnContexts)) {
-            throw new Exception('Missing required <saml:AuthnContext> in <saml:AuthnStatement>.');
+            throw new \Exception('Missing required <saml:AuthnContext> in <saml:AuthnStatement>.');
         }
         $authnContextEl = $authnContexts[0];
 
         // Get the AuthnContextDeclRef (if available)
         $authnContextDeclRefs = Utils::xpQuery($authnContextEl, './saml_assertion:AuthnContextDeclRef');
         if (count($authnContextDeclRefs) > 1) {
-            throw new Exception(
+            throw new \Exception(
                 'More than one <saml:AuthnContextDeclRef> found?'
             );
         } elseif (count($authnContextDeclRefs) === 1) {
@@ -434,7 +434,7 @@ private function parseAuthnContext(DOMElement $authnStatementEl)
         // Get the AuthnContextDecl (if available)
         $authnContextDecls = Utils::xpQuery($authnContextEl, './saml_assertion:AuthnContextDecl');
         if (count($authnContextDecls) > 1) {
-            throw new Exception(
+            throw new \Exception(
                 'More than one <saml:AuthnContextDecl> found?'
             );
         } elseif (count($authnContextDecls) === 1) {
@@ -444,14 +444,14 @@ private function parseAuthnContext(DOMElement $authnStatementEl)
         // Get the AuthnContextClassRef (if available)
         $authnContextClassRefs = Utils::xpQuery($authnContextEl, './saml_assertion:AuthnContextClassRef');
         if (count($authnContextClassRefs) > 1) {
-            throw new Exception('More than one <saml:AuthnContextClassRef> in <saml:AuthnContext>.');
+            throw new \Exception('More than one <saml:AuthnContextClassRef> in <saml:AuthnContext>.');
         } elseif (count($authnContextClassRefs) === 1) {
             $this->setAuthnContextClassRef(trim($authnContextClassRefs[0]->textContent));
         }
 
         // Constraint from XSD: MUST have one of the three
         if (empty($this->authnContextClassRef) && empty($this->authnContextDecl) && empty($this->authnContextDeclRef)) {
-            throw new Exception(
+            throw new \Exception(
                 'Missing either <saml:AuthnContextClassRef> or <saml:AuthnContextDeclRef> or <saml:AuthnContextDecl>'
             );
         }
@@ -466,16 +466,16 @@ private function parseAuthnContext(DOMElement $authnStatementEl)
     /**
      * Parse attribute statements in assertion.
      *
-     * @param DOMElement $xml The XML element with the assertion.
-     * @throws Exception
+     * @param \DOMElement $xml The XML element with the assertion.
+     * @throws \Exception
      */
-    private function parseAttributes(DOMElement $xml)
+    private function parseAttributes(\DOMElement $xml)
     {
         $firstAttribute = TRUE;
         $attributes = Utils::xpQuery($xml, './saml_assertion:AttributeStatement/saml_assertion:Attribute');
         foreach ($attributes as $attribute) {
             if (!$attribute->hasAttribute('Name')) {
-                throw new Exception('Missing name on <saml:Attribute> element.');
+                throw new \Exception('Missing name on <saml:Attribute> element.');
             }
             $name = $attribute->getAttribute('Name');
 
@@ -508,9 +508,9 @@ private function parseAttributes(DOMElement $xml)
     /**
      * Parse encrypted attribute statements in assertion.
      *
-     * @param DOMElement $xml The XML element with the assertion.
+     * @param \DOMElement $xml The XML element with the assertion.
      */
-    private function parseEncryptedAttributes(DOMElement $xml)
+    private function parseEncryptedAttributes(\DOMElement $xml)
     {
         $this->encryptedAttributes = Utils::xpQuery(
             $xml,
@@ -521,9 +521,9 @@ private function parseEncryptedAttributes(DOMElement $xml)
     /**
      * Parse signature on assertion.
      *
-     * @param DOMElement $xml The assertion XML element.
+     * @param \DOMElement $xml The assertion XML element.
      */
-    private function parseSignature(DOMElement $xml)
+    private function parseSignature(\DOMElement $xml)
     {
         /* Validate the signature element of the message. */
         $sig = Utils::validateElement($xml);
@@ -630,12 +630,12 @@ public function setIssuer($issuer)
      *
      * @see \SAML2\Utils::addNameId()
      * @return array|NULL The name identifier of the assertion.
-     * @throws Exception
+     * @throws \Exception
      */
     public function getNameId()
     {
         if ($this->encryptedNameId !== NULL) {
-            throw new Exception('Attempted to retrieve encrypted NameID without decrypting it first.');
+            throw new \Exception('Attempted to retrieve encrypted NameID without decrypting it first.');
         }
 
         return $this->nameId;
@@ -733,7 +733,7 @@ public function hasEncryptedAttributes()
      *
      * @param XMLSecurityKey $key
      * @param array $blacklist
-     * @throws Exception
+     * @throws \Exception
      */
     public function decryptAttributes(XMLSecurityKey $key, array $blacklist = array())
     {
@@ -751,7 +751,7 @@ public function decryptAttributes(XMLSecurityKey $key, array $blacklist = array(
             );
 
             if (!$attribute->hasAttribute('Name')) {
-                throw new Exception('Missing name on <saml:Attribute> element.');
+                throw new \Exception('Missing name on <saml:Attribute> element.');
             }
             $name = $attribute->getAttribute('Name');
 
@@ -1015,12 +1015,12 @@ public function setAuthnContextClassRef($authnContextClassRef)
      * Set the authentication context declaration.
      *
      * @param \SAML2\XML\Chunk $authnContextDecl
-     * @throws Exception
+     * @throws \Exception
      */
     public function setAuthnContextDecl(Chunk $authnContextDecl)
     {
         if (!empty($this->authnContextDeclRef)) {
-            throw new Exception(
+            throw new \Exception(
                 'AuthnContextDeclRef is already registered! May only have either a Decl or a DeclRef, not both!'
             );
         }
@@ -1045,12 +1045,12 @@ public function getAuthnContextDecl()
      * Set the authentication context declaration reference.
      *
      * @param string $authnContextDeclRef
-     * @throws Exception
+     * @throws \Exception
      */
     public function setAuthnContextDeclRef($authnContextDeclRef)
     {
         if (!empty($this->authnContextDecl)) {
-            throw new Exception(
+            throw new \Exception(
                 'AuthnContextDecl is already registered! May only have either a Decl or a DeclRef, not both!'
             );
         }
@@ -1234,10 +1234,10 @@ public function getWasSignedAtConstruction()
     /**
      * Convert this assertion to an XML element.
      *
-     * @param  DOMNode|NULL $parentElement The DOM node the assertion should be created in.
-     * @return DOMElement   This assertion.
+     * @param  \DOMNode|NULL $parentElement The DOM node the assertion should be created in.
+     * @return \DOMElement   This assertion.
      */
-    public function toXML(DOMNode $parentElement = NULL)
+    public function toXML(\DOMNode $parentElement = NULL)
     {
         if ($parentElement === NULL) {
             $document = DOMDocumentFactory::create();
@@ -1282,9 +1282,9 @@ public function toXML(DOMNode $parentElement = NULL)
     /**
      * Add a Subject-node to the assertion.
      *
-     * @param DOMElement $root The assertion element we should add the subject to.
+     * @param \DOMElement $root The assertion element we should add the subject to.
      */
-    private function addSubject(DOMElement $root)
+    private function addSubject(\DOMElement $root)
     {
         if ($this->nameId === NULL && $this->encryptedNameId === NULL) {
             /* We don't have anything to create a Subject node for. */
@@ -1312,9 +1312,9 @@ private function addSubject(DOMElement $root)
     /**
      * Add a Conditions-node to the assertion.
      *
-     * @param DOMElement $root The assertion element we should add the conditions to.
+     * @param \DOMElement $root The assertion element we should add the conditions to.
      */
-    private function addConditions(DOMElement $root)
+    private function addConditions(\DOMElement $root)
     {
         $document = $root->ownerDocument;
 
@@ -1340,9 +1340,9 @@ private function addConditions(DOMElement $root)
     /**
      * Add a AuthnStatement-node to the assertion.
      *
-     * @param DOMElement $root The assertion element we should add the authentication statement to.
+     * @param \DOMElement $root The assertion element we should add the authentication statement to.
      */
-    private function addAuthnStatement(DOMElement $root)
+    private function addAuthnStatement(\DOMElement $root)
     {
         if ($this->authnInstant === NULL ||
             (
@@ -1406,9 +1406,9 @@ private function addAuthnStatement(DOMElement $root)
     /**
      * Add an AttributeStatement-node to the assertion.
      *
-     * @param DOMElement $root The assertion element we should add the subject to.
+     * @param \DOMElement $root The assertion element we should add the subject to.
      */
-    private function addAttributeStatement(DOMElement $root)
+    private function addAttributeStatement(\DOMElement $root)
     {
         if (empty($this->attributes)) {
             return;
@@ -1446,7 +1446,7 @@ private function addAttributeStatement(DOMElement $root)
                     $attributeValue->setAttributeNS(Constants::NS_XSI, 'xsi:nil', 'true');
                 }
 
-                if ($value instanceof DOMNodeList) {
+                if ($value instanceof \DOMNodeList) {
                     for ($i = 0; $i < $value->length; $i++) {
                         $node = $document->importNode($value->item($i), TRUE);
                         $attributeValue->appendChild($node);
@@ -1462,9 +1462,9 @@ private function addAttributeStatement(DOMElement $root)
     /**
      * Add an EncryptedAttribute Statement-node to the assertion.
      *
-     * @param DOMElement $root The assertion element we should add the Encrypted Attribute Statement to.
+     * @param \DOMElement $root The assertion element we should add the Encrypted Attribute Statement to.
      */
-    private function addEncryptedAttributeStatement(DOMElement $root)
+    private function addEncryptedAttributeStatement(\DOMElement $root)
     {
         if ($this->requiredEncAttributes == FALSE) {
             return;
@@ -1500,7 +1500,7 @@ private function addEncryptedAttributeStatement(DOMElement $root)
                     $attributeValue->setAttributeNS(Constants::NS_XSI, 'xsi:type', $type);
                 }
 
-                if ($value instanceof DOMNodeList) {
+                if ($value instanceof \DOMNodeList) {
                     for ($i = 0; $i < $value->length; $i++) {
                         $node = $document2->importNode($value->item($i), TRUE);
                         $attributeValue->appendChild($node);
diff --git a/src/SAML2/Assertion/Decrypter.php b/src/SAML2/Assertion/Decrypter.php
index 7835b2223..54723f23b 100644
--- a/src/SAML2/Assertion/Decrypter.php
+++ b/src/SAML2/Assertion/Decrypter.php
@@ -73,7 +73,7 @@ public function decrypt(EncryptedAssertion $assertion)
 
                 return $decryptedAssertion;
 
-            } catch (Exception $e) {
+            } catch (\Exception $e) {
                 $this->logger->debug(sprintf(
                     'Could not decrypt assertion with key "#%d", "%s" thrown: "%s"',
                     $index,
diff --git a/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php b/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
index 56c9c4118..2e979e7d4 100644
--- a/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
+++ b/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
@@ -58,7 +58,7 @@ public function transform(Assertion $assertion)
             try {
                 $assertion->decryptNameId($key, $blacklistedKeys);
                 $this->logger->debug(sprintf('Decrypted assertion NameId with key "#%d"', $index));
-            } catch (Exception $e) {
+            } catch (\Exception $e) {
                 $this->logger->debug(sprintf(
                     'Decrypting assertion NameId with key "#%d" failed, "%s" thrown: "%s"',
                     $index,
diff --git a/src/SAML2/AttributeQuery.php b/src/SAML2/AttributeQuery.php
index 8a90ef86e..6d38274c3 100644
--- a/src/SAML2/AttributeQuery.php
+++ b/src/SAML2/AttributeQuery.php
@@ -39,10 +39,10 @@ class AttributeQuery extends SubjectQuery
     /**
      * Constructor for SAML 2 attribute query messages.
      *
-     * @param DOMElement|NULL $xml The input message.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The input message.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct('AttributeQuery', $xml);
 
@@ -57,7 +57,7 @@ public function __construct(DOMElement $xml = NULL)
         $attributes = Utils::xpQuery($xml, './saml_assertion:Attribute');
         foreach ($attributes as $attribute) {
             if (!$attribute->hasAttribute('Name')) {
-                throw new Exception('Missing name on <saml:Attribute> element.');
+                throw new \Exception('Missing name on <saml:Attribute> element.');
             }
             $name = $attribute->getAttribute('Name');
 
@@ -135,7 +135,7 @@ public function setAttributeNameFormat($nameFormat)
     /**
      * Convert the attribute query message to an XML element.
      *
-     * @return DOMElement This attribute query.
+     * @return \DOMElement This attribute query.
      */
     public function toUnsignedXML()
     {
diff --git a/src/SAML2/AuthnRequest.php b/src/SAML2/AuthnRequest.php
index 3b137a4d2..3a42f2750 100644
--- a/src/SAML2/AuthnRequest.php
+++ b/src/SAML2/AuthnRequest.php
@@ -125,10 +125,10 @@ class AuthnRequest extends Request
     /**
      * Constructor for SAML 2 authentication request messages.
      *
-     * @param DOMElement|NULL $xml The input message.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The input message.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct('AuthnRequest', $xml);
 
@@ -168,9 +168,9 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * @param $xml
      *
-     * @throws Exception
+     * @throws \Exception
      */
-    private function parseSubject(DOMElement $xml)
+    private function parseSubject(\DOMElement $xml)
     {
         $subject = Utils::xpQuery($xml, './saml_assertion:Subject');
         if (empty($subject)) {
@@ -178,7 +178,7 @@ private function parseSubject(DOMElement $xml)
         }
 
         if (count($subject) > 1) {
-            throw new Exception('More than one <saml:Subject> in <saml:AuthnRequest>.');
+            throw new \Exception('More than one <saml:Subject> in <saml:AuthnRequest>.');
         }
         $subject = $subject[0];
 
@@ -187,9 +187,9 @@ private function parseSubject(DOMElement $xml)
             './saml_assertion:NameID | ./saml_assertion:EncryptedID/xenc:EncryptedData'
         );
         if (empty($nameId)) {
-            throw new Exception('Missing <saml:NameID> or <saml:EncryptedID> in <saml:Subject>.');
+            throw new \Exception('Missing <saml:NameID> or <saml:EncryptedID> in <saml:Subject>.');
         } elseif (count($nameId) > 1) {
-            throw new Exception('More than one <saml:NameID> or <saml:EncryptedID> in <saml:Subject>.');
+            throw new \Exception('More than one <saml:NameID> or <saml:EncryptedID> in <saml:Subject>.');
         }
         $nameId = $nameId[0];
         if ($nameId->localName === 'EncryptedData') {
@@ -206,11 +206,11 @@ private function parseSubject(DOMElement $xml)
     }
 
     /**
-     * @param DOMElement $xml
+     * @param \DOMElement $xml
      *
-     * @throws Exception
+     * @throws \Exception
      */
-    protected function parseNameIdPolicy(DOMElement $xml)
+    protected function parseNameIdPolicy(\DOMElement $xml)
     {
         $nameIdPolicy = Utils::xpQuery($xml, './saml_protocol:NameIDPolicy');
         if (empty($nameIdPolicy)) {
@@ -230,9 +230,9 @@ protected function parseNameIdPolicy(DOMElement $xml)
     }
 
     /**
-     * @param DOMElement $xml
+     * @param \DOMElement $xml
      */
-    protected function parseRequestedAuthnContext(DOMElement $xml)
+    protected function parseRequestedAuthnContext(\DOMElement $xml)
     {
         $requestedAuthnContext = Utils::xpQuery($xml, './saml_protocol:RequestedAuthnContext');
         if (empty($requestedAuthnContext)) {
@@ -259,11 +259,11 @@ protected function parseRequestedAuthnContext(DOMElement $xml)
     }
 
     /**
-     * @param DOMElement $xml
+     * @param \DOMElement $xml
      *
-     * @throws Exception
+     * @throws \Exception
      */
-    protected function parseScoping(DOMElement $xml)
+    protected function parseScoping(\DOMElement $xml)
     {
         $scoping = Utils::xpQuery($xml, './saml_protocol:Scoping');
         if (empty($scoping)) {
@@ -279,7 +279,7 @@ protected function parseScoping(DOMElement $xml)
 
         foreach ($idpEntries as $idpEntry) {
             if (!$idpEntry->hasAttribute('ProviderID')) {
-                throw new Exception("Could not get ProviderID from Scoping/IDPEntry element in AuthnRequest object");
+                throw new \Exception("Could not get ProviderID from Scoping/IDPEntry element in AuthnRequest object");
             }
             $this->IDPList[] = $idpEntry->getAttribute('ProviderID');
         }
@@ -570,12 +570,12 @@ public function setRequestedAuthnContext($requestedAuthnContext)
      *
      * @see \SAML2\Utils::addNameId()
      * @return array|NULL The name identifier of the assertion.
-     * @throws Exception
+     * @throws \Exception
      */
     public function getNameId()
     {
         if ($this->encryptedNameId !== NULL) {
-            throw new Exception('Attempted to retrieve encrypted NameID without decrypting it first.');
+            throw new \Exception('Attempted to retrieve encrypted NameID without decrypting it first.');
         }
 
         return $this->nameId;
@@ -605,7 +605,7 @@ public function setNameId($nameId)
     public function encryptNameId(XMLSecurityKey $key)
     {
         /* First create a XML representation of the NameID. */
-        $doc  = new DOMDocument();
+        $doc  = new \DOMDocument();
         $root = $doc->createElement('root');
         $doc->appendChild($root);
         Utils::addNameId($root, $this->nameId);
@@ -671,7 +671,7 @@ public function setSubjectConfirmation(array $subjectConfirmation)
     /**
      * Convert this authentication request to an XML element.
      *
-     * @return DOMElement This authentication request.
+     * @return \DOMElement This authentication request.
      */
     public function toUnsignedXML()
     {
@@ -770,9 +770,9 @@ public function toUnsignedXML()
     /**
      * Add a Subject-node to the assertion.
      *
-     * @param DOMElement $root The assertion element we should add the subject to.
+     * @param \DOMElement $root The assertion element we should add the subject to.
      */
-    private function addSubject(DOMElement $root)
+    private function addSubject(\DOMElement $root)
     {
         // If there is no nameId (encrypted or not) there is nothing to create a subject for
         if ($this->nameId === NULL && $this->encryptedNameId === NULL) {
diff --git a/src/SAML2/Binding.php b/src/SAML2/Binding.php
index 0f608464d..5728292d0 100644
--- a/src/SAML2/Binding.php
+++ b/src/SAML2/Binding.php
@@ -23,7 +23,7 @@ abstract class Binding
      *
      * @param  string        $urn The URN of the binding.
      * @return \SAML2\Binding The binding.
-     * @throws Exception
+     * @throws \Exception
      */
     public static function getBinding($urn)
     {
@@ -39,7 +39,7 @@ public static function getBinding($urn)
             case Constants::BINDING_HOK_SSO:
                 return new HTTPPost();
             default:
-                throw new Exception('Unsupported binding: ' . var_export($urn, TRUE));
+                throw new \Exception('Unsupported binding: ' . var_export($urn, TRUE));
         }
     }
 
@@ -52,7 +52,7 @@ public static function getBinding($urn)
      * An exception will be thrown if it is unable to guess the binding.
      *
      * @return \SAML2\Binding The binding.
-     * @throws Exception
+     * @throws \Exception
      */
     public static function getCurrentBinding()
     {
@@ -96,7 +96,7 @@ public static function getCurrentBinding()
             $logger->warning('Content-Type: ' . var_export($_SERVER['CONTENT_TYPE'], TRUE));
         }
 
-        throw new Exception('Unable to find the current binding.');
+        throw new \Exception('Unable to find the current binding.');
     }
 
     /**
diff --git a/src/SAML2/Certificate/Exception/InvalidCertificateStructureException.php b/src/SAML2/Certificate/Exception/InvalidCertificateStructureException.php
index a82de953c..1ac6d5078 100644
--- a/src/SAML2/Certificate/Exception/InvalidCertificateStructureException.php
+++ b/src/SAML2/Certificate/Exception/InvalidCertificateStructureException.php
@@ -8,7 +8,7 @@
  * Named Exception for what the name describes. This should not occur, as it has to be
  * caught on the configuration side.
  */
-class InvalidCertificateStructureException extends DomainException implements
+class InvalidCertificateStructureException extends \DomainException implements
     Throwable
 {
 }
diff --git a/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php b/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php
index 29c65bbc5..967f27e29 100644
--- a/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php
+++ b/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php
@@ -8,7 +8,7 @@
 /**
  * Named exception for when a non-existent key-usage is given
  */
-class InvalidKeyUsageException extends InvalidArgumentException implements
+class InvalidKeyUsageException extends \InvalidArgumentException implements
     Throwable
 {
     /**
diff --git a/src/SAML2/Certificate/Exception/NoKeysFoundException.php b/src/SAML2/Certificate/Exception/NoKeysFoundException.php
index deebc5ef8..aa1886e21 100644
--- a/src/SAML2/Certificate/Exception/NoKeysFoundException.php
+++ b/src/SAML2/Certificate/Exception/NoKeysFoundException.php
@@ -7,6 +7,6 @@
 /**
  * Named exception. Indicates that although required, no keys could be loaded from the configuration
  */
-class NoKeysFoundException extends DomainException implements Throwable
+class NoKeysFoundException extends \DomainException implements Throwable
 {
 }
diff --git a/src/SAML2/Certificate/FingerprintCollection.php b/src/SAML2/Certificate/FingerprintCollection.php
index ccd234529..efa35c743 100644
--- a/src/SAML2/Certificate/FingerprintCollection.php
+++ b/src/SAML2/Certificate/FingerprintCollection.php
@@ -19,7 +19,7 @@ public function add($fingerprint)
     {
         if (!$fingerprint instanceof Fingerprint) {
             throw InvalidArgumentException::invalidType(
-                'SAML2_Certificate_Fingerprint ',
+                'SAML2\Certificate\Fingerprint ',
                 $fingerprint
             );
         }
diff --git a/src/SAML2/Certificate/Key.php b/src/SAML2/Certificate/Key.php
index 7a7fb0433..98e14715c 100644
--- a/src/SAML2/Certificate/Key.php
+++ b/src/SAML2/Certificate/Key.php
@@ -9,7 +9,7 @@
  * Simple DTO wrapper for (X509) keys. Implements ArrayAccess
  * for easier backwards compatibility.
  */
-class Key implements ArrayAccess
+class Key implements \ArrayAccess
 {
     // Possible key usages
     const USAGE_SIGNING = 'signing';
@@ -88,7 +88,7 @@ public function offsetUnset($offset)
      * Asserts that the parameter is of type string
      * @param mixed $test
      *
-     * @throws Exception
+     * @throws \Exception
      */
     protected function assertIsString($test)
     {
diff --git a/src/SAML2/Certificate/KeyCollection.php b/src/SAML2/Certificate/KeyCollection.php
index 6ff2e323e..62bb5326d 100644
--- a/src/SAML2/Certificate/KeyCollection.php
+++ b/src/SAML2/Certificate/KeyCollection.php
@@ -19,7 +19,7 @@ public function add($key)
     {
         if (!$key instanceof Key) {
             throw InvalidArgumentException::invalidType(
-                'SAML2_Certificate_Key',
+                'SAML2\Certificate\Key',
                 $key
             );
         }
diff --git a/src/SAML2/Certificate/PrivateKeyLoader.php b/src/SAML2/Certificate/PrivateKeyLoader.php
index 711875669..394324f91 100644
--- a/src/SAML2/Certificate/PrivateKeyLoader.php
+++ b/src/SAML2/Certificate/PrivateKeyLoader.php
@@ -3,7 +3,7 @@
 namespace SAML2\Certificate;
 
 use RobRichards\XMLSecLibs\XMLSecurityKey;
-use SAML2\Configuration\PrivateKey;
+use SAML2\Configuration\PrivateKey as PrivateKeyConfiguration;
 use SAML2\Utilities\File;
 use SAML2\Configuration\DecryptionProvider;
 use SAML2\Utilities\ArrayCollection;
@@ -17,7 +17,7 @@ class PrivateKeyLoader
      *
      * @return \SAML2\Certificate\PrivateKey
      */
-    public function loadPrivateKey(PrivateKey $key)
+    public function loadPrivateKey(PrivateKeyConfiguration $key)
     {
         $privateKey = File::getFileContents($key->getFilePath());
 
@@ -29,7 +29,7 @@ public function loadPrivateKey(PrivateKey $key)
      * @param \SAML2\Configuration\DecryptionProvider $serviceProvider
      *
      * @return \SAML2\Utilities\ArrayCollection
-     * @throws Exception
+     * @throws \Exception
      */
     public function loadDecryptionKeys(
         DecryptionProvider $identityProvider,
@@ -63,7 +63,7 @@ public function loadDecryptionKeys(
      * @param \SAML2\Certificate\PrivateKey $privateKey
      *
      * @return XMLSecurityKey
-     * @throws Exception
+     * @throws \Exception
      */
     private function convertPrivateKeyToRsaKey(PrivateKey $privateKey)
     {
diff --git a/src/SAML2/DOMDocumentFactory.php b/src/SAML2/DOMDocumentFactory.php
index 232254bf9..a1f757bd9 100644
--- a/src/SAML2/DOMDocumentFactory.php
+++ b/src/SAML2/DOMDocumentFactory.php
@@ -15,7 +15,7 @@ private function __construct()
     /**
      * @param string $xml
      *
-     * @return DOMDocument
+     * @return \DOMDocument
      */
     public static function fromString($xml)
     {
@@ -61,7 +61,7 @@ public static function fromString($xml)
     /**
      * @param $file
      *
-     * @return DOMDocument
+     * @return \DOMDocument
      */
     public static function fromFile($file)
     {
@@ -77,8 +77,8 @@ public static function fromFile($file)
             throw new InvalidArgumentException(sprintf('File "%s" is not readable', $file));
         }
 
-        // libxml_disable_entity_loader(true) disables DOMDocument::load() method
-        // so we need to read the content and use DOMDocument::loadXML()
+        // libxml_disable_entity_loader(true) disables \DOMDocument::load() method
+        // so we need to read the content and use \DOMDocument::loadXML()
         $xml = file_get_contents($file);
         if ($xml === FALSE) {
             throw new RuntimeException(sprintf(
@@ -95,10 +95,10 @@ public static function fromFile($file)
     }
 
     /**
-     * @return DOMDocument
+     * @return \DOMDocument
      */
     public static function create()
     {
-        return new DOMDocument();
+        return new \DOMDocument();
     }
 }
diff --git a/src/SAML2/EncryptedAssertion.php b/src/SAML2/EncryptedAssertion.php
index 51da22e75..cb504c9f8 100644
--- a/src/SAML2/EncryptedAssertion.php
+++ b/src/SAML2/EncryptedAssertion.php
@@ -15,17 +15,17 @@ class EncryptedAssertion
     /**
      * The current encrypted assertion.
      *
-     * @var DOMElement
+     * @var \DOMElement
      */
     private $encryptedData;
 
     /**
      * Constructor for SAML 2 encrypted assertions.
      *
-     * @param DOMElement|NULL $xml The encrypted assertion XML element.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The encrypted assertion XML element.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
@@ -33,9 +33,9 @@ public function __construct(DOMElement $xml = NULL)
 
         $data = Utils::xpQuery($xml, './xenc:EncryptedData');
         if (count($data) === 0) {
-            throw new Exception('Missing encrypted data in <saml:EncryptedAssertion>.');
+            throw new \Exception('Missing encrypted data in <saml:EncryptedAssertion>.');
         } elseif (count($data) > 1) {
-            throw new Exception('More than one encrypted data element in <saml:EncryptedAssertion>.');
+            throw new \Exception('More than one encrypted data element in <saml:EncryptedAssertion>.');
         }
         $this->encryptedData = $data[0];
     }
@@ -45,7 +45,7 @@ public function __construct(DOMElement $xml = NULL)
      *
      * @param \SAML2\Assertion $assertion The assertion.
      * @param XMLSecurityKey  $key       The key we should use to encrypt the assertion.
-     * @throws Exception
+     * @throws \Exception
      */
     public function setAssertion(Assertion $assertion, XMLSecurityKey $key)
     {
@@ -75,7 +75,7 @@ public function setAssertion(Assertion $assertion, XMLSecurityKey $key)
                 break;
 
             default:
-                throw new Exception('Unknown key type for encryption: ' . $key->type);
+                throw new \Exception('Unknown key type for encryption: ' . $key->type);
         }
 
         $this->encryptedData = $enc->encryptNode($symmetricKey);
@@ -100,10 +100,10 @@ public function getAssertion(XMLSecurityKey $inputKey, array $blacklist = array(
     /**
      * Convert this encrypted assertion to an XML element.
      *
-     * @param  DOMNode|NULL $parentElement The DOM node the assertion should be created in.
-     * @return DOMElement   This encrypted assertion.
+     * @param  \DOMNode|NULL $parentElement The DOM node the assertion should be created in.
+     * @return \DOMElement   This encrypted assertion.
      */
-    public function toXML(DOMNode $parentElement = NULL)
+    public function toXML(\DOMNode $parentElement = NULL)
     {
         if ($parentElement === NULL) {
             $document = DOMDocumentFactory::create();
diff --git a/src/SAML2/Exception/InvalidArgumentException.php b/src/SAML2/Exception/InvalidArgumentException.php
index 8def35a42..c3e9f8e18 100644
--- a/src/SAML2/Exception/InvalidArgumentException.php
+++ b/src/SAML2/Exception/InvalidArgumentException.php
@@ -2,7 +2,7 @@
 
 namespace SAML2\Exception;
 
-class InvalidArgumentException extends InvalidArgumentException implements Throwable
+class InvalidArgumentException extends \InvalidArgumentException implements Throwable
 {
     /**
      * @param string $expected description of expected type
diff --git a/src/SAML2/Exception/RuntimeException.php b/src/SAML2/Exception/RuntimeException.php
index ca5750b4c..26c8c4e48 100644
--- a/src/SAML2/Exception/RuntimeException.php
+++ b/src/SAML2/Exception/RuntimeException.php
@@ -5,6 +5,6 @@
 /**
  * Named exception
  */
-class RuntimeException extends RuntimeException implements Throwable
+class RuntimeException extends \RuntimeException implements Throwable
 {
 }
diff --git a/src/SAML2/Exception/UnparseableXmlException.php b/src/SAML2/Exception/UnparseableXmlException.php
index 28ea7b913..11cc67c65 100644
--- a/src/SAML2/Exception/UnparseableXmlException.php
+++ b/src/SAML2/Exception/UnparseableXmlException.php
@@ -10,7 +10,7 @@ final class UnparseableXmlException extends RuntimeException
         LIBXML_ERR_FATAL   => 'FATAL'
     );
 
-    public function __construct(LibXMLError $error)
+    public function __construct(\LibXMLError $error)
     {
         $message = sprintf(
             'Unable to parse XML - "%s[%d]": "%s" in "%s" at line %d on column %d"',
diff --git a/src/SAML2/HTTPArtifact.php b/src/SAML2/HTTPArtifact.php
index aeaadbdcf..24ac1072c 100644
--- a/src/SAML2/HTTPArtifact.php
+++ b/src/SAML2/HTTPArtifact.php
@@ -25,13 +25,13 @@ class HTTPArtifact extends Binding
      *
      * @param  \SAML2\Message $message The message.
      * @return string        The URL the user should be redirected to in order to send a message.
-     * @throws Exception
+     * @throws \Exception
      */
     public function getRedirectURL(Message $message)
     {
         $store = SimpleSAML_Store::getInstance();
         if ($store === FALSE) {
-            throw new Exception('Unable to send artifact without a datastore configured.');
+            throw new \Exception('Unable to send artifact without a datastore configured.');
         }
 
         $generatedId = pack('H*', ((string) SimpleSAML_Utilities::stringToHex(SimpleSAML_Utilities::generateRandomBytes(20))));
@@ -71,7 +71,7 @@ public function send(Message $message)
      * Throws an exception if it is unable receive the message.
      *
      * @return \SAML2\Message The received message.
-     * @throws Exception
+     * @throws \Exception
      */
     public function receive()
     {
@@ -81,7 +81,7 @@ public function receive()
             $sourceId = bin2hex(substr($artifact, 4, 20));
 
         } else {
-            throw new Exception('Missing SAMLArt parameter.');
+            throw new \Exception('Missing SAMLArt parameter.');
         }
 
         $metadataHandler = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
@@ -89,7 +89,7 @@ public function receive()
         $idpMetadata = $metadataHandler->getMetaDataConfigForSha1($sourceId, 'saml20-idp-remote');
 
         if ($idpMetadata === NULL) {
-            throw new Exception('No metadata found for remote provider with SHA1 ID: ' . var_export($sourceId, TRUE));
+            throw new \Exception('No metadata found for remote provider with SHA1 ID: ' . var_export($sourceId, TRUE));
         }
 
         $endpoint = NULL;
@@ -101,7 +101,7 @@ public function receive()
         }
 
         if ($endpoint === NULL) {
-            throw new Exception('No ArtifactResolutionService with the correct index.');
+            throw new \Exception('No ArtifactResolutionService with the correct index.');
         }
 
         Utils::getContainer()->getLogger()->debug("ArtifactResolutionService endpoint being used is := " . $endpoint['Location']);
@@ -125,7 +125,7 @@ public function receive()
         $artifactResponse = $soap->send($ar, $this->spMetadata);
 
         if (!$artifactResponse->isSuccess()) {
-            throw new Exception('Received error from ArtifactResolutionService.');
+            throw new \Exception('Received error from ArtifactResolutionService.');
         }
 
         $xml = $artifactResponse->getAny();
diff --git a/src/SAML2/HTTPPost.php b/src/SAML2/HTTPPost.php
index b6ee4757e..4bbe11380 100644
--- a/src/SAML2/HTTPPost.php
+++ b/src/SAML2/HTTPPost.php
@@ -54,7 +54,7 @@ public function send(Message $message)
      * Throws an exception if it is unable receive the message.
      *
      * @return \SAML2\Message The received message.
-     * @throws Exception
+     * @throws \Exception
      */
     public function receive()
     {
@@ -63,7 +63,7 @@ public function receive()
         } elseif (array_key_exists('SAMLResponse', $_POST)) {
             $msg = $_POST['SAMLResponse'];
         } else {
-            throw new Exception('Missing SAMLRequest or SAMLResponse parameter.');
+            throw new \Exception('Missing SAMLRequest or SAMLResponse parameter.');
         }
 
         $msg = base64_decode($msg);
diff --git a/src/SAML2/HTTPRedirect.php b/src/SAML2/HTTPRedirect.php
index d7e52b8ae..80bc85624 100644
--- a/src/SAML2/HTTPRedirect.php
+++ b/src/SAML2/HTTPRedirect.php
@@ -89,7 +89,7 @@ public function send(Message $message)
      * Throws an exception if it is unable receive the message.
      *
      * @return \SAML2\Message The received message.
-     * @throws Exception
+     * @throws \Exception
      *
      * NPath is currently too high but solving that just moves code around.
      * @SuppressWarnings(PHPMD.NPathComplexity)
@@ -102,21 +102,21 @@ public function receive()
         } elseif (array_key_exists('SAMLResponse', $data)) {
             $message = $data['SAMLResponse'];
         } else {
-            throw new Exception('Missing SAMLRequest or SAMLResponse parameter.');
+            throw new \Exception('Missing SAMLRequest or SAMLResponse parameter.');
         }
 
         if (isset($data['SAMLEncoding']) && $data['SAMLEncoding'] !== self::DEFLATE) {
-            throw new Exception('Unknown SAMLEncoding: ' . var_export($data['SAMLEncoding'], TRUE));
+            throw new \Exception('Unknown SAMLEncoding: ' . var_export($data['SAMLEncoding'], TRUE));
         }
 
         $message = base64_decode($message);
         if ($message === FALSE) {
-            throw new Exception('Error while base64 decoding SAML message.');
+            throw new \Exception('Error while base64 decoding SAML message.');
         }
 
         $message = gzinflate($message);
         if ($message === FALSE) {
-            throw new Exception('Error while inflating SAML message.');
+            throw new \Exception('Error while inflating SAML message.');
         }
 
         Utils::getContainer()->debugMessage($message, 'in');
@@ -133,7 +133,7 @@ public function receive()
         }
 
         if (!array_key_exists('SigAlg', $data)) {
-            throw new Exception('Missing signature algorithm.');
+            throw new \Exception('Missing signature algorithm.');
         }
 
         $signData = array(
@@ -205,7 +205,7 @@ private static function parseQuery()
      *
      * @param array          $data The data we need to validate the query string.
      * @param XMLSecurityKey $key  The key we should validate the query against.
-     * @throws Exception
+     * @throws \Exception
      */
     public static function validateSignature(array $data, XMLSecurityKey $key)
     {
@@ -220,14 +220,14 @@ public static function validateSignature(array $data, XMLSecurityKey $key)
         $signature = base64_decode($signature);
 
         if ($key->type !== XMLSecurityKey::RSA_SHA1) {
-            throw new Exception('Invalid key type for validating signature on query string.');
+            throw new \Exception('Invalid key type for validating signature on query string.');
         }
         if ($key->type !== $sigAlg) {
             $key = Utils::castKey($key, $sigAlg);
         }
 
         if (!$key->verifySignature($query, $signature)) {
-            throw new Exception('Unable to validate signature on query string.');
+            throw new \Exception('Unable to validate signature on query string.');
         }
     }
 
diff --git a/src/SAML2/LogoutRequest.php b/src/SAML2/LogoutRequest.php
index ae0f001f8..56616811d 100644
--- a/src/SAML2/LogoutRequest.php
+++ b/src/SAML2/LogoutRequest.php
@@ -24,7 +24,7 @@ class LogoutRequest extends Request
      *
      * If this is not NULL, the NameID needs decryption before it can be accessed.
      *
-     * @var DOMElement|NULL
+     * @var \DOMElement|NULL
      */
     private $encryptedNameId;
 
@@ -45,10 +45,10 @@ class LogoutRequest extends Request
     /**
      * Constructor for SAML 2 logout request messages.
      *
-     * @param DOMElement|NULL $xml The input message.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The input message.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct('LogoutRequest', $xml);
 
@@ -64,9 +64,9 @@ public function __construct(DOMElement $xml = NULL)
 
         $nameId = Utils::xpQuery($xml, './saml_assertion:NameID | ./saml_assertion:EncryptedID/xenc:EncryptedData');
         if (empty($nameId)) {
-            throw new Exception('Missing <saml:NameID> or <saml:EncryptedID> in <samlp:LogoutRequest>.');
+            throw new \Exception('Missing <saml:NameID> or <saml:EncryptedID> in <samlp:LogoutRequest>.');
         } elseif (count($nameId) > 1) {
-            throw new Exception('More than one <saml:NameID> or <saml:EncryptedD> in <samlp:LogoutRequest>.');
+            throw new \Exception('More than one <saml:NameID> or <saml:EncryptedD> in <samlp:LogoutRequest>.');
         }
         $nameId = $nameId[0];
         if ($nameId->localName === 'EncryptedData') {
@@ -172,12 +172,12 @@ public function decryptNameId(XMLSecurityKey $key, array $blacklist = array())
      * Retrieve the name identifier of the session that should be terminated.
      *
      * @return array The name identifier of the session that should be terminated.
-     * @throws Exception
+     * @throws \Exception
      */
     public function getNameId()
     {
         if ($this->encryptedNameId !== NULL) {
-            throw new Exception('Attempted to retrieve encrypted NameID without decrypting it first.');
+            throw new \Exception('Attempted to retrieve encrypted NameID without decrypting it first.');
         }
 
         return $this->nameId;
@@ -251,7 +251,7 @@ public function setSessionIndex($sessionIndex)
     /**
      * Convert this logout request message to an XML element.
      *
-     * @return DOMElement This logout request.
+     * @return \DOMElement This logout request.
      */
     public function toUnsignedXML()
     {
diff --git a/src/SAML2/LogoutResponse.php b/src/SAML2/LogoutResponse.php
index 20f05278f..cc46c25dd 100644
--- a/src/SAML2/LogoutResponse.php
+++ b/src/SAML2/LogoutResponse.php
@@ -12,9 +12,9 @@ class LogoutResponse extends StatusResponse
     /**
      * Constructor for SAML 2 response messages.
      *
-     * @param DOMElement|NULL $xml     The input message.
+     * @param \DOMElement|NULL $xml     The input message.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct('LogoutResponse', $xml);
 
diff --git a/src/SAML2/Message.php b/src/SAML2/Message.php
index aa7751123..2ea9e8d3f 100644
--- a/src/SAML2/Message.php
+++ b/src/SAML2/Message.php
@@ -77,12 +77,12 @@ abstract class Message implements SignedElement
     private $relayState;
 
     /**
-     * The DOMDocument we are currently building.
+     * The \DOMDocument we are currently building.
      *
      * This variable is used while generating XML from this message. It holds the
-     * DOMDocument of the XML we are generating.
+     * \DOMDocument of the XML we are generating.
      *
-     * @var DOMDocument
+     * @var \DOMDocument
      */
     protected $document;
 
@@ -117,7 +117,7 @@ abstract class Message implements SignedElement
     /**
      * Initialize a message.
      *
-     * This constructor takes an optional parameter with a DOMElement. If this
+     * This constructor takes an optional parameter with a \DOMElement. If this
      * parameter is given, the message will be initialized with data from that
      * XML element.
      *
@@ -125,10 +125,10 @@ abstract class Message implements SignedElement
      * default values.
      *
      * @param string          $tagName The tag name of the root element.
-     * @param DOMElement|NULL $xml     The input message.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml     The input message.
+     * @throws \Exception
      */
-    protected function __construct($tagName, DOMElement $xml = NULL)
+    protected function __construct($tagName, \DOMElement $xml = NULL)
     {
         assert('is_string($tagName)');
         $this->tagName = $tagName;
@@ -143,13 +143,13 @@ protected function __construct($tagName, DOMElement $xml = NULL)
         }
 
         if (!$xml->hasAttribute('ID')) {
-            throw new Exception('Missing ID attribute on SAML message.');
+            throw new \Exception('Missing ID attribute on SAML message.');
         }
         $this->id = $xml->getAttribute('ID');
 
         if ($xml->getAttribute('Version') !== '2.0') {
             /* Currently a very strict check. */
-            throw new Exception('Unsupported version: ' . $xml->getAttribute('Version'));
+            throw new \Exception('Unsupported version: ' . $xml->getAttribute('Version'));
         }
 
         $this->issueInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('IssueInstant'));
@@ -175,12 +175,12 @@ protected function __construct($tagName, DOMElement $xml = NULL)
                 $this->messageContainedSignatureUponConstruction = TRUE;
                 $this->certificates = $sig['Certificates'];
                 $this->validators[] = array(
-                    'Function' => array('SAML2_Utils', 'validateSignature'),
+                    'Function' => array('\SAML2\Utils', 'validateSignature'),
                     'Data' => $sig,
                     );
             }
 
-        } catch (Exception $e) {
+        } catch (\Exception $e) {
             /* Ignore signature validation errors. */
         }
 
@@ -215,7 +215,7 @@ public function addValidator($function, $data)
      *
      * @param  XMLSecurityKey $key The key we should check against.
      * @return boolean        TRUE on success, FALSE when we don't have a signature.
-     * @throws Exception
+     * @throws \Exception
      */
     public function validate(XMLSecurityKey $key)
     {
@@ -234,7 +234,7 @@ public function validate(XMLSecurityKey $key)
                 /* We were able to validate the message with this validator. */
 
                 return TRUE;
-            } catch (Exception $e) {
+            } catch (\Exception $e) {
                 $exceptions[] = $e;
             }
         }
@@ -396,7 +396,7 @@ public function setRelayState($relayState)
      *
      * This method does not sign the resulting XML document.
      *
-     * @return DOMElement The root element of the DOM tree.
+     * @return \DOMElement The root element of the DOM tree.
      */
     public function toUnsignedXML()
     {
@@ -437,7 +437,7 @@ public function toUnsignedXML()
      * This method sign the resulting XML document if the private key for
      * the signature is set.
      *
-     * @return DOMElement The root element of the DOM tree.
+     * @return \DOMElement The root element of the DOM tree.
      */
     public function toSignedXML()
     {
@@ -521,14 +521,14 @@ public function getCertificates()
     /**
      * Convert an XML element into a message.
      *
-     * @param  DOMElement    $xml The root XML element.
+     * @param  \DOMElement    $xml The root XML element.
      * @return \SAML2\Message The message.
-     * @throws Exception
+     * @throws \Exception
      */
-    public static function fromXML(DOMElement $xml)
+    public static function fromXML(\DOMElement $xml)
     {
         if ($xml->namespaceURI !== Constants::NS_SAMLP) {
-            throw new Exception('Unknown namespace of SAML message: ' . var_export($xml->namespaceURI, TRUE));
+            throw new \Exception('Unknown namespace of SAML message: ' . var_export($xml->namespaceURI, TRUE));
         }
 
         switch ($xml->localName) {
@@ -547,7 +547,7 @@ public static function fromXML(DOMElement $xml)
             case 'ArtifactResolve':
                 return new ArtifactResolve($xml);
             default:
-                throw new Exception('Unknown SAML message: ' . var_export($xml->localName, TRUE));
+                throw new \Exception('Unknown SAML message: ' . var_export($xml->localName, TRUE));
         }
 
     }
diff --git a/src/SAML2/Response.php b/src/SAML2/Response.php
index 4987c069b..384e35994 100644
--- a/src/SAML2/Response.php
+++ b/src/SAML2/Response.php
@@ -17,9 +17,9 @@ class Response extends StatusResponse
     /**
      * Constructor for SAML 2 response messages.
      *
-     * @param DOMElement|NULL $xml The input message.
+     * @param \DOMElement|NULL $xml The input message.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct('Response', $xml);
 
@@ -65,7 +65,7 @@ public function setAssertions(array $assertions)
     /**
      * Convert the response message to an XML element.
      *
-     * @return DOMElement This response.
+     * @return \DOMElement This response.
      */
     public function toUnsignedXML()
     {
diff --git a/src/SAML2/Response/Exception/UnsignedResponseException.php b/src/SAML2/Response/Exception/UnsignedResponseException.php
index e47ad3688..09aac9591 100644
--- a/src/SAML2/Response/Exception/UnsignedResponseException.php
+++ b/src/SAML2/Response/Exception/UnsignedResponseException.php
@@ -4,6 +4,6 @@
 
 use SAML2\Exception\Throwable;
 
-class UnsignedResponseException extends RuntimeException implements Throwable
+class UnsignedResponseException extends \RuntimeException implements Throwable
 {
 }
diff --git a/src/SAML2/SOAP.php b/src/SAML2/SOAP.php
index 008abec05..e10c3c9cb 100644
--- a/src/SAML2/SOAP.php
+++ b/src/SAML2/SOAP.php
@@ -38,14 +38,14 @@ public function send(Message $message)
      * Throws an exception if it is unable receive the message.
      *
      * @return \SAML2\Message The received message.
-     * @throws Exception
+     * @throws \Exception
      */
     public function receive()
     {
         $postText = file_get_contents('php://input');
 
         if (empty($postText)) {
-            throw new Exception('Invalid message received to AssertionConsumerService endpoint.');
+            throw new \Exception('Invalid message received to AssertionConsumerService endpoint.');
         }
 
         $document = DOMDocumentFactory::fromString($postText);
diff --git a/src/SAML2/SOAPClient.php b/src/SAML2/SOAPClient.php
index 3a1713107..d587d7c95 100644
--- a/src/SAML2/SOAPClient.php
+++ b/src/SAML2/SOAPClient.php
@@ -23,7 +23,7 @@ class SOAPClient
      * @param  SimpleSAML_Configuration $srcMetadata The metadata of the issuer of the message.
      * @param  SimpleSAML_Configuration $dstMetadata The metadata of the destination of the message.
      * @return \SAML2\Message            The response we received.
-     * @throws Exception
+     * @throws \Exception
      */
     public function send(Message $msg, SimpleSAML_Configuration $srcMetadata, SimpleSAML_Configuration $dstMetadata = NULL)
     {
@@ -87,7 +87,7 @@ public function send(Message $msg, SimpleSAML_Configuration $srcMetadata, Simple
 
         $context = stream_context_create($ctxOpts);
         if ($context === NULL) {
-            throw new Exception('Unable to create SSL stream context');
+            throw new \Exception('Unable to create SSL stream context');
         }
 
         $options = array(
@@ -119,21 +119,21 @@ public function send(Message $msg, SimpleSAML_Configuration $srcMetadata, Simple
         /* Perform SOAP Request over HTTP */
         $soapresponsexml = $x->__doRequest($request, $destination, $action, $version);
         if ($soapresponsexml === NULL || $soapresponsexml === "") {
-            throw new Exception('Empty SOAP response, check peer certificate.');
+            throw new \Exception('Empty SOAP response, check peer certificate.');
         }
 
         Utils::getContainer()->debugMessage($soapresponsexml, 'in');
 
-        // Convert to SAML2_Message (DOMElement)
+        // Convert to SAML2\Message (\DOMElement)
         try {
             $dom = DOMDocumentFactory::fromString($soapresponsexml);
         } catch (RuntimeException $e) {
-            throw new Exception('Not a SOAP response.', 0, $e);
+            throw new \Exception('Not a SOAP response.', 0, $e);
         }
 
         $soapfault = $this->getSOAPFault($dom);
         if (isset($soapfault)) {
-            throw new Exception($soapfault);
+            throw new \Exception($soapfault);
         }
         //Extract the message from the response
         $samlresponse = Utils::xpQuery($dom->firstChild, '/soap-env:Envelope/soap-env:Body/*[1]');
@@ -184,7 +184,7 @@ private static function addSSLValidator(Message $msg, $context)
             return;
         }
 
-        $msg->addValidator(array('SAML2_SOAPClient', 'validateSSL'), $keyInfo['key']);
+        $msg->addValidator(array('\SAML2\SOAPClient', 'validateSSL'), $keyInfo['key']);
     }
 
     /**
@@ -192,7 +192,7 @@ private static function addSSLValidator(Message $msg, $context)
      *
      * @param string         $data The public key that was used on the connection.
      * @param XMLSecurityKey $key  The key we should validate the certificate against.
-     * @throws Exception
+     * @throws \Exception
      */
     public static function validateSSL($data, XMLSecurityKey $key)
     {
@@ -200,11 +200,11 @@ public static function validateSSL($data, XMLSecurityKey $key)
 
         $keyInfo = openssl_pkey_get_details($key->key);
         if ($keyInfo === FALSE) {
-            throw new Exception('Unable to get key details from XMLSecurityKey.');
+            throw new \Exception('Unable to get key details from XMLSecurityKey.');
         }
 
         if (!isset($keyInfo['key'])) {
-            throw new Exception('Missing key in public key details.');
+            throw new \Exception('Missing key in public key details.');
         }
 
         if ($keyInfo['key'] !== $data) {
diff --git a/src/SAML2/Signature/AbstractChainedValidator.php b/src/SAML2/Signature/AbstractChainedValidator.php
index b921c01ab..bd6adbab5 100644
--- a/src/SAML2/Signature/AbstractChainedValidator.php
+++ b/src/SAML2/Signature/AbstractChainedValidator.php
@@ -23,7 +23,7 @@ public function __construct(\Psr\Log\LoggerInterface $logger)
      * @param \SAML2\SignedElement      $element
      * @param \SAML2\Certificate\X509[] $pemCandidates
      *
-     * @throws Exception
+     * @throws \Exception
      *
      * @return bool
      */
@@ -44,7 +44,7 @@ protected function validateElementWithKeys(SignedElement $element, $pemCandidate
                     return TRUE;
                 }
                 $this->logger->debug(sprintf('Validation with key "#%d" failed without exception.', $index));
-            } catch (Exception $e) {
+            } catch (\Exception $e) {
                 $this->logger->debug(sprintf(
                     'Validation with key "#%d" failed with exception: %s',
                     $index,
diff --git a/src/SAML2/Signature/MissingConfigurationException.php b/src/SAML2/Signature/MissingConfigurationException.php
index 2483dfe51..8014b0b32 100644
--- a/src/SAML2/Signature/MissingConfigurationException.php
+++ b/src/SAML2/Signature/MissingConfigurationException.php
@@ -4,6 +4,6 @@
 
 use SAML2\Exception\Throwable;
 
-class MissingConfigurationException extends RuntimeException implements Throwable
+class MissingConfigurationException extends \RuntimeException implements Throwable
 {
 }
diff --git a/src/SAML2/SignedElementHelper.php b/src/SAML2/SignedElementHelper.php
index ea7c8ce38..476a63687 100644
--- a/src/SAML2/SignedElementHelper.php
+++ b/src/SAML2/SignedElementHelper.php
@@ -39,9 +39,9 @@ class SignedElementHelper implements SignedElement
     /**
      * Initialize the helper class.
      *
-     * @param DOMElement|NULL $xml The XML element which may be signed.
+     * @param \DOMElement|NULL $xml The XML element which may be signed.
      */
-    protected function __construct(DOMElement $xml = NULL)
+    protected function __construct(\DOMElement $xml = NULL)
     {
         $this->certificates = array();
         $this->validators = array();
@@ -57,12 +57,12 @@ protected function __construct(DOMElement $xml = NULL)
             if ($sig !== FALSE) {
                 $this->certificates = $sig['Certificates'];
                 $this->validators[] = array(
-                    'Function' => array('SAML2_Utils', 'validateSignature'),
+                    'Function' => array('\SAML2\Utils', 'validateSignature'),
                     'Data' => $sig,
                 );
             }
 
-        } catch (Exception $e) {
+        } catch (\Exception $e) {
             /* Ignore signature validation errors. */
         }
     }
@@ -94,7 +94,7 @@ public function addValidator($function, $data)
      *
      * @param  XMLSecurityKey $key The key we should check against.
      * @return boolean        TRUE on success, FALSE when we don't have a signature.
-     * @throws Exception
+     * @throws \Exception
      */
     public function validate(XMLSecurityKey $key)
     {
@@ -113,7 +113,7 @@ public function validate(XMLSecurityKey $key)
                 /* We were able to validate the message with this validator. */
 
                 return TRUE;
-            } catch (Exception $e) {
+            } catch (\Exception $e) {
                 $exceptions[] = $e;
             }
         }
@@ -190,7 +190,7 @@ public function getValidatingCertificates()
                 if ($this->validate($key)) {
                     $ret[] = $cert;
                 }
-            } catch (Exception $e) {
+            } catch (\Exception $e) {
                 /* This certificate does not sign this element. */
             }
         }
@@ -201,11 +201,11 @@ public function getValidatingCertificates()
     /**
      * Sign the given XML element.
      *
-     * @param DOMElement      $root         The element we should sign.
-     * @param DOMElement|NULL $insertBefore The element we should insert the signature node before.
-     * @return DOMElement|NULL
+     * @param \DOMElement      $root         The element we should sign.
+     * @param \DOMElement|NULL $insertBefore The element we should insert the signature node before.
+     * @return \DOMElement|NULL
      */
-    protected function signElement(DOMElement $root, DOMElement $insertBefore = NULL)
+    protected function signElement(\DOMElement $root, \DOMElement $insertBefore = NULL)
     {
         if ($this->signatureKey === NULL) {
             /* We cannot sign this element. */
diff --git a/src/SAML2/StatusResponse.php b/src/SAML2/StatusResponse.php
index 2bc0fb6ae..f7af9de21 100644
--- a/src/SAML2/StatusResponse.php
+++ b/src/SAML2/StatusResponse.php
@@ -44,10 +44,10 @@ abstract class StatusResponse extends Message
      * Constructor for SAML 2 response messages.
      *
      * @param string          $tagName The tag name of the root element.
-     * @param DOMElement|NULL $xml     The input message.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml     The input message.
+     * @throws \Exception
      */
-    protected function __construct($tagName, DOMElement $xml = NULL)
+    protected function __construct($tagName, \DOMElement $xml = NULL)
     {
         parent::__construct($tagName, $xml);
 
@@ -67,13 +67,13 @@ protected function __construct($tagName, DOMElement $xml = NULL)
 
         $status = Utils::xpQuery($xml, './saml_protocol:Status');
         if (empty($status)) {
-            throw new Exception('Missing status code on response.');
+            throw new \Exception('Missing status code on response.');
         }
         $status = $status[0];
 
         $statusCode = Utils::xpQuery($status, './saml_protocol:StatusCode');
         if (empty($statusCode)) {
-            throw new Exception('Missing status code in status element.');
+            throw new \Exception('Missing status code in status element.');
         }
         $statusCode = $statusCode[0];
 
@@ -165,7 +165,7 @@ public function setStatus(array $status)
     /**
      * Convert status response message to an XML element.
      *
-     * @return DOMElement This status response.
+     * @return \DOMElement This status response.
      */
     public function toUnsignedXML()
     {
diff --git a/src/SAML2/SubjectQuery.php b/src/SAML2/SubjectQuery.php
index 108f538ba..cff29d5dd 100644
--- a/src/SAML2/SubjectQuery.php
+++ b/src/SAML2/SubjectQuery.php
@@ -27,9 +27,9 @@ abstract class SubjectQuery extends Request
      * Constructor for SAML 2 subject query messages.
      *
      * @param string          $tagName The tag name of the root element.
-     * @param DOMElement|NULL $xml     The input message.
+     * @param \DOMElement|NULL $xml     The input message.
      */
-    protected function __construct($tagName, DOMElement $xml = NULL)
+    protected function __construct($tagName, \DOMElement $xml = NULL)
     {
         parent::__construct($tagName, $xml);
 
@@ -44,25 +44,25 @@ protected function __construct($tagName, DOMElement $xml = NULL)
     /**
      * Parse subject in query.
      *
-     * @param DOMElement $xml The SubjectQuery XML element.
-     * @throws Exception
+     * @param \DOMElement $xml The SubjectQuery XML element.
+     * @throws \Exception
      */
-    private function parseSubject(DOMElement $xml)
+    private function parseSubject(\DOMElement $xml)
     {
         $subject = Utils::xpQuery($xml, './saml_assertion:Subject');
         if (empty($subject)) {
             /* No Subject node. */
-            throw new Exception('Missing subject in subject query.');
+            throw new \Exception('Missing subject in subject query.');
         } elseif (count($subject) > 1) {
-            throw new Exception('More than one <saml:Subject> in <saml:Assertion>.');
+            throw new \Exception('More than one <saml:Subject> in <saml:Assertion>.');
         }
         $subject = $subject[0];
 
         $nameId = Utils::xpQuery($subject, './saml_assertion:NameID');
         if (empty($nameId)) {
-            throw new Exception('Missing <saml:NameID> in <saml:Subject>.');
+            throw new \Exception('Missing <saml:NameID> in <saml:Subject>.');
         } elseif (count($nameId) > 1) {
-            throw new Exception('More than one <saml:NameID> in <saml:Subject>.');
+            throw new \Exception('More than one <saml:NameID> in <saml:Subject>.');
         }
         $nameId = $nameId[0];
         $this->nameId = Utils::parseNameId($nameId);
@@ -102,7 +102,7 @@ public function setNameId($nameId)
     /**
      * Convert subject query message to an XML element.
      *
-     * @return DOMElement This subject query.
+     * @return \DOMElement This subject query.
      */
     public function toUnsignedXML()
     {
diff --git a/src/SAML2/Utilities/ArrayCollection.php b/src/SAML2/Utilities/ArrayCollection.php
index 5e3a0b2b8..04273ece2 100644
--- a/src/SAML2/Utilities/ArrayCollection.php
+++ b/src/SAML2/Utilities/ArrayCollection.php
@@ -31,7 +31,7 @@ public function get($key)
         return isset($this->elements[$key]) ? $this->elements[$key] : NULL;
     }
 
-    public function filter(Closure $f)
+    public function filter(\Closure $f)
     {
         return new self(array_filter($this->elements, $f));
     }
@@ -59,7 +59,7 @@ public function getOnlyElement()
     {
         if ($this->count() !== 1) {
             throw new RuntimeException(sprintf(
-                'SAML2_Utilities_ArrayCollection::getOnlyElement requires that the collection has exactly one element, '
+                __CLASS__ . '::' . __METHOD__ . ' requires that the collection has exactly one element, '
                 . '"%d" elements found',
                 $this->count()
             ));
@@ -78,7 +78,7 @@ public function last()
         return end($this->elements);
     }
 
-    public function map(Closure $function)
+    public function map(\Closure $function)
     {
         return new self(array_map($function, $this->elements));
     }
@@ -90,7 +90,7 @@ public function count()
 
     public function getIterator()
     {
-        return new ArrayIterator($this->elements);
+        return new \ArrayIterator($this->elements);
     }
 
     public function offsetExists($offset)
diff --git a/src/SAML2/Utilities/Collection.php b/src/SAML2/Utilities/Collection.php
index a59beb4e6..0a3866497 100644
--- a/src/SAML2/Utilities/Collection.php
+++ b/src/SAML2/Utilities/Collection.php
@@ -2,7 +2,7 @@
 
 namespace SAML2\Utilities;
 
-interface Collection extends ArrayAccess, Countable, IteratorAggregate
+interface Collection extends \ArrayAccess, \Countable, \IteratorAggregate
 {
     /**
      * Add an element to the collection
@@ -43,14 +43,14 @@ public function last();
      *
      * @return mixed
      */
-    public function map(Closure $function);
+    public function map(\Closure $function);
 
     /**
      * @param callable $filterFunction
      *
      * @return \SAML2\Utilities\Collection
      */
-    public function filter(Closure $filterFunction);
+    public function filter(\Closure $filterFunction);
 
     /**
      * Get the element at index
diff --git a/src/SAML2/Utils.php b/src/SAML2/Utils.php
index 604d0167a..cfe339dca 100644
--- a/src/SAML2/Utils.php
+++ b/src/SAML2/Utils.php
@@ -34,11 +34,11 @@ class Utils
      * an array will be returned. This array contains the information required to
      * check the signature against a public key.
      *
-     * @param  DOMElement  $root The element which should be validated.
+     * @param  \DOMElement  $root The element which should be validated.
      * @return array|bool An array with information about the Signature-element.
-     * @throws Exception
+     * @throws \Exception
      */
-    public static function validateElement(DOMElement $root)
+    public static function validateElement(\DOMElement $root)
     {
         /* Create an XML security object. */
         $objXMLSecDSig = new XMLSecurityDSig();
@@ -53,7 +53,7 @@ public static function validateElement(DOMElement $root)
 
             return FALSE;
         } elseif (count($signatureElement) > 1) {
-            throw new Exception('XMLSec: more than one signature element in root.');
+            throw new \Exception('XMLSec: more than one signature element in root.');
         }
         $signatureElement = $signatureElement[0];
         $objXMLSecDSig->sigNode = $signatureElement;
@@ -63,24 +63,24 @@ public static function validateElement(DOMElement $root)
 
         /* Validate referenced xml nodes. */
         if (!$objXMLSecDSig->validateReference()) {
-            throw new Exception('XMLsec: digest validation failed');
+            throw new \Exception('XMLsec: digest validation failed');
         }
 
         /* Check that $root is one of the signed nodes. */
         $rootSigned = FALSE;
-        /** @var DOMNode $signedNode */
+        /** @var \DOMNode $signedNode */
         foreach ($objXMLSecDSig->getValidatedNodes() as $signedNode) {
             if ($signedNode->isSameNode($root)) {
                 $rootSigned = TRUE;
                 break;
-            } elseif ($root->parentNode instanceof DOMDocument && $signedNode->isSameNode($root->ownerDocument)) {
+            } elseif ($root->parentNode instanceof \DOMDocument && $signedNode->isSameNode($root->ownerDocument)) {
                 /* $root is the root element of a signed document. */
                 $rootSigned = TRUE;
                 break;
             }
         }
         if (!$rootSigned) {
-            throw new Exception('XMLSec: The root element is not signed.');
+            throw new \Exception('XMLSec: The root element is not signed.');
         }
 
         /* Now we extract all available X509 certificates in the signature element. */
@@ -107,7 +107,7 @@ public static function validateElement(DOMElement $root)
      * @param  string         $algorithm The desired algorithm.
      * @param  string         $type      Public or private key, defaults to public.
      * @return XMLSecurityKey The new key.
-     * @throws Exception
+     * @throws \Exception
      */
     public static function castKey(XMLSecurityKey $key, $algorithm, $type = 'public')
     {
@@ -121,10 +121,10 @@ public static function castKey(XMLSecurityKey $key, $algorithm, $type = 'public'
 
         $keyInfo = openssl_pkey_get_details($key->key);
         if ($keyInfo === FALSE) {
-            throw new Exception('Unable to get key details from XMLSecurityKey.');
+            throw new \Exception('Unable to get key details from XMLSecurityKey.');
         }
         if (!isset($keyInfo['key'])) {
-            throw new Exception('Missing key in public key details.');
+            throw new \Exception('Missing key in public key details.');
         }
 
         $newKey = new XMLSecurityKey($algorithm, array('type'=>$type));
@@ -141,7 +141,7 @@ public static function castKey(XMLSecurityKey $key, $algorithm, $type = 'public'
      *
      * @param array          $info The information returned by the validateElement()-function.
      * @param XMLSecurityKey $key  The publickey that should validate the Signature object.
-     * @throws Exception
+     * @throws \Exception
      */
     public static function validateSignature(array $info, XMLSecurityKey $key)
     {
@@ -152,11 +152,11 @@ public static function validateSignature(array $info, XMLSecurityKey $key)
 
         $sigMethod = self::xpQuery($objXMLSecDSig->sigNode, './ds:SignedInfo/ds:SignatureMethod');
         if (empty($sigMethod)) {
-            throw new Exception('Missing SignatureMethod element.');
+            throw new \Exception('Missing SignatureMethod element.');
         }
         $sigMethod = $sigMethod[0];
         if (!$sigMethod->hasAttribute('Algorithm')) {
-            throw new Exception('Missing Algorithm-attribute on SignatureMethod element.');
+            throw new \Exception('Missing Algorithm-attribute on SignatureMethod element.');
         }
         $algo = $sigMethod->getAttribute('Algorithm');
 
@@ -166,7 +166,7 @@ public static function validateSignature(array $info, XMLSecurityKey $key)
 
         /* Check the signature. */
         if (! $objXMLSecDSig->verify($key)) {
-            throw new Exception("Unable to validate Signature");
+            throw new \Exception("Unable to validate Signature");
         }
     }
 
@@ -174,23 +174,23 @@ public static function validateSignature(array $info, XMLSecurityKey $key)
     /**
      * Do an XPath query on an XML node.
      *
-     * @param  DOMNode $node  The XML node.
+     * @param  \DOMNode $node  The XML node.
      * @param  string  $query The query.
-     * @return DOMElement[]    Array with matching DOM nodes.
+     * @return \DOMElement[]    Array with matching DOM nodes.
      */
-    public static function xpQuery(DOMNode $node, $query)
+    public static function xpQuery(\DOMNode $node, $query)
     {
         assert('is_string($query)');
         static $xpCache = NULL;
 
-        if ($node instanceof DOMDocument) {
+        if ($node instanceof \DOMDocument) {
             $doc = $node;
         } else {
             $doc = $node->ownerDocument;
         }
 
         if ($xpCache === NULL || !$xpCache->document->isSameNode($doc)) {
-            $xpCache = new DOMXPath($doc);
+            $xpCache = new \DOMXPath($doc);
             $xpCache->registerNamespace('soap-env', Constants::NS_SOAP);
             $xpCache->registerNamespace('saml_protocol', Constants::NS_SAMLP);
             $xpCache->registerNamespace('saml_assertion', Constants::NS_SAML);
@@ -210,13 +210,13 @@ public static function xpQuery(DOMNode $node, $query)
 
 
     /**
-     * Make an exact copy the specific DOMElement.
+     * Make an exact copy the specific \DOMElement.
      *
-     * @param  DOMElement      $element The element we should copy.
-     * @param  DOMElement|NULL $parent  The target parent element.
-     * @return DOMElement      The copied element.
+     * @param  \DOMElement      $element The element we should copy.
+     * @param  \DOMElement|NULL $parent  The target parent element.
+     * @return \DOMElement      The copied element.
      */
-    public static function copyElement(DOMElement $element, DOMElement $parent = NULL)
+    public static function copyElement(\DOMElement $element, \DOMElement $parent = NULL)
     {
         if ($parent === NULL) {
             $document = DOMDocumentFactory::create();
@@ -238,7 +238,7 @@ public static function copyElement(DOMElement $element, DOMElement $parent = NUL
             }
         }
 
-        /** @var DOMElement $newElement */
+        /** @var \DOMElement $newElement */
         $newElement = $document->importNode($element, TRUE);
         if ($parent !== NULL) {
             /* We need to append the child to the parent before we add the namespaces. */
@@ -257,13 +257,13 @@ public static function copyElement(DOMElement $element, DOMElement $parent = NUL
     /**
      * Parse a boolean attribute.
      *
-     * @param  DOMElement $node          The element we should fetch the attribute from.
+     * @param  \DOMElement $node          The element we should fetch the attribute from.
      * @param  string     $attributeName The name of the attribute.
      * @param  mixed      $default       The value that should be returned if the attribute doesn't exist.
      * @return bool|mixed The value of the attribute, or $default if the attribute doesn't exist.
-     * @throws Exception
+     * @throws \Exception
      */
-    public static function parseBoolean(DOMElement $node, $attributeName, $default = NULL)
+    public static function parseBoolean(\DOMElement $node, $attributeName, $default = NULL)
     {
         assert('is_string($attributeName)');
 
@@ -279,7 +279,7 @@ public static function parseBoolean(DOMElement $node, $attributeName, $default =
             case 'true':
                 return TRUE;
             default:
-                throw new Exception('Invalid value of boolean attribute ' . var_export($attributeName, TRUE) . ': ' . var_export($value, TRUE));
+                throw new \Exception('Invalid value of boolean attribute ' . var_export($attributeName, TRUE) . ': ' . var_export($value, TRUE));
         }
     }
 
@@ -292,10 +292,10 @@ public static function parseBoolean(DOMElement $node, $attributeName, $default =
      *
      * Only the 'Value'-element is required.
      *
-     * @param DOMElement $node   The DOM node we should append the NameId to.
+     * @param \DOMElement $node   The DOM node we should append the NameId to.
      * @param array      $nameId The name identifier.
      */
-    public static function addNameId(DOMElement $node, array $nameId)
+    public static function addNameId(\DOMElement $node, array $nameId)
     {
         assert('array_key_exists("Value", $nameId)');
 
@@ -315,10 +315,10 @@ public static function addNameId(DOMElement $node, array $nameId)
     /**
      * Parse a NameID element.
      *
-     * @param  DOMElement $xml The DOM element we should parse.
+     * @param  \DOMElement $xml The DOM element we should parse.
      * @return array      The parsed name identifier.
      */
-    public static function parseNameId(DOMElement $xml)
+    public static function parseNameId(\DOMElement $xml)
     {
         $ret = array('Value' => trim($xml->textContent));
 
@@ -336,14 +336,14 @@ public static function parseNameId(DOMElement $xml)
      *
      * @param XMLSecurityKey $key           The key we should use to sign the message.
      * @param array          $certificates  The certificates we should add to the signature node.
-     * @param DOMElement     $root          The XML node we should sign.
-     * @param DOMNode        $insertBefore  The XML element we should insert the signature element before.
+     * @param \DOMElement     $root          The XML node we should sign.
+     * @param \DOMNode        $insertBefore  The XML element we should insert the signature element before.
      */
     public static function insertSignature(
         XMLSecurityKey $key,
         array $certificates,
-        DOMElement $root,
-        DOMNode $insertBefore = NULL
+        \DOMElement $root,
+        \DOMNode $insertBefore = NULL
     ) {
         $objXMLSecDSig = new XMLSecurityDSig();
         $objXMLSecDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N);
@@ -384,13 +384,13 @@ public static function insertSignature(
      *
      * This is an internal helper function.
      *
-     * @param  DOMElement     $encryptedData The encrypted data.
+     * @param  \DOMElement     $encryptedData The encrypted data.
      * @param  XMLSecurityKey $inputKey      The decryption key.
      * @param  array          &$blacklist    Blacklisted decryption algorithms.
-     * @return DOMElement     The decrypted element.
-     * @throws Exception
+     * @return \DOMElement     The decrypted element.
+     * @throws \Exception
      */
-    private static function doDecryptElement(DOMElement $encryptedData, XMLSecurityKey $inputKey, array &$blacklist)
+    private static function doDecryptElement(\DOMElement $encryptedData, XMLSecurityKey $inputKey, array &$blacklist)
     {
         $enc = new XMLSecEnc();
 
@@ -399,12 +399,12 @@ private static function doDecryptElement(DOMElement $encryptedData, XMLSecurityK
 
         $symmetricKey = $enc->locateKey($encryptedData);
         if (!$symmetricKey) {
-            throw new Exception('Could not locate key algorithm in encrypted data.');
+            throw new \Exception('Could not locate key algorithm in encrypted data.');
         }
 
         $symmetricKeyInfo = $enc->locateKeyInfo($symmetricKey);
         if (!$symmetricKeyInfo) {
-            throw new Exception('Could not locate <dsig:KeyInfo> for the encrypted key.');
+            throw new \Exception('Could not locate <dsig:KeyInfo> for the encrypted key.');
         }
 
         $inputKeyAlgo = $inputKey->getAlgorith();
@@ -412,7 +412,7 @@ private static function doDecryptElement(DOMElement $encryptedData, XMLSecurityK
             $symKeyInfoAlgo = $symmetricKeyInfo->getAlgorith();
 
             if (in_array($symKeyInfoAlgo, $blacklist, TRUE)) {
-                throw new Exception('Algorithm disabled: ' . var_export($symKeyInfoAlgo, TRUE));
+                throw new \Exception('Algorithm disabled: ' . var_export($symKeyInfoAlgo, TRUE));
             }
 
             if ($symKeyInfoAlgo === XMLSecurityKey::RSA_OAEP_MGF1P && $inputKeyAlgo === XMLSecurityKey::RSA_1_5) {
@@ -427,7 +427,7 @@ private static function doDecryptElement(DOMElement $encryptedData, XMLSecurityK
 
             /* Make sure that the input key format is the same as the one used to encrypt the key. */
             if ($inputKeyAlgo !== $symKeyInfoAlgo) {
-                throw new Exception(
+                throw new \Exception(
                     'Algorithm mismatch between input key and key used to encrypt ' .
                     ' the symmetric key for the message. Key was: ' .
                     var_export($inputKeyAlgo, TRUE) . '; message was: ' .
@@ -444,18 +444,18 @@ private static function doDecryptElement(DOMElement $encryptedData, XMLSecurityK
                 /* To protect against "key oracle" attacks, we need to be able to create a
                  * symmetric key, and for that we need to know the key size.
                  */
-                throw new Exception('Unknown key size for encryption algorithm: ' . var_export($symmetricKey->type, TRUE));
+                throw new \Exception('Unknown key size for encryption algorithm: ' . var_export($symmetricKey->type, TRUE));
             }
 
             try {
                 $key = $encKey->decryptKey($symmetricKeyInfo);
                 if (strlen($key) != $keySize) {
-                    throw new Exception(
+                    throw new \Exception(
                         'Unexpected key size (' . strlen($key) * 8 . 'bits) for encryption algorithm: ' .
                         var_export($symmetricKey->type, TRUE)
                     );
                 }
-            } catch (Exception $e) {
+            } catch (\Exception $e) {
                 /* We failed to decrypt this key. Log it, and substitute a "random" key. */
                 Utils::getContainer()->getLogger()->error('Failed to decrypt symmetric key: ' . $e->getMessage());
                 /* Create a replacement key, so that it looks like we fail in the same way as if the key was correctly padded. */
@@ -481,7 +481,7 @@ private static function doDecryptElement(DOMElement $encryptedData, XMLSecurityK
             $symKeyAlgo = $symmetricKey->getAlgorith();
             /* Make sure that the input key has the correct format. */
             if ($inputKeyAlgo !== $symKeyAlgo) {
-                throw new Exception(
+                throw new \Exception(
                     'Algorithm mismatch between input key and key in message. ' .
                     'Key was: ' . var_export($inputKeyAlgo, TRUE) . '; message was: ' .
                     var_export($symKeyAlgo, TRUE)
@@ -492,7 +492,7 @@ private static function doDecryptElement(DOMElement $encryptedData, XMLSecurityK
 
         $algorithm = $symmetricKey->getAlgorith();
         if (in_array($algorithm, $blacklist, TRUE)) {
-            throw new Exception('Algorithm disabled: ' . var_export($algorithm, TRUE));
+            throw new \Exception('Algorithm disabled: ' . var_export($algorithm, TRUE));
         }
 
         /** @var string $decrypted */
@@ -511,16 +511,16 @@ private static function doDecryptElement(DOMElement $encryptedData, XMLSecurityK
         try {
             $newDoc = DOMDocumentFactory::fromString($xml);
         } catch (RuntimeException $e) {
-            throw new Exception('Failed to parse decrypted XML. Maybe the wrong sharedkey was used?', 0, $e);
+            throw new \Exception('Failed to parse decrypted XML. Maybe the wrong sharedkey was used?', 0, $e);
         }
 
         $decryptedElement = $newDoc->firstChild->firstChild;
         if ($decryptedElement === NULL) {
-            throw new Exception('Missing encrypted element.');
+            throw new \Exception('Missing encrypted element.');
         }
 
-        if (!($decryptedElement instanceof DOMElement)) {
-            throw new Exception('Decrypted element was not actually a DOMElement.');
+        if (!($decryptedElement instanceof \DOMElement)) {
+            throw new \Exception('Decrypted element was not actually a \DOMElement.');
         }
 
         return $decryptedElement;
@@ -529,35 +529,35 @@ private static function doDecryptElement(DOMElement $encryptedData, XMLSecurityK
     /**
      * Decrypt an encrypted element.
      *
-     * @param  DOMElement     $encryptedData The encrypted data.
+     * @param  \DOMElement     $encryptedData The encrypted data.
      * @param  XMLSecurityKey $inputKey      The decryption key.
      * @param  array          $blacklist     Blacklisted decryption algorithms.
-     * @return DOMElement     The decrypted element.
-     * @throws Exception
+     * @return \DOMElement     The decrypted element.
+     * @throws \Exception
      */
-    public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey $inputKey, array $blacklist = array())
+    public static function decryptElement(\DOMElement $encryptedData, XMLSecurityKey $inputKey, array $blacklist = array())
     {
         try {
             return self::doDecryptElement($encryptedData, $inputKey, $blacklist);
-        } catch (Exception $e) {
+        } catch (\Exception $e) {
             /*
              * Something went wrong during decryption, but for security
              * reasons we cannot tell the user what failed.
              */
             Utils::getContainer()->getLogger()->error('Decryption failed: ' . $e->getMessage());
-            throw new Exception('Failed to decrypt XML element.', 0, $e);
+            throw new \Exception('Failed to decrypt XML element.', 0, $e);
         }
     }
 
     /**
      * Extract localized strings from a set of nodes.
      *
-     * @param  DOMElement $parent       The element that contains the localized strings.
+     * @param  \DOMElement $parent       The element that contains the localized strings.
      * @param  string     $namespaceURI The namespace URI the localized strings should have.
      * @param  string     $localName    The localName of the localized strings.
      * @return array      Localized strings.
      */
-    public static function extractLocalizedStrings(DOMElement $parent, $namespaceURI, $localName)
+    public static function extractLocalizedStrings(\DOMElement $parent, $namespaceURI, $localName)
     {
         assert('is_string($namespaceURI)');
         assert('is_string($localName)');
@@ -582,12 +582,12 @@ public static function extractLocalizedStrings(DOMElement $parent, $namespaceURI
     /**
      * Extract strings from a set of nodes.
      *
-     * @param  DOMElement $parent       The element that contains the localized strings.
+     * @param  \DOMElement $parent       The element that contains the localized strings.
      * @param  string     $namespaceURI The namespace URI the string elements should have.
      * @param  string     $localName    The localName of the string elements.
      * @return array      The string values of the various nodes.
      */
-    public static function extractStrings(DOMElement $parent, $namespaceURI, $localName)
+    public static function extractStrings(\DOMElement $parent, $namespaceURI, $localName)
     {
         assert('is_string($namespaceURI)');
         assert('is_string($localName)');
@@ -606,13 +606,13 @@ public static function extractStrings(DOMElement $parent, $namespaceURI, $localN
     /**
      * Append string element.
      *
-     * @param  DOMElement $parent    The parent element we should append the new nodes to.
+     * @param  \DOMElement $parent    The parent element we should append the new nodes to.
      * @param  string     $namespace The namespace of the created element.
      * @param  string     $name      The name of the created element.
      * @param  string     $value     The value of the element.
-     * @return DOMElement The generated element.
+     * @return \DOMElement The generated element.
      */
-    public static function addString(DOMElement $parent, $namespace, $name, $value)
+    public static function addString(\DOMElement $parent, $namespace, $name, $value)
     {
         assert('is_string($namespace)');
         assert('is_string($name)');
@@ -630,13 +630,13 @@ public static function addString(DOMElement $parent, $namespace, $name, $value)
     /**
      * Append string elements.
      *
-     * @param DOMElement $parent    The parent element we should append the new nodes to.
+     * @param \DOMElement $parent    The parent element we should append the new nodes to.
      * @param string     $namespace The namespace of the created elements
      * @param string     $name      The name of the created elements
      * @param bool       $localized Whether the strings are localized, and should include the xml:lang attribute.
      * @param array      $values    The values we should create the elements from.
      */
-    public static function addStrings(DOMElement $parent, $namespace, $name, $localized, array $values)
+    public static function addStrings(\DOMElement $parent, $namespace, $name, $localized, array $values)
     {
         assert('is_string($namespace)');
         assert('is_string($name)');
@@ -696,7 +696,7 @@ public static function createKeyDescriptor($x509Data)
      *
      * @param string $time The time we should convert.
      * @return int Converted to a unix timestamp.
-     * @throws Exception
+     * @throws \Exception
      */
     public static function xsDateTimeToTimestamp($time)
     {
@@ -705,7 +705,7 @@ public static function xsDateTimeToTimestamp($time)
         // We use a very strict regex to parse the timestamp.
         $regex = '/^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)(?:\\.\\d+)?Z$/D';
         if (preg_match($regex, $time, $matches) == 0) {
-            throw new Exception(
+            throw new \Exception(
                 'Invalid SAML2 timestamp passed to xsDateTimeToTimestamp: ' . $time
             );
         }
diff --git a/src/SAML2/XML/Chunk.php b/src/SAML2/XML/Chunk.php
index 98e72c26f..ea7e91e13 100644
--- a/src/SAML2/XML/Chunk.php
+++ b/src/SAML2/XML/Chunk.php
@@ -9,7 +9,7 @@
  *
  * @package SimpleSAMLphp
  */
-class Chunk implements Serializable
+class Chunk implements \Serializable
 {
     /**
      * The localName of the element.
@@ -26,18 +26,18 @@ class Chunk implements Serializable
     public $namespaceURI;
 
     /**
-     * The DOMElement we contain.
+     * The \DOMElement we contain.
      *
-     * @var DOMElement
+     * @var \DOMElement
      */
     public $xml;
 
     /**
-     * Create a XMLChunk from a copy of the given DOMElement.
+     * Create a XMLChunk from a copy of the given \DOMElement.
      *
-     * @param DOMElement $xml The element we should copy.
+     * @param \DOMElement $xml The element we should copy.
      */
-    public function __construct(DOMElement $xml)
+    public function __construct(\DOMElement $xml)
     {
         $this->localName = $xml->localName;
         $this->namespaceURI = $xml->namespaceURI;
@@ -46,9 +46,9 @@ public function __construct(DOMElement $xml)
     }
 
     /**
-     * Get this DOMElement.
+     * Get this \DOMElement.
      *
-     * @return DOMElement This element.
+     * @return \DOMElement This element.
      * @deprecated
      */
     public function getXML()
@@ -59,10 +59,10 @@ public function getXML()
     /**
      * Append this XML element to a different XML element.
      *
-     * @param  DOMElement $parent The element we should append this element to.
-     * @return DOMElement The new element.
+     * @param  \DOMElement $parent The element we should append this element to.
+     * @return \DOMElement The new element.
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         return Utils::copyElement($this->xml, $parent);
     }
diff --git a/src/SAML2/XML/ds/KeyInfo.php b/src/SAML2/XML/ds/KeyInfo.php
index 4ca502904..b0e2ae4e8 100644
--- a/src/SAML2/XML/ds/KeyInfo.php
+++ b/src/SAML2/XML/ds/KeyInfo.php
@@ -32,9 +32,9 @@ class KeyInfo
     /**
      * Initialize a KeyInfo element.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
@@ -45,7 +45,7 @@ public function __construct(DOMElement $xml = NULL)
         }
 
         for ($n = $xml->firstChild; $n !== NULL; $n = $n->nextSibling) {
-            if (!($n instanceof DOMElement)) {
+            if (!($n instanceof \DOMElement)) {
                 continue;
             }
 
@@ -70,10 +70,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this KeyInfo to XML.
      *
-     * @param DOMElement $parent The element we should append this KeyInfo to.
-     * @return DOMElement
+     * @param \DOMElement $parent The element we should append this KeyInfo to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_null($this->Id) || is_string($this->Id)');
         assert('is_array($this->info)');
diff --git a/src/SAML2/XML/ds/KeyName.php b/src/SAML2/XML/ds/KeyName.php
index 856bd561a..7a5ae791a 100644
--- a/src/SAML2/XML/ds/KeyName.php
+++ b/src/SAML2/XML/ds/KeyName.php
@@ -22,9 +22,9 @@ class KeyName
     /**
      * Initialize a KeyName element.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
@@ -36,10 +36,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this KeyName element to XML.
      *
-     * @param DOMElement $parent The element we should append this KeyName element to.
-     * @return DOMElement
+     * @param \DOMElement $parent The element we should append this KeyName element to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_string($this->name)');
 
diff --git a/src/SAML2/XML/ds/X509Certificate.php b/src/SAML2/XML/ds/X509Certificate.php
index 77bc15e59..b851af149 100644
--- a/src/SAML2/XML/ds/X509Certificate.php
+++ b/src/SAML2/XML/ds/X509Certificate.php
@@ -22,9 +22,9 @@ class X509Certificate
     /**
      * Initialize an X509Certificate element.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
@@ -36,10 +36,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this X509Certificate element to XML.
      *
-     * @param DOMElement $parent The element we should append this X509Certificate element to.
-     * @return DOMElement
+     * @param \DOMElement $parent The element we should append this X509Certificate element to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_string($this->certificate)');
 
diff --git a/src/SAML2/XML/ds/X509Data.php b/src/SAML2/XML/ds/X509Data.php
index 9ce186b52..2c69a560b 100644
--- a/src/SAML2/XML/ds/X509Data.php
+++ b/src/SAML2/XML/ds/X509Data.php
@@ -25,16 +25,16 @@ class X509Data
     /**
      * Initialize a X509Data.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
         }
 
         for ($n = $xml->firstChild; $n !== NULL; $n = $n->nextSibling) {
-            if (!($n instanceof DOMElement)) {
+            if (!($n instanceof \DOMElement)) {
                 continue;
             }
 
@@ -56,10 +56,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this X509Data element to XML.
      *
-     * @param DOMElement $parent The element we should append this X509Data element to.
-     * @return DOMElement
+     * @param \DOMElement $parent The element we should append this X509Data element to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_array($this->data)');
 
diff --git a/src/SAML2/XML/md/AdditionalMetadataLocation.php b/src/SAML2/XML/md/AdditionalMetadataLocation.php
index 77a88f9dd..0f4a3cf75 100644
--- a/src/SAML2/XML/md/AdditionalMetadataLocation.php
+++ b/src/SAML2/XML/md/AdditionalMetadataLocation.php
@@ -29,17 +29,17 @@ class AdditionalMetadataLocation
     /**
      * Initialize an AdditionalMetadataLocation element.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
         }
 
         if (!$xml->hasAttribute('namespace')) {
-            throw new Exception('Missing namespace attribute on AdditionalMetadataLocation element.');
+            throw new \Exception('Missing namespace attribute on AdditionalMetadataLocation element.');
         }
         $this->namespace = $xml->getAttribute('namespace');
 
@@ -49,10 +49,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this AdditionalMetadataLocation to XML.
      *
-     * @param  DOMElement $parent The element we should append to.
-     * @return DOMElement This AdditionalMetadataLocation-element.
+     * @param  \DOMElement $parent The element we should append to.
+     * @return \DOMElement This AdditionalMetadataLocation-element.
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_string($this->namespace)');
         assert('is_string($this->location)');
diff --git a/src/SAML2/XML/md/AffiliationDescriptor.php b/src/SAML2/XML/md/AffiliationDescriptor.php
index ecf547751..fd393fc83 100644
--- a/src/SAML2/XML/md/AffiliationDescriptor.php
+++ b/src/SAML2/XML/md/AffiliationDescriptor.php
@@ -71,10 +71,10 @@ class AffiliationDescriptor extends SignedElementHelper
     /**
      * Initialize a AffiliationDescriptor.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct($xml);
 
@@ -83,7 +83,7 @@ public function __construct(DOMElement $xml = NULL)
         }
 
         if (!$xml->hasAttribute('affiliationOwnerID')) {
-            throw new Exception('Missing affiliationOwnerID on AffiliationDescriptor.');
+            throw new \Exception('Missing affiliationOwnerID on AffiliationDescriptor.');
         }
         $this->affiliationOwnerID = $xml->getAttribute('affiliationOwnerID');
 
@@ -103,7 +103,7 @@ public function __construct(DOMElement $xml = NULL)
 
         $this->AffiliateMember = Utils::extractStrings($xml, Constants::NS_MD, 'AffiliateMember');
         if (empty($this->AffiliateMember)) {
-            throw new Exception('Missing AffiliateMember in AffiliationDescriptor.');
+            throw new \Exception('Missing AffiliateMember in AffiliationDescriptor.');
         }
 
         foreach (Utils::xpQuery($xml, './saml_metadata:KeyDescriptor') as $kd) {
@@ -114,10 +114,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Add this AffiliationDescriptor to an EntityDescriptor.
      *
-     * @param DOMElement $parent The EntityDescriptor we should append this endpoint to.
-     * @return DOMElement
+     * @param \DOMElement $parent The EntityDescriptor we should append this endpoint to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_string($this->affiliationOwnerID)');
         assert('is_null($this->ID) || is_string($this->ID)');
diff --git a/src/SAML2/XML/md/AttributeAuthorityDescriptor.php b/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
index e688ac87f..ff28eb6da 100644
--- a/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
+++ b/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
@@ -61,10 +61,10 @@ class AttributeAuthorityDescriptor extends RoleDescriptor
     /**
      * Initialize an IDPSSODescriptor.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct('md:AttributeAuthorityDescriptor', $xml);
 
@@ -76,7 +76,7 @@ public function __construct(DOMElement $xml = NULL)
             $this->AttributeService[] = new EndpointType($ep);
         }
         if (empty($this->AttributeService)) {
-            throw new Exception('Must have at least one AttributeService in AttributeAuthorityDescriptor.');
+            throw new \Exception('Must have at least one AttributeService in AttributeAuthorityDescriptor.');
         }
 
         foreach (Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) {
@@ -95,10 +95,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Add this AttributeAuthorityDescriptor to an EntityDescriptor.
      *
-     * @param DOMElement $parent The EntityDescriptor we should append this IDPSSODescriptor to.
-     * @return DOMElement
+     * @param \DOMElement $parent The EntityDescriptor we should append this IDPSSODescriptor to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_array($this->AttributeService)');
         assert('!empty($this->AttributeService)');
diff --git a/src/SAML2/XML/md/AttributeConsumingService.php b/src/SAML2/XML/md/AttributeConsumingService.php
index 94044c803..7f10b8101 100644
--- a/src/SAML2/XML/md/AttributeConsumingService.php
+++ b/src/SAML2/XML/md/AttributeConsumingService.php
@@ -56,17 +56,17 @@ class AttributeConsumingService
     /**
      * Initialize / parse an AttributeConsumingService.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
         }
 
         if (!$xml->hasAttribute('index')) {
-            throw new Exception('Missing index on AttributeConsumingService.');
+            throw new \Exception('Missing index on AttributeConsumingService.');
         }
         $this->index = (int) $xml->getAttribute('index');
 
@@ -74,7 +74,7 @@ public function __construct(DOMElement $xml = NULL)
 
         $this->ServiceName = Utils::extractLocalizedStrings($xml, Constants::NS_MD, 'ServiceName');
         if (empty($this->ServiceName)) {
-            throw new Exception('Missing ServiceName in AttributeConsumingService.');
+            throw new \Exception('Missing ServiceName in AttributeConsumingService.');
         }
 
         $this->ServiceDescription = Utils::extractLocalizedStrings($xml, Constants::NS_MD, 'ServiceDescription');
@@ -85,12 +85,12 @@ public function __construct(DOMElement $xml = NULL)
     }
 
     /**
-     * Convert to DOMElement.
+     * Convert to \DOMElement.
      *
-     * @param DOMElement $parent The element we should append this AttributeConsumingService to.
-     * @return DOMElement
+     * @param \DOMElement $parent The element we should append this AttributeConsumingService to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_int($this->index)');
         assert('is_null($this->isDefault) || is_bool($this->isDefault)');
diff --git a/src/SAML2/XML/md/AuthnAuthorityDescriptor.php b/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
index 4b2920790..3e8da4445 100644
--- a/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
+++ b/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
@@ -42,10 +42,10 @@ class AuthnAuthorityDescriptor extends RoleDescriptor
     /**
      * Initialize an IDPSSODescriptor.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct('md:AuthnAuthorityDescriptor', $xml);
 
@@ -57,7 +57,7 @@ public function __construct(DOMElement $xml = NULL)
             $this->AuthnQueryService[] = new EndpointType($ep);
         }
         if (empty($this->AuthnQueryService)) {
-            throw new Exception('Must have at least one AuthnQueryService in AuthnAuthorityDescriptor.');
+            throw new \Exception('Must have at least one AuthnQueryService in AuthnAuthorityDescriptor.');
         }
 
         foreach (Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) {
@@ -70,10 +70,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Add this IDPSSODescriptor to an EntityDescriptor.
      *
-     * @param DOMElement $parent The EntityDescriptor we should append this AuthnAuthorityDescriptor to.
-     * @return DOMElement
+     * @param \DOMElement $parent The EntityDescriptor we should append this AuthnAuthorityDescriptor to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_array($this->AuthnQueryService)');
         assert('!empty($this->AuthnQueryService)');
diff --git a/src/SAML2/XML/md/ContactPerson.php b/src/SAML2/XML/md/ContactPerson.php
index 1c17515e6..fa31dbe71 100644
--- a/src/SAML2/XML/md/ContactPerson.php
+++ b/src/SAML2/XML/md/ContactPerson.php
@@ -66,17 +66,17 @@ class ContactPerson
     /**
      * Initialize a ContactPerson element.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
         }
 
         if (!$xml->hasAttribute('contactType')) {
-            throw new Exception('Missing contactType on ContactPerson.');
+            throw new \Exception('Missing contactType on ContactPerson.');
         }
         $this->contactType = $xml->getAttribute('contactType');
 
@@ -90,13 +90,13 @@ public function __construct(DOMElement $xml = NULL)
     }
 
     /**
-     * Retrieve the value of a child DOMElements as an array of strings.
+     * Retrieve the value of a child \DOMElements as an array of strings.
      *
-     * @param  DOMElement $parent The parent element.
+     * @param  \DOMElement $parent The parent element.
      * @param  string     $name   The name of the child elements.
      * @return array      The value of the child elements.
      */
-    private static function getStringElements(DOMElement $parent, $name)
+    private static function getStringElements(\DOMElement $parent, $name)
     {
         assert('is_string($name)');
 
@@ -111,14 +111,14 @@ private static function getStringElements(DOMElement $parent, $name)
     }
 
     /**
-     * Retrieve the value of a child DOMElement as a string.
+     * Retrieve the value of a child \DOMElement as a string.
      *
-     * @param  DOMElement  $parent The parent element.
+     * @param  \DOMElement  $parent The parent element.
      * @param  string      $name   The name of the child element.
      * @return string|NULL The value of the child element.
-     * @throws Exception
+     * @throws \Exception
      */
-    private static function getStringElement(DOMElement $parent, $name)
+    private static function getStringElement(\DOMElement $parent, $name)
     {
         assert('is_string($name)');
 
@@ -127,7 +127,7 @@ private static function getStringElement(DOMElement $parent, $name)
             return NULL;
         }
         if (count($e) > 1) {
-            throw new Exception('More than one ' . $name . ' in ' . $parent->tagName);
+            throw new \Exception('More than one ' . $name . ' in ' . $parent->tagName);
         }
 
         return $e[0];
@@ -136,10 +136,10 @@ private static function getStringElement(DOMElement $parent, $name)
     /**
      * Convert this ContactPerson to XML.
      *
-     * @param  DOMElement $parent The element we should add this contact to.
-     * @return DOMElement The new ContactPerson-element.
+     * @param  \DOMElement $parent The element we should add this contact to.
+     * @return \DOMElement The new ContactPerson-element.
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_string($this->contactType)');
         assert('is_array($this->Extensions)');
diff --git a/src/SAML2/XML/md/EndpointType.php b/src/SAML2/XML/md/EndpointType.php
index 3b5c6f557..9ab2dd818 100644
--- a/src/SAML2/XML/md/EndpointType.php
+++ b/src/SAML2/XML/md/EndpointType.php
@@ -42,22 +42,22 @@ class EndpointType
     /**
      * Initialize an EndpointType.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
         }
 
         if (!$xml->hasAttribute('Binding')) {
-            throw new Exception('Missing Binding on ' . $xml->tagName);
+            throw new \Exception('Missing Binding on ' . $xml->tagName);
         }
         $this->Binding = $xml->getAttribute('Binding');
 
         if (!$xml->hasAttribute('Location')) {
-            throw new Exception('Missing Location on ' . $xml->tagName);
+            throw new \Exception('Missing Location on ' . $xml->tagName);
         }
         $this->Location = $xml->getAttribute('Location');
 
@@ -121,7 +121,7 @@ public function getAttributeNS($namespaceURI, $localName)
      * @param string $namespaceURI  The namespace URI.
      * @param string $qualifiedName The local name.
      * @param string $value         The attribute value.
-     * @throws Exception
+     * @throws \Exception
      */
     public function setAttributeNS($namespaceURI, $qualifiedName, $value)
     {
@@ -130,7 +130,7 @@ public function setAttributeNS($namespaceURI, $qualifiedName, $value)
 
         $name = explode(':', $qualifiedName, 2);
         if (count($name) < 2) {
-            throw new Exception('Not a qualified name.');
+            throw new \Exception('Not a qualified name.');
         }
         $localName = $name[1];
 
@@ -160,11 +160,11 @@ public function removeAttributeNS($namespaceURI, $localName)
     /**
      * Add this endpoint to an XML element.
      *
-     * @param DOMElement $parent The element we should append this endpoint to.
+     * @param \DOMElement $parent The element we should append this endpoint to.
      * @param string     $name   The name of the element we should create.
-     * @return DOMElement
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent, $name)
+    public function toXML(\DOMElement $parent, $name)
     {
         assert('is_string($name)');
         assert('is_string($this->Binding)');
diff --git a/src/SAML2/XML/md/EntitiesDescriptor.php b/src/SAML2/XML/md/EntitiesDescriptor.php
index c47cc02fe..c4992fedc 100644
--- a/src/SAML2/XML/md/EntitiesDescriptor.php
+++ b/src/SAML2/XML/md/EntitiesDescriptor.php
@@ -61,9 +61,9 @@ class EntitiesDescriptor extends SignedElementHelper
     /**
      * Initialize an EntitiesDescriptor.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct($xml);
 
@@ -98,10 +98,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this EntitiesDescriptor to XML.
      *
-     * @param DOMElement|NULL $parent The EntitiesDescriptor we should append this EntitiesDescriptor to.
-     * @return DOMElement
+     * @param \DOMElement|NULL $parent The EntitiesDescriptor we should append this EntitiesDescriptor to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent = NULL)
+    public function toXML(\DOMElement $parent = NULL)
     {
         assert('is_null($this->ID) || is_string($this->ID)');
         assert('is_null($this->validUntil) || is_int($this->validUntil)');
diff --git a/src/SAML2/XML/md/EntityDescriptor.php b/src/SAML2/XML/md/EntityDescriptor.php
index 2adf20240..308c26c81 100644
--- a/src/SAML2/XML/md/EntityDescriptor.php
+++ b/src/SAML2/XML/md/EntityDescriptor.php
@@ -91,10 +91,10 @@ class EntityDescriptor extends SignedElementHelper
     /**
      * Initialize an EntitiyDescriptor.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct($xml);
 
@@ -103,7 +103,7 @@ public function __construct(DOMElement $xml = NULL)
         }
 
         if (!$xml->hasAttribute('entityID')) {
-            throw new Exception('Missing required attribute entityID on EntityDescriptor.');
+            throw new \Exception('Missing required attribute entityID on EntityDescriptor.');
         }
         $this->entityID = $xml->getAttribute('entityID');
 
@@ -120,7 +120,7 @@ public function __construct(DOMElement $xml = NULL)
         $this->Extensions = Extensions::getList($xml);
 
         for ($node = $xml->firstChild; $node !== NULL; $node = $node->nextSibling) {
-            if (!($node instanceof DOMElement)) {
+            if (!($node instanceof \DOMElement)) {
                 continue;
             }
 
@@ -152,20 +152,20 @@ public function __construct(DOMElement $xml = NULL)
 
         $affiliationDescriptor = Utils::xpQuery($xml, './saml_metadata:AffiliationDescriptor');
         if (count($affiliationDescriptor) > 1) {
-            throw new Exception('More than one AffiliationDescriptor in the entity.');
+            throw new \Exception('More than one AffiliationDescriptor in the entity.');
         } elseif (!empty($affiliationDescriptor)) {
             $this->AffiliationDescriptor = new AffiliationDescriptor($affiliationDescriptor[0]);
         }
 
         if (empty($this->RoleDescriptor) && is_null($this->AffiliationDescriptor)) {
-            throw new Exception('Must have either one of the RoleDescriptors or an AffiliationDescriptor in EntityDescriptor.');
+            throw new \Exception('Must have either one of the RoleDescriptors or an AffiliationDescriptor in EntityDescriptor.');
         } elseif (!empty($this->RoleDescriptor) && !is_null($this->AffiliationDescriptor)) {
-            throw new Exception('AffiliationDescriptor cannot be combined with other RoleDescriptor elements in EntityDescriptor.');
+            throw new \Exception('AffiliationDescriptor cannot be combined with other RoleDescriptor elements in EntityDescriptor.');
         }
 
         $organization = Utils::xpQuery($xml, './saml_metadata:Organization');
         if (count($organization) > 1) {
-            throw new Exception('More than one Organization in the entity.');
+            throw new \Exception('More than one Organization in the entity.');
         } elseif (!empty($organization)) {
             $this->Organization = new Organization($organization[0]);
         }
@@ -182,10 +182,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Create this EntityDescriptor.
      *
-     * @param DOMElement|NULL $parent The EntitiesDescriptor we should append this EntityDescriptor to.
-     * @return DOMElement
+     * @param \DOMElement|NULL $parent The EntitiesDescriptor we should append this EntityDescriptor to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent = NULL)
+    public function toXML(\DOMElement $parent = NULL)
     {
         assert('is_string($this->entityID)');
         assert('is_null($this->ID) || is_string($this->ID)');
@@ -193,8 +193,8 @@ public function toXML(DOMElement $parent = NULL)
         assert('is_null($this->cacheDuration) || is_string($this->cacheDuration)');
         assert('is_array($this->Extensions)');
         assert('is_array($this->RoleDescriptor)');
-        assert('is_null($this->AffiliationDescriptor) || $this->AffiliationDescriptor instanceof SAML2_XML_md_AffiliationDescriptor');
-        assert('is_null($this->Organization) || $this->Organization instanceof SAML2_XML_md_Organization');
+        assert('is_null($this->AffiliationDescriptor) || $this->AffiliationDescriptor instanceof \SAML2\XML\md\AffiliationDescriptor');
+        assert('is_null($this->Organization) || $this->Organization instanceof \SAML2\XML\md\Organization');
         assert('is_array($this->ContactPerson)');
         assert('is_array($this->AdditionalMetadataLocation)');
 
diff --git a/src/SAML2/XML/md/Extensions.php b/src/SAML2/XML/md/Extensions.php
index 8e1706853..4c44a8a39 100644
--- a/src/SAML2/XML/md/Extensions.php
+++ b/src/SAML2/XML/md/Extensions.php
@@ -23,10 +23,10 @@ class Extensions
     /**
      * Get a list of Extensions in the given element.
      *
-     * @param  DOMElement $parent The element that may contain the md:Extensions element.
+     * @param  \DOMElement $parent The element that may contain the md:Extensions element.
      * @return \SAML2\XML\Chunk[]  Array of extensions.
      */
-    public static function getList(DOMElement $parent)
+    public static function getList(\DOMElement $parent)
     {
         $ret = array();
         foreach (Utils::xpQuery($parent, './saml_metadata:Extensions/*') as $node) {
@@ -53,10 +53,10 @@ public static function getList(DOMElement $parent)
     /**
      * Add a list of Extensions to the given element.
      *
-     * @param DOMElement        $parent     The element we should add the extensions to.
+     * @param \DOMElement        $parent     The element we should add the extensions to.
      * @param \SAML2\XML\Chunk[] $extensions List of extension objects.
      */
-    public static function addList(DOMElement $parent, array $extensions)
+    public static function addList(\DOMElement $parent, array $extensions)
     {
         if (empty($extensions)) {
             return;
diff --git a/src/SAML2/XML/md/IDPSSODescriptor.php b/src/SAML2/XML/md/IDPSSODescriptor.php
index dda70df8e..23ad7574c 100644
--- a/src/SAML2/XML/md/IDPSSODescriptor.php
+++ b/src/SAML2/XML/md/IDPSSODescriptor.php
@@ -68,9 +68,9 @@ class IDPSSODescriptor extends SSODescriptorType
     /**
      * Initialize an IDPSSODescriptor.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct('md:IDPSSODescriptor', $xml);
 
@@ -102,10 +102,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Add this IDPSSODescriptor to an EntityDescriptor.
      *
-     * @param DOMElement $parent The EntityDescriptor we should append this IDPSSODescriptor to.
-     * @return DOMElement
+     * @param \DOMElement $parent The EntityDescriptor we should append this IDPSSODescriptor to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_null($this->WantAuthnRequestsSigned) || is_bool($this->WantAuthnRequestsSigned)');
         assert('is_array($this->SingleSignOnService)');
diff --git a/src/SAML2/XML/md/IndexedEndpointType.php b/src/SAML2/XML/md/IndexedEndpointType.php
index e781eeabe..f6523cb3e 100644
--- a/src/SAML2/XML/md/IndexedEndpointType.php
+++ b/src/SAML2/XML/md/IndexedEndpointType.php
@@ -28,10 +28,10 @@ class IndexedEndpointType extends EndpointType
     /**
      * Initialize an IndexedEndpointType.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct($xml);
 
@@ -40,7 +40,7 @@ public function __construct(DOMElement $xml = NULL)
         }
 
         if (!$xml->hasAttribute('index')) {
-            throw new Exception('Missing index on ' . $xml->tagName);
+            throw new \Exception('Missing index on ' . $xml->tagName);
         }
         $this->index = (int) $xml->getAttribute('index');
 
@@ -50,11 +50,11 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Add this endpoint to an XML element.
      *
-     * @param DOMElement $parent The element we should append this endpoint to.
+     * @param \DOMElement $parent The element we should append this endpoint to.
      * @param string     $name   The name of the element we should create.
-     * @return DOMElement
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent, $name)
+    public function toXML(\DOMElement $parent, $name)
     {
         assert('is_string($name)');
         assert('is_int($this->index)');
diff --git a/src/SAML2/XML/md/KeyDescriptor.php b/src/SAML2/XML/md/KeyDescriptor.php
index 95873cbad..da93adaf0 100644
--- a/src/SAML2/XML/md/KeyDescriptor.php
+++ b/src/SAML2/XML/md/KeyDescriptor.php
@@ -42,10 +42,10 @@ class KeyDescriptor
     /**
      * Initialize an KeyDescriptor.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
@@ -57,9 +57,9 @@ public function __construct(DOMElement $xml = NULL)
 
         $keyInfo = Utils::xpQuery($xml, './ds:KeyInfo');
         if (count($keyInfo) > 1) {
-            throw new Exception('More than one ds:KeyInfo in the KeyDescriptor.');
+            throw new \Exception('More than one ds:KeyInfo in the KeyDescriptor.');
         } elseif (empty($keyInfo)) {
-            throw new Exception('No ds:KeyInfo in the KeyDescriptor.');
+            throw new \Exception('No ds:KeyInfo in the KeyDescriptor.');
         }
         $this->KeyInfo = new KeyInfo($keyInfo[0]);
 
@@ -72,13 +72,13 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this KeyDescriptor to XML.
      *
-     * @param DOMElement $parent The element we should append this KeyDescriptor to.
-     * @return DOMElement
+     * @param \DOMElement $parent The element we should append this KeyDescriptor to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_null($this->use) || is_string($this->use)');
-        assert('$this->KeyInfo instanceof SAML2_XML_ds_KeyInfo');
+        assert('$this->KeyInfo instanceof \SAML2\XML\ds\KeyInfo');
         assert('is_array($this->EncryptionMethod)');
 
         $doc = $parent->ownerDocument;
diff --git a/src/SAML2/XML/md/Organization.php b/src/SAML2/XML/md/Organization.php
index 67f183ab5..3653507d2 100644
--- a/src/SAML2/XML/md/Organization.php
+++ b/src/SAML2/XML/md/Organization.php
@@ -45,9 +45,9 @@ class Organization
     /**
      * Initialize an Organization element.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
@@ -74,10 +74,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this Organization to XML.
      *
-     * @param  DOMElement $parent The element we should add this organization to.
-     * @return DOMElement This Organization-element.
+     * @param  \DOMElement $parent The element we should add this organization to.
+     * @return \DOMElement This Organization-element.
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_array($this->Extensions)');
         assert('is_array($this->OrganizationName)');
diff --git a/src/SAML2/XML/md/PDPDescriptor.php b/src/SAML2/XML/md/PDPDescriptor.php
index 72bd27c8c..f1738398c 100644
--- a/src/SAML2/XML/md/PDPDescriptor.php
+++ b/src/SAML2/XML/md/PDPDescriptor.php
@@ -42,10 +42,10 @@ class PDPDescriptor extends RoleDescriptor
     /**
      * Initialize an IDPSSODescriptor.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct('md:PDPDescriptor', $xml);
 
@@ -57,7 +57,7 @@ public function __construct(DOMElement $xml = NULL)
             $this->AuthzService[] = new EndpointType($ep);
         }
         if (empty($this->AuthzService)) {
-            throw new Exception('Must have at least one AuthzService in PDPDescriptor.');
+            throw new \Exception('Must have at least one AuthzService in PDPDescriptor.');
         }
 
         foreach (Utils::xpQuery($xml, './saml_metadata:AssertionIDRequestService') as $ep) {
@@ -70,10 +70,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Add this PDPDescriptor to an EntityDescriptor.
      *
-     * @param DOMElement $parent The EntityDescriptor we should append this IDPSSODescriptor to.
-     * @return DOMElement
+     * @param \DOMElement $parent The EntityDescriptor we should append this IDPSSODescriptor to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_array($this->AuthzService)');
         assert('!empty($this->AuthzService)');
diff --git a/src/SAML2/XML/md/RequestedAttribute.php b/src/SAML2/XML/md/RequestedAttribute.php
index af8a2f958..abfb1ddd6 100644
--- a/src/SAML2/XML/md/RequestedAttribute.php
+++ b/src/SAML2/XML/md/RequestedAttribute.php
@@ -23,9 +23,9 @@ class RequestedAttribute extends Attribute
     /**
      * Initialize an RequestedAttribute.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct($xml);
 
@@ -39,10 +39,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this RequestedAttribute to XML.
      *
-     * @param DOMElement $parent The element we should append this RequestedAttribute to.
-     * @return DOMElement
+     * @param \DOMElement $parent The element we should append this RequestedAttribute to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_bool($this->isRequired) || is_null($this->isRequired)');
 
diff --git a/src/SAML2/XML/md/RoleDescriptor.php b/src/SAML2/XML/md/RoleDescriptor.php
index e0b0ff589..60308a422 100644
--- a/src/SAML2/XML/md/RoleDescriptor.php
+++ b/src/SAML2/XML/md/RoleDescriptor.php
@@ -93,10 +93,10 @@ class RoleDescriptor extends SignedElementHelper
      * Initialize a RoleDescriptor.
      *
      * @param string          $elementName The name of this element.
-     * @param DOMElement|NULL $xml         The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml         The XML element we should load.
+     * @throws \Exception
      */
-    protected function __construct($elementName, DOMElement $xml = NULL)
+    protected function __construct($elementName, \DOMElement $xml = NULL)
     {
         assert('is_string($elementName)');
 
@@ -118,7 +118,7 @@ protected function __construct($elementName, DOMElement $xml = NULL)
         }
 
         if (!$xml->hasAttribute('protocolSupportEnumeration')) {
-            throw new Exception('Missing protocolSupportEnumeration attribute on ' . $xml->localName);
+            throw new \Exception('Missing protocolSupportEnumeration attribute on ' . $xml->localName);
         }
         $this->protocolSupportEnumeration = preg_split('/[\s]+/', $xml->getAttribute('protocolSupportEnumeration'));
 
@@ -134,7 +134,7 @@ protected function __construct($elementName, DOMElement $xml = NULL)
 
         $organization = Utils::xpQuery($xml, './saml_metadata:Organization');
         if (count($organization) > 1) {
-            throw new Exception('More than one Organization in the entity.');
+            throw new \Exception('More than one Organization in the entity.');
         } elseif (!empty($organization)) {
             $this->Organization = new Organization($organization[0]);
         }
@@ -147,10 +147,10 @@ protected function __construct($elementName, DOMElement $xml = NULL)
     /**
      * Add this RoleDescriptor to an EntityDescriptor.
      *
-     * @param DOMElement $parent The EntityDescriptor we should append this endpoint to.
-     * @return DOMElement
+     * @param \DOMElement $parent The EntityDescriptor we should append this endpoint to.
+     * @return \DOMElement
      */
-    protected function toXML(DOMElement $parent)
+    protected function toXML(\DOMElement $parent)
     {
         assert('is_null($this->ID) || is_string($this->ID)');
         assert('is_null($this->validUntil) || is_int($this->validUntil)');
@@ -159,7 +159,7 @@ protected function toXML(DOMElement $parent)
         assert('is_null($this->errorURL) || is_string($this->errorURL)');
         assert('is_array($this->Extensions)');
         assert('is_array($this->KeyDescriptor)');
-        assert('is_null($this->Organization) || $this->Organization instanceof SAML2_XML_md_Organization');
+        assert('is_null($this->Organization) || $this->Organization instanceof \SAML2\XML\md\Organization');
         assert('is_array($this->ContactPerson)');
 
         $e = $parent->ownerDocument->createElementNS(Constants::NS_MD, $this->elementName);
diff --git a/src/SAML2/XML/md/SPSSODescriptor.php b/src/SAML2/XML/md/SPSSODescriptor.php
index 1be2af64d..3f765d6fb 100644
--- a/src/SAML2/XML/md/SPSSODescriptor.php
+++ b/src/SAML2/XML/md/SPSSODescriptor.php
@@ -46,9 +46,9 @@ class SPSSODescriptor extends SSODescriptorType
     /**
      * Initialize a SPSSODescriptor.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct('md:SPSSODescriptor', $xml);
 
@@ -71,10 +71,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Add this SPSSODescriptor to an EntityDescriptor.
      *
-     * @param DOMElement $parent The EntityDescriptor we should append this SPSSODescriptor to.
+     * @param \DOMElement $parent The EntityDescriptor we should append this SPSSODescriptor to.
      * @return void
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_null($this->AuthnRequestsSigned) || is_bool($this->AuthnRequestsSigned)');
         assert('is_null($this->WantAssertionsSigned) || is_bool($this->WantAssertionsSigned)');
diff --git a/src/SAML2/XML/md/SSODescriptorType.php b/src/SAML2/XML/md/SSODescriptorType.php
index 9138f80ef..e691d730f 100644
--- a/src/SAML2/XML/md/SSODescriptorType.php
+++ b/src/SAML2/XML/md/SSODescriptorType.php
@@ -52,9 +52,9 @@ abstract class SSODescriptorType extends RoleDescriptor
      * Initialize a SSODescriptor.
      *
      * @param string          $elementName The name of this element.
-     * @param DOMElement|NULL $xml         The XML element we should load.
+     * @param \DOMElement|NULL $xml         The XML element we should load.
      */
-    protected function __construct($elementName, DOMElement $xml = NULL)
+    protected function __construct($elementName, \DOMElement $xml = NULL)
     {
         assert('is_string($elementName)');
 
@@ -82,10 +82,10 @@ protected function __construct($elementName, DOMElement $xml = NULL)
     /**
      * Add this SSODescriptorType to an EntityDescriptor.
      *
-     * @param  DOMElement $parent The EntityDescriptor we should append this SSODescriptorType to.
-     * @return DOMElement The generated SSODescriptor DOMElement.
+     * @param  \DOMElement $parent The EntityDescriptor we should append this SSODescriptorType to.
+     * @return \DOMElement The generated SSODescriptor DOMElement.
      */
-    protected function toXML(DOMElement $parent)
+    protected function toXML(\DOMElement $parent)
     {
         assert('is_array($this->ArtifactResolutionService)');
         assert('is_array($this->SingleLogoutService)');
diff --git a/src/SAML2/XML/md/UnknownRoleDescriptor.php b/src/SAML2/XML/md/UnknownRoleDescriptor.php
index 663eb8e9d..37447cae0 100644
--- a/src/SAML2/XML/md/UnknownRoleDescriptor.php
+++ b/src/SAML2/XML/md/UnknownRoleDescriptor.php
@@ -21,9 +21,9 @@ class UnknownRoleDescriptor extends RoleDescriptor
     /**
      * Initialize an unknown RoleDescriptor.
      *
-     * @param DOMElement $xml The XML element we should load.
+     * @param \DOMElement $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml)
+    public function __construct(\DOMElement $xml)
     {
         parent::__construct('md:RoleDescriptor', $xml);
 
@@ -33,10 +33,10 @@ public function __construct(DOMElement $xml)
     /**
      * Add this RoleDescriptor to an EntityDescriptor.
      *
-     * @param DOMElement $parent The EntityDescriptor we should append this RoleDescriptor to.
+     * @param \DOMElement $parent The EntityDescriptor we should append this RoleDescriptor to.
      * @return void
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         $this->xml->toXML($parent);
     }
diff --git a/src/SAML2/XML/mdattr/EntityAttributes.php b/src/SAML2/XML/mdattr/EntityAttributes.php
index b5762b388..044af9152 100644
--- a/src/SAML2/XML/mdattr/EntityAttributes.php
+++ b/src/SAML2/XML/mdattr/EntityAttributes.php
@@ -31,9 +31,9 @@ class EntityAttributes
     /**
      * Create a EntityAttributes element.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
@@ -52,10 +52,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this EntityAttributes to XML.
      *
-     * @param DOMElement $parent The element we should append to.
-     * @return DOMElement
+     * @param \DOMElement $parent The element we should append to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_array($this->children)');
 
diff --git a/src/SAML2/XML/mdrpi/PublicationInfo.php b/src/SAML2/XML/mdrpi/PublicationInfo.php
index 38f137ba9..ee7da3279 100644
--- a/src/SAML2/XML/mdrpi/PublicationInfo.php
+++ b/src/SAML2/XML/mdrpi/PublicationInfo.php
@@ -45,17 +45,17 @@ class PublicationInfo
     /**
      * Create/parse a mdrpi:PublicationInfo element.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
         }
 
         if (!$xml->hasAttribute('publisher')) {
-            throw new Exception('Missing required attribute "publisher" in mdrpi:PublicationInfo element.');
+            throw new \Exception('Missing required attribute "publisher" in mdrpi:PublicationInfo element.');
         }
         $this->publisher = $xml->getAttribute('publisher');
 
@@ -73,10 +73,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this element to XML.
      *
-     * @param DOMElement $parent The element we should append to.
-     * @return DOMElement
+     * @param \DOMElement $parent The element we should append to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_string($this->publisher)');
         assert('is_int($this->creationInstant) || is_null($this->creationInstant)');
diff --git a/src/SAML2/XML/mdrpi/RegistrationInfo.php b/src/SAML2/XML/mdrpi/RegistrationInfo.php
index 1701195f6..611a8654f 100644
--- a/src/SAML2/XML/mdrpi/RegistrationInfo.php
+++ b/src/SAML2/XML/mdrpi/RegistrationInfo.php
@@ -38,17 +38,17 @@ class RegistrationInfo
     /**
      * Create/parse a mdrpi:RegistrationInfo element.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
         }
 
         if (!$xml->hasAttribute('registrationAuthority')) {
-            throw new Exception('Missing required attribute "registrationAuthority" in mdrpi:RegistrationInfo element.');
+            throw new \Exception('Missing required attribute "registrationAuthority" in mdrpi:RegistrationInfo element.');
         }
         $this->registrationAuthority = $xml->getAttribute('registrationAuthority');
 
@@ -62,17 +62,17 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this element to XML.
      *
-     * @param DOMElement $parent The element we should append to.
-     * @return DOMElement
+     * @param \DOMElement $parent The element we should append to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_string($this->registrationAuthority)');
         assert('is_int($this->registrationInstant) || is_null($this->registrationInstant)');
         assert('is_array($this->RegistrationPolicy)');
 
         if (empty($this->registrationAuthority)) {
-            throw new Exception('Missing required registration authority.');
+            throw new \Exception('Missing required registration authority.');
         }
 
         $doc = $parent->ownerDocument;
diff --git a/src/SAML2/XML/mdui/DiscoHints.php b/src/SAML2/XML/mdui/DiscoHints.php
index 823da041b..c566bfad2 100644
--- a/src/SAML2/XML/mdui/DiscoHints.php
+++ b/src/SAML2/XML/mdui/DiscoHints.php
@@ -51,9 +51,9 @@ class DiscoHints
     /**
      * Create a DiscoHints element.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
@@ -71,10 +71,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this DiscoHints to XML.
      *
-     * @param DOMElement $parent The element we should append to.
-     * @return DOMElement|NULL
+     * @param \DOMElement $parent The element we should append to.
+     * @return \DOMElement|NULL
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_array($this->IPHint)');
         assert('is_array($this->DomainHint)');
diff --git a/src/SAML2/XML/mdui/Keywords.php b/src/SAML2/XML/mdui/Keywords.php
index 1044479b1..1acca098b 100644
--- a/src/SAML2/XML/mdui/Keywords.php
+++ b/src/SAML2/XML/mdui/Keywords.php
@@ -27,20 +27,20 @@ class Keywords
     /**
      * Initialize a Keywords.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
         }
 
         if (!$xml->hasAttribute('xml:lang')) {
-            throw new Exception('Missing lang on Keywords.');
+            throw new \Exception('Missing lang on Keywords.');
         }
         if (!is_string($xml->textContent) || !strlen($xml->textContent)) {
-            throw new Exception('Missing value for Keywords.');
+            throw new \Exception('Missing value for Keywords.');
         }
         $this->Keywords = array();
         foreach (explode(' ', $xml->textContent) as $keyword) {
@@ -52,11 +52,11 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this Keywords to XML.
      *
-     * @param DOMElement $parent The element we should append this Keywords to.
-     * @return DOMElement
-     * @throws Exception
+     * @param \DOMElement $parent The element we should append this Keywords to.
+     * @return \DOMElement
+     * @throws \Exception
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_string($this->lang)');
         assert('is_array($this->Keywords)');
@@ -68,7 +68,7 @@ public function toXML(DOMElement $parent)
         $value = '';
         foreach ($this->Keywords as $keyword) {
             if (strpos($keyword, "+") !== FALSE) {
-                throw new Exception('Keywords may not contain a "+" character.');
+                throw new \Exception('Keywords may not contain a "+" character.');
             }
             $value .= str_replace(' ', '+', $keyword) . ' ';
         }
diff --git a/src/SAML2/XML/mdui/Logo.php b/src/SAML2/XML/mdui/Logo.php
index 57b773468..aa5a0e2fb 100644
--- a/src/SAML2/XML/mdui/Logo.php
+++ b/src/SAML2/XML/mdui/Logo.php
@@ -41,23 +41,23 @@ class Logo
     /**
      * Initialize a Logo.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
         }
 
         if (!$xml->hasAttribute('width')) {
-            throw new Exception('Missing width of Logo.');
+            throw new \Exception('Missing width of Logo.');
         }
         if (!$xml->hasAttribute('height')) {
-            throw new Exception('Missing height of Logo.');
+            throw new \Exception('Missing height of Logo.');
         }
         if (!is_string($xml->textContent) || !strlen($xml->textContent)) {
-            throw new Exception('Missing url value for Logo.');
+            throw new \Exception('Missing url value for Logo.');
         }
         $this->url = $xml->textContent;
         $this->width = (int) $xml->getAttribute('width');
@@ -68,10 +68,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this Logo to XML.
      *
-     * @param DOMElement $parent The element we should append this Logo to.
-     * @return DOMElement
+     * @param \DOMElement $parent The element we should append this Logo to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_int($this->width)');
         assert('is_int($this->height)');
diff --git a/src/SAML2/XML/mdui/UIInfo.php b/src/SAML2/XML/mdui/UIInfo.php
index a2bc6a9de..324760724 100644
--- a/src/SAML2/XML/mdui/UIInfo.php
+++ b/src/SAML2/XML/mdui/UIInfo.php
@@ -72,9 +72,9 @@ class UIInfo
     /**
      * Create a UIInfo element.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
@@ -104,10 +104,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this UIInfo to XML.
      *
-     * @param DOMElement $parent The element we should append to.
-     * @return DOMElement|NULL
+     * @param \DOMElement $parent The element we should append to.
+     * @return \DOMElement|NULL
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_array($this->DisplayName)');
         assert('is_array($this->InformationURL)');
diff --git a/src/SAML2/XML/saml/Attribute.php b/src/SAML2/XML/saml/Attribute.php
index 0323c69b7..9cd64bc56 100644
--- a/src/SAML2/XML/saml/Attribute.php
+++ b/src/SAML2/XML/saml/Attribute.php
@@ -45,17 +45,17 @@ class Attribute
     /**
      * Initialize an Attribute.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
         }
 
         if (!$xml->hasAttribute('Name')) {
-            throw new Exception('Missing Name on Attribute.');
+            throw new \Exception('Missing Name on Attribute.');
         }
         $this->Name = $xml->getAttribute('Name');
 
@@ -76,12 +76,12 @@ public function __construct(DOMElement $xml = NULL)
      * Internal implementation of toXML.
      * This function allows RequestedAttribute to specify the element name and namespace.
      *
-     * @param DOMElement $parent    The element we should append this Attribute to.
+     * @param \DOMElement $parent    The element we should append this Attribute to.
      * @param string     $namespace The namespace the element should be created in.
      * @param string     $name      The name of the element.
-     * @return DOMElement
+     * @return \DOMElement
      */
-    protected function toXMLInternal(DOMElement $parent, $namespace, $name)
+    protected function toXMLInternal(\DOMElement $parent, $namespace, $name)
     {
         assert('is_string($namespace)');
         assert('is_string($name)');
@@ -113,10 +113,10 @@ protected function toXMLInternal(DOMElement $parent, $namespace, $name)
     /**
      * Convert this Attribute to XML.
      *
-     * @param DOMElement $parent The element we should append this Attribute to.
-     * @return DOMElement
+     * @param \DOMElement $parent The element we should append this Attribute to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         return $this->toXMLInternal($parent, Constants::NS_SAML, 'saml:Attribute');
     }
diff --git a/src/SAML2/XML/saml/AttributeValue.php b/src/SAML2/XML/saml/AttributeValue.php
index 37021e399..760ce4f79 100644
--- a/src/SAML2/XML/saml/AttributeValue.php
+++ b/src/SAML2/XML/saml/AttributeValue.php
@@ -11,12 +11,12 @@
  *
  * @package SimpleSAMLphp
  */
-class AttributeValue implements Serializable
+class AttributeValue implements \Serializable
 {
     /**
-     * The raw DOMElement representing this value.
+     * The raw \DOMElement representing this value.
      *
-     * @var DOMElement
+     * @var \DOMElement
      */
     public $element;
 
@@ -25,12 +25,12 @@ class AttributeValue implements Serializable
      *
      * @param mixed $value The value of this element. Can be one of:
      *  - string                      Create an attribute value with a simple string.
-     *  - DOMElement(AttributeValue)  Create an attribute value of the given DOMElement.
-     *  - DOMElement                  Create an attribute value with the given DOMElement as a child.
+     *  - \DOMElement(AttributeValue)  Create an attribute value of the given DOMElement.
+     *  - \DOMElement                  Create an attribute value with the given DOMElement as a child.
      */
     public function __construct($value)
     {
-        assert('is_string($value) || $value instanceof DOMElement');
+        assert('is_string($value) || $value instanceof \DOMElement');
 
         if (is_string($value)) {
             $doc = DOMDocumentFactory::create();
@@ -59,13 +59,13 @@ public function __construct($value)
     /**
      * Append this attribute value to an element.
      *
-     * @param  DOMElement $parent The element we should append this attribute value to.
-     * @return DOMElement The generated AttributeValue element.
+     * @param  \DOMElement $parent The element we should append this attribute value to.
+     * @return \DOMElement The generated AttributeValue element.
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
-        assert('$this->element instanceof DOMElement');
-        assert('$this->element->namespaceURI === SAML2_Constants::NS_SAML && $this->element->localName === "AttributeValue"');
+        assert('$this->element instanceof \DOMElement');
+        assert('$this->element->namespaceURI === \SAML2\Constants::NS_SAML && $this->element->localName === "AttributeValue"');
 
         $v = Utils::copyElement($this->element, $parent);
 
@@ -89,7 +89,7 @@ public function getString()
      */
     public function __toString()
     {
-        assert('$this->element instanceof DOMElement');
+        assert('$this->element instanceof \DOMElement');
 
         $doc = $this->element->ownerDocument;
 
diff --git a/src/SAML2/XML/saml/NameID.php b/src/SAML2/XML/saml/NameID.php
index 45be3916a..e5346f391 100644
--- a/src/SAML2/XML/saml/NameID.php
+++ b/src/SAML2/XML/saml/NameID.php
@@ -50,9 +50,9 @@ class NameID
     /**
      * Initialize a saml:NameID.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
@@ -80,10 +80,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this NameID to XML.
      *
-     * @param  DOMElement|NULL $parent The element we should append to.
-     * @return DOMElement      This AdditionalMetadataLocation-element.
+     * @param  \DOMElement|NULL $parent The element we should append to.
+     * @return \DOMElement      This AdditionalMetadataLocation-element.
      */
-    public function toXML(DOMElement $parent = NULL)
+    public function toXML(\DOMElement $parent = NULL)
     {
         assert('is_string($this->NameQualifier) || is_null($this->NameQualifier)');
         assert('is_string($this->SPNameQualifier) || is_null($this->SPNameQualifier)');
diff --git a/src/SAML2/XML/saml/SubjectConfirmation.php b/src/SAML2/XML/saml/SubjectConfirmation.php
index 81f5c8fa4..c6973a946 100644
--- a/src/SAML2/XML/saml/SubjectConfirmation.php
+++ b/src/SAML2/XML/saml/SubjectConfirmation.php
@@ -36,30 +36,30 @@ class SubjectConfirmation
     /**
      * Initialize (and parse? a SubjectConfirmation element.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
-     * @throws Exception
+     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @throws \Exception
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
         }
 
         if (!$xml->hasAttribute('Method')) {
-            throw new Exception('SubjectConfirmation element without Method attribute.');
+            throw new \Exception('SubjectConfirmation element without Method attribute.');
         }
         $this->Method = $xml->getAttribute('Method');
 
         $nid = Utils::xpQuery($xml, './saml_assertion:NameID');
         if (count($nid) > 1) {
-            throw new Exception('More than one NameID in a SubjectConfirmation element.');
+            throw new \Exception('More than one NameID in a SubjectConfirmation element.');
         } elseif (!empty($nid)) {
             $this->NameID = new NameID($nid[0]);
         }
 
         $scd = Utils::xpQuery($xml, './saml_assertion:SubjectConfirmationData');
         if (count($scd) > 1) {
-            throw new Exception('More than one SubjectConfirmationData child in a SubjectConfirmation element.');
+            throw new \Exception('More than one SubjectConfirmationData child in a SubjectConfirmation element.');
         } elseif (!empty($scd)) {
             $this->SubjectConfirmationData = new SubjectConfirmationData($scd[0]);
         }
@@ -68,14 +68,14 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this element to XML.
      *
-     * @param  DOMElement $parent The parent element we should append this element to.
-     * @return DOMElement This element, as XML.
+     * @param  \DOMElement $parent The parent element we should append this element to.
+     * @return \DOMElement This element, as XML.
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_string($this->Method)');
-        assert('is_null($this->NameID) || $this->NameID instanceof SAML2_XML_saml_NameID');
-        assert('is_null($this->SubjectConfirmationData) || $this->SubjectConfirmationData instanceof SAML2_XML_saml_SubjectConfirmationData');
+        assert('is_null($this->NameID) || $this->NameID instanceof \SAML2\XML\saml\NameID');
+        assert('is_null($this->SubjectConfirmationData) || $this->SubjectConfirmationData instanceof SAML2\XML\saml\SubjectConfirmationData');
 
         $e = $parent->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:SubjectConfirmation');
         $parent->appendChild($e);
diff --git a/src/SAML2/XML/saml/SubjectConfirmationData.php b/src/SAML2/XML/saml/SubjectConfirmationData.php
index 73849258c..cbfa4be7d 100644
--- a/src/SAML2/XML/saml/SubjectConfirmationData.php
+++ b/src/SAML2/XML/saml/SubjectConfirmationData.php
@@ -63,9 +63,9 @@ class SubjectConfirmationData
     /**
      * Initialize (and parse) a SubjectConfirmationData element.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
@@ -87,7 +87,7 @@ public function __construct(DOMElement $xml = NULL)
             $this->Address = $xml->getAttribute('Address');
         }
         for ($n = $xml->firstChild; $n !== NULL; $n = $n->nextSibling) {
-            if (!($n instanceof DOMElement)) {
+            if (!($n instanceof \DOMElement)) {
                 continue;
             }
             if ($n->namespaceURI !== XMLSecurityDSig::XMLDSIGNS) {
@@ -108,10 +108,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this element to XML.
      *
-     * @param  DOMElement $parent The parent element we should append this element to.
-     * @return DOMElement This element, as XML.
+     * @param  \DOMElement $parent The parent element we should append this element to.
+     * @return \DOMElement This element, as XML.
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_null($this->NotBefore) || is_int($this->NotBefore)');
         assert('is_null($this->NotOnOrAfter) || is_int($this->NotOnOrAfter)');
diff --git a/src/SAML2/XML/samlp/Extensions.php b/src/SAML2/XML/samlp/Extensions.php
index ff1e7d9c5..b2cd18f8b 100644
--- a/src/SAML2/XML/samlp/Extensions.php
+++ b/src/SAML2/XML/samlp/Extensions.php
@@ -16,10 +16,10 @@ class Extensions
     /**
      * Get a list of Extensions in the given element.
      *
-     * @param  DOMElement $parent The element that may contain the samlp:Extensions element.
+     * @param  \DOMElement $parent The element that may contain the samlp:Extensions element.
      * @return array      Array of extensions.
      */
-    public static function getList(DOMElement $parent)
+    public static function getList(\DOMElement $parent)
     {
         $ret = array();
         foreach (Utils::xpQuery($parent, './saml_protocol:Extensions/*') as $node) {
@@ -32,10 +32,10 @@ public static function getList(DOMElement $parent)
     /**
      * Add a list of Extensions to the given element.
      *
-     * @param DOMElement        $parent     The element we should add the extensions to.
+     * @param \DOMElement        $parent     The element we should add the extensions to.
      * @param \SAML2\XML\Chunk[] $extensions List of extension objects.
      */
-    public static function addList(DOMElement $parent, array $extensions)
+    public static function addList(\DOMElement $parent, array $extensions)
     {
         if (empty($extensions)) {
             return;
diff --git a/src/SAML2/XML/shibmd/Scope.php b/src/SAML2/XML/shibmd/Scope.php
index 25b680137..29a15c5e0 100644
--- a/src/SAML2/XML/shibmd/Scope.php
+++ b/src/SAML2/XML/shibmd/Scope.php
@@ -34,9 +34,9 @@ class Scope
     /**
      * Create a Scope.
      *
-     * @param DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|NULL $xml The XML element we should load.
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         if ($xml === NULL) {
             return;
@@ -49,10 +49,10 @@ public function __construct(DOMElement $xml = NULL)
     /**
      * Convert this Scope to XML.
      *
-     * @param DOMElement $parent The element we should append this Scope to.
-     * @return DOMElement
+     * @param \DOMElement $parent The element we should append this Scope to.
+     * @return \DOMElement
      */
-    public function toXML(DOMElement $parent)
+    public function toXML(\DOMElement $parent)
     {
         assert('is_string($this->scope)');
         assert('is_bool($this->regexp) || is_null($this->regexp)');
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php
index 6d388d71b..66879836e 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php
@@ -28,7 +28,7 @@ class NotBeforeTest extends ControlledTimeTest
     public function setUp()
     {
         parent::setUp();
-        $this->assertion = m::mock('SAML2_Assertion');
+        $this->assertion = m::mock('SAML2\Assertion');
     }
 
     /**
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php
index 69f50e7ff..75a241910 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php
@@ -23,7 +23,7 @@ class NotOnOrAfterTest extends ControlledTimeTest
     public function setUp()
     {
         parent::setUp();
-        $this->assertion = m::mock('SAML2_Assertion');
+        $this->assertion = m::mock('SAML2\Assertion');
     }
 
     /**
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php
index 04fb073de..b819ec053 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php
@@ -23,7 +23,7 @@ class SessionNotOnOrAfterTest extends ControlledTimeTest
     public function setUp()
     {
         parent::setUp();
-        $this->assertion = m::mock('SAML2_Assertion');
+        $this->assertion = m::mock('SAML2\Assertion');
     }
 
     /**
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
index ad8c92b31..4c05e22dd 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
@@ -25,8 +25,8 @@ class SpIsValidAudienceTest extends \PHPUnit_Framework_TestCase
     public function setUp()
     {
         parent::setUp();
-        $this->assertion = m::mock('SAML2_Assertion');
-        $this->serviceProvider = m::mock('SAML2_Configuration_ServiceProvider');
+        $this->assertion = m::mock('SAML2\Assertion');
+        $this->serviceProvider = m::mock('SAML2\Configuration\ServiceProvider');
     }
 
     /**
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
index 5951ae3e9..0b1d16e94 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
@@ -16,7 +16,7 @@ class SubjectConfirmationTest extends \PHPUnit_Framework_TestCase
 
     public function setUp()
     {
-        $this->subjectConfirmation = m::mock('SAML2_XML_saml_SubjectConfirmation');
+        $this->subjectConfirmation = m::mock('SAML2\XML\saml\SubjectConfirmation');
     }
 
     /**
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php
index 5890d65ed..22128a940 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php
@@ -28,8 +28,8 @@ class SubjectConfirmationNotBeforeTest extends ControlledTimeTest
     public function setUp()
     {
         parent::setUp();
-        $this->subjectConfirmation = m::mock('SAML2_XML_saml_SubjectConfirmation');
-        $this->subjectConfirmationData = m::mock('SAML2_XML_saml_SubjectConfirmationData');
+        $this->subjectConfirmation = m::mock('SAML2\XML\saml\SubjectConfirmation');
+        $this->subjectConfirmationData = m::mock('SAML2\XML\saml\SubjectConfirmationData');
         $this->subjectConfirmation->SubjectConfirmationData = $this->subjectConfirmationData;
     }
 
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php
index 8078906de..24bfe87d0 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php
@@ -28,8 +28,8 @@ class SubjectConfirmationNotOnOrAfterTest extends ControlledTimeTest
     public function setUp()
     {
         parent::setUp();
-        $this->subjectConfirmation                          = m::mock('SAML2_XML_saml_SubjectConfirmation');
-        $this->subjectConfirmationData                      = m::mock('SAML2_XML_saml_SubjectConfirmationData');
+        $this->subjectConfirmation                          = m::mock('SAML2\XML\saml\SubjectConfirmation');
+        $this->subjectConfirmationData                      = m::mock('SAML2\XML\saml\SubjectConfirmationData');
         $this->subjectConfirmation->SubjectConfirmationData = $this->subjectConfirmationData;
     }
 
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMathchesTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMathchesTest.php
index 50afeb662..d4178fe34 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMathchesTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMathchesTest.php
@@ -23,8 +23,8 @@ class SubjectConfirmationRecipientMatchesTest extends
     public function setUp()
     {
         parent::setUp();
-        $this->subjectConfirmation                          = m::mock('SAML2_XML_saml_SubjectConfirmation');
-        $this->subjectConfirmationData                      = m::mock('SAML2_XML_saml_SubjectConfirmationData');
+        $this->subjectConfirmation                          = m::mock('SAML2\XML\saml\SubjectConfirmation');
+        $this->subjectConfirmationData                      = m::mock('SAML2\XML\saml\SubjectConfirmationData');
         $this->subjectConfirmation->SubjectConfirmationData = $this->subjectConfirmationData;
     }
 
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
index 7e8790ee4..2939b254b 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
@@ -27,10 +27,10 @@ class SubjectConfirmationResponseToMatchesTest extends
     public function setUp()
     {
         parent::setUp();
-        $this->subjectConfirmation                          = m::mock('SAML2_XML_saml_SubjectConfirmation');
-        $this->subjectConfirmationData                      = m::mock('SAML2_XML_saml_SubjectConfirmationData');
+        $this->subjectConfirmation                          = m::mock('SAML2\XML\saml\SubjectConfirmation');
+        $this->subjectConfirmationData                      = m::mock('SAML2\XML\saml\SubjectConfirmationData');
         $this->subjectConfirmation->SubjectConfirmationData = $this->subjectConfirmationData;
-        $this->response                                     = m::mock('SAML2_Response');
+        $this->response                                     = m::mock('SAML2\Response');
     }
 
     /**
diff --git a/tests/SAML2/AssertionTest.php b/tests/SAML2/AssertionTest.php
index d7bb152a2..606f1c323 100644
--- a/tests/SAML2/AssertionTest.php
+++ b/tests/SAML2/AssertionTest.php
@@ -12,21 +12,21 @@ class AssertionTest extends \PHPUnit_Framework_TestCase
     public function testMarshalling()
     {
         // Create an assertion
-        $assertion = new \Assertion();
+        $assertion = new Assertion();
         $assertion->setIssuer('testIssuer');
         $assertion->setValidAudiences(array('audience1', 'audience2'));
         $assertion->setAuthnContext('someAuthnContext');
 
-        // Marshall it to a DOMElement
+        // Marshall it to a \DOMElement
         $assertionElement = $assertion->toXML();
 
         // Test for an Issuer
-        $issuerElements = \Utils::xpQuery($assertionElement, './saml_assertion:Issuer');
+        $issuerElements = Utils::xpQuery($assertionElement, './saml_assertion:Issuer');
         $this->assertCount(1, $issuerElements);
         $this->assertEquals('testIssuer', $issuerElements[0]->textContent);
 
         // Test for an AudienceRestriction
-        $audienceElements = \Utils::xpQuery(
+        $audienceElements = Utils::xpQuery(
             $assertionElement,
             './saml_assertion:Conditions/saml_assertion:AudienceRestriction/saml_assertion:Audience'
         );
@@ -35,7 +35,7 @@ public function testMarshalling()
         $this->assertEquals('audience2', $audienceElements[1]->textContent);
 
         // Test for an Authentication Context
-        $authnContextElements = \Utils::xpQuery(
+        $authnContextElements = Utils::xpQuery(
             $assertionElement,
             './saml_assertion:AuthnStatement/saml_assertion:AuthnContext/saml_assertion:AuthnContextClassRef'
         );
@@ -70,7 +70,7 @@ public function testUnmarshalling()
 </saml:Assertion>
 XML;
         $document  = DOMDocumentFactory::fromString($xml);
-        $assertion = new \Assertion($document->firstChild);
+        $assertion = new Assertion($document->firstChild);
 
         // Test for valid audiences
         $assertionValidAudiences = $assertion->getValidAudiences();
@@ -110,7 +110,7 @@ public function testAuthnContextDeclAndClassRef()
         // Try with unmarshalling
         $document = DOMDocumentFactory::fromString($xml);
 
-        $assertion = new \Assertion($document->documentElement);
+        $assertion = new Assertion($document->documentElement);
         $authnContextDecl = $assertion->getAuthnContextDecl();
         $this->assertNotEmpty($authnContextDecl);
         $this->assertEquals('AuthnContextDecl', $authnContextDecl->localName);
@@ -142,7 +142,7 @@ public function testAuthnContextDeclRefAndClassRef()
 
         $document = DOMDocumentFactory::fromString($xml);
 
-        $assertion = new \Assertion($document->documentElement);
+        $assertion = new Assertion($document->documentElement);
         $this->assertEquals('/relative/path/to/document.xml', $assertion->getAuthnContextDeclRef());
         $this->assertEquals('someAuthnContext', $assertion->getAuthnContextClassRef());
     }
@@ -155,25 +155,25 @@ public function testAuthnContextDeclAndRefConstraint()
 XML;
 
         $document  = DOMDocumentFactory::fromString($xml);
-        $assertion = new \Assertion();
+        $assertion = new Assertion();
 
         $e = null;
         try {
             $assertion->setAuthnContextDecl(new Chunk($document->documentElement));
             $assertion->setAuthnContextDeclRef('/relative/path/to/document.xml');
         }
-        catch (Exception $e) {}
+        catch (\Exception $e) {}
         $this->assertNotEmpty($e);
 
         // Try again in reverse order for good measure.
-        $assertion = new \Assertion();
+        $assertion = new Assertion();
 
         $e = null;
         try {
             $assertion->setAuthnContextDeclRef('/relative/path/to/document.xml');
             $assertion->setAuthnContextDecl(new Chunk($document->documentElement));
         }
-        catch (Exception $e) {}
+        catch (\Exception $e) {}
         $this->assertNotEmpty($e);
 
         // Try with unmarshalling
@@ -201,9 +201,9 @@ public function testAuthnContextDeclAndRefConstraint()
 
         $e = null;
         try {
-            new \Assertion($document->documentElement);
+            new Assertion($document->documentElement);
         }
-        catch (Exception $e) {}
+        catch (\Exception $e) {}
         $this->assertNotEmpty($e);
     }
 
@@ -228,9 +228,9 @@ public function testMustHaveClassRefOrDeclOrDeclRef()
         );
         $e = null;
         try {
-            $assertion = new \Assertion($document->firstChild);
+            $assertion = new Assertion($document->firstChild);
         }
-        catch (Exception $e) {
+        catch (\Exception $e) {
         }
         $this->assertNotEmpty($e);
     }
@@ -261,14 +261,14 @@ public function testNoAuthnContextDeclRefFallback()
 </saml:Assertion>
 XML
         );
-        $assertion = new \Assertion($document->firstChild);
+        $assertion = new Assertion($document->firstChild);
         $this->assertEmpty($assertion->getAuthnContextClassRef());
         $this->assertEquals($authnContextDeclRef, $assertion->getAuthnContextDeclRef());
     }
 
     public function testHasEncryptedAttributes()
     {
-        $document = new DOMDocument();
+        $document = new \DOMDocument();
         $document->loadXML(<<<XML
     <saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
                     Version="2.0"
@@ -325,7 +325,7 @@ public function testHasEncryptedAttributes()
     </saml:Assertion>
 XML
         );
-        $assertion = new \Assertion($document->firstChild);
+        $assertion = new Assertion($document->firstChild);
         $this->assertTrue($assertion->hasEncryptedAttributes());
     }
 }
diff --git a/tests/SAML2/AuthnRequestTest.php b/tests/SAML2/AuthnRequestTest.php
index c44091368..4f616a535 100644
--- a/tests/SAML2/AuthnRequestTest.php
+++ b/tests/SAML2/AuthnRequestTest.php
@@ -5,7 +5,7 @@
 /**
  * Class \SAML2\AuthnRequestTest
  */
-class AuthnRequestTest extends PHPUnit_Framework_TestCase
+class AuthnRequestTest extends \PHPUnit_Framework_TestCase
 {
     public function testUnmarshalling()
     {
@@ -40,7 +40,7 @@ public function testUnmarshalling()
 
     public function testMarshallingOfSimpleRequest()
     {
-        $document = new DOMDocument();
+        $document = new \DOMDocument();
         $document->loadXML(<<<AUTHNREQUEST
 <samlp:AuthnRequest
   xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
@@ -107,7 +107,7 @@ public function testExtensionOrdering()
 
     public function testThatTheSubjectIsCorrectlyRead()
     {
-        $document = new DOMDocument();
+        $document = new \DOMDocument();
         $document->loadXML(<<<AUTHNREQUEST
 <samlp:AuthnRequest
     xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
@@ -145,7 +145,7 @@ public function testThatTheSubjectCanBeSetBySettingTheNameId()
 
     public function testThatAnEncryptedNameIdCanBeDecrypted()
     {
-        $document = new DOMDocument();
+        $document = new \DOMDocument();
         $document->loadXML(<<<AUTHNREQUEST
 <samlp:AuthnRequest
     xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
@@ -207,7 +207,7 @@ public function testThatAnEncryptedNameIdResultsInTheCorrectXmlStructure()
         $key = CertificatesMock::getPublicKey();
         $request->encryptNameId($key);
 
-        $expectedStructureDocument = new DOMDocument();
+        $expectedStructureDocument = new \DOMDocument();
         $expectedStructureDocument->loadXML(<<<AUTHNREQUEST
 <samlp:AuthnRequest
     xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
@@ -261,7 +261,7 @@ public function testIDPlistAttributes()
             array('ProviderID' => 'urn:example:1', 'Name' => 'Voorbeeld', 'Something' => 'Else')
         ));
 
-        $expectedStructureDocument = new DOMDocument();
+        $expectedStructureDocument = new \DOMDocument();
         $expectedStructureDocument->loadXML(<<<AUTHNREQUEST
 <samlp:AuthnRequest
     xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
diff --git a/tests/SAML2/Certificate/FingerprintLoaderTest.php b/tests/SAML2/Certificate/FingerprintLoaderTest.php
index 83f9efaf6..fb82bda5c 100644
--- a/tests/SAML2/Certificate/FingerprintLoaderTest.php
+++ b/tests/SAML2/Certificate/FingerprintLoaderTest.php
@@ -5,7 +5,7 @@
 use SAML2\Configuration\ArrayAdapter;
 use SAML2\Certificate\Stub\ImplementsToString;
 
-class FingerprintLoaderTest extends PHPUnit_Framework_TestCase
+class FingerprintLoaderTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @var \SAML2\Certificate\FingerprintLoader
@@ -20,7 +20,7 @@ class FingerprintLoaderTest extends PHPUnit_Framework_TestCase
     public function setUp()
     {
         $this->fingerprintLoader = new FingerprintLoader();
-        $this->configurationMock = \Mockery::mock('SAML2_Configuration_CertificateProvider');
+        $this->configurationMock = \Mockery::mock('SAML2\Configuration\CertificateProvider');
     }
 
     /**
@@ -55,7 +55,7 @@ public function it_correctly_parses_arrays_and_traversables($configurationValue)
             ->andReturn($configurationValue);
 
         $result = $this->fingerprintLoader->loadFingerprints($this->configurationMock);
-        $this->assertInstanceOf('SAML2_Certificate_FingerprintCollection', $result);
+        $this->assertInstanceOf('\SAML2\Certificate\FingerprintCollection', $result);
         $this->assertCount(count($configurationValue), $result);
     }
 
diff --git a/tests/SAML2/Certificate/FingerprintTest.php b/tests/SAML2/Certificate/FingerprintTest.php
index 777c7412a..4e9b58101 100644
--- a/tests/SAML2/Certificate/FingerprintTest.php
+++ b/tests/SAML2/Certificate/FingerprintTest.php
@@ -2,7 +2,7 @@
 
 namespace SAML2\Certificate;
 
-class FingerprintTest extends PHPUnit_Framework_TestCase
+class FingerprintTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @var \SAML2\Certificate\Fingerprint
diff --git a/tests/SAML2/Certificate/KeyLoaderTest.php b/tests/SAML2/Certificate/KeyLoaderTest.php
index d54402b5f..18eb319c7 100644
--- a/tests/SAML2/Certificate/KeyLoaderTest.php
+++ b/tests/SAML2/Certificate/KeyLoaderTest.php
@@ -26,7 +26,7 @@ class KeyLoaderTest extends \PHPUnit_Framework_TestCase
     public function setUp()
     {
         $this->keyLoader = new KeyLoader();
-        $this->configurationMock = \Mockery::mock('SAML2_Configuration_CertificateProvider');
+        $this->configurationMock = \Mockery::mock('SAML2\Configuration\CertificateProvider');
     }
 
     /**
diff --git a/tests/SAML2/Certificate/PrivateKeyLoaderTest.php b/tests/SAML2/Certificate/PrivateKeyLoaderTest.php
index 68d6da9e6..380c5648e 100644
--- a/tests/SAML2/Certificate/PrivateKeyLoaderTest.php
+++ b/tests/SAML2/Certificate/PrivateKeyLoaderTest.php
@@ -28,7 +28,7 @@ public function loading_a_configured_private_key_returns_a_certificate_private_k
     ) {
         $resultingKey = $this->privateKeyLoader->loadPrivateKey($configuredKey);
 
-        $this->assertInstanceOf('SAML2_Certificate_PrivateKey', $resultingKey);
+        $this->assertInstanceOf('\SAML2\Certificate\PrivateKey', $resultingKey);
         $this->assertEquals($resultingKey->getKeyAsString(), "This would normally contain the private key data.\n");
         $this->assertEquals($resultingKey->getPassphrase(), $configuredKey->getPassPhrase());
     }
diff --git a/tests/SAML2/Certificate/X509Test.php b/tests/SAML2/Certificate/X509Test.php
index 4b2e7d4a3..425b078e0 100644
--- a/tests/SAML2/Certificate/X509Test.php
+++ b/tests/SAML2/Certificate/X509Test.php
@@ -2,7 +2,7 @@
 
 namespace SAML2\Certificate;
 
-class X509Test extends PHPUnit_Framework_TestCase
+class X509Test extends \PHPUnit_Framework_TestCase
 {
     /**
      * @group certificate
diff --git a/tests/SAML2/Configuration/ArrayAdapterTest.php b/tests/SAML2/Configuration/ArrayAdapterTest.php
index 39a6cbaa8..9d75d0858 100644
--- a/tests/SAML2/Configuration/ArrayAdapterTest.php
+++ b/tests/SAML2/Configuration/ArrayAdapterTest.php
@@ -2,7 +2,7 @@
 
 namespace SAML2\Configuration;
 
-class ArrayAdapterTest extends PHPUnit_Framework_TestCase
+class ArrayAdapterTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @group configuration
diff --git a/tests/SAML2/ControlledTimeTest.php b/tests/SAML2/ControlledTimeTest.php
index d1d351032..af5f2468c 100644
--- a/tests/SAML2/ControlledTimeTest.php
+++ b/tests/SAML2/ControlledTimeTest.php
@@ -16,7 +16,7 @@ abstract class ControlledTimeTest extends \PHPUnit_Framework_TestCase
 
     public function setUp()
     {
-        $timing = m::mock('alias:SAML2_Utilities_Temporal');
+        $timing = m::mock('alias:SAML2\Utilities\Temporal');
         $timing->shouldReceive('getTime')->andReturn($this->currentTime);
     }
 }
diff --git a/tests/SAML2/DOMDocumentFactoryTest.php b/tests/SAML2/DOMDocumentFactoryTest.php
index ddf5c857a..25bcf4a79 100644
--- a/tests/SAML2/DOMDocumentFactoryTest.php
+++ b/tests/SAML2/DOMDocumentFactoryTest.php
@@ -2,7 +2,7 @@
 
 namespace SAML2;
 
-class DOMDocumentFactoryTest extends PHPUnit_Framework_TestCase
+class DOMDocumentFactoryTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @param mixed $argument
@@ -135,7 +135,7 @@ public function nonStringProvider()
         return array(
             'integer' => array(1),
             'float'   => array(1.234),
-            'object'  => array(new stdClass()),
+            'object'  => array(new \stdClass()),
             'null'    => array(NULL),
             'boolean' => array(FALSE),
             'array'   => array(array()),
diff --git a/tests/SAML2/LogoutRequestTest.php b/tests/SAML2/LogoutRequestTest.php
index bebccea39..956f29bad 100644
--- a/tests/SAML2/LogoutRequestTest.php
+++ b/tests/SAML2/LogoutRequestTest.php
@@ -8,7 +8,7 @@
 class LogoutRequestTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var DOMElement
+     * @var \DOMElement
      */
     private $logoutRequestElement;
 
diff --git a/tests/SAML2/Response/SignatureValidationTest.php b/tests/SAML2/Response/SignatureValidationTest.php
index c1fcd7156..f9b4ac185 100644
--- a/tests/SAML2/Response/SignatureValidationTest.php
+++ b/tests/SAML2/Response/SignatureValidationTest.php
@@ -13,7 +13,7 @@
 /**
  * Test that ensures that either the response or the assertion(s) or both must be signed.
  */
-class SignatureValidationTest extends PHPUnit_Framework_TestCase
+class SignatureValidationTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @var \SAML2\Configuration\IdentityProvider
@@ -26,12 +26,12 @@ class SignatureValidationTest extends PHPUnit_Framework_TestCase
     private $serviceProviderConfiguration;
 
     /**
-     * @var Mockery\MockInterface Mock of \SAML2\Assertion\ProcessorBuilder
+     * @var \Mockery\MockInterface Mock of \SAML2\Assertion\ProcessorBuilder
      */
     private $assertionProcessorBuilder;
 
     /**
-     * @var Mockery\MockInterface Mock of \SAML2\Assertion\Processor
+     * @var \Mockery\MockInterface Mock of \SAML2\Assertion\Processor
      */
     private $assertionProcessor;
 
@@ -46,8 +46,8 @@ class SignatureValidationTest extends PHPUnit_Framework_TestCase
      */
     public function setUp()
     {
-        $this->assertionProcessorBuilder = Mockery::mock('alias:SAML2_Assertion_ProcessorBuilder');
-        $this->assertionProcessor = Mockery::mock('SAML2_Assertion_Processor');
+        $this->assertionProcessorBuilder = \Mockery::mock('alias:SAML2\Assertion\ProcessorBuilder');
+        $this->assertionProcessor = \Mockery::mock('SAML2\Assertion\Processor');
         $this->assertionProcessorBuilder
             ->shouldReceive('build')
             ->once()
@@ -68,7 +68,7 @@ public function setUp()
      */
     public function tearDown()
     {
-        Mockery::close();
+        \Mockery::close();
     }
 
     /**
@@ -146,7 +146,7 @@ public function testThatAnUnsignedResponseWithNoSignedAssertionsThrowsAnExceptio
      */
     private function getSignedResponseWithUnsignedAssertion()
     {
-        $doc = new DOMDocument();
+        $doc = new \DOMDocument();
         $doc->load(__DIR__ . '/response.xml');
         $response = new Response($doc->firstChild);
         $response->setSignatureKey(CertificatesMock::getPrivateKey());
@@ -161,7 +161,7 @@ private function getSignedResponseWithUnsignedAssertion()
      */
     private function getUnsignedResponseWithSignedAssertion()
     {
-        $doc = new DOMDocument();
+        $doc = new \DOMDocument();
         $doc->load(__DIR__ . '/response.xml');
         $response = new Response($doc->firstChild);
 
@@ -181,7 +181,7 @@ private function getUnsignedResponseWithSignedAssertion()
      */
     private function getSignedResponseWithSignedAssertion()
     {
-        $doc = new DOMDocument();
+        $doc = new \DOMDocument();
         $doc->load(__DIR__ . '/response.xml');
         $response = new Response($doc->firstChild);
         $response->setSignatureKey(CertificatesMock::getPrivateKey());
@@ -200,7 +200,7 @@ private function getSignedResponseWithSignedAssertion()
      */
     private function getUnsignedResponseWithUnsignedAssertion()
     {
-        $doc = new DOMDocument();
+        $doc = new \DOMDocument();
         $doc->load(__DIR__ . '/response.xml');
         return new Response($doc->firstChild);
     }
diff --git a/tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php b/tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
index f9d614115..8a70fedd8 100644
--- a/tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
+++ b/tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
@@ -14,7 +14,7 @@ class DestinationMatchesTest extends \PHPUnit_Framework_TestCase
 
     public function setUp()
     {
-        $this->response = \Mockery::mock('SAML2_Response');
+        $this->response = \Mockery::mock('SAML2\Response');
     }
 
     /**
diff --git a/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php b/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
index faf7a34a9..2b2392ad1 100644
--- a/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
+++ b/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
@@ -14,7 +14,7 @@ class IsSuccessfulTest extends \PHPUnit_Framework_TestCase
 
     public function setUp()
     {
-        $this->response = \Mockery::mock('SAML2_Response');
+        $this->response = \Mockery::mock('SAML2\Response');
     }
 
     /**
diff --git a/tests/SAML2/Response/XmlSignatureWrappingTest.php b/tests/SAML2/Response/XmlSignatureWrappingTest.php
index 085d8dc1d..c0ef0d6c6 100644
--- a/tests/SAML2/Response/XmlSignatureWrappingTest.php
+++ b/tests/SAML2/Response/XmlSignatureWrappingTest.php
@@ -9,7 +9,7 @@
 use SAML2\DOMDocumentFactory;
 use SAML2\Assertion;
 
-class XmlSignatureWrappingTest extends PHPUnit_Framework_TestCase
+class XmlSignatureWrappingTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @var \SAML2\Signature\Validator
diff --git a/tests/SAML2/ResponseTest.php b/tests/SAML2/ResponseTest.php
index 9aae81df9..c452a0f30 100644
--- a/tests/SAML2/ResponseTest.php
+++ b/tests/SAML2/ResponseTest.php
@@ -5,7 +5,7 @@
 /**
  * Class \SAML2\ResponseTest
  */
-class ResponseTest extends PHPUnit_Framework_TestCase
+class ResponseTest extends \PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
diff --git a/tests/SAML2/Signature/FingerprintValidatorTest.php b/tests/SAML2/Signature/FingerprintValidatorTest.php
index df491650a..c0c2b9794 100644
--- a/tests/SAML2/Signature/FingerprintValidatorTest.php
+++ b/tests/SAML2/Signature/FingerprintValidatorTest.php
@@ -25,8 +25,8 @@ class FingerprintValidatorTest extends \PHPUnit_Framework_TestCase
 
     public function setUp()
     {
-        $this->mockConfiguration = \Mockery::mock('SAML2_Configuration_CertificateProvider');
-        $this->mockSignedElement = \Mockery::mock('SAML2_SignedElement');
+        $this->mockConfiguration = \Mockery::mock('SAML2\Configuration\CertificateProvider');
+        $this->mockSignedElement = \Mockery::mock('SAML2\SignedElement');
     }
 
     /**
diff --git a/tests/SAML2/Signature/PublicKeyValidatorTest.php b/tests/SAML2/Signature/PublicKeyValidatorTest.php
index c0cb78e43..0fb07284f 100644
--- a/tests/SAML2/Signature/PublicKeyValidatorTest.php
+++ b/tests/SAML2/Signature/PublicKeyValidatorTest.php
@@ -19,8 +19,8 @@ class PublicKeyValidatorTest extends \PHPUnit_Framework_TestCase
 
     public function setUp()
     {
-        $this->mockConfiguration = \Mockery::mock('SAML2_Configuration_CertificateProvider');
-        $this->mockSignedElement = \Mockery::mock('SAML2_SignedElement');
+        $this->mockConfiguration = \Mockery::mock('SAML2\Configuration\CertificateProvider');
+        $this->mockSignedElement = \Mockery::mock('SAML2\SignedElement');
     }
 
     /**
@@ -95,7 +95,7 @@ public function signed_message_with_valid_signature_is_validated_correctly()
 
     private function prepareKeyLoader($returnValue)
     {
-        return \Mockery::mock('SAML2_Certificate_KeyLoader')
+        return \Mockery::mock('SAML2\Certificate\KeyLoader')
             ->shouldReceive('extractPublicKeys')
             ->andReturn($returnValue)
             ->getMock();
diff --git a/tests/SAML2/SignedElementHelperMock.php b/tests/SAML2/SignedElementHelperMock.php
index 806ef435a..6a3a04516 100644
--- a/tests/SAML2/SignedElementHelperMock.php
+++ b/tests/SAML2/SignedElementHelperMock.php
@@ -8,15 +8,15 @@
 class SignedElementHelperMock extends SignedElementHelper
 {
     /**
-     * @param DOMElement $xml
+     * @param \DOMElement $xml
      */
-    public function __construct(DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = NULL)
     {
         parent::__construct($xml);
     }
 
     /**
-     * @return DOMElement
+     * @return \DOMElement
      */
     public function toSignedXML()
     {
diff --git a/tests/SAML2/StatusResponseTest.php b/tests/SAML2/StatusResponseTest.php
index 800d41026..3bffa0a42 100644
--- a/tests/SAML2/StatusResponseTest.php
+++ b/tests/SAML2/StatusResponseTest.php
@@ -5,7 +5,7 @@
 /**
  * Class \SAML2\StatusResponseTest
  */
-class StatusResponseTest extends PHPUnit_Framework_TestCase
+class StatusResponseTest extends \PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
diff --git a/tests/SAML2/UtilsTest.php b/tests/SAML2/UtilsTest.php
index 4cc2aeb54..8760cdef0 100644
--- a/tests/SAML2/UtilsTest.php
+++ b/tests/SAML2/UtilsTest.php
@@ -5,7 +5,7 @@
 /**
  * Class \SAML2\UtilsTest
  */
-class UtilsTest extends PHPUnit_Framework_TestCase
+class UtilsTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * Test querying a SAML XML document.
@@ -188,7 +188,7 @@ public function testXsDateTimeToTimestamp($shouldPass, $time, $expectedTs = null
             $ts = Utils::xsDateTimeToTimestamp($time);
             $this->assertTrue($shouldPass);
             $this->assertEquals($expectedTs, $ts);
-        } catch (Exception $e) {
+        } catch (\Exception $e) {
             $this->assertFalse($shouldPass);
         }
     }
diff --git a/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php b/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
index 6615a5655..159c66308 100644
--- a/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
+++ b/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
@@ -9,7 +9,7 @@
 /**
  * Class \SAML2\XML\md\AdditionalMetadataLocationTest
  */
-class AdditionalMetadataLocationTest extends PHPUnit_Framework_TestCase
+class AdditionalMetadataLocationTest extends \PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
diff --git a/tests/SAML2/XML/md/AffiliationDescriptorTest.php b/tests/SAML2/XML/md/AffiliationDescriptorTest.php
index 1a58c3f39..67e6cb8fc 100644
--- a/tests/SAML2/XML/md/AffiliationDescriptorTest.php
+++ b/tests/SAML2/XML/md/AffiliationDescriptorTest.php
@@ -6,7 +6,7 @@
 use SAML2\Utils;
 use SAML2\Constants;
 
-class AffiliationDescriptorTest extends PHPUnit_Framework_TestCase
+class AffiliationDescriptorTest extends \PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
diff --git a/tests/SAML2/XML/md/EndpointTypeTest.php b/tests/SAML2/XML/md/EndpointTypeTest.php
index 4af9e7e35..67c365a79 100644
--- a/tests/SAML2/XML/md/EndpointTypeTest.php
+++ b/tests/SAML2/XML/md/EndpointTypeTest.php
@@ -9,7 +9,7 @@
 /**
  * Class \SAML2\XML\md\EndpointType
  */
-class EndpointTypeTest extends PHPUnit_Framework_TestCase
+class EndpointTypeTest extends \PHPUnit_Framework_TestCase
 {
     public function testMarshalling()
     {
diff --git a/tests/SAML2/XML/md/RoleDescriptorMock.php b/tests/SAML2/XML/md/RoleDescriptorMock.php
index bf3ac40b3..84960c717 100644
--- a/tests/SAML2/XML/md/RoleDescriptorMock.php
+++ b/tests/SAML2/XML/md/RoleDescriptorMock.php
@@ -6,11 +6,11 @@
 
 
 class RoleDescriptorMock extends RoleDescriptor {
-    public function __construct(DOMElement $xml = NULL) {
+    public function __construct(\DOMElement $xml = NULL) {
         parent::__construct('md:RoleDescriptor', $xml);
     }
 
-    public function toXML(DOMElement $parent) {
+    public function toXML(\DOMElement $parent) {
         $xml = parent::toXML($parent);
         $xml->setAttributeNS(Constants::NS_XSI, 'xsi:type', 'myns:MyElement');
         $xml->setAttributeNS('http://example.org/mynsdefinition', 'myns:tmp', 'tmp');

From 8fcd3e0b9d83ec02ffef8c7aac1114a9fc4f8389 Mon Sep 17 00:00:00 2001
From: Charles Bell <cb8@users.noreply.github.com>
Date: Sun, 29 Nov 2015 21:15:16 +0100
Subject: [PATCH 09/17] Use proper namespaces in examples

---
 README.md | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index fe713264b..59d36b6d0 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ Usage
 composer require simplesamlphp/saml2
 ```
 
-* Provide the required external dependencies by extending and implementing the ```SAML2_Compat_AbstractContainer```
+* Provide the required external dependencies by extending and implementing the ```SAML2\Compat\AbstractContainer```
   then injecting it in the ContainerSingleton (see example below).
 
 * **Make sure you've read the security section below**
@@ -45,24 +45,24 @@ Example:
 
     // Implement the Container interface (out of scope for example)
     require 'container.php';
-    SAML2_Compat_ContainerSingleton::setContainer($container);
+    SAML2\Compat\ContainerSingleton::setContainer($container);
 
     // Set up an AuthnRequest
-    $request = new SAML2_AuthnRequest();
+    $request = new SAML2\AuthnRequest();
     $request->setId($container->generateId());
     $request->setIssuer('https://sp.example.edu');
     $request->setDestination('https://idp.example.edu');
 
     // Send it off using the HTTP-Redirect binding
-    $binding = new SAML2_HTTPRedirect();
+    $binding = new SAML2\HTTPRedirect();
     $binding->send($request);
 ```
 
 Security
 --------
-* Should you need to create a DOMDocument instance, use the `SAML2_DOMDocumentFactory` to create DOMDocuments from
-  either a string (`SAML2_DOMDocumentFactory::fromString($theXmlAsString)`), a file (`SAML2_DOMDocumentFactory::fromFile($pathToTheFile)`)
-  or just a new instance (`SAML2_DOMDocumentFactory::create()`). This in order to protect yourself against the
+* Should you need to create a DOMDocument instance, use the `SAML2\DOMDocumentFactory` to create DOMDocuments from
+  either a string (`SAML2\DOMDocumentFactory::fromString($theXmlAsString)`), a file (`SAML2\DOMDocumentFactory::fromFile($pathToTheFile)`)
+  or just a new instance (`SAML2\DOMDocumentFactory::create()`). This in order to protect yourself against the
   [XXE Processing Vulnerability](https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing), as well as
   [XML Entity Expansion](https://phpsecurity.readthedocs.org/en/latest/Injection-Attacks.html#defenses-against-xml-entity-expansion) attacks
 

From 3bd4fe44c187f3f8bcc50a33bb1b0a99fe963f7a Mon Sep 17 00:00:00 2001
From: Charles Bell <cb8@users.noreply.github.com>
Date: Sun, 29 Nov 2015 21:22:17 +0100
Subject: [PATCH 10/17] Format 'use' statements

---
 src/SAML2/ArtifactResolve.php                 |  1 +
 src/SAML2/Assertion.php                       |  2 +-
 src/SAML2/Assertion/Decrypter.php             |  4 ++--
 src/SAML2/Assertion/Processor.php             | 12 +++++------
 src/SAML2/Assertion/ProcessorBuilder.php      | 20 +++++++++----------
 .../Transformer/DecodeBase64Transformer.php   |  4 ++--
 .../NameIdDecryptionTransformer.php           |  6 +++---
 .../Transformer/TransformerChain.php          |  4 ++--
 .../Validation/AssertionValidator.php         |  4 ++--
 .../ConstraintValidator/NotBefore.php         |  2 +-
 .../ConstraintValidator/NotOnOrAfter.php      |  2 +-
 .../SessionNotOnOrAfter.php                   |  2 +-
 .../ConstraintValidator/SpIsValidAudience.php |  6 +++---
 .../SubjectConfirmationMethod.php             |  4 ++--
 .../SubjectConfirmationNotBefore.php          |  4 ++--
 .../SubjectConfirmationNotOnOrAfter.php       |  4 ++--
 .../SubjectConfirmationRecipientMatches.php   |  2 +-
 .../SubjectConfirmationResponseToMatches.php  |  2 +-
 .../SubjectConfirmationValidator.php          |  2 +-
 .../Exception/InvalidKeyUsageException.php    |  2 +-
 .../Certificate/FingerprintCollection.php     |  2 +-
 src/SAML2/Certificate/KeyCollection.php       |  2 +-
 src/SAML2/Certificate/KeyLoader.php           |  6 +++---
 src/SAML2/Certificate/PrivateKeyLoader.php    |  4 ++--
 src/SAML2/DOMDocumentFactory.php              |  2 +-
 src/SAML2/Response/Processor.php              | 12 +++++------
 .../DestinationMatches.php                    |  2 +-
 .../ConstraintValidator/IsSuccessful.php      |  4 ++--
 .../Validation/PreconditionValidator.php      |  2 +-
 src/SAML2/Signature/ChainedValidator.php      |  2 +-
 src/SAML2/Signature/FingerprintValidator.php  |  4 ++--
 src/SAML2/Signature/PublicKeyValidator.php    |  6 +++---
 src/SAML2/Signature/Validator.php             |  6 +++---
 src/SAML2/Signature/ValidatorChain.php        |  2 +-
 src/SAML2/Signature/ValidatorInterface.php    |  2 +-
 src/SAML2/Utils.php                           |  4 ++--
 src/SAML2/XML/Chunk.php                       |  3 ++-
 .../XML/md/AdditionalMetadataLocation.php     |  2 +-
 src/SAML2/XML/md/AffiliationDescriptor.php    |  2 +-
 .../XML/md/AttributeAuthorityDescriptor.php   |  2 +-
 .../XML/md/AttributeConsumingService.php      |  2 +-
 src/SAML2/XML/md/AuthnAuthorityDescriptor.php |  2 +-
 src/SAML2/XML/md/ContactPerson.php            |  2 +-
 src/SAML2/XML/md/EntitiesDescriptor.php       |  4 ++--
 src/SAML2/XML/md/EntityDescriptor.php         |  4 ++--
 src/SAML2/XML/md/Extensions.php               | 10 +++++-----
 src/SAML2/XML/md/IDPSSODescriptor.php         |  2 +-
 src/SAML2/XML/md/KeyDescriptor.php            |  4 ++--
 src/SAML2/XML/md/Organization.php             |  2 +-
 src/SAML2/XML/md/PDPDescriptor.php            |  2 +-
 src/SAML2/XML/md/RequestedAttribute.php       |  4 ++--
 src/SAML2/XML/md/RoleDescriptor.php           |  2 +-
 src/SAML2/XML/md/SSODescriptorType.php        |  2 +-
 src/SAML2/XML/mdattr/EntityAttributes.php     |  2 +-
 src/SAML2/XML/saml/Attribute.php              |  2 +-
 src/SAML2/XML/saml/AttributeValue.php         |  2 +-
 src/SAML2/XML/saml/NameID.php                 |  2 +-
 src/SAML2/XML/saml/SubjectConfirmation.php    |  2 +-
 .../XML/saml/SubjectConfirmationData.php      |  2 +-
 src/SAML2/XML/samlp/Extensions.php            |  2 +-
 .../ConstraintValidator/NotBeforeTest.php     |  5 ++---
 .../ConstraintValidator/NotOnOrAfterTest.php  |  5 ++---
 .../SessionNotOnOrAfterTest.php               |  5 ++---
 .../SpIsValidAudienceTest.php                 |  3 +--
 .../SubjectConfirmationMethodTest.php         |  7 +++----
 .../SubjectConfirmationNotBeforeTest.php      |  5 ++---
 .../SubjectConfirmationNotOnOrAfterTest.php   |  5 ++---
 ...bjectConfirmationRecipientMathchesTest.php |  7 +++----
 ...bjectConfirmationResponseToMatchesTest.php |  3 +--
 .../Certificate/FingerprintLoaderTest.php     |  2 +-
 tests/SAML2/ControlledTimeTest.php            |  2 +-
 .../Response/SignatureValidationTest.php      |  6 +++---
 .../ConstraintValidator/IsSuccessfulTest.php  |  2 +-
 .../Response/XmlSignatureWrappingTest.php     |  6 +++---
 .../Signature/FingerprintValidatorTest.php    |  6 +++---
 .../SAML2/Signature/MockChainedValidator.php  |  2 +-
 .../Signature/PublicKeyValidatorTest.php      |  8 ++++----
 tests/SAML2/Signature/ValidatorChainTest.php  |  2 +-
 .../XML/md/AdditionalMetadataLocationTest.php |  2 +-
 .../XML/md/AffiliationDescriptorTest.php      |  2 +-
 tests/SAML2/XML/md/EndpointTypeTest.php       |  2 +-
 tests/SAML2/XML/md/RoleDescriptorMock.php     |  1 -
 tests/SAML2/XML/md/RoleDescriptorTest.php     |  2 +-
 tests/SAML2/XML/saml/AttributeTest.php        |  6 +++---
 tests/SAML2/XML/saml/NameIDTest.php           |  4 ++--
 .../XML/saml/SubjectConfirmationDataTest.php  |  2 +-
 .../XML/saml/SubjectConfirmationTest.php      |  2 +-
 87 files changed, 156 insertions(+), 164 deletions(-)

diff --git a/src/SAML2/ArtifactResolve.php b/src/SAML2/ArtifactResolve.php
index eb69ddc20..547d323b9 100644
--- a/src/SAML2/ArtifactResolve.php
+++ b/src/SAML2/ArtifactResolve.php
@@ -1,6 +1,7 @@
 <?php
 
 namespace SAML2;
+
 /**
  * The Artifact is part of the SAML 2.0 IdP code, and it builds an artifact object.
  * I am using strings, because I find them easier to work with.
diff --git a/src/SAML2/Assertion.php b/src/SAML2/Assertion.php
index 383e770e2..ca7168660 100644
--- a/src/SAML2/Assertion.php
+++ b/src/SAML2/Assertion.php
@@ -5,8 +5,8 @@
 use RobRichards\XMLSecLibs\XMLSecEnc;
 use RobRichards\XMLSecLibs\XMLSecurityKey;
 use SAML2\Utilities\Temporal;
-use SAML2\XML\saml\SubjectConfirmation;
 use SAML2\XML\Chunk;
+use SAML2\XML\saml\SubjectConfirmation;
 
 /**
  * Class representing a SAML 2 assertion.
diff --git a/src/SAML2/Assertion/Decrypter.php b/src/SAML2/Assertion/Decrypter.php
index 54723f23b..4226ffda9 100644
--- a/src/SAML2/Assertion/Decrypter.php
+++ b/src/SAML2/Assertion/Decrypter.php
@@ -2,11 +2,11 @@
 
 namespace SAML2\Assertion;
 
+use SAML2\Assertion\Exception\NotDecryptedException;
+use SAML2\Certificate\PrivateKeyLoader;
 use SAML2\Configuration\IdentityProvider;
 use SAML2\Configuration\ServiceProvider;
-use SAML2\Certificate\PrivateKeyLoader;
 use SAML2\EncryptedAssertion;
-use SAML2\Assertion\Exception\NotDecryptedException;
 
 class Decrypter
 {
diff --git a/src/SAML2/Assertion/Processor.php b/src/SAML2/Assertion/Processor.php
index 738e3cc03..452662174 100644
--- a/src/SAML2/Assertion/Processor.php
+++ b/src/SAML2/Assertion/Processor.php
@@ -2,17 +2,17 @@
 
 namespace SAML2\Assertion;
 
-use SAML2\Signature\Validator;
+use SAML2\Assertion;
+use SAML2\Assertion\Exception\InvalidAssertionException;
+use SAML2\Assertion\Exception\InvalidSubjectConfirmationException;
+use SAML2\Assertion\Transformer\Transformer;
 use SAML2\Assertion\Validation\AssertionValidator;
 use SAML2\Assertion\Validation\SubjectConfirmationValidator;
-use SAML2\Assertion\Transformer\Transformer;
 use SAML2\Configuration\IdentityProvider;
-use SAML2\Utilities\ArrayCollection;
 use SAML2\Response\Exception\InvalidSignatureException;
-use SAML2\Assertion;
 use SAML2\Response\Exception\UnencryptedAssertionFoundException;
-use SAML2\Assertion\Exception\InvalidAssertionException;
-use SAML2\Assertion\Exception\InvalidSubjectConfirmationException;
+use SAML2\Signature\Validator;
+use SAML2\Utilities\ArrayCollection;
 
 /**
  * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - due to all the named exceptions
diff --git a/src/SAML2/Assertion/ProcessorBuilder.php b/src/SAML2/Assertion/ProcessorBuilder.php
index 129392d4f..5f6c40d8b 100644
--- a/src/SAML2/Assertion/ProcessorBuilder.php
+++ b/src/SAML2/Assertion/ProcessorBuilder.php
@@ -2,26 +2,26 @@
 
 namespace SAML2\Assertion;
 
-use SAML2\Signature\Validator;
-use SAML2\Configuration\Destination;
-use SAML2\Configuration\IdentityProvider;
-use SAML2\Configuration\ServiceProvider;
-use SAML2\Response;
-use SAML2\Certificate\PrivateKeyLoader;
+use SAML2\Assertion\Transformer\DecodeBase64Transformer;
+use SAML2\Assertion\Transformer\NameIdDecryptionTransformer;
+use SAML2\Assertion\Transformer\TransformerChain;
 use SAML2\Assertion\Validation\AssertionValidator;
 use SAML2\Assertion\Validation\ConstraintValidator\NotBefore;
 use SAML2\Assertion\Validation\ConstraintValidator\NotOnOrAfter;
 use SAML2\Assertion\Validation\ConstraintValidator\SessionNotOnOrAfter;
 use SAML2\Assertion\Validation\ConstraintValidator\SpIsValidAudience;
-use SAML2\Assertion\Validation\SubjectConfirmationValidator;
 use SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationMethod;
 use SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationNotBefore;
 use SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationNotOnOrAfter;
 use SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationRecipientMatches;
 use SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationResponseToMatches;
-use SAML2\Assertion\Transformer\TransformerChain;
-use SAML2\Assertion\Transformer\DecodeBase64Transformer;
-use SAML2\Assertion\Transformer\NameIdDecryptionTransformer;
+use SAML2\Assertion\Validation\SubjectConfirmationValidator;
+use SAML2\Certificate\PrivateKeyLoader;
+use SAML2\Configuration\Destination;
+use SAML2\Configuration\IdentityProvider;
+use SAML2\Configuration\ServiceProvider;
+use SAML2\Response;
+use SAML2\Signature\Validator;
 
 /**
  * Simple Builder that allows to build a new Assertion Processor.
diff --git a/src/SAML2/Assertion/Transformer/DecodeBase64Transformer.php b/src/SAML2/Assertion/Transformer/DecodeBase64Transformer.php
index 5da384c1e..f8738c0b5 100644
--- a/src/SAML2/Assertion/Transformer/DecodeBase64Transformer.php
+++ b/src/SAML2/Assertion/Transformer/DecodeBase64Transformer.php
@@ -2,9 +2,9 @@
 
 namespace SAML2\Assertion\Transformer;
 
-use SAML2\Configuration\IdentityProviderAware;
-use SAML2\Configuration\IdentityProvider;
 use SAML2\Assertion;
+use SAML2\Configuration\IdentityProvider;
+use SAML2\Configuration\IdentityProviderAware;
 
 class DecodeBase64Transformer implements
     Transformer,
diff --git a/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php b/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
index 2e979e7d4..93bc2063a 100644
--- a/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
+++ b/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
@@ -2,13 +2,13 @@
 
 namespace SAML2\Assertion\Transformer;
 
-use SAML2\Configuration\IdentityProviderAware;
-use SAML2\Configuration\ServiceProviderAware;
-use SAML2\Certificate\PrivateKeyLoader;
 use SAML2\Assertion;
 use SAML2\Assertion\Exception\NotDecryptedException;
+use SAML2\Certificate\PrivateKeyLoader;
 use SAML2\Configuration\IdentityProvider;
+use SAML2\Configuration\IdentityProviderAware;
 use SAML2\Configuration\ServiceProvider;
+use SAML2\Configuration\ServiceProviderAware;
 
 class NameIdDecryptionTransformer implements
     Transformer,
diff --git a/src/SAML2/Assertion/Transformer/TransformerChain.php b/src/SAML2/Assertion/Transformer/TransformerChain.php
index d33d16e5d..3490bd5c4 100644
--- a/src/SAML2/Assertion/Transformer/TransformerChain.php
+++ b/src/SAML2/Assertion/Transformer/TransformerChain.php
@@ -2,11 +2,11 @@
 
 namespace SAML2\Assertion\Transformer;
 
+use SAML2\Assertion;
 use SAML2\Configuration\IdentityProvider;
-use SAML2\Configuration\ServiceProvider;
 use SAML2\Configuration\IdentityProviderAware;
+use SAML2\Configuration\ServiceProvider;
 use SAML2\Configuration\ServiceProviderAware;
-use SAML2\Assertion;
 
 class TransformerChain implements Transformer
 {
diff --git a/src/SAML2/Assertion/Validation/AssertionValidator.php b/src/SAML2/Assertion/Validation/AssertionValidator.php
index f005ea76d..b39cabfbb 100644
--- a/src/SAML2/Assertion/Validation/AssertionValidator.php
+++ b/src/SAML2/Assertion/Validation/AssertionValidator.php
@@ -2,11 +2,11 @@
 
 namespace SAML2\Assertion\Validation;
 
+use SAML2\Assertion;
 use SAML2\Configuration\IdentityProvider;
-use SAML2\Configuration\ServiceProvider;
 use SAML2\Configuration\IdentityProviderAware;
+use SAML2\Configuration\ServiceProvider;
 use SAML2\Configuration\ServiceProviderAware;
-use SAML2\Assertion;
 
 class AssertionValidator
 {
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/NotBefore.php b/src/SAML2/Assertion/Validation/ConstraintValidator/NotBefore.php
index 071cffe55..197772dbe 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/NotBefore.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/NotBefore.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
-use SAML2\Assertion\Validation\AssertionConstraintValidator;
 use SAML2\Assertion;
+use SAML2\Assertion\Validation\AssertionConstraintValidator;
 use SAML2\Assertion\Validation\Result;
 use SAML2\Utilities\Temporal;
 
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfter.php b/src/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfter.php
index 3b214eb5c..38527df78 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfter.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfter.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
-use SAML2\Assertion\Validation\AssertionConstraintValidator;
 use SAML2\Assertion;
+use SAML2\Assertion\Validation\AssertionConstraintValidator;
 use SAML2\Assertion\Validation\Result;
 use SAML2\Utilities\Temporal;
 
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfter.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfter.php
index 157324345..74f9bc4d8 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfter.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfter.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
-use SAML2\Assertion\Validation\AssertionConstraintValidator;
 use SAML2\Assertion;
+use SAML2\Assertion\Validation\AssertionConstraintValidator;
 use SAML2\Assertion\Validation\Result;
 use SAML2\Utilities\Temporal;
 
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php
index ece7d8733..5456f92fa 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php
@@ -2,11 +2,11 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
-use SAML2\Assertion\Validation\AssertionConstraintValidator;
-use SAML2\Configuration\ServiceProviderAware;
-use SAML2\Configuration\ServiceProvider;
 use SAML2\Assertion;
+use SAML2\Assertion\Validation\AssertionConstraintValidator;
 use SAML2\Assertion\Validation\Result;
+use SAML2\Configuration\ServiceProvider;
+use SAML2\Configuration\ServiceProviderAware;
 
 class SpIsValidAudience implements
     AssertionConstraintValidator,
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethod.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethod.php
index 2d1ce9d1f..28523685a 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethod.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethod.php
@@ -2,10 +2,10 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
-use SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
-use SAML2\XML\saml\SubjectConfirmation;
 use SAML2\Assertion\Validation\Result;
+use SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
 use SAML2\Constants;
+use SAML2\XML\saml\SubjectConfirmation;
 
 class SubjectConfirmationMethod implements
     SubjectConfirmationConstraintValidator
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBefore.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBefore.php
index 199707eb7..41f72ba42 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBefore.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBefore.php
@@ -2,10 +2,10 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
-use SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
-use SAML2\XML\saml\SubjectConfirmation;
 use SAML2\Assertion\Validation\Result;
+use SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
 use SAML2\Utilities\Temporal;
+use SAML2\XML\saml\SubjectConfirmation;
 
 class SubjectConfirmationNotBefore implements
     SubjectConfirmationConstraintValidator
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfter.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfter.php
index d947b9764..43262b1d0 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfter.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfter.php
@@ -2,10 +2,10 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
-use SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
-use SAML2\XML\saml\SubjectConfirmation;
 use SAML2\Assertion\Validation\Result;
+use SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
 use SAML2\Utilities\Temporal;
+use SAML2\XML\saml\SubjectConfirmation;
 
 class SubjectConfirmationNotOnOrAfter implements
     SubjectConfirmationConstraintValidator
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMatches.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMatches.php
index 3f29aed43..140ab969a 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMatches.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMatches.php
@@ -2,10 +2,10 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
+use SAML2\Assertion\Validation\Result;
 use SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
 use SAML2\Configuration\Destination;
 use SAML2\XML\saml\SubjectConfirmation;
-use SAML2\Assertion\Validation\Result;
 
 class SubjectConfirmationRecipientMatches implements
     SubjectConfirmationConstraintValidator
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatches.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatches.php
index dec78f2df..655eabb0b 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatches.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatches.php
@@ -2,10 +2,10 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
+use SAML2\Assertion\Validation\Result;
 use SAML2\Assertion\Validation\SubjectConfirmationConstraintValidator;
 use SAML2\Response;
 use SAML2\XML\saml\SubjectConfirmation;
-use SAML2\Assertion\Validation\Result;
 
 class SubjectConfirmationResponseToMatches implements
     SubjectConfirmationConstraintValidator
diff --git a/src/SAML2/Assertion/Validation/SubjectConfirmationValidator.php b/src/SAML2/Assertion/Validation/SubjectConfirmationValidator.php
index e8bc2cccf..bbd5ba982 100644
--- a/src/SAML2/Assertion/Validation/SubjectConfirmationValidator.php
+++ b/src/SAML2/Assertion/Validation/SubjectConfirmationValidator.php
@@ -3,8 +3,8 @@
 namespace SAML2\Assertion\Validation;
 
 use SAML2\Configuration\IdentityProvider;
-use SAML2\Configuration\ServiceProvider;
 use SAML2\Configuration\IdentityProviderAware;
+use SAML2\Configuration\ServiceProvider;
 use SAML2\Configuration\ServiceProviderAware;
 use SAML2\XML\saml\SubjectConfirmation;
 
diff --git a/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php b/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php
index 967f27e29..65aecf864 100644
--- a/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php
+++ b/src/SAML2/Certificate/Exception/InvalidKeyUsageException.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\Certificate\Exception;
 
-use SAML2\Exception\Throwable;
 use SAML2\Certificate\Key;
+use SAML2\Exception\Throwable;
 
 /**
  * Named exception for when a non-existent key-usage is given
diff --git a/src/SAML2/Certificate/FingerprintCollection.php b/src/SAML2/Certificate/FingerprintCollection.php
index efa35c743..7527d050e 100644
--- a/src/SAML2/Certificate/FingerprintCollection.php
+++ b/src/SAML2/Certificate/FingerprintCollection.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\Certificate;
 
-use SAML2\Utilities\ArrayCollection;
 use SAML2\Exception\InvalidArgumentException;
+use SAML2\Utilities\ArrayCollection;
 
 /**
  * Simple collection object for transporting keys
diff --git a/src/SAML2/Certificate/KeyCollection.php b/src/SAML2/Certificate/KeyCollection.php
index 62bb5326d..ca4d296ce 100644
--- a/src/SAML2/Certificate/KeyCollection.php
+++ b/src/SAML2/Certificate/KeyCollection.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\Certificate;
 
-use SAML2\Utilities\ArrayCollection;
 use SAML2\Exception\InvalidArgumentException;
+use SAML2\Utilities\ArrayCollection;
 
 /**
  * Simple collection object for transporting keys
diff --git a/src/SAML2/Certificate/KeyLoader.php b/src/SAML2/Certificate/KeyLoader.php
index dee6d1b4b..33f4c808d 100644
--- a/src/SAML2/Certificate/KeyLoader.php
+++ b/src/SAML2/Certificate/KeyLoader.php
@@ -2,12 +2,12 @@
 
 namespace SAML2\Certificate;
 
-use SAML2\Configuration\CertificateProvider;
+use SAML2\Certificate\Exception\InvalidCertificateStructureException;
 use SAML2\Certificate\Exception\NoKeysFoundException;
+use SAML2\Configuration\CertificateProvider;
 use SAML2\Exception\InvalidArgumentException;
-use SAML2\Utilities\File;
 use SAML2\Utilities\Certificate;
-use SAML2\Certificate\Exception\InvalidCertificateStructureException;
+use SAML2\Utilities\File;
 
 /**
  * KeyLoader
diff --git a/src/SAML2/Certificate/PrivateKeyLoader.php b/src/SAML2/Certificate/PrivateKeyLoader.php
index 394324f91..aafdeeca1 100644
--- a/src/SAML2/Certificate/PrivateKeyLoader.php
+++ b/src/SAML2/Certificate/PrivateKeyLoader.php
@@ -3,10 +3,10 @@
 namespace SAML2\Certificate;
 
 use RobRichards\XMLSecLibs\XMLSecurityKey;
-use SAML2\Configuration\PrivateKey as PrivateKeyConfiguration;
-use SAML2\Utilities\File;
 use SAML2\Configuration\DecryptionProvider;
+use SAML2\Configuration\PrivateKey as PrivateKeyConfiguration;
 use SAML2\Utilities\ArrayCollection;
+use SAML2\Utilities\File;
 
 class PrivateKeyLoader
 {
diff --git a/src/SAML2/DOMDocumentFactory.php b/src/SAML2/DOMDocumentFactory.php
index a1f757bd9..042908ab7 100644
--- a/src/SAML2/DOMDocumentFactory.php
+++ b/src/SAML2/DOMDocumentFactory.php
@@ -3,8 +3,8 @@
 namespace SAML2;
 
 use SAML2\Exception\InvalidArgumentException;
-use SAML2\Exception\UnparseableXmlException;
 use SAML2\Exception\RuntimeException;
+use SAML2\Exception\UnparseableXmlException;
 
 final class DOMDocumentFactory
 {
diff --git a/src/SAML2/Response/Processor.php b/src/SAML2/Response/Processor.php
index 5f7440ace..198349c9e 100644
--- a/src/SAML2/Response/Processor.php
+++ b/src/SAML2/Response/Processor.php
@@ -2,17 +2,17 @@
 
 namespace SAML2\Response;
 
-use SAML2\Signature\Validator;
-use SAML2\Configuration\ServiceProvider;
-use SAML2\Configuration\IdentityProvider;
+use SAML2\Assertion\ProcessorBuilder;
 use SAML2\Configuration\Destination;
+use SAML2\Configuration\IdentityProvider;
+use SAML2\Configuration\ServiceProvider;
 use SAML2\Response;
-use SAML2\Response\Validation\PreconditionValidator;
-use SAML2\Assertion\ProcessorBuilder;
-use SAML2\Response\Exception\PreconditionNotMetException;
 use SAML2\Response\Exception\InvalidResponseException;
 use SAML2\Response\Exception\NoAssertionsFoundException;
+use SAML2\Response\Exception\PreconditionNotMetException;
 use SAML2\Response\Exception\UnsignedResponseException;
+use SAML2\Response\Validation\PreconditionValidator;
+use SAML2\Signature\Validator;
 
 /**
  * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - due to specific exceptions
diff --git a/src/SAML2/Response/Validation/ConstraintValidator/DestinationMatches.php b/src/SAML2/Response/Validation/ConstraintValidator/DestinationMatches.php
index b1be9b605..edd0eb854 100644
--- a/src/SAML2/Response/Validation/ConstraintValidator/DestinationMatches.php
+++ b/src/SAML2/Response/Validation/ConstraintValidator/DestinationMatches.php
@@ -2,9 +2,9 @@
 
 namespace SAML2\Response\Validation\ConstraintValidator;
 
-use SAML2\Response\Validation\ConstraintValidator;
 use SAML2\Configuration\Destination;
 use SAML2\Response;
+use SAML2\Response\Validation\ConstraintValidator;
 use SAML2\Response\Validation\Result;
 
 class DestinationMatches implements
diff --git a/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php b/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php
index 1f5c901e6..2accc7a04 100644
--- a/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php
+++ b/src/SAML2/Response/Validation/ConstraintValidator/IsSuccessful.php
@@ -2,10 +2,10 @@
 
 namespace SAML2\Response\Validation\ConstraintValidator;
 
-use SAML2\Response\Validation\ConstraintValidator;
+use SAML2\Constants;
 use SAML2\Response;
+use SAML2\Response\Validation\ConstraintValidator;
 use SAML2\Response\Validation\Result;
-use SAML2\Constants;
 
 class IsSuccessful implements
     ConstraintValidator
diff --git a/src/SAML2/Response/Validation/PreconditionValidator.php b/src/SAML2/Response/Validation/PreconditionValidator.php
index 89dc8efbd..c656cd1a8 100644
--- a/src/SAML2/Response/Validation/PreconditionValidator.php
+++ b/src/SAML2/Response/Validation/PreconditionValidator.php
@@ -3,8 +3,8 @@
 namespace SAML2\Response\Validation;
 
 use SAML2\Configuration\Destination;
-use SAML2\Response\Validation\ConstraintValidator\IsSuccessful;
 use SAML2\Response\Validation\ConstraintValidator\DestinationMatches;
+use SAML2\Response\Validation\ConstraintValidator\IsSuccessful;
 
 /**
  * Validates the preconditions that have to be met prior to processing of the response.
diff --git a/src/SAML2/Signature/ChainedValidator.php b/src/SAML2/Signature/ChainedValidator.php
index 1519dd2ba..efee82f6d 100644
--- a/src/SAML2/Signature/ChainedValidator.php
+++ b/src/SAML2/Signature/ChainedValidator.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\Signature;
 
-use SAML2\SignedElement;
 use SAML2\Configuration\CertificateProvider;
+use SAML2\SignedElement;
 
 /**
  * Interface \SAML2\Validator\Responsible
diff --git a/src/SAML2/Signature/FingerprintValidator.php b/src/SAML2/Signature/FingerprintValidator.php
index b6a46f407..a3fa255f8 100644
--- a/src/SAML2/Signature/FingerprintValidator.php
+++ b/src/SAML2/Signature/FingerprintValidator.php
@@ -3,9 +3,9 @@
 namespace SAML2\Signature;
 
 use SAML2\Certificate\FingerprintLoader;
-use SAML2\SignedElement;
-use SAML2\Configuration\CertificateProvider;
 use SAML2\Certificate\X509;
+use SAML2\Configuration\CertificateProvider;
+use SAML2\SignedElement;
 
 /**
  * Validates the signature based on the fingerprint of the certificate
diff --git a/src/SAML2/Signature/PublicKeyValidator.php b/src/SAML2/Signature/PublicKeyValidator.php
index d504cae55..a98b5433c 100644
--- a/src/SAML2/Signature/PublicKeyValidator.php
+++ b/src/SAML2/Signature/PublicKeyValidator.php
@@ -2,11 +2,11 @@
 
 namespace SAML2\Signature;
 
-use SAML2\Certificate\KeyLoader;
-use SAML2\SignedElement;
-use SAML2\Configuration\CertificateProvider;
 use SAML2\Certificate\Key;
+use SAML2\Certificate\KeyLoader;
 use SAML2\Certificate\X509;
+use SAML2\Configuration\CertificateProvider;
+use SAML2\SignedElement;
 
 class PublicKeyValidator extends AbstractChainedValidator
 {
diff --git a/src/SAML2/Signature/Validator.php b/src/SAML2/Signature/Validator.php
index e363bac6a..c74f284a8 100644
--- a/src/SAML2/Signature/Validator.php
+++ b/src/SAML2/Signature/Validator.php
@@ -2,10 +2,10 @@
 
 namespace SAML2\Signature;
 
-use SAML2\SignedElement;
-use SAML2\Configuration\CertificateProvider;
-use SAML2\Certificate\KeyLoader;
 use SAML2\Certificate\FingerprintLoader;
+use SAML2\Certificate\KeyLoader;
+use SAML2\Configuration\CertificateProvider;
+use SAML2\SignedElement;
 
 /**
  * Signature Validator.
diff --git a/src/SAML2/Signature/ValidatorChain.php b/src/SAML2/Signature/ValidatorChain.php
index 892f7463a..9d437e81f 100644
--- a/src/SAML2/Signature/ValidatorChain.php
+++ b/src/SAML2/Signature/ValidatorChain.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\Signature;
 
-use SAML2\SignedElement;
 use SAML2\Configuration\CertificateProvider;
+use SAML2\SignedElement;
 
 /**
  * Allows for validation of a signature trying different validators till a validator is found
diff --git a/src/SAML2/Signature/ValidatorInterface.php b/src/SAML2/Signature/ValidatorInterface.php
index 63252eead..47dd4e5a9 100644
--- a/src/SAML2/Signature/ValidatorInterface.php
+++ b/src/SAML2/Signature/ValidatorInterface.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\Signature;
 
-use SAML2\SignedElement;
 use SAML2\Configuration\CertificateProvider;
+use SAML2\SignedElement;
 
 interface ValidatorInterface
 {
diff --git a/src/SAML2/Utils.php b/src/SAML2/Utils.php
index cfe339dca..8be5c101d 100644
--- a/src/SAML2/Utils.php
+++ b/src/SAML2/Utils.php
@@ -5,12 +5,12 @@
 use RobRichards\XMLSecLibs\XMLSecEnc;
 use RobRichards\XMLSecLibs\XMLSecurityDSig;
 use RobRichards\XMLSecLibs\XMLSecurityKey;
+use SAML2\Compat\ContainerSingleton;
 use SAML2\Exception\RuntimeException;
+use SAML2\XML\ds\KeyInfo;
 use SAML2\XML\ds\X509Certificate;
 use SAML2\XML\ds\X509Data;
-use SAML2\XML\ds\KeyInfo;
 use SAML2\XML\md\KeyDescriptor;
-use SAML2\Compat\ContainerSingleton;
 
 /**
  * Helper functions for the SAML2 library.
diff --git a/src/SAML2/XML/Chunk.php b/src/SAML2/XML/Chunk.php
index ea7e91e13..6f412eb62 100644
--- a/src/SAML2/XML/Chunk.php
+++ b/src/SAML2/XML/Chunk.php
@@ -2,8 +2,9 @@
 
 namespace SAML2\XML;
 
-use SAML2\Utils;
 use SAML2\DOMDocumentFactory;
+use SAML2\Utils;
+
 /**
  * Serializable class used to hold an XML element.
  *
diff --git a/src/SAML2/XML/md/AdditionalMetadataLocation.php b/src/SAML2/XML/md/AdditionalMetadataLocation.php
index 0f4a3cf75..03e622531 100644
--- a/src/SAML2/XML/md/AdditionalMetadataLocation.php
+++ b/src/SAML2/XML/md/AdditionalMetadataLocation.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\XML\md;
 
-use SAML2\Utils;
 use SAML2\Constants;
+use SAML2\Utils;
 
 /**
  * Class representing SAML 2 metadata AdditionalMetadataLocation element.
diff --git a/src/SAML2/XML/md/AffiliationDescriptor.php b/src/SAML2/XML/md/AffiliationDescriptor.php
index fd393fc83..de17b7c0e 100644
--- a/src/SAML2/XML/md/AffiliationDescriptor.php
+++ b/src/SAML2/XML/md/AffiliationDescriptor.php
@@ -2,9 +2,9 @@
 
 namespace SAML2\XML\md;
 
+use SAML2\Constants;
 use SAML2\SignedElementHelper;
 use SAML2\Utils;
-use SAML2\Constants;
 
 /**
  * Class representing SAML 2 AffiliationDescriptor element.
diff --git a/src/SAML2/XML/md/AttributeAuthorityDescriptor.php b/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
index ff28eb6da..749c0b32c 100644
--- a/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
+++ b/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\XML\md;
 
-use SAML2\Utils;
 use SAML2\Constants;
+use SAML2\Utils;
 use SAML2\XML\saml\Attribute;
 
 /**
diff --git a/src/SAML2/XML/md/AttributeConsumingService.php b/src/SAML2/XML/md/AttributeConsumingService.php
index 7f10b8101..7de8e49ee 100644
--- a/src/SAML2/XML/md/AttributeConsumingService.php
+++ b/src/SAML2/XML/md/AttributeConsumingService.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\XML\md;
 
-use SAML2\Utils;
 use SAML2\Constants;
+use SAML2\Utils;
 
 /**
  * Class representing SAML 2 Metadata AttributeConsumingService element.
diff --git a/src/SAML2/XML/md/AuthnAuthorityDescriptor.php b/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
index 3e8da4445..751c00aa2 100644
--- a/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
+++ b/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\XML\md;
 
-use SAML2\Utils;
 use SAML2\Constants;
+use SAML2\Utils;
 
 /**
  * Class representing SAML 2 metadata AuthnAuthorityDescriptor.
diff --git a/src/SAML2/XML/md/ContactPerson.php b/src/SAML2/XML/md/ContactPerson.php
index fa31dbe71..56e81c53b 100644
--- a/src/SAML2/XML/md/ContactPerson.php
+++ b/src/SAML2/XML/md/ContactPerson.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\XML\md;
 
-use SAML2\Utils;
 use SAML2\Constants;
+use SAML2\Utils;
 
 /**
  * Class representing SAML 2 ContactPerson.
diff --git a/src/SAML2/XML/md/EntitiesDescriptor.php b/src/SAML2/XML/md/EntitiesDescriptor.php
index c4992fedc..643e51929 100644
--- a/src/SAML2/XML/md/EntitiesDescriptor.php
+++ b/src/SAML2/XML/md/EntitiesDescriptor.php
@@ -2,10 +2,10 @@
 
 namespace SAML2\XML\md;
 
+use SAML2\Constants;
+use SAML2\DOMDocumentFactory;
 use SAML2\SignedElementHelper;
 use SAML2\Utils;
-use SAML2\DOMDocumentFactory;
-use SAML2\Constants;
 
 /**
  * Class representing SAML 2 EntitiesDescriptor element.
diff --git a/src/SAML2/XML/md/EntityDescriptor.php b/src/SAML2/XML/md/EntityDescriptor.php
index 308c26c81..9084e0ab5 100644
--- a/src/SAML2/XML/md/EntityDescriptor.php
+++ b/src/SAML2/XML/md/EntityDescriptor.php
@@ -2,10 +2,10 @@
 
 namespace SAML2\XML\md;
 
-use SAML2\SignedElementHelper;
-use SAML2\Utils;
 use SAML2\Constants;
 use SAML2\DOMDocumentFactory;
+use SAML2\SignedElementHelper;
+use SAML2\Utils;
 
 /**
  * Class representing SAML 2 EntityDescriptor element.
diff --git a/src/SAML2/XML/md/Extensions.php b/src/SAML2/XML/md/Extensions.php
index 4c44a8a39..758d36172 100644
--- a/src/SAML2/XML/md/Extensions.php
+++ b/src/SAML2/XML/md/Extensions.php
@@ -2,16 +2,16 @@
 
 namespace SAML2\XML\md;
 
+use SAML2\Constants;
 use SAML2\Utils;
-use SAML2\XML\shibmd\Scope;
+use SAML2\XML\Chunk;
 use SAML2\XML\mdattr\EntityAttributes;
 use SAML2\XML\mdrpi\Common;
-use SAML2\XML\mdrpi\RegistrationInfo;
 use SAML2\XML\mdrpi\PublicationInfo;
-use SAML2\XML\mdui\UIInfo;
+use SAML2\XML\mdrpi\RegistrationInfo;
 use SAML2\XML\mdui\DiscoHints;
-use SAML2\XML\Chunk;
-use SAML2\Constants;
+use SAML2\XML\mdui\UIInfo;
+use SAML2\XML\shibmd\Scope;
 
 /**
  * Class for handling SAML2 metadata extensions.
diff --git a/src/SAML2/XML/md/IDPSSODescriptor.php b/src/SAML2/XML/md/IDPSSODescriptor.php
index 23ad7574c..2d4e46b48 100644
--- a/src/SAML2/XML/md/IDPSSODescriptor.php
+++ b/src/SAML2/XML/md/IDPSSODescriptor.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\XML\md;
 
-use SAML2\Utils;
 use SAML2\Constants;
+use SAML2\Utils;
 use SAML2\XML\saml\Attribute;
 
 /**
diff --git a/src/SAML2/XML/md/KeyDescriptor.php b/src/SAML2/XML/md/KeyDescriptor.php
index da93adaf0..2e04a9197 100644
--- a/src/SAML2/XML/md/KeyDescriptor.php
+++ b/src/SAML2/XML/md/KeyDescriptor.php
@@ -2,10 +2,10 @@
 
 namespace SAML2\XML\md;
 
+use SAML2\Constants;
 use SAML2\Utils;
-use SAML2\XML\ds\KeyInfo;
 use SAML2\XML\Chunk;
-use SAML2\Constants;
+use SAML2\XML\ds\KeyInfo;
 
 /**
  * Class representing a KeyDescriptor element.
diff --git a/src/SAML2/XML/md/Organization.php b/src/SAML2/XML/md/Organization.php
index 3653507d2..010dc81a6 100644
--- a/src/SAML2/XML/md/Organization.php
+++ b/src/SAML2/XML/md/Organization.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\XML\md;
 
-use SAML2\Utils;
 use SAML2\Constants;
+use SAML2\Utils;
 
 /**
  * Class representing SAML 2 Organization element.
diff --git a/src/SAML2/XML/md/PDPDescriptor.php b/src/SAML2/XML/md/PDPDescriptor.php
index f1738398c..21890e81d 100644
--- a/src/SAML2/XML/md/PDPDescriptor.php
+++ b/src/SAML2/XML/md/PDPDescriptor.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\XML\md;
 
-use SAML2\Utils;
 use SAML2\Constants;
+use SAML2\Utils;
 
 /**
  * Class representing SAML 2 metadata PDPDescriptor.
diff --git a/src/SAML2/XML/md/RequestedAttribute.php b/src/SAML2/XML/md/RequestedAttribute.php
index abfb1ddd6..bbe727f13 100644
--- a/src/SAML2/XML/md/RequestedAttribute.php
+++ b/src/SAML2/XML/md/RequestedAttribute.php
@@ -2,9 +2,9 @@
 
 namespace SAML2\XML\md;
 
-use SAML2\XML\saml\Attribute;
-use SAML2\Utils;
 use SAML2\Constants;
+use SAML2\Utils;
+use SAML2\XML\saml\Attribute;
 
 /**
  * Class representing SAML 2 metadata RequestedAttribute.
diff --git a/src/SAML2/XML/md/RoleDescriptor.php b/src/SAML2/XML/md/RoleDescriptor.php
index 60308a422..51c31c84b 100644
--- a/src/SAML2/XML/md/RoleDescriptor.php
+++ b/src/SAML2/XML/md/RoleDescriptor.php
@@ -2,9 +2,9 @@
 
 namespace SAML2\XML\md;
 
+use SAML2\Constants;
 use SAML2\SignedElementHelper;
 use SAML2\Utils;
-use SAML2\Constants;
 
 /**
  * Class representing SAML 2 RoleDescriptor element.
diff --git a/src/SAML2/XML/md/SSODescriptorType.php b/src/SAML2/XML/md/SSODescriptorType.php
index e691d730f..c043a6fec 100644
--- a/src/SAML2/XML/md/SSODescriptorType.php
+++ b/src/SAML2/XML/md/SSODescriptorType.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\XML\md;
 
-use SAML2\Utils;
 use SAML2\Constants;
+use SAML2\Utils;
 
 /**
  * Class representing SAML 2 SSODescriptorType.
diff --git a/src/SAML2/XML/mdattr/EntityAttributes.php b/src/SAML2/XML/mdattr/EntityAttributes.php
index 044af9152..3e3a50172 100644
--- a/src/SAML2/XML/mdattr/EntityAttributes.php
+++ b/src/SAML2/XML/mdattr/EntityAttributes.php
@@ -3,8 +3,8 @@
 namespace SAML2\XML\mdattr;
 
 use SAML2\Utils;
-use SAML2\XML\saml\Attribute;
 use SAML2\XML\Chunk;
+use SAML2\XML\saml\Attribute;
 
 /**
  * Class for handling the EntityAttributes metadata extension.
diff --git a/src/SAML2/XML/saml/Attribute.php b/src/SAML2/XML/saml/Attribute.php
index 9cd64bc56..a126de1ea 100644
--- a/src/SAML2/XML/saml/Attribute.php
+++ b/src/SAML2/XML/saml/Attribute.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\XML\saml;
 
-use SAML2\Utils;
 use SAML2\Constants;
+use SAML2\Utils;
 
 /**
  * Class representing SAML 2 Attribute.
diff --git a/src/SAML2/XML/saml/AttributeValue.php b/src/SAML2/XML/saml/AttributeValue.php
index 760ce4f79..8fbefae83 100644
--- a/src/SAML2/XML/saml/AttributeValue.php
+++ b/src/SAML2/XML/saml/AttributeValue.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\XML\saml;
 
-use SAML2\DOMDocumentFactory;
 use SAML2\Constants;
+use SAML2\DOMDocumentFactory;
 use SAML2\Utils;
 
 /**
diff --git a/src/SAML2/XML/saml/NameID.php b/src/SAML2/XML/saml/NameID.php
index e5346f391..77fe7a185 100644
--- a/src/SAML2/XML/saml/NameID.php
+++ b/src/SAML2/XML/saml/NameID.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\XML\saml;
 
-use SAML2\DOMDocumentFactory;
 use SAML2\Constants;
+use SAML2\DOMDocumentFactory;
 
 /**
  * Class representing the saml:NameID element.
diff --git a/src/SAML2/XML/saml/SubjectConfirmation.php b/src/SAML2/XML/saml/SubjectConfirmation.php
index c6973a946..a08f62497 100644
--- a/src/SAML2/XML/saml/SubjectConfirmation.php
+++ b/src/SAML2/XML/saml/SubjectConfirmation.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\XML\saml;
 
-use SAML2\Utils;
 use SAML2\Constants;
+use SAML2\Utils;
 
 /**
  * Class representing SAML 2 SubjectConfirmation element.
diff --git a/src/SAML2/XML/saml/SubjectConfirmationData.php b/src/SAML2/XML/saml/SubjectConfirmationData.php
index cbfa4be7d..3628c5658 100644
--- a/src/SAML2/XML/saml/SubjectConfirmationData.php
+++ b/src/SAML2/XML/saml/SubjectConfirmationData.php
@@ -3,10 +3,10 @@
 namespace SAML2\XML\saml;
 
 use RobRichards\XMLSecLibs\XMLSecurityDSig;
+use SAML2\Constants;
 use SAML2\Utils;
 use SAML2\XML\Chunk;
 use SAML2\XML\ds\KeyInfo;
-use SAML2\Constants;
 
 /**
  * Class representing SAML 2 SubjectConfirmationData element.
diff --git a/src/SAML2/XML/samlp/Extensions.php b/src/SAML2/XML/samlp/Extensions.php
index b2cd18f8b..45c9d5a8e 100644
--- a/src/SAML2/XML/samlp/Extensions.php
+++ b/src/SAML2/XML/samlp/Extensions.php
@@ -2,9 +2,9 @@
 
 namespace SAML2\XML\samlp;
 
+use SAML2\Constants;
 use SAML2\Utils;
 use SAML2\XML\Chunk;
-use SAML2\Constants;
 
 /**
  * Class for handling SAML2 extensions.
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php
index 66879836e..4eff8b76d 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php
@@ -2,10 +2,9 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
-use SAML2\ControlledTimeTest;
+use Mockery as m;
 use SAML2\Assertion\Validation\Result;
-
-use \Mockery as m;
+use SAML2\ControlledTimeTest;
 
 /**
  * Because we're mocking a static call, we have to run it in separate processes so as to no contaminate the other
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php
index 75a241910..9999dcfb2 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php
@@ -2,10 +2,9 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
-use SAML2\ControlledTimeTest;
+use Mockery as m;
 use SAML2\Assertion\Validation\Result;
-
-use \Mockery as m;
+use SAML2\ControlledTimeTest;
 
 /**
  * Because we're mocking a static call, we have to run it in separate processes so as to no contaminate the other
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php
index b819ec053..d49165f5c 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php
@@ -2,10 +2,9 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
-use SAML2\ControlledTimeTest;
+use Mockery as m;
 use SAML2\Assertion\Validation\Result;
-
-use \Mockery as m;
+use SAML2\ControlledTimeTest;
 
 /**
  * Because we're mocking a static call, we have to run it in separate processes so as to no contaminate the other
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
index 4c05e22dd..513324158 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
@@ -2,10 +2,9 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
+use Mockery as m;
 use SAML2\Assertion\Validation\Result;
 
-use \Mockery as m;
-
 /**
  * Because we're mocking a static call, we have to run it in separate processes so as to no contaminate the other
  * tests.
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
index 0b1d16e94..731a0e800 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
@@ -2,12 +2,11 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
-use SAML2\Constants;
+use Mockery as m;
 use SAML2\Assertion\Validation\Result;
+use SAML2\Constants;
 
-use \Mockery as m;
-
-class SubjectConfirmationTest extends \PHPUnit_Framework_TestCase
+class SubjectConfirmationMethodTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * @var \Mockery\MockInterface
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php
index 22128a940..4ff9f3419 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotBeforeTest.php
@@ -2,10 +2,9 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
-use SAML2\ControlledTimeTest;
+use Mockery as m;
 use SAML2\Assertion\Validation\Result;
-
-use \Mockery as m;
+use SAML2\ControlledTimeTest;
 
 /**
  * Because we're mocking a static call, we have to run it in separate processes so as to no contaminate the other
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php
index 24bfe87d0..81bcb3308 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationNotOnOrAfterTest.php
@@ -2,10 +2,9 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
-use SAML2\ControlledTimeTest;
+use Mockery as m;
 use SAML2\Assertion\Validation\Result;
-
-use \Mockery as m;
+use SAML2\ControlledTimeTest;
 
 /**
  * Because we're mocking a static call, we have to run it in separate processes so as to no contaminate the other
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMathchesTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMathchesTest.php
index d4178fe34..5a98a2433 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMathchesTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationRecipientMathchesTest.php
@@ -2,12 +2,11 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
-use SAML2\Configuration\Destination;
+use Mockery as m;
 use SAML2\Assertion\Validation\Result;
+use SAML2\Configuration\Destination;
 
-use \Mockery as m;
-
-class SubjectConfirmationRecipientMatchesTest extends
+class SubjectConfirmationRecipientMathchesTest extends
     \PHPUnit_Framework_TestCase
 {
     /**
diff --git a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
index 2939b254b..74213bafc 100644
--- a/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
+++ b/tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
@@ -2,10 +2,9 @@
 
 namespace SAML2\Assertion\Validation\ConstraintValidator;
 
+use Mockery as m;
 use SAML2\Assertion\Validation\Result;
 
-use \Mockery as m;
-
 class SubjectConfirmationResponseToMatchesTest extends
     \PHPUnit_Framework_TestCase
 {
diff --git a/tests/SAML2/Certificate/FingerprintLoaderTest.php b/tests/SAML2/Certificate/FingerprintLoaderTest.php
index fb82bda5c..713bee0e4 100644
--- a/tests/SAML2/Certificate/FingerprintLoaderTest.php
+++ b/tests/SAML2/Certificate/FingerprintLoaderTest.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\Certificate;
 
-use SAML2\Configuration\ArrayAdapter;
 use SAML2\Certificate\Stub\ImplementsToString;
+use SAML2\Configuration\ArrayAdapter;
 
 class FingerprintLoaderTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/SAML2/ControlledTimeTest.php b/tests/SAML2/ControlledTimeTest.php
index af5f2468c..a4e13e71d 100644
--- a/tests/SAML2/ControlledTimeTest.php
+++ b/tests/SAML2/ControlledTimeTest.php
@@ -2,7 +2,7 @@
 
 namespace SAML2;
 
-use \Mockery as m;
+use Mockery as m;
 
 /**
  * Because we're mocking a static call, we have to run it in separate processes so as to no contaminate the other
diff --git a/tests/SAML2/Response/SignatureValidationTest.php b/tests/SAML2/Response/SignatureValidationTest.php
index f9b4ac185..d9d079e84 100644
--- a/tests/SAML2/Response/SignatureValidationTest.php
+++ b/tests/SAML2/Response/SignatureValidationTest.php
@@ -2,13 +2,13 @@
 
 namespace SAML2\Response;
 
-use SAML2\Utilities\Certificate;
+use SAML2\Assertion;
 use SAML2\CertificatesMock;
+use SAML2\Configuration\Destination;
 use SAML2\Configuration\IdentityProvider;
 use SAML2\Configuration\ServiceProvider;
-use SAML2\Configuration\Destination;
 use SAML2\Response;
-use SAML2\Assertion;
+use SAML2\Utilities\Certificate;
 
 /**
  * Test that ensures that either the response or the assertion(s) or both must be signed.
diff --git a/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php b/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
index 2b2392ad1..0cf5a160d 100644
--- a/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
+++ b/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\Response\Validation\ConstraintValidator;
 
-use SAML2\Response\Validation\Result;
 use SAML2\Constants;
+use SAML2\Response\Validation\Result;
 
 class IsSuccessfulTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/SAML2/Response/XmlSignatureWrappingTest.php b/tests/SAML2/Response/XmlSignatureWrappingTest.php
index c0ef0d6c6..e56342d24 100644
--- a/tests/SAML2/Response/XmlSignatureWrappingTest.php
+++ b/tests/SAML2/Response/XmlSignatureWrappingTest.php
@@ -2,12 +2,12 @@
 
 namespace SAML2\Response;
 
-use SAML2\Signature\Validator;
-use SAML2\Utilities\Certificate;
+use SAML2\Assertion;
 use SAML2\CertificatesMock;
 use SAML2\Configuration\IdentityProvider;
 use SAML2\DOMDocumentFactory;
-use SAML2\Assertion;
+use SAML2\Signature\Validator;
+use SAML2\Utilities\Certificate;
 
 class XmlSignatureWrappingTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/SAML2/Signature/FingerprintValidatorTest.php b/tests/SAML2/Signature/FingerprintValidatorTest.php
index c0c2b9794..7c18c38f6 100644
--- a/tests/SAML2/Signature/FingerprintValidatorTest.php
+++ b/tests/SAML2/Signature/FingerprintValidatorTest.php
@@ -2,14 +2,14 @@
 
 namespace SAML2\Signature;
 
-use SAML2\SimpleTestLogger;
 use SAML2\Certificate\FingerprintLoader;
-use SAML2\Utilities\Certificate;
-use SAML2\CertificatesMock;
 use SAML2\Certificate\X509;
+use SAML2\CertificatesMock;
 use SAML2\Configuration\IdentityProvider;
 use SAML2\DOMDocumentFactory;
 use SAML2\Response;
+use SAML2\SimpleTestLogger;
+use SAML2\Utilities\Certificate;
 
 class FingerprintValidatorTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/SAML2/Signature/MockChainedValidator.php b/tests/SAML2/Signature/MockChainedValidator.php
index 93de58649..39f3f323a 100644
--- a/tests/SAML2/Signature/MockChainedValidator.php
+++ b/tests/SAML2/Signature/MockChainedValidator.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\Signature;
 
-use SAML2\SignedElement;
 use SAML2\Configuration\CertificateProvider;
+use SAML2\SignedElement;
 
 /**
  * MockChainedValidator, to be able to test the validatorchain without having to use
diff --git a/tests/SAML2/Signature/PublicKeyValidatorTest.php b/tests/SAML2/Signature/PublicKeyValidatorTest.php
index 0fb07284f..41e222b6b 100644
--- a/tests/SAML2/Signature/PublicKeyValidatorTest.php
+++ b/tests/SAML2/Signature/PublicKeyValidatorTest.php
@@ -2,15 +2,15 @@
 
 namespace SAML2\Signature;
 
-use SAML2\Certificate\KeyCollection;
 use SAML2\Certificate\Key;
-use SAML2\SimpleTestLogger;
-use SAML2\Utilities\Certificate;
+use SAML2\Certificate\KeyCollection;
+use SAML2\Certificate\KeyLoader;
 use SAML2\CertificatesMock;
 use SAML2\Configuration\IdentityProvider;
-use SAML2\Certificate\KeyLoader;
 use SAML2\DOMDocumentFactory;
 use SAML2\Response;
+use SAML2\SimpleTestLogger;
+use SAML2\Utilities\Certificate;
 
 class PublicKeyValidatorTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/SAML2/Signature/ValidatorChainTest.php b/tests/SAML2/Signature/ValidatorChainTest.php
index c05ff9afe..4ceb0bfd6 100644
--- a/tests/SAML2/Signature/ValidatorChainTest.php
+++ b/tests/SAML2/Signature/ValidatorChainTest.php
@@ -2,8 +2,8 @@
 
 namespace SAML2\Signature;
 
-use SAML2\Response;
 use SAML2\Configuration\IdentityProvider;
+use SAML2\Response;
 
 class ValidatorChainTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php b/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
index 159c66308..dfae62127 100644
--- a/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
+++ b/tests/SAML2/XML/md/AdditionalMetadataLocationTest.php
@@ -2,9 +2,9 @@
 
 namespace SAML2\XML\md;
 
+use SAML2\Constants;
 use SAML2\DOMDocumentFactory;
 use SAML2\Utils;
-use SAML2\Constants;
 
 /**
  * Class \SAML2\XML\md\AdditionalMetadataLocationTest
diff --git a/tests/SAML2/XML/md/AffiliationDescriptorTest.php b/tests/SAML2/XML/md/AffiliationDescriptorTest.php
index 67e6cb8fc..0972ea0b9 100644
--- a/tests/SAML2/XML/md/AffiliationDescriptorTest.php
+++ b/tests/SAML2/XML/md/AffiliationDescriptorTest.php
@@ -2,9 +2,9 @@
 
 namespace SAML2\XML\md;
 
+use SAML2\Constants;
 use SAML2\DOMDocumentFactory;
 use SAML2\Utils;
-use SAML2\Constants;
 
 class AffiliationDescriptorTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/SAML2/XML/md/EndpointTypeTest.php b/tests/SAML2/XML/md/EndpointTypeTest.php
index 67c365a79..1bb5f5cff 100644
--- a/tests/SAML2/XML/md/EndpointTypeTest.php
+++ b/tests/SAML2/XML/md/EndpointTypeTest.php
@@ -2,9 +2,9 @@
 
 namespace SAML2\XML\md;
 
+use SAML2\Constants;
 use SAML2\DOMDocumentFactory;
 use SAML2\Utils;
-use SAML2\Constants;
 
 /**
  * Class \SAML2\XML\md\EndpointType
diff --git a/tests/SAML2/XML/md/RoleDescriptorMock.php b/tests/SAML2/XML/md/RoleDescriptorMock.php
index 84960c717..d98caa20e 100644
--- a/tests/SAML2/XML/md/RoleDescriptorMock.php
+++ b/tests/SAML2/XML/md/RoleDescriptorMock.php
@@ -4,7 +4,6 @@
 
 use SAML2\Constants;
 
-
 class RoleDescriptorMock extends RoleDescriptor {
     public function __construct(\DOMElement $xml = NULL) {
         parent::__construct('md:RoleDescriptor', $xml);
diff --git a/tests/SAML2/XML/md/RoleDescriptorTest.php b/tests/SAML2/XML/md/RoleDescriptorTest.php
index c201c7a5c..9fd142e8f 100644
--- a/tests/SAML2/XML/md/RoleDescriptorTest.php
+++ b/tests/SAML2/XML/md/RoleDescriptorTest.php
@@ -2,9 +2,9 @@
 
 namespace SAML2\XML\md;
 
+use SAML2\Constants;
 use SAML2\DOMDocumentFactory;
 use SAML2\Utils;
-use SAML2\Constants;
 
 require 'RoleDescriptorMock.php';
 
diff --git a/tests/SAML2/XML/saml/AttributeTest.php b/tests/SAML2/XML/saml/AttributeTest.php
index 17378e60d..5ba8e73e1 100644
--- a/tests/SAML2/XML/saml/AttributeTest.php
+++ b/tests/SAML2/XML/saml/AttributeTest.php
@@ -2,11 +2,11 @@
 
 namespace SAML2\XML\md;
 
-use SAML2\XML\saml\Attribute;
-use SAML2\XML\saml\AttributeValue;
+use SAML2\Constants;
 use SAML2\DOMDocumentFactory;
 use SAML2\Utils;
-use SAML2\Constants;
+use SAML2\XML\saml\Attribute;
+use SAML2\XML\saml\AttributeValue;
 
 /**
  * Class \SAML2\XML\md\AttributeTest
diff --git a/tests/SAML2/XML/saml/NameIDTest.php b/tests/SAML2/XML/saml/NameIDTest.php
index d29cca258..f66234464 100644
--- a/tests/SAML2/XML/saml/NameIDTest.php
+++ b/tests/SAML2/XML/saml/NameIDTest.php
@@ -2,10 +2,10 @@
 
 namespace SAML2\XML\md;
 
-use SAML2\XML\saml\NameID;
-use SAML2\Utils;
 use SAML2\Constants;
 use SAML2\DOMDocumentFactory;
+use SAML2\Utils;
+use SAML2\XML\saml\NameID;
 
 /**
  * Class \SAML2\XML\md\NameIDTest
diff --git a/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php b/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php
index 8eb8daf03..4edc17104 100644
--- a/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php
+++ b/tests/SAML2/XML/saml/SubjectConfirmationDataTest.php
@@ -2,9 +2,9 @@
 
 namespace SAML2\XML\saml;
 
+use SAML2\Constants;
 use SAML2\DOMDocumentFactory;
 use SAML2\Utils;
-use SAML2\Constants;
 
 /**
  * Class \SAML2\XML\saml\SubjectConfirmationDataTest
diff --git a/tests/SAML2/XML/saml/SubjectConfirmationTest.php b/tests/SAML2/XML/saml/SubjectConfirmationTest.php
index a4ebd9f9e..48c16898e 100644
--- a/tests/SAML2/XML/saml/SubjectConfirmationTest.php
+++ b/tests/SAML2/XML/saml/SubjectConfirmationTest.php
@@ -2,9 +2,9 @@
 
 namespace SAML2\XML\saml;
 
+use SAML2\Constants;
 use SAML2\DOMDocumentFactory;
 use SAML2\Utils;
-use SAML2\Constants;
 
 /**
  * Class \SAML2\XML\saml\SubjectConfirmationTest

From 8f07e8e8347c1c38fce1d7b4c3aa01bf242ea0ac Mon Sep 17 00:00:00 2001
From: Charles Bell <cb8@users.noreply.github.com>
Date: Sun, 29 Nov 2015 21:45:33 +0100
Subject: [PATCH 11/17] Format code according to PSR-2

---
 src/SAML2/ArtifactResolve.php                 |   4 +-
 src/SAML2/ArtifactResponse.php                |  16 +-
 src/SAML2/Assertion.php                       | 237 +++++++++---------
 src/SAML2/Assertion/Decrypter.php             |   1 -
 src/SAML2/Assertion/ProcessorBuilder.php      |   1 -
 .../ConstraintValidator/SpIsValidAudience.php |   2 +-
 .../SubjectConfirmationResponseToMatches.php  |   4 +-
 src/SAML2/AttributeQuery.php                  |  15 +-
 src/SAML2/AuthnRequest.php                    |  80 +++---
 src/SAML2/Binding.php                         |  17 +-
 .../Certificate/FingerprintCollection.php     |   4 +-
 src/SAML2/Certificate/KeyLoader.php           |  10 +-
 src/SAML2/Certificate/PrivateKey.php          |   6 +-
 src/SAML2/Certificate/PrivateKeyLoader.php    |   2 +-
 src/SAML2/Certificate/X509.php                |   4 +-
 src/SAML2/Compat/Ssp/Logger.php               |  34 +--
 src/SAML2/Configuration/ArrayAdapter.php      |   2 +-
 .../Configuration/DecryptionProvider.php      |   2 +-
 src/SAML2/Configuration/IdentityProvider.php  |   4 +-
 src/SAML2/Configuration/PrivateKey.php        |   2 +-
 src/SAML2/Configuration/Queryable.php         |   2 +-
 src/SAML2/Configuration/ServiceProvider.php   |   4 +-
 .../Configuration/SimpleSAMLConverter.php     |  12 +-
 src/SAML2/DOMDocumentFactory.php              |   6 +-
 src/SAML2/EncryptedAssertion.php              |  15 +-
 src/SAML2/HTTPArtifact.php                    |  22 +-
 src/SAML2/HTTPPost.php                        |   5 +-
 src/SAML2/HTTPRedirect.php                    |   9 +-
 src/SAML2/LogoutRequest.php                   |  45 ++--
 src/SAML2/LogoutResponse.php                  |   5 +-
 src/SAML2/Message.php                         |  73 +++---
 src/SAML2/Response.php                        |  10 +-
 src/SAML2/Response/Processor.php              |   4 +-
 src/SAML2/SOAP.php                            |   3 +-
 src/SAML2/SOAPClient.php                      |  32 ++-
 .../Signature/AbstractChainedValidator.php    |   8 +-
 src/SAML2/Signature/FingerprintValidator.php  |  10 +-
 src/SAML2/Signature/PublicKeyValidator.php    |   6 +-
 src/SAML2/SignedElement.php                   |  12 +-
 src/SAML2/SignedElementHelper.php             |  40 ++-
 src/SAML2/StatusResponse.php                  |  33 ++-
 src/SAML2/SubjectQuery.php                    |  11 +-
 src/SAML2/Utilities/ArrayCollection.php       |   6 +-
 src/SAML2/Utilities/File.php                  |   2 +-
 src/SAML2/Utils.php                           |  84 +++----
 src/SAML2/XML/ds/KeyInfo.php                  |  13 +-
 src/SAML2/XML/ds/KeyName.php                  |   7 +-
 src/SAML2/XML/ds/X509Certificate.php          |   7 +-
 src/SAML2/XML/ds/X509Data.php                 |   9 +-
 .../XML/md/AdditionalMetadataLocation.php     |   7 +-
 src/SAML2/XML/md/AffiliationDescriptor.php    |  15 +-
 .../XML/md/AttributeAuthorityDescriptor.php   |  11 +-
 .../XML/md/AttributeConsumingService.php      |  21 +-
 src/SAML2/XML/md/AuthnAuthorityDescriptor.php |   9 +-
 src/SAML2/XML/md/ContactPerson.php            |  21 +-
 src/SAML2/XML/md/EndpointType.php             |  15 +-
 src/SAML2/XML/md/EntitiesDescriptor.php       |  21 +-
 src/SAML2/XML/md/EntityDescriptor.php         |  29 ++-
 src/SAML2/XML/md/Extensions.php               |   1 -
 src/SAML2/XML/md/IDPSSODescriptor.php         |  19 +-
 src/SAML2/XML/md/IndexedEndpointType.php      |  17 +-
 src/SAML2/XML/md/KeyDescriptor.php            |  12 +-
 src/SAML2/XML/md/Organization.php             |  13 +-
 src/SAML2/XML/md/PDPDescriptor.php            |   9 +-
 src/SAML2/XML/md/RequestedAttribute.php       |  17 +-
 src/SAML2/XML/md/RoleDescriptor.php           |  19 +-
 src/SAML2/XML/md/SPSSODescriptor.php          |  27 +-
 src/SAML2/XML/md/SSODescriptorType.php        |   9 +-
 src/SAML2/XML/md/UnknownRoleDescriptor.php    |   1 -
 src/SAML2/XML/mdattr/EntityAttributes.php     |   8 +-
 src/SAML2/XML/mdrpi/Common.php                |   1 -
 src/SAML2/XML/mdrpi/PublicationInfo.php       |  17 +-
 src/SAML2/XML/mdrpi/RegistrationInfo.php      |  13 +-
 src/SAML2/XML/mdui/DiscoHints.php             |  17 +-
 src/SAML2/XML/mdui/Keywords.php               |   9 +-
 src/SAML2/XML/mdui/Logo.php                   |   9 +-
 src/SAML2/XML/mdui/UIInfo.php                 |  19 +-
 src/SAML2/XML/saml/Attribute.php              |  13 +-
 src/SAML2/XML/saml/NameID.php                 |  29 ++-
 src/SAML2/XML/saml/SubjectConfirmation.php    |  11 +-
 .../XML/saml/SubjectConfirmationData.php      |  19 +-
 src/SAML2/XML/samlp/Extensions.php            |   1 -
 src/SAML2/XML/shibmd/Scope.php                |  17 +-
 tests/SAML2/AssertionTest.php                 |  11 +-
 tests/SAML2/Certificate/FingerprintTest.php   |   2 +-
 tests/SAML2/DOMDocumentFactoryTest.php        |   4 +-
 .../ConstraintValidator/IsSuccessfulTest.php  |   1 -
 .../SAML2/Signature/MockChainedValidator.php  |   1 -
 tests/SAML2/SignedElementHelperMock.php       |   2 +-
 tests/SAML2/Utilities/FileTest.php            |   2 +-
 tests/SAML2/UtilsTest.php                     |   8 +-
 .../XML/md/AffiliationDescriptorTest.php      |   2 -
 tests/SAML2/XML/md/EndpointTypeTest.php       |   9 +-
 .../SAML2/XML/md/IndexedEndpointTypeTest.php  |   6 +-
 tests/SAML2/XML/md/RoleDescriptorMock.php     |   9 +-
 tests/SAML2/XML/saml/AttributeTest.php        |   1 -
 tests/SAML2/XML/saml/NameIDTest.php           |   4 -
 97 files changed, 698 insertions(+), 782 deletions(-)

diff --git a/src/SAML2/ArtifactResolve.php b/src/SAML2/ArtifactResolve.php
index 547d323b9..6aedcd1cb 100644
--- a/src/SAML2/ArtifactResolve.php
+++ b/src/SAML2/ArtifactResolve.php
@@ -14,7 +14,7 @@ class ArtifactResolve extends Request
 {
     private $artifact;
 
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct('ArtifactResolve', $xml);
 
@@ -22,7 +22,6 @@ public function __construct(\DOMElement $xml = NULL)
             $results = Utils::xpQuery($xml, './saml_protocol:Artifact');
             $this->artifact = $results[0]->textContent;
         }
-
     }
 
     /**
@@ -59,5 +58,4 @@ public function toUnsignedXML()
 
         return $root;
     }
-
 }
diff --git a/src/SAML2/ArtifactResponse.php b/src/SAML2/ArtifactResponse.php
index bb3e1d8ab..436914b0c 100644
--- a/src/SAML2/ArtifactResponse.php
+++ b/src/SAML2/ArtifactResponse.php
@@ -12,25 +12,24 @@ class ArtifactResponse extends StatusResponse
 {
     /**
      * The \DOMElement with the message the artifact refers
-     * to, or NULL if we don't refer to any artifact.
+     * to, or null if we don't refer to any artifact.
      *
-     * @var \DOMElement|NULL
+     * @var \DOMElement|null
      */
     private $any;
 
 
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct('ArtifactResponse', $xml);
 
         if (!is_null($xml)) {
-
             $status = Utils::xpQuery($xml, './saml_protocol:Status');
             assert('!empty($status)'); /* Will have failed during StatusResponse parsing. */
 
             $status = $status[0];
 
-            for ($any = $status->nextSibling; $any !== NULL; $any = $any->nextSibling) {
+            for ($any = $status->nextSibling; $any !== null; $any = $any->nextSibling) {
                 if ($any instanceof \DOMElement) {
                     $this->any = $any;
                     break;
@@ -38,10 +37,9 @@ public function __construct(\DOMElement $xml = NULL)
                 /* Ignore comments and text nodes. */
             }
         }
-
     }
 
-    public function setAny(\DOMElement $any = NULL)
+    public function setAny(\DOMElement $any = null)
     {
         $this->any = $any;
     }
@@ -60,12 +58,10 @@ public function toUnsignedXML()
     {
         $root = parent::toUnsignedXML();
         if (isset($this->any)) {
-            $node = $root->ownerDocument->importNode($this->any, TRUE);
+            $node = $root->ownerDocument->importNode($this->any, true);
             $root->appendChild($node);
-
         }
 
         return $root;
     }
-
 }
diff --git a/src/SAML2/Assertion.php b/src/SAML2/Assertion.php
index ca7168660..5500d3cb4 100644
--- a/src/SAML2/Assertion.php
+++ b/src/SAML2/Assertion.php
@@ -39,34 +39,34 @@ class Assertion implements SignedElement
     /**
      * The NameId of the subject in the assertion.
      *
-     * If the NameId is NULL, no subject was included in the assertion.
+     * If the NameId is null, no subject was included in the assertion.
      *
-     * @var array|NULL
+     * @var array|null
      */
     private $nameId;
 
     /**
      * The encrypted NameId of the subject.
      *
-     * If this is not NULL, the NameId needs decryption before it can be accessed.
+     * If this is not null, the NameId needs decryption before it can be accessed.
      *
-     * @var \DOMElement|NULL
+     * @var \DOMElement|null
      */
     private $encryptedNameId;
 
     /**
      * The encrypted Attributes.
      *
-     * If this is not NULL, these Attributes need decryption before they can be accessed.
+     * If this is not null, these Attributes need decryption before they can be accessed.
      *
-     * @var \DOMElement[]|NULL
+     * @var \DOMElement[]|null
      */
     private $encryptedAttributes;
 
     /**
      * Private key we should use to encrypt the attributes.
      *
-     * @var XMLSecurityKey|NULL
+     * @var XMLSecurityKey|null
      */
     private $encryptionKey;
 
@@ -89,25 +89,25 @@ class Assertion implements SignedElement
      *
      * This is an array of valid service providers.
      *
-     * If no restrictions on the audience are present, this variable contains NULL.
+     * If no restrictions on the audience are present, this variable contains null.
      *
-     * @var array|NULL
+     * @var array|null
      */
     private $validAudiences;
 
     /**
      * The session expiration timestamp.
      *
-     * @var int|NULL
+     * @var int|null
      */
     private $sessionNotOnOrAfter;
 
     /**
      * The session index for this user on the IdP.
      *
-     * Contains NULL if no session index is present.
+     * Contains null if no session index is present.
      *
-     * @var string|NULL
+     * @var string|null
      */
     private $sessionIndex;
 
@@ -121,7 +121,7 @@ class Assertion implements SignedElement
     /**
      * The authentication context reference for this assertion.
      *
-     * @var string|NULL
+     * @var string|null
      */
     private $authnContextClassRef;
 
@@ -171,9 +171,9 @@ class Assertion implements SignedElement
     /**
      * The private key we should use to sign the assertion.
      *
-     * The private key can be NULL, in which case the assertion is sent unsigned.
+     * The private key can be null, in which case the assertion is sent unsigned.
      *
-     * @var XMLSecurityKey|NULL
+     * @var XMLSecurityKey|null
      */
     private $signatureKey;
 
@@ -187,7 +187,7 @@ class Assertion implements SignedElement
     /**
      * The data needed to verify the signature.
      *
-     * @var array|NULL
+     * @var array|null
      */
     private $signatureData;
 
@@ -209,15 +209,15 @@ class Assertion implements SignedElement
     /**
      * @var bool
      */
-    protected $wasSignedAtConstruction = FALSE;
+    protected $wasSignedAtConstruction = false;
 
     /**
      * Constructor for SAML 2 assertions.
      *
-     * @param \DOMElement|NULL $xml The input assertion.
+     * @param \DOMElement|null $xml The input assertion.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         $this->id = Utils::getContainer()->generateId();
         $this->issueInstant = Temporal::getTime();
@@ -229,7 +229,7 @@ public function __construct(\DOMElement $xml = NULL)
         $this->AuthenticatingAuthority = array();
         $this->SubjectConfirmation = array();
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -324,31 +324,30 @@ private function parseConditions(\DOMElement $xml)
 
         if ($conditions->hasAttribute('NotBefore')) {
             $notBefore = Utils::xsDateTimeToTimestamp($conditions->getAttribute('NotBefore'));
-            if ($this->notBefore === NULL || $this->notBefore < $notBefore) {
+            if ($this->notBefore === null || $this->notBefore < $notBefore) {
                 $this->notBefore = $notBefore;
             }
         }
         if ($conditions->hasAttribute('NotOnOrAfter')) {
             $notOnOrAfter = Utils::xsDateTimeToTimestamp($conditions->getAttribute('NotOnOrAfter'));
-            if ($this->notOnOrAfter === NULL || $this->notOnOrAfter > $notOnOrAfter) {
+            if ($this->notOnOrAfter === null || $this->notOnOrAfter > $notOnOrAfter) {
                 $this->notOnOrAfter = $notOnOrAfter;
             }
         }
 
-        for ($node = $conditions->firstChild; $node !== NULL; $node = $node->nextSibling) {
+        for ($node = $conditions->firstChild; $node !== null; $node = $node->nextSibling) {
             if ($node instanceof \DOMText) {
                 continue;
             }
             if ($node->namespaceURI !== Constants::NS_SAML) {
-                throw new \Exception('Unknown namespace of condition: ' . var_export($node->namespaceURI, TRUE));
+                throw new \Exception('Unknown namespace of condition: ' . var_export($node->namespaceURI, true));
             }
             switch ($node->localName) {
                 case 'AudienceRestriction':
                     $audiences = Utils::extractStrings($node, Constants::NS_SAML, 'Audience');
-                    if ($this->validAudiences === NULL) {
+                    if ($this->validAudiences === null) {
                         /* The first (and probably last) AudienceRestriction element. */
                         $this->validAudiences = $audiences;
-
                     } else {
                         /*
                          * The set of AudienceRestriction are ANDed together, so we need
@@ -364,10 +363,9 @@ private function parseConditions(\DOMElement $xml)
                     /* Currently ignored. */
                     break;
                 default:
-                    throw new \Exception('Unknown condition: ' . var_export($node->localName, TRUE));
+                    throw new \Exception('Unknown condition: ' . var_export($node->localName, true));
             }
         }
-
     }
 
     /**
@@ -380,7 +378,7 @@ private function parseAuthnStatement(\DOMElement $xml)
     {
         $authnStatements = Utils::xpQuery($xml, './saml_assertion:AuthnStatement');
         if (empty($authnStatements)) {
-            $this->authnInstant = NULL;
+            $this->authnInstant = null;
 
             return;
         } elseif (count($authnStatements) > 1) {
@@ -471,7 +469,7 @@ private function parseAuthnContext(\DOMElement $authnStatementEl)
      */
     private function parseAttributes(\DOMElement $xml)
     {
-        $firstAttribute = TRUE;
+        $firstAttribute = true;
         $attributes = Utils::xpQuery($xml, './saml_assertion:AttributeStatement/saml_assertion:Attribute');
         foreach ($attributes as $attribute) {
             if (!$attribute->hasAttribute('Name')) {
@@ -487,7 +485,7 @@ private function parseAttributes(\DOMElement $xml)
 
             if ($firstAttribute) {
                 $this->nameFormat = $nameFormat;
-                $firstAttribute = FALSE;
+                $firstAttribute = false;
             } else {
                 if ($this->nameFormat !== $nameFormat) {
                     $this->nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
@@ -527,8 +525,8 @@ private function parseSignature(\DOMElement $xml)
     {
         /* Validate the signature element of the message. */
         $sig = Utils::validateElement($xml);
-        if ($sig !== FALSE) {
-            $this->wasSignedAtConstruction = TRUE;
+        if ($sig !== false) {
+            $this->wasSignedAtConstruction = true;
             $this->certificates = $sig['Certificates'];
             $this->signatureData = $sig;
         }
@@ -537,24 +535,24 @@ private function parseSignature(\DOMElement $xml)
     /**
      * Validate this assertion against a public key.
      *
-     * If no signature was present on the assertion, we will return FALSE.
-     * Otherwise, TRUE will be returned. An exception is thrown if the
+     * If no signature was present on the assertion, we will return false.
+     * Otherwise, true will be returned. An exception is thrown if the
      * signature validation fails.
      *
      * @param  XMLSecurityKey $key The key we should check against.
-     * @return boolean        TRUE if successful, FALSE if it is unsigned.
+     * @return boolean        true if successful, false if it is unsigned.
      */
     public function validate(XMLSecurityKey $key)
     {
         assert('$key->type === XMLSecurityKey::RSA_SHA1');
 
-        if ($this->signatureData === NULL) {
-            return FALSE;
+        if ($this->signatureData === null) {
+            return false;
         }
 
         Utils::validateSignature($this->signatureData, $key);
 
-        return TRUE;
+        return true;
     }
 
     /**
@@ -629,12 +627,12 @@ public function setIssuer($issuer)
      * The returned NameId is in the format used by \SAML2\Utils::addNameId().
      *
      * @see \SAML2\Utils::addNameId()
-     * @return array|NULL The name identifier of the assertion.
+     * @return array|null The name identifier of the assertion.
      * @throws \Exception
      */
     public function getNameId()
     {
-        if ($this->encryptedNameId !== NULL) {
+        if ($this->encryptedNameId !== null) {
             throw new \Exception('Attempted to retrieve encrypted NameID without decrypting it first.');
         }
 
@@ -647,7 +645,7 @@ public function getNameId()
      * The NameId must be in the format accepted by \SAML2\Utils::addNameId().
      *
      * @see \SAML2\Utils::addNameId()
-     * @param array|NULL $nameId The name identifier of the assertion.
+     * @param array|null $nameId The name identifier of the assertion.
      */
     public function setNameId($nameId)
     {
@@ -659,11 +657,11 @@ public function setNameId($nameId)
     /**
      * Check whether the NameId is encrypted.
      *
-     * @return TRUE if the NameId is encrypted, FALSE if not.
+     * @return true if the NameId is encrypted, false if not.
      */
     public function isNameIdEncrypted()
     {
-        return $this->encryptedNameId !== NULL;
+        return $this->encryptedNameId !== null;
     }
 
     /**
@@ -694,7 +692,7 @@ public function encryptNameId(XMLSecurityKey $key)
         $enc->encryptKey($key, $symmetricKey);
 
         $this->encryptedNameId = $enc->encryptNode($symmetricKey);
-        $this->nameId = NULL;
+        $this->nameId = null;
     }
 
     /**
@@ -705,7 +703,7 @@ public function encryptNameId(XMLSecurityKey $key)
      */
     public function decryptNameId(XMLSecurityKey $key, array $blacklist = array())
     {
-        if ($this->encryptedNameId === NULL) {
+        if ($this->encryptedNameId === null) {
             /* No NameID to decrypt. */
 
             return;
@@ -715,7 +713,7 @@ public function decryptNameId(XMLSecurityKey $key, array $blacklist = array())
         Utils::getContainer()->debugMessage($nameId, 'decrypt');
         $this->nameId = Utils::parseNameId($nameId);
 
-        $this->encryptedNameId = NULL;
+        $this->encryptedNameId = null;
     }
 
     /**
@@ -725,7 +723,7 @@ public function decryptNameId(XMLSecurityKey $key, array $blacklist = array())
      */
     public function hasEncryptedAttributes()
     {
-        return $this->encryptedAttributes !== NULL;
+        return $this->encryptedAttributes !== null;
     }
 
     /**
@@ -737,10 +735,10 @@ public function hasEncryptedAttributes()
      */
     public function decryptAttributes(XMLSecurityKey $key, array $blacklist = array())
     {
-        if ($this->encryptedAttributes === NULL) {
+        if ($this->encryptedAttributes === null) {
             return;
         }
-        $firstAttribute = TRUE;
+        $firstAttribute = true;
         $attributes = $this->encryptedAttributes;
         foreach ($attributes as $attributeEnc) {
             /*Decrypt node <EncryptedAttribute>*/
@@ -763,7 +761,7 @@ public function decryptAttributes(XMLSecurityKey $key, array $blacklist = array(
 
             if ($firstAttribute) {
                 $this->nameFormat = $nameFormat;
-                $firstAttribute = FALSE;
+                $firstAttribute = false;
             } else {
                 if ($this->nameFormat !== $nameFormat) {
                     $this->nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
@@ -784,10 +782,10 @@ public function decryptAttributes(XMLSecurityKey $key, array $blacklist = array(
     /**
      * Retrieve the earliest timestamp this assertion is valid.
      *
-     * This function returns NULL if there are no restrictions on how early the
+     * This function returns null if there are no restrictions on how early the
      * assertion can be used.
      *
-     * @return int|NULL The earliest timestamp this assertion is valid.
+     * @return int|null The earliest timestamp this assertion is valid.
      */
     public function getNotBefore()
     {
@@ -797,9 +795,9 @@ public function getNotBefore()
     /**
      * Set the earliest timestamp this assertion can be used.
      *
-     * Set this to NULL if no limit is required.
+     * Set this to null if no limit is required.
      *
-     * @param int|NULL $notBefore The earliest timestamp this assertion is valid.
+     * @param int|null $notBefore The earliest timestamp this assertion is valid.
      */
     public function setNotBefore($notBefore)
     {
@@ -811,10 +809,10 @@ public function setNotBefore($notBefore)
     /**
      * Retrieve the expiration timestamp of this assertion.
      *
-     * This function returns NULL if there are no restrictions on how
+     * This function returns null if there are no restrictions on how
      * late the assertion can be used.
      *
-     * @return int|NULL The latest timestamp this assertion is valid.
+     * @return int|null The latest timestamp this assertion is valid.
      */
     public function getNotOnOrAfter()
     {
@@ -824,9 +822,9 @@ public function getNotOnOrAfter()
     /**
      * Set the expiration timestamp of this assertion.
      *
-     * Set this to NULL if no limit is required.
+     * Set this to null if no limit is required.
      *
-     * @param int|NULL $notOnOrAfter The latest timestamp this assertion is valid.
+     * @param int|null $notOnOrAfter The latest timestamp this assertion is valid.
      */
     public function setNotOnOrAfter($notOnOrAfter)
     {
@@ -838,7 +836,7 @@ public function setNotOnOrAfter($notOnOrAfter)
     /**
      * Set $EncryptedAttributes if attributes will send encrypted
      *
-     * @param boolean $ea TRUE to encrypt attributes in the assertion.
+     * @param boolean $ea true to encrypt attributes in the assertion.
      */
     public function setEncryptedAttributes($ea)
     {
@@ -848,9 +846,9 @@ public function setEncryptedAttributes($ea)
     /**
      * Retrieve the audiences that are allowed to receive this assertion.
      *
-     * This may be NULL, in which case all audiences are allowed.
+     * This may be null, in which case all audiences are allowed.
      *
-     * @return array|NULL The allowed audiences.
+     * @return array|null The allowed audiences.
      */
     public function getValidAudiences()
     {
@@ -860,11 +858,11 @@ public function getValidAudiences()
     /**
      * Set the audiences that are allowed to receive this assertion.
      *
-     * This may be NULL, in which case all audiences are allowed.
+     * This may be null, in which case all audiences are allowed.
      *
-     * @param array|NULL $validAudiences The allowed audiences.
+     * @param array|null $validAudiences The allowed audiences.
      */
-    public function setValidAudiences(array $validAudiences = NULL)
+    public function setValidAudiences(array $validAudiences = null)
     {
         $this->validAudiences = $validAudiences;
     }
@@ -872,7 +870,7 @@ public function setValidAudiences(array $validAudiences = NULL)
     /**
      * Retrieve the AuthnInstant of the assertion.
      *
-     * @return int|NULL The timestamp the user was authenticated, or NULL if the user isn't authenticated.
+     * @return int|null The timestamp the user was authenticated, or NULL if the user isn't authenticated.
      */
     public function getAuthnInstant()
     {
@@ -883,7 +881,7 @@ public function getAuthnInstant()
     /**
      * Set the AuthnInstant of the assertion.
      *
-     * @param int|NULL $authnInstant Timestamp the user was authenticated, or NULL if we don't want an AuthnStatement.
+     * @param int|null $authnInstant Timestamp the user was authenticated, or NULL if we don't want an AuthnStatement.
      */
     public function setAuthnInstant($authnInstant)
     {
@@ -895,10 +893,10 @@ public function setAuthnInstant($authnInstant)
     /**
      * Retrieve the session expiration timestamp.
      *
-     * This function returns NULL if there are no restrictions on the
+     * This function returns null if there are no restrictions on the
      * session lifetime.
      *
-     * @return int|NULL The latest timestamp this session is valid.
+     * @return int|null The latest timestamp this session is valid.
      */
     public function getSessionNotOnOrAfter()
     {
@@ -908,9 +906,9 @@ public function getSessionNotOnOrAfter()
     /**
      * Set the session expiration timestamp.
      *
-     * Set this to NULL if no limit is required.
+     * Set this to null if no limit is required.
      *
-     * @param int|NULL $sessionNotOnOrAfter The latest timestamp this session is valid.
+     * @param int|null $sessionNotOnOrAfter The latest timestamp this session is valid.
      */
     public function setSessionNotOnOrAfter($sessionNotOnOrAfter)
     {
@@ -922,7 +920,7 @@ public function setSessionNotOnOrAfter($sessionNotOnOrAfter)
     /**
      * Retrieve the session index of the user at the IdP.
      *
-     * @return string|NULL The session index of the user at the IdP.
+     * @return string|null The session index of the user at the IdP.
      */
     public function getSessionIndex()
     {
@@ -935,7 +933,7 @@ public function getSessionIndex()
      * Note that the authentication context must be set before the
      * session index can be inluded in the assertion.
      *
-     * @param string|NULL $sessionIndex The session index of the user at the IdP.
+     * @param string|null $sessionIndex The session index of the user at the IdP.
      */
     public function setSessionIndex($sessionIndex)
     {
@@ -947,7 +945,7 @@ public function setSessionIndex($sessionIndex)
     /**
      * Retrieve the authentication method used to authenticate the user.
      *
-     * This will return NULL if no authentication statement was
+     * This will return null if no authentication statement was
      * included in the assertion.
      *
      * Note that this returns either the AuthnContextClassRef or the AuthnConextDeclRef, whose definition overlaps
@@ -956,7 +954,7 @@ public function setSessionIndex($sessionIndex)
      * Should no longer be required, please use either getAuthnConextClassRef or getAuthnContextDeclRef.
      *
      * @deprecated use getAuthnContextClassRef
-     * @return string|NULL The authentication method.
+     * @return string|null The authentication method.
      */
     public function getAuthnContext()
     {
@@ -966,17 +964,17 @@ public function getAuthnContext()
         if (!empty($this->authnContextDeclRef)) {
             return $this->authnContextDeclRef;
         }
-        return NULL;
+        return null;
     }
 
     /**
      * Set the authentication method used to authenticate the user.
      *
-     * If this is set to NULL, no authentication statement will be
-     * included in the assertion. The default is NULL.
+     * If this is set to null, no authentication statement will be
+     * included in the assertion. The default is null.
      *
      * @deprecated use setAuthnContextClassRef
-     * @param string|NULL $authnContext The authentication method.
+     * @param string|null $authnContext The authentication method.
      */
     public function setAuthnContext($authnContext)
     {
@@ -986,10 +984,10 @@ public function setAuthnContext($authnContext)
     /**
      * Retrieve the authentication method used to authenticate the user.
      *
-     * This will return NULL if no authentication statement was
+     * This will return null if no authentication statement was
      * included in the assertion.
      *
-     * @return string|NULL The authentication method.
+     * @return string|null The authentication method.
      */
     public function getAuthnContextClassRef()
     {
@@ -999,10 +997,10 @@ public function getAuthnContextClassRef()
     /**
      * Set the authentication method used to authenticate the user.
      *
-     * If this is set to NULL, no authentication statement will be
-     * included in the assertion. The default is NULL.
+     * If this is set to null, no authentication statement will be
+     * included in the assertion. The default is null.
      *
-     * @param string|NULL $authnContextClassRef The authentication method.
+     * @param string|null $authnContextClassRef The authentication method.
      */
     public function setAuthnContextClassRef($authnContextClassRef)
     {
@@ -1034,7 +1032,7 @@ public function setAuthnContextDecl(Chunk $authnContextDecl)
      * See:
      * @url http://docs.oasis-open.org/security/saml/v2.0/saml-authn-context-2.0-os.pdf
      *
-     * @return \SAML2\XML\Chunk|NULL
+     * @return \SAML2\XML\Chunk|null
      */
     public function getAuthnContextDecl()
     {
@@ -1161,7 +1159,7 @@ public function setSubjectConfirmation(array $SubjectConfirmation)
     /**
      * Retrieve the private key we should use to sign the assertion.
      *
-     * @return XMLSecurityKey|NULL The key, or NULL if no key is specified.
+     * @return XMLSecurityKey|null The key, or NULL if no key is specified.
      */
     public function getSignatureKey()
     {
@@ -1171,11 +1169,11 @@ public function getSignatureKey()
     /**
      * Set the private key we should use to sign the assertion.
      *
-     * If the key is NULL, the assertion will be sent unsigned.
+     * If the key is null, the assertion will be sent unsigned.
      *
-     * @param XMLSecurityKey|NULL $signatureKey
+     * @param XMLSecurityKey|null $signatureKey
      */
-    public function setSignatureKey(XMLsecurityKey $signatureKey = NULL)
+    public function setSignatureKey(XMLsecurityKey $signatureKey = null)
     {
         $this->signatureKey = $signatureKey;
     }
@@ -1183,7 +1181,7 @@ public function setSignatureKey(XMLsecurityKey $signatureKey = NULL)
     /**
      * Return the key we should use to encrypt the assertion.
      *
-     * @return XMLSecurityKey|NULL The key, or NULL if no key is specified..
+     * @return XMLSecurityKey|null The key, or NULL if no key is specified..
      *
      */
     public function getEncryptionKey()
@@ -1194,9 +1192,9 @@ public function getEncryptionKey()
     /**
      * Set the private key we should use to encrypt the attributes.
      *
-     * @param XMLSecurityKey|NULL $Key
+     * @param XMLSecurityKey|null $Key
      */
-    public function setEncryptionKey(XMLSecurityKey $Key = NULL)
+    public function setEncryptionKey(XMLSecurityKey $Key = null)
     {
         $this->encryptionKey = $Key;
     }
@@ -1234,12 +1232,12 @@ public function getWasSignedAtConstruction()
     /**
      * Convert this assertion to an XML element.
      *
-     * @param  \DOMNode|NULL $parentElement The DOM node the assertion should be created in.
+     * @param  \DOMNode|null $parentElement The DOM node the assertion should be created in.
      * @return \DOMElement   This assertion.
      */
-    public function toXML(\DOMNode $parentElement = NULL)
+    public function toXML(\DOMNode $parentElement = null)
     {
-        if ($parentElement === NULL) {
+        if ($parentElement === null) {
             $document = DOMDocumentFactory::create();
             $parentElement = $document;
         } else {
@@ -1266,13 +1264,13 @@ public function toXML(\DOMNode $parentElement = NULL)
         $this->addSubject($root);
         $this->addConditions($root);
         $this->addAuthnStatement($root);
-        if ($this->requiredEncAttributes == FALSE) {
+        if ($this->requiredEncAttributes == false) {
             $this->addAttributeStatement($root);
         } else {
             $this->addEncryptedAttributeStatement($root);
         }
 
-        if ($this->signatureKey !== NULL) {
+        if ($this->signatureKey !== null) {
             Utils::insertSignature($this->signatureKey, $this->certificates, $root, $issuer->nextSibling);
         }
 
@@ -1286,7 +1284,7 @@ public function toXML(\DOMNode $parentElement = NULL)
      */
     private function addSubject(\DOMElement $root)
     {
-        if ($this->nameId === NULL && $this->encryptedNameId === NULL) {
+        if ($this->nameId === null && $this->encryptedNameId === null) {
             /* We don't have anything to create a Subject node for. */
 
             return;
@@ -1295,12 +1293,12 @@ private function addSubject(\DOMElement $root)
         $subject = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:Subject');
         $root->appendChild($subject);
 
-        if ($this->encryptedNameId === NULL) {
+        if ($this->encryptedNameId === null) {
             Utils::addNameId($subject, $this->nameId);
         } else {
             $eid = $subject->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:' . 'EncryptedID');
             $subject->appendChild($eid);
-            $eid->appendChild($subject->ownerDocument->importNode($this->encryptedNameId, TRUE));
+            $eid->appendChild($subject->ownerDocument->importNode($this->encryptedNameId, true));
         }
 
         foreach ($this->SubjectConfirmation as $sc) {
@@ -1321,18 +1319,18 @@ private function addConditions(\DOMElement $root)
         $conditions = $document->createElementNS(Constants::NS_SAML, 'saml:Conditions');
         $root->appendChild($conditions);
 
-        if ($this->notBefore !== NULL) {
+        if ($this->notBefore !== null) {
             $conditions->setAttribute('NotBefore', gmdate('Y-m-d\TH:i:s\Z', $this->notBefore));
         }
-        if ($this->notOnOrAfter !== NULL) {
+        if ($this->notOnOrAfter !== null) {
             $conditions->setAttribute('NotOnOrAfter', gmdate('Y-m-d\TH:i:s\Z', $this->notOnOrAfter));
         }
 
-        if ($this->validAudiences !== NULL) {
+        if ($this->validAudiences !== null) {
             $ar = $document->createElementNS(Constants::NS_SAML, 'saml:AudienceRestriction');
             $conditions->appendChild($ar);
 
-            Utils::addStrings($ar, Constants::NS_SAML, 'saml:Audience', FALSE, $this->validAudiences);
+            Utils::addStrings($ar, Constants::NS_SAML, 'saml:Audience', false, $this->validAudiences);
         }
     }
 
@@ -1344,11 +1342,11 @@ private function addConditions(\DOMElement $root)
      */
     private function addAuthnStatement(\DOMElement $root)
     {
-        if ($this->authnInstant === NULL ||
+        if ($this->authnInstant === null ||
             (
-                $this->authnContextClassRef === NULL &&
-                $this->authnContextDecl === NULL &&
-                $this->authnContextDeclRef === NULL
+                $this->authnContextClassRef === null &&
+                $this->authnContextDecl === null &&
+                $this->authnContextDeclRef === null
             )
         ) {
             /* No authentication context or AuthnInstant => no authentication statement. */
@@ -1363,10 +1361,10 @@ private function addAuthnStatement(\DOMElement $root)
 
         $authnStatementEl->setAttribute('AuthnInstant', gmdate('Y-m-d\TH:i:s\Z', $this->authnInstant));
 
-        if ($this->sessionNotOnOrAfter !== NULL) {
+        if ($this->sessionNotOnOrAfter !== null) {
             $authnStatementEl->setAttribute('SessionNotOnOrAfter', gmdate('Y-m-d\TH:i:s\Z', $this->sessionNotOnOrAfter));
         }
-        if ($this->sessionIndex !== NULL) {
+        if ($this->sessionIndex !== null) {
             $authnStatementEl->setAttribute('SessionIndex', $this->sessionIndex);
         }
 
@@ -1397,7 +1395,7 @@ private function addAuthnStatement(\DOMElement $root)
             $authnContextEl,
             Constants::NS_SAML,
             'saml:AuthenticatingAuthority',
-            FALSE,
+            false,
             $this->AuthenticatingAuthority
         );
     }
@@ -1434,12 +1432,12 @@ private function addAttributeStatement(\DOMElement $root)
                 } elseif (is_int($value)) {
                     $type = 'xs:integer';
                 } else {
-                    $type = NULL;
+                    $type = null;
                 }
 
                 $attributeValue = $document->createElementNS(Constants::NS_SAML, 'saml:AttributeValue');
                 $attribute->appendChild($attributeValue);
-                if ($type !== NULL) {
+                if ($type !== null) {
                     $attributeValue->setAttributeNS(Constants::NS_XSI, 'xsi:type', $type);
                 }
                 if (is_null($value)) {
@@ -1448,7 +1446,7 @@ private function addAttributeStatement(\DOMElement $root)
 
                 if ($value instanceof \DOMNodeList) {
                     for ($i = 0; $i < $value->length; $i++) {
-                        $node = $document->importNode($value->item($i), TRUE);
+                        $node = $document->importNode($value->item($i), true);
                         $attributeValue->appendChild($node);
                     }
                 } else {
@@ -1466,7 +1464,7 @@ private function addAttributeStatement(\DOMElement $root)
      */
     private function addEncryptedAttributeStatement(\DOMElement $root)
     {
-        if ($this->requiredEncAttributes == FALSE) {
+        if ($this->requiredEncAttributes == false) {
             return;
         }
 
@@ -1491,18 +1489,18 @@ private function addEncryptedAttributeStatement(\DOMElement $root)
                 } elseif (is_int($value)) {
                     $type = 'xs:integer';
                 } else {
-                    $type = NULL;
+                    $type = null;
                 }
 
                 $attributeValue = $document2->createElementNS(Constants::NS_SAML, 'saml:AttributeValue');
                 $attribute->appendChild($attributeValue);
-                if ($type !== NULL) {
+                if ($type !== null) {
                     $attributeValue->setAttributeNS(Constants::NS_XSI, 'xsi:type', $type);
                 }
 
                 if ($value instanceof \DOMNodeList) {
                     for ($i = 0; $i < $value->length; $i++) {
-                        $node = $document2->importNode($value->item($i), TRUE);
+                        $node = $document2->importNode($value->item($i), true);
                         $attributeValue->appendChild($node);
                     }
                 } else {
@@ -1524,9 +1522,8 @@ private function addEncryptedAttributeStatement(\DOMElement $root)
 
             $EncAttribute = $document->createElementNS(Constants::NS_SAML, 'saml:EncryptedAttribute');
             $attributeStatement->appendChild($EncAttribute);
-            $n = $document->importNode($EncrNode, TRUE);
+            $n = $document->importNode($EncrNode, true);
             $EncAttribute->appendChild($n);
         }
     }
-
 }
diff --git a/src/SAML2/Assertion/Decrypter.php b/src/SAML2/Assertion/Decrypter.php
index 4226ffda9..38892a4d1 100644
--- a/src/SAML2/Assertion/Decrypter.php
+++ b/src/SAML2/Assertion/Decrypter.php
@@ -72,7 +72,6 @@ public function decrypt(EncryptedAssertion $assertion)
                 $this->logger->debug(sprintf('Decrypted Assertion with key "#%d"', $index));
 
                 return $decryptedAssertion;
-
             } catch (\Exception $e) {
                 $this->logger->debug(sprintf(
                     'Could not decrypt assertion with key "#%d", "%s" thrown: "%s"',
diff --git a/src/SAML2/Assertion/ProcessorBuilder.php b/src/SAML2/Assertion/ProcessorBuilder.php
index 5f6c40d8b..7fd0dbe3d 100644
--- a/src/SAML2/Assertion/ProcessorBuilder.php
+++ b/src/SAML2/Assertion/ProcessorBuilder.php
@@ -125,5 +125,4 @@ private static function createAssertionTransformerChain(
 
         return $chain;
     }
-
 }
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php
index 5456f92fa..0ea473ac3 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudience.php
@@ -25,7 +25,7 @@ public function setServiceProvider(ServiceProvider $serviceProvider)
     public function validate(Assertion $assertion, Result $result)
     {
         $intendedAudiences = $assertion->getValidAudiences();
-        if ($intendedAudiences === NULL) {
+        if ($intendedAudiences === null) {
             return;
         }
 
diff --git a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatches.php b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatches.php
index 655eabb0b..91db324fe 100644
--- a/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatches.php
+++ b/src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatches.php
@@ -34,8 +34,8 @@ public function validate(
     private function getInResponseTo()
     {
         $inResponseTo = $this->response->getInResponseTo();
-        if ($inResponseTo === NULL) {
-            return FALSE;
+        if ($inResponseTo === null) {
+            return false;
         }
 
         return $inResponseTo;
diff --git a/src/SAML2/AttributeQuery.php b/src/SAML2/AttributeQuery.php
index 6d38274c3..0d834d046 100644
--- a/src/SAML2/AttributeQuery.php
+++ b/src/SAML2/AttributeQuery.php
@@ -39,21 +39,21 @@ class AttributeQuery extends SubjectQuery
     /**
      * Constructor for SAML 2 attribute query messages.
      *
-     * @param \DOMElement|NULL $xml The input message.
+     * @param \DOMElement|null $xml The input message.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct('AttributeQuery', $xml);
 
         $this->attributes = array();
         $this->nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
-        $firstAttribute = TRUE;
+        $firstAttribute = true;
         $attributes = Utils::xpQuery($xml, './saml_assertion:Attribute');
         foreach ($attributes as $attribute) {
             if (!$attribute->hasAttribute('Name')) {
@@ -69,7 +69,7 @@ public function __construct(\DOMElement $xml = NULL)
 
             if ($firstAttribute) {
                 $this->nameFormat = $nameFormat;
-                $firstAttribute = FALSE;
+                $firstAttribute = false;
             } else {
                 if ($this->nameFormat !== $nameFormat) {
                     $this->nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
@@ -156,11 +156,11 @@ public function toUnsignedXML()
                 } elseif (is_int($value)) {
                     $type = 'xs:integer';
                 } else {
-                    $type = NULL;
+                    $type = null;
                 }
 
                 $attributeValue = Utils::addString($attribute, Constants::NS_SAML, 'saml:AttributeValue', $value);
-                if ($type !== NULL) {
+                if ($type !== null) {
                     $attributeValue->setAttributeNS(Constants::NS_XSI, 'xsi:type', $type);
                 }
             }
@@ -168,5 +168,4 @@ public function toUnsignedXML()
 
         return $root;
     }
-
 }
diff --git a/src/SAML2/AuthnRequest.php b/src/SAML2/AuthnRequest.php
index 3a42f2750..bf083adc2 100644
--- a/src/SAML2/AuthnRequest.php
+++ b/src/SAML2/AuthnRequest.php
@@ -37,7 +37,7 @@ class AuthnRequest extends Request
 
 
     /**
-     * Set to TRUE if this request is passive.
+     * Set to true if this request is passive.
      *
      * @var bool.
      */
@@ -55,7 +55,7 @@ class AuthnRequest extends Request
      *
      * @var int
      */
-    private $ProxyCount = NULL;
+    private $ProxyCount = null;
 
     /**
      * The RequesterID list in this request's scoping element
@@ -68,7 +68,7 @@ class AuthnRequest extends Request
     /**
      * The URL of the asertion consumer service where the response should be delivered.
      *
-     * @var string|NULL
+     * @var string|null
      */
     private $assertionConsumerServiceURL;
 
@@ -76,7 +76,7 @@ class AuthnRequest extends Request
     /**
      * What binding should be used when sending the response.
      *
-     * @var string|NULL
+     * @var string|null
      */
     private $protocolBinding;
 
@@ -84,14 +84,14 @@ class AuthnRequest extends Request
     /**
      * The index of the AttributeConsumingService.
      *
-     * @var int|NULL
+     * @var int|null
      */
     private $attributeConsumingServiceIndex;
 
     /**
      * The index of the AssertionConsumerService.
      *
-     * @var int|NULL
+     * @var int|null
      */
     private $assertionConsumerServiceIndex;
 
@@ -125,23 +125,23 @@ class AuthnRequest extends Request
     /**
      * Constructor for SAML 2 authentication request messages.
      *
-     * @param \DOMElement|NULL $xml The input message.
+     * @param \DOMElement|null $xml The input message.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct('AuthnRequest', $xml);
 
         $this->nameIdPolicy = array();
-        $this->forceAuthn = FALSE;
-        $this->isPassive = FALSE;
+        $this->forceAuthn = false;
+        $this->isPassive = false;
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
-        $this->forceAuthn = Utils::parseBoolean($xml, 'ForceAuthn', FALSE);
-        $this->isPassive = Utils::parseBoolean($xml, 'IsPassive', FALSE);
+        $this->forceAuthn = Utils::parseBoolean($xml, 'ForceAuthn', false);
+        $this->isPassive = Utils::parseBoolean($xml, 'IsPassive', false);
 
         if ($xml->hasAttribute('AssertionConsumerServiceURL')) {
             $this->assertionConsumerServiceURL = $xml->getAttribute('AssertionConsumerServiceURL');
@@ -225,7 +225,7 @@ protected function parseNameIdPolicy(\DOMElement $xml)
             $this->nameIdPolicy['SPNameQualifier'] = $nameIdPolicy->getAttribute('SPNameQualifier');
         }
         if ($nameIdPolicy->hasAttribute('AllowCreate')) {
-            $this->nameIdPolicy['AllowCreate'] = Utils::parseBoolean($nameIdPolicy, 'AllowCreate', FALSE);
+            $this->nameIdPolicy['AllowCreate'] = Utils::parseBoolean($nameIdPolicy, 'AllowCreate', false);
         }
     }
 
@@ -456,7 +456,7 @@ public function getRequesterID()
     /**
      * Retrieve the value of the AssertionConsumerServiceURL attribute.
      *
-     * @return string|NULL The AssertionConsumerServiceURL attribute.
+     * @return string|null The AssertionConsumerServiceURL attribute.
      */
     public function getAssertionConsumerServiceURL()
     {
@@ -466,7 +466,7 @@ public function getAssertionConsumerServiceURL()
     /**
      * Set the value of the AssertionConsumerServiceURL attribute.
      *
-     * @param string|NULL $assertionConsumerServiceURL The AssertionConsumerServiceURL attribute.
+     * @param string|null $assertionConsumerServiceURL The AssertionConsumerServiceURL attribute.
      */
     public function setAssertionConsumerServiceURL($assertionConsumerServiceURL)
     {
@@ -478,7 +478,7 @@ public function setAssertionConsumerServiceURL($assertionConsumerServiceURL)
     /**
      * Retrieve the value of the ProtocolBinding attribute.
      *
-     * @return string|NULL The ProtocolBinding attribute.
+     * @return string|null The ProtocolBinding attribute.
      */
     public function getProtocolBinding()
     {
@@ -500,7 +500,7 @@ public function setProtocolBinding($protocolBinding)
     /**
      * Retrieve the value of the AttributeConsumingServiceIndex attribute.
      *
-     * @return int|NULL The AttributeConsumingServiceIndex attribute.
+     * @return int|null The AttributeConsumingServiceIndex attribute.
      */
     public function getAttributeConsumingServiceIndex()
     {
@@ -510,7 +510,7 @@ public function getAttributeConsumingServiceIndex()
     /**
      * Set the value of the AttributeConsumingServiceIndex attribute.
      *
-     * @param int|NULL $attributeConsumingServiceIndex The AttributeConsumingServiceIndex attribute.
+     * @param int|null $attributeConsumingServiceIndex The AttributeConsumingServiceIndex attribute.
      */
     public function setAttributeConsumingServiceIndex($attributeConsumingServiceIndex)
     {
@@ -522,7 +522,7 @@ public function setAttributeConsumingServiceIndex($attributeConsumingServiceInde
     /**
      * Retrieve the value of the AssertionConsumerServiceIndex attribute.
      *
-     * @return int|NULL The AssertionConsumerServiceIndex attribute.
+     * @return int|null The AssertionConsumerServiceIndex attribute.
      */
     public function getAssertionConsumerServiceIndex()
     {
@@ -532,7 +532,7 @@ public function getAssertionConsumerServiceIndex()
     /**
      * Set the value of the AssertionConsumerServiceIndex attribute.
      *
-     * @param int|NULL $assertionConsumerServiceIndex The AssertionConsumerServiceIndex attribute.
+     * @param int|null $assertionConsumerServiceIndex The AssertionConsumerServiceIndex attribute.
      */
     public function setAssertionConsumerServiceIndex($assertionConsumerServiceIndex)
     {
@@ -544,7 +544,7 @@ public function setAssertionConsumerServiceIndex($assertionConsumerServiceIndex)
     /**
      * Retrieve the RequestedAuthnContext.
      *
-     * @return array|NULL The RequestedAuthnContext.
+     * @return array|null The RequestedAuthnContext.
      */
     public function getRequestedAuthnContext()
     {
@@ -554,7 +554,7 @@ public function getRequestedAuthnContext()
     /**
      * Set the RequestedAuthnContext.
      *
-     * @param array|NULL $requestedAuthnContext The RequestedAuthnContext.
+     * @param array|null $requestedAuthnContext The RequestedAuthnContext.
      */
     public function setRequestedAuthnContext($requestedAuthnContext)
     {
@@ -569,12 +569,12 @@ public function setRequestedAuthnContext($requestedAuthnContext)
      * The returned NameId is in the format used by \SAML2\Utils::addNameId().
      *
      * @see \SAML2\Utils::addNameId()
-     * @return array|NULL The name identifier of the assertion.
+     * @return array|null The name identifier of the assertion.
      * @throws \Exception
      */
     public function getNameId()
     {
-        if ($this->encryptedNameId !== NULL) {
+        if ($this->encryptedNameId !== null) {
             throw new \Exception('Attempted to retrieve encrypted NameID without decrypting it first.');
         }
 
@@ -588,7 +588,7 @@ public function getNameId()
      *
      * @see \SAML2\Utils::addNameId()
      *
-     * @param array|NULL $nameId The name identifier of the assertion.
+     * @param array|null $nameId The name identifier of the assertion.
      */
     public function setNameId($nameId)
     {
@@ -625,7 +625,7 @@ public function encryptNameId(XMLSecurityKey $key)
         $enc->encryptKey($key, $symmetricKey);
 
         $this->encryptedNameId = $enc->encryptNode($symmetricKey);
-        $this->nameId          = NULL;
+        $this->nameId          = null;
     }
 
     /**
@@ -636,7 +636,7 @@ public function encryptNameId(XMLSecurityKey $key)
      */
     public function decryptNameId(XMLSecurityKey $key, array $blacklist = array())
     {
-        if ($this->encryptedNameId === NULL) {
+        if ($this->encryptedNameId === null) {
             /* No NameID to decrypt. */
             return;
         }
@@ -645,7 +645,7 @@ public function decryptNameId(XMLSecurityKey $key, array $blacklist = array())
         Utils::getContainer()->debugMessage($nameId, 'decrypt');
         $this->nameId = Utils::parseNameId($nameId);
 
-        $this->encryptedNameId = NULL;
+        $this->encryptedNameId = null;
     }
 
     /**
@@ -681,7 +681,7 @@ public function toUnsignedXML()
             $root->setAttribute('ForceAuthn', 'true');
         }
 
-        if ($this->ProviderName !== NULL) {
+        if ($this->ProviderName !== null) {
             $root->setAttribute('ProviderName', $this->ProviderName);
         }
 
@@ -689,18 +689,18 @@ public function toUnsignedXML()
             $root->setAttribute('IsPassive', 'true');
         }
 
-        if ($this->assertionConsumerServiceIndex !== NULL) {
+        if ($this->assertionConsumerServiceIndex !== null) {
             $root->setAttribute('AssertionConsumerServiceIndex', $this->assertionConsumerServiceIndex);
         } else {
-            if ($this->assertionConsumerServiceURL !== NULL) {
+            if ($this->assertionConsumerServiceURL !== null) {
                 $root->setAttribute('AssertionConsumerServiceURL', $this->assertionConsumerServiceURL);
             }
-            if ($this->protocolBinding !== NULL) {
+            if ($this->protocolBinding !== null) {
                 $root->setAttribute('ProtocolBinding', $this->protocolBinding);
             }
         }
 
-        if ($this->attributeConsumingServiceIndex !== NULL) {
+        if ($this->attributeConsumingServiceIndex !== null) {
             $root->setAttribute('AttributeConsumingServiceIndex', $this->attributeConsumingServiceIndex);
         }
 
@@ -732,10 +732,10 @@ public function toUnsignedXML()
             }
         }
 
-        if ($this->ProxyCount !== NULL || count($this->IDPList) > 0 || count($this->RequesterID) > 0) {
+        if ($this->ProxyCount !== null || count($this->IDPList) > 0 || count($this->RequesterID) > 0) {
             $scoping = $this->document->createElementNS(Constants::NS_SAMLP, 'Scoping');
             $root->appendChild($scoping);
-            if ($this->ProxyCount !== NULL) {
+            if ($this->ProxyCount !== null) {
                 $scoping->setAttribute('ProxyCount', $this->ProxyCount);
             }
             if (count($this->IDPList) > 0) {
@@ -760,7 +760,7 @@ public function toUnsignedXML()
                 $scoping->appendChild($idplist);
             }
             if (count($this->RequesterID) > 0) {
-                Utils::addStrings($scoping, Constants::NS_SAMLP, 'RequesterID', FALSE, $this->RequesterID);
+                Utils::addStrings($scoping, Constants::NS_SAMLP, 'RequesterID', false, $this->RequesterID);
             }
         }
 
@@ -775,18 +775,18 @@ public function toUnsignedXML()
     private function addSubject(\DOMElement $root)
     {
         // If there is no nameId (encrypted or not) there is nothing to create a subject for
-        if ($this->nameId === NULL && $this->encryptedNameId === NULL) {
+        if ($this->nameId === null && $this->encryptedNameId === null) {
             return;
         }
 
         $subject = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:Subject');
         $root->appendChild($subject);
 
-        if ($this->encryptedNameId === NULL) {
+        if ($this->encryptedNameId === null) {
             Utils::addNameId($subject, $this->nameId);
         } else {
             $eid = $subject->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:EncryptedID');
-            $eid->appendChild($subject->ownerDocument->importNode($this->encryptedNameId, TRUE));
+            $eid->appendChild($subject->ownerDocument->importNode($this->encryptedNameId, true));
             $subject->appendChild($eid);
         }
 
diff --git a/src/SAML2/Binding.php b/src/SAML2/Binding.php
index 5728292d0..bad461e0f 100644
--- a/src/SAML2/Binding.php
+++ b/src/SAML2/Binding.php
@@ -12,7 +12,7 @@ abstract class Binding
     /**
      * The destination of messages.
      *
-     * This can be NULL, in which case the destination in the message is used.
+     * This can be null, in which case the destination in the message is used.
      */
     protected $destination;
 
@@ -39,7 +39,7 @@ public static function getBinding($urn)
             case Constants::BINDING_HOK_SSO:
                 return new HTTPPost();
             default:
-                throw new \Exception('Unsupported binding: ' . var_export($urn, TRUE));
+                throw new \Exception('Unsupported binding: ' . var_export($urn, true));
         }
     }
 
@@ -71,7 +71,7 @@ public static function getCurrentBinding()
                     $contentType = explode(';', $contentType);
                     $contentType = $contentType[0]; /* Remove charset. */
                 } else {
-                    $contentType = NULL;
+                    $contentType = null;
                 }
                 if (array_key_exists('SAMLRequest', $_POST) || array_key_exists('SAMLResponse', $_POST)) {
                     return new HTTPPost();
@@ -85,7 +85,7 @@ public static function getCurrentBinding()
 
         $logger = Utils::getContainer()->getLogger();
         $logger->warning('Unable to find the SAML 2 binding used for this request.');
-        $logger->warning('Request method: ' . var_export($_SERVER['REQUEST_METHOD'], TRUE));
+        $logger->warning('Request method: ' . var_export($_SERVER['REQUEST_METHOD'], true));
         if (!empty($_GET)) {
             $logger->warning("GET parameters: '" . implode("', '", array_map('addslashes', array_keys($_GET))) . "'");
         }
@@ -93,7 +93,7 @@ public static function getCurrentBinding()
             $logger->warning("POST parameters: '" . implode("', '", array_map('addslashes', array_keys($_POST))) . "'");
         }
         if (isset($_SERVER['CONTENT_TYPE'])) {
-            $logger->warning('Content-Type: ' . var_export($_SERVER['CONTENT_TYPE'], TRUE));
+            $logger->warning('Content-Type: ' . var_export($_SERVER['CONTENT_TYPE'], true));
         }
 
         throw new \Exception('Unable to find the current binding.');
@@ -102,7 +102,7 @@ public static function getCurrentBinding()
     /**
      * Retrieve the destination of a message.
      *
-     * @return string|NULL $destination  The destination the message will be delivered to.
+     * @return string|null $destination  The destination the message will be delivered to.
      */
     public function getDestination()
     {
@@ -112,9 +112,9 @@ public function getDestination()
     /**
      * Override the destination of a message.
      *
-     * Set to NULL to use the destination set in the message.
+     * Set to null to use the destination set in the message.
      *
-     * @param string|NULL $destination The destination the message should be delivered to.
+     * @param string|null $destination The destination the message should be delivered to.
      */
     public function setDestination($destination)
     {
@@ -142,5 +142,4 @@ abstract public function send(Message $message);
      * @return \SAML2\Message The received message.
      */
     abstract public function receive();
-
 }
diff --git a/src/SAML2/Certificate/FingerprintCollection.php b/src/SAML2/Certificate/FingerprintCollection.php
index 7527d050e..cf0e0e253 100644
--- a/src/SAML2/Certificate/FingerprintCollection.php
+++ b/src/SAML2/Certificate/FingerprintCollection.php
@@ -37,10 +37,10 @@ public function contains(Fingerprint $otherFingerprint)
         foreach ($this->elements as $fingerprint) {
             /** @var \SAML2\Certificate\Fingerprint $fingerprint */
             if ($fingerprint->equals($otherFingerprint)) {
-                return TRUE;
+                return true;
             }
         }
 
-        return FALSE;
+        return false;
     }
 }
diff --git a/src/SAML2/Certificate/KeyLoader.php b/src/SAML2/Certificate/KeyLoader.php
index 33f4c808d..ebf8dd5ca 100644
--- a/src/SAML2/Certificate/KeyLoader.php
+++ b/src/SAML2/Certificate/KeyLoader.php
@@ -37,8 +37,8 @@ public function __construct()
      */
     public static function extractPublicKeys(
         CertificateProvider $config,
-        $usage = NULL,
-        $required = FALSE,
+        $usage = null,
+        $required = false,
         $prefix = ''
     ) {
         $keyLoader = new self();
@@ -48,15 +48,15 @@ public static function extractPublicKeys(
 
     /**
      * @param \SAML2\Configuration\CertificateProvider $config
-     * @param NULL|string                             $usage
+     * @param null|string                             $usage
      * @param bool                                    $required
      *
      * @return \SAML2\Certificate\KeyCollection
      */
     public function loadKeysFromConfiguration(
         CertificateProvider $config,
-        $usage = NULL,
-        $required = FALSE
+        $usage = null,
+        $required = false
     ) {
         $keys = $config->getKeys();
         $certificateData = $config->getCertificateData();
diff --git a/src/SAML2/Certificate/PrivateKey.php b/src/SAML2/Certificate/PrivateKey.php
index 405dd9590..883d38990 100644
--- a/src/SAML2/Certificate/PrivateKey.php
+++ b/src/SAML2/Certificate/PrivateKey.php
@@ -6,7 +6,7 @@
 
 class PrivateKey extends Key
 {
-    public static function create($keyContents, $passphrase = NULL)
+    public static function create($keyContents, $passphrase = null)
     {
         if (!is_string($keyContents)) {
             throw InvalidArgumentException::invalidType('string', $keyContents);
@@ -16,7 +16,7 @@ public static function create($keyContents, $passphrase = NULL)
             throw InvalidArgumentException::invalidType('string', $passphrase);
         }
 
-        $keyData = array ('PEM' => $keyContents, self::USAGE_ENCRYPTION => TRUE);
+        $keyData = array('PEM' => $keyContents, self::USAGE_ENCRYPTION => true);
         if ($passphrase) {
             $keyData['passphrase'] = $passphrase;
         }
@@ -31,6 +31,6 @@ public function getKeyAsString()
 
     public function getPassphrase()
     {
-        return isset($this->keyData['passphrase']) ? $this->keyData['passphrase'] : NULL;
+        return isset($this->keyData['passphrase']) ? $this->keyData['passphrase'] : null;
     }
 }
diff --git a/src/SAML2/Certificate/PrivateKeyLoader.php b/src/SAML2/Certificate/PrivateKeyLoader.php
index aafdeeca1..82a335587 100644
--- a/src/SAML2/Certificate/PrivateKeyLoader.php
+++ b/src/SAML2/Certificate/PrivateKeyLoader.php
@@ -52,7 +52,7 @@ public function loadDecryptionKeys(
             $decryptionKeys->add($this->convertPrivateKeyToRsaKey($loadedKey));
         }
 
-        $privateKey = $serviceProvider->getPrivateKey(PrivateKey::NAME_DEFAULT, TRUE);
+        $privateKey = $serviceProvider->getPrivateKey(PrivateKey::NAME_DEFAULT, true);
         $loadedKey  = $this->loadPrivateKey($privateKey);
         $decryptionKeys->add($this->convertPrivateKeyToRsaKey($loadedKey));
 
diff --git a/src/SAML2/Certificate/X509.php b/src/SAML2/Certificate/X509.php
index 6686be76f..904ab0f83 100644
--- a/src/SAML2/Certificate/X509.php
+++ b/src/SAML2/Certificate/X509.php
@@ -15,8 +15,8 @@ class X509 extends Key
     public static function createFromCertificateData($certificateContents)
     {
         $data = array(
-            'encryption'      => TRUE,
-            'signing'         => TRUE,
+            'encryption'      => true,
+            'signing'         => true,
             'type'            => 'X509Certificate',
             'X509Certificate' => $certificateContents
         );
diff --git a/src/SAML2/Compat/Ssp/Logger.php b/src/SAML2/Compat/Ssp/Logger.php
index 46a63cce9..8bc25f276 100644
--- a/src/SAML2/Compat/Ssp/Logger.php
+++ b/src/SAML2/Compat/Ssp/Logger.php
@@ -9,11 +9,11 @@ class Logger implements Psr\Log\LoggerInterface
      *
      * @param string $message
      * @param array $context
-     * @return NULL
+     * @return null
      */
     public function emergency($message, array $context = array())
     {
-        SimpleSAML_Logger::emergency($message . var_export($context, TRUE));
+        SimpleSAML_Logger::emergency($message . var_export($context, true));
     }
 
     /**
@@ -24,11 +24,11 @@ public function emergency($message, array $context = array())
      *
      * @param string $message
      * @param array $context
-     * @return NULL
+     * @return null
      */
     public function alert($message, array $context = array())
     {
-        SimpleSAML_Logger::alert($message . var_export($context, TRUE));
+        SimpleSAML_Logger::alert($message . var_export($context, true));
     }
 
     /**
@@ -38,11 +38,11 @@ public function alert($message, array $context = array())
      *
      * @param string $message
      * @param array $context
-     * @return NULL
+     * @return null
      */
     public function critical($message, array $context = array())
     {
-        SimpleSAML_Logger::critical($message . var_export($context, TRUE));
+        SimpleSAML_Logger::critical($message . var_export($context, true));
     }
 
     /**
@@ -51,11 +51,11 @@ public function critical($message, array $context = array())
      *
      * @param string $message
      * @param array $context
-     * @return NULL
+     * @return null
      */
     public function error($message, array $context = array())
     {
-        SimpleSAML_Logger::error($message . var_export($context, TRUE));
+        SimpleSAML_Logger::error($message . var_export($context, true));
     }
 
     /**
@@ -66,11 +66,11 @@ public function error($message, array $context = array())
      *
      * @param string $message
      * @param array $context
-     * @return NULL
+     * @return null
      */
     public function warning($message, array $context = array())
     {
-        SimpleSAML_Logger::warning($message . var_export($context, TRUE));
+        SimpleSAML_Logger::warning($message . var_export($context, true));
     }
 
     /**
@@ -78,11 +78,11 @@ public function warning($message, array $context = array())
      *
      * @param string $message
      * @param array $context
-     * @return NULL
+     * @return null
      */
     public function notice($message, array $context = array())
     {
-        SimpleSAML_Logger::notice($message . var_export($context, TRUE));
+        SimpleSAML_Logger::notice($message . var_export($context, true));
     }
 
     /**
@@ -92,11 +92,11 @@ public function notice($message, array $context = array())
      *
      * @param string $message
      * @param array $context
-     * @return NULL
+     * @return null
      */
     public function info($message, array $context = array())
     {
-        SimpleSAML_Logger::info($message . var_export($context, TRUE));
+        SimpleSAML_Logger::info($message . var_export($context, true));
     }
 
     /**
@@ -104,11 +104,11 @@ public function info($message, array $context = array())
      *
      * @param string $message
      * @param array $context
-     * @return NULL
+     * @return null
      */
     public function debug($message, array $context = array())
     {
-        SimpleSAML_Logger::debug($message . var_export($context, TRUE));
+        SimpleSAML_Logger::debug($message . var_export($context, true));
     }
 
     /**
@@ -117,7 +117,7 @@ public function debug($message, array $context = array())
      * @param mixed $level
      * @param string $message
      * @param array $context
-     * @return NULL
+     * @return null
      */
     public function log($level, $message, array $context = array())
     {
diff --git a/src/SAML2/Configuration/ArrayAdapter.php b/src/SAML2/Configuration/ArrayAdapter.php
index 64d24198a..018509c78 100644
--- a/src/SAML2/Configuration/ArrayAdapter.php
+++ b/src/SAML2/Configuration/ArrayAdapter.php
@@ -20,7 +20,7 @@ public function __construct(array $configuration)
         $this->configuration = $configuration;
     }
 
-    public function get($key, $defaultValue = NULL)
+    public function get($key, $defaultValue = null)
     {
         if (!$this->has($key)) {
             return $defaultValue;
diff --git a/src/SAML2/Configuration/DecryptionProvider.php b/src/SAML2/Configuration/DecryptionProvider.php
index eb3e651bd..06ac6476b 100644
--- a/src/SAML2/Configuration/DecryptionProvider.php
+++ b/src/SAML2/Configuration/DecryptionProvider.php
@@ -20,7 +20,7 @@ public function getSharedKey();
      *
      * @return mixed
      */
-    public function getPrivateKey($name, $required = FALSE);
+    public function getPrivateKey($name, $required = false);
 
     /**
      * @return array
diff --git a/src/SAML2/Configuration/IdentityProvider.php b/src/SAML2/Configuration/IdentityProvider.php
index 366c8cadd..4c0d56e2a 100644
--- a/src/SAML2/Configuration/IdentityProvider.php
+++ b/src/SAML2/Configuration/IdentityProvider.php
@@ -45,7 +45,7 @@ public function hasBase64EncodedAttributes()
         return $this->get('base64EncodedAttributes');
     }
 
-    public function getPrivateKey($name, $required = FALSE)
+    public function getPrivateKey($name, $required = false)
     {
         $privateKeys = $this->get('privateKeys');
         $key = array_filter($privateKeys, function (PrivateKey $key) use ($name) {
@@ -63,7 +63,7 @@ public function getPrivateKey($name, $required = FALSE)
         }
 
         if (!$keyCount) {
-            return NULL;
+            return null;
         }
 
         return array_pop($key);
diff --git a/src/SAML2/Configuration/PrivateKey.php b/src/SAML2/Configuration/PrivateKey.php
index 6b45982f7..41149a51a 100644
--- a/src/SAML2/Configuration/PrivateKey.php
+++ b/src/SAML2/Configuration/PrivateKey.php
@@ -27,7 +27,7 @@ class PrivateKey extends ArrayAdapter
      */
     private $name;
 
-    public function __construct($filePath, $name, $passphrase = NULL)
+    public function __construct($filePath, $name, $passphrase = null)
     {
         if (!is_string($filePath)) {
             throw InvalidArgumentException::invalidType('string', $filePath);
diff --git a/src/SAML2/Configuration/Queryable.php b/src/SAML2/Configuration/Queryable.php
index 8de48bed2..8e73e25d2 100644
--- a/src/SAML2/Configuration/Queryable.php
+++ b/src/SAML2/Configuration/Queryable.php
@@ -24,5 +24,5 @@ public function has($key);
      *
      * @return mixed
      */
-    public function get($key, $default = NULL);
+    public function get($key, $default = null);
 }
diff --git a/src/SAML2/Configuration/ServiceProvider.php b/src/SAML2/Configuration/ServiceProvider.php
index b565d8ace..59b88a0ae 100644
--- a/src/SAML2/Configuration/ServiceProvider.php
+++ b/src/SAML2/Configuration/ServiceProvider.php
@@ -47,7 +47,7 @@ public function getSharedKey()
         return $this->get('sharedKey');
     }
 
-    public function getPrivateKey($name, $required = FALSE)
+    public function getPrivateKey($name, $required = false)
     {
         $privateKeys = $this->get('privateKeys');
         $key         = array_filter($privateKeys, function (PrivateKey $key) use ($name) {
@@ -65,7 +65,7 @@ public function getPrivateKey($name, $required = FALSE)
         }
 
         if (!$keyCount) {
-            return NULL;
+            return null;
         }
 
         return array_pop($key);
diff --git a/src/SAML2/Configuration/SimpleSAMLConverter.php b/src/SAML2/Configuration/SimpleSAMLConverter.php
index 64c755ca7..14f563ab7 100644
--- a/src/SAML2/Configuration/SimpleSAMLConverter.php
+++ b/src/SAML2/Configuration/SimpleSAMLConverter.php
@@ -75,7 +75,7 @@ private static function pluckConfiguration(SimpleSAML_Configuration $configurati
             $extracted['certificateFingerprint'] = $configuration->getArrayizeString('certFingerprint');
         }
 
-        $extracted['assertionEncryptionEnabled'] = $configuration->getBoolean('assertion.encryption', FALSE);
+        $extracted['assertionEncryptionEnabled'] = $configuration->getBoolean('assertion.encryption', false);
 
         if ($configuration->has('sharedKey')) {
             $extracted['sharedKey'] = $configuration->getString('sharedKey');
@@ -86,7 +86,7 @@ private static function pluckConfiguration(SimpleSAML_Configuration $configurati
 
     private static function enrichForIdentityProvider(SimpleSAML_Configuration $configuration, &$baseConfiguration)
     {
-        $baseConfiguration['base64EncodedAttributes'] = $configuration->getBoolean('base64attributes', FALSE);
+        $baseConfiguration['base64EncodedAttributes'] = $configuration->getBoolean('base64attributes', false);
         $baseConfiguration['entityId'] = $configuration->getString('entityid');
     }
 
@@ -100,22 +100,22 @@ private static function enrichForDecryptionProvider(
         array &$baseConfiguration
     ) {
         if ($configuration->has('sharedKey')) {
-            $baseConfiguration['sharedKey'] = $configuration->getString('sharedKey', NULL);
+            $baseConfiguration['sharedKey'] = $configuration->getString('sharedKey', null);
         }
 
         if ($configuration->has('new_privatekey')) {
             $baseConfiguration['privateKeys'][] = new PrivateKey(
                 $configuration->getString('new_privatekey'),
                 PrivateKey::NAME_NEW,
-                $configuration->getString('new_privatekey_pass', NULL)
+                $configuration->getString('new_privatekey_pass', null)
             );
         }
 
-        if ($configuration->getBoolean('assertion.encryption', FALSE)) {
+        if ($configuration->getBoolean('assertion.encryption', false)) {
             $baseConfiguration['privateKeys'][] = new PrivateKey(
                 $configuration->getString('privatekey'),
                 PrivateKey::NAME_DEFAULT,
-                $configuration->getString('privatekey_pass', NULL)
+                $configuration->getString('privatekey_pass', null)
             );
 
             if ($configuration->has('encryption.blacklisted-algorithms')) {
diff --git a/src/SAML2/DOMDocumentFactory.php b/src/SAML2/DOMDocumentFactory.php
index 042908ab7..44c2902bb 100644
--- a/src/SAML2/DOMDocumentFactory.php
+++ b/src/SAML2/DOMDocumentFactory.php
@@ -23,8 +23,8 @@ public static function fromString($xml)
             throw InvalidArgumentException::invalidType('non-empty string', $xml);
         }
 
-        $entityLoader   = libxml_disable_entity_loader(TRUE);
-        $internalErrors = libxml_use_internal_errors(TRUE);
+        $entityLoader   = libxml_disable_entity_loader(true);
+        $internalErrors = libxml_use_internal_errors(true);
         libxml_clear_errors();
 
         $domDocument = self::create();
@@ -80,7 +80,7 @@ public static function fromFile($file)
         // libxml_disable_entity_loader(true) disables \DOMDocument::load() method
         // so we need to read the content and use \DOMDocument::loadXML()
         $xml = file_get_contents($file);
-        if ($xml === FALSE) {
+        if ($xml === false) {
             throw new RuntimeException(sprintf(
                 'Contents of readable file "%s" could not be gotten',
                 $file
diff --git a/src/SAML2/EncryptedAssertion.php b/src/SAML2/EncryptedAssertion.php
index cb504c9f8..3ce8c3c24 100644
--- a/src/SAML2/EncryptedAssertion.php
+++ b/src/SAML2/EncryptedAssertion.php
@@ -22,12 +22,12 @@ class EncryptedAssertion
     /**
      * Constructor for SAML 2 encrypted assertions.
      *
-     * @param \DOMElement|NULL $xml The encrypted assertion XML element.
+     * @param \DOMElement|null $xml The encrypted assertion XML element.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -100,12 +100,12 @@ public function getAssertion(XMLSecurityKey $inputKey, array $blacklist = array(
     /**
      * Convert this encrypted assertion to an XML element.
      *
-     * @param  \DOMNode|NULL $parentElement The DOM node the assertion should be created in.
+     * @param  \DOMNode|null $parentElement The DOM node the assertion should be created in.
      * @return \DOMElement   This encrypted assertion.
      */
-    public function toXML(\DOMNode $parentElement = NULL)
+    public function toXML(\DOMNode $parentElement = null)
     {
-        if ($parentElement === NULL) {
+        if ($parentElement === null) {
             $document = DOMDocumentFactory::create();
             $parentElement = $document;
         } else {
@@ -115,9 +115,8 @@ public function toXML(\DOMNode $parentElement = NULL)
         $root = $document->createElementNS(Constants::NS_SAML, 'saml:' . 'EncryptedAssertion');
         $parentElement->appendChild($root);
 
-        $root->appendChild($document->importNode($this->encryptedData, TRUE));
+        $root->appendChild($document->importNode($this->encryptedData, true));
 
         return $root;
     }
-
 }
diff --git a/src/SAML2/HTTPArtifact.php b/src/SAML2/HTTPArtifact.php
index 24ac1072c..aea96f403 100644
--- a/src/SAML2/HTTPArtifact.php
+++ b/src/SAML2/HTTPArtifact.php
@@ -30,12 +30,12 @@ class HTTPArtifact extends Binding
     public function getRedirectURL(Message $message)
     {
         $store = SimpleSAML_Store::getInstance();
-        if ($store === FALSE) {
+        if ($store === false) {
             throw new \Exception('Unable to send artifact without a datastore configured.');
         }
 
         $generatedId = pack('H*', ((string) SimpleSAML_Utilities::stringToHex(SimpleSAML_Utilities::generateRandomBytes(20))));
-        $artifact = base64_encode("\x00\x04\x00\x00" . sha1($message->getIssuer(), TRUE) . $generatedId) ;
+        $artifact = base64_encode("\x00\x04\x00\x00" . sha1($message->getIssuer(), true) . $generatedId) ;
         $artifactData = $message->toUnsignedXML();
         $artifactDataString = $artifactData->ownerDocument->saveXML($artifactData);
 
@@ -45,7 +45,7 @@ public function getRedirectURL(Message $message)
             'SAMLart' => $artifact,
         );
         $relayState = $message->getRelayState();
-        if ($relayState !== NULL) {
+        if ($relayState !== null) {
             $params['RelayState'] = $relayState;
         }
 
@@ -79,7 +79,6 @@ public function receive()
             $artifact = base64_decode($_REQUEST['SAMLart']);
             $endpointIndex =  bin2hex(substr($artifact, 2, 2));
             $sourceId = bin2hex(substr($artifact, 4, 20));
-
         } else {
             throw new \Exception('Missing SAMLArt parameter.');
         }
@@ -88,11 +87,11 @@ public function receive()
 
         $idpMetadata = $metadataHandler->getMetaDataConfigForSha1($sourceId, 'saml20-idp-remote');
 
-        if ($idpMetadata === NULL) {
-            throw new \Exception('No metadata found for remote provider with SHA1 ID: ' . var_export($sourceId, TRUE));
+        if ($idpMetadata === null) {
+            throw new \Exception('No metadata found for remote provider with SHA1 ID: ' . var_export($sourceId, true));
         }
 
-        $endpoint = NULL;
+        $endpoint = null;
         foreach ($idpMetadata->getEndpoints('ArtifactResolutionService') as $ep) {
             if ($ep['index'] ===  hexdec($endpointIndex)) {
                 $endpoint = $ep;
@@ -100,7 +99,7 @@ public function receive()
             }
         }
 
-        if ($endpoint === NULL) {
+        if ($endpoint === null) {
             throw new \Exception('No ArtifactResolutionService with the correct index.');
         }
 
@@ -129,10 +128,10 @@ public function receive()
         }
 
         $xml = $artifactResponse->getAny();
-        if ($xml === NULL) {
+        if ($xml === null) {
             /* Empty ArtifactResponse - possibly because of Artifact replay? */
 
-            return NULL;
+            return null;
         }
 
         $samlResponse = Message::fromXML($xml);
@@ -154,7 +153,7 @@ public function setSPMetadata(SimpleSAML_Configuration $sp)
     }
 
     /**
-     * A validator which returns TRUE if the ArtifactResponse was signed with the given key
+     * A validator which returns true if the ArtifactResponse was signed with the given key
      *
      * @param \SAML2\ArtifactResponse $message
      * @param XMLSecurityKey $key
@@ -164,5 +163,4 @@ public static function validateSignature(ArtifactResponse $message, XMLSecurityK
     {
         return $message->validate($key);
     }
-
 }
diff --git a/src/SAML2/HTTPPost.php b/src/SAML2/HTTPPost.php
index 4bbe11380..95a704c27 100644
--- a/src/SAML2/HTTPPost.php
+++ b/src/SAML2/HTTPPost.php
@@ -18,7 +18,7 @@ class HTTPPost extends Binding
      */
     public function send(Message $message)
     {
-        if ($this->destination === NULL) {
+        if ($this->destination === null) {
             $destination = $message->getDestination();
         } else {
             $destination = $this->destination;
@@ -41,7 +41,7 @@ public function send(Message $message)
         $post = array();
         $post[$msgType] = $msgStr;
 
-        if ($relayState !== NULL) {
+        if ($relayState !== null) {
             $post['RelayState'] = $relayState;
         }
 
@@ -81,5 +81,4 @@ public function receive()
 
         return $msg;
     }
-
 }
diff --git a/src/SAML2/HTTPRedirect.php b/src/SAML2/HTTPRedirect.php
index 80bc85624..bdd70b709 100644
--- a/src/SAML2/HTTPRedirect.php
+++ b/src/SAML2/HTTPRedirect.php
@@ -21,7 +21,7 @@ class HTTPRedirect extends Binding
      */
     public function getRedirectURL(Message $message)
     {
-        if ($this->destination === NULL) {
+        if ($this->destination === null) {
             $destination = $message->getDestination();
         } else {
             $destination = $this->destination;
@@ -48,11 +48,11 @@ public function getRedirectURL(Message $message)
         }
         $msg .= urlencode($msgStr);
 
-        if ($relayState !== NULL) {
+        if ($relayState !== null) {
             $msg .= '&RelayState=' . urlencode($relayState);
         }
 
-        if ($key !== NULL) {
+        if ($key !== null) {
             /* Add the signature. */
             $msg .= '&SigAlg=' . urlencode($key->type);
 
@@ -60,7 +60,7 @@ public function getRedirectURL(Message $message)
             $msg .= '&Signature=' . urlencode(base64_encode($signature));
         }
 
-        if (strpos($destination, '?') === FALSE) {
+        if (strpos($destination, '?') === false) {
             $destination .= '?' . $msg;
         } else {
             $destination .= '&' . $msg;
@@ -230,5 +230,4 @@ public static function validateSignature(array $data, XMLSecurityKey $key)
             throw new \Exception('Unable to validate signature on query string.');
         }
     }
-
 }
diff --git a/src/SAML2/LogoutRequest.php b/src/SAML2/LogoutRequest.php
index 56616811d..10f356ccc 100644
--- a/src/SAML2/LogoutRequest.php
+++ b/src/SAML2/LogoutRequest.php
@@ -15,16 +15,16 @@ class LogoutRequest extends Request
     /**
      * The expiration time of this request.
      *
-     * @var int|NULL
+     * @var int|null
      */
     private $notOnOrAfter;
 
     /**
      * The encrypted NameID in the request.
      *
-     * If this is not NULL, the NameID needs decryption before it can be accessed.
+     * If this is not null, the NameID needs decryption before it can be accessed.
      *
-     * @var \DOMElement|NULL
+     * @var \DOMElement|null
      */
     private $encryptedNameId;
 
@@ -45,16 +45,16 @@ class LogoutRequest extends Request
     /**
      * Constructor for SAML 2 logout request messages.
      *
-     * @param \DOMElement|NULL $xml The input message.
+     * @param \DOMElement|null $xml The input message.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct('LogoutRequest', $xml);
 
         $this->sessionIndexes = array();
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -85,7 +85,7 @@ public function __construct(\DOMElement $xml = NULL)
     /**
      * Retrieve the expiration time of this request.
      *
-     * @return int|NULL The expiration time of this request.
+     * @return int|null The expiration time of this request.
      */
     public function getNotOnOrAfter()
     {
@@ -95,7 +95,7 @@ public function getNotOnOrAfter()
     /**
      * Set the expiration time of this request.
      *
-     * @param int|NULL $notOnOrAfter The expiration time of this request.
+     * @param int|null $notOnOrAfter The expiration time of this request.
      */
     public function setNotOnOrAfter($notOnOrAfter)
     {
@@ -107,15 +107,15 @@ public function setNotOnOrAfter($notOnOrAfter)
     /**
      * Check whether the NameId is encrypted.
      *
-     * @return TRUE if the NameId is encrypted, FALSE if not.
+     * @return true if the NameId is encrypted, false if not.
      */
     public function isNameIdEncrypted()
     {
-        if ($this->encryptedNameId !== NULL) {
-            return TRUE;
+        if ($this->encryptedNameId !== null) {
+            return true;
         }
 
-        return FALSE;
+        return false;
     }
 
     /**
@@ -144,7 +144,7 @@ public function encryptNameId(XMLSecurityKey $key)
         $enc->encryptKey($key, $symmetricKey);
 
         $this->encryptedNameId = $enc->encryptNode($symmetricKey);
-        $this->nameId = NULL;
+        $this->nameId = null;
     }
 
     /**
@@ -155,7 +155,7 @@ public function encryptNameId(XMLSecurityKey $key)
      */
     public function decryptNameId(XMLSecurityKey $key, array $blacklist = array())
     {
-        if ($this->encryptedNameId === NULL) {
+        if ($this->encryptedNameId === null) {
             /* No NameID to decrypt. */
 
             return;
@@ -165,7 +165,7 @@ public function decryptNameId(XMLSecurityKey $key, array $blacklist = array())
         Utils::getContainer()->debugMessage($nameId, 'decrypt');
         $this->nameId = Utils::parseNameId($nameId);
 
-        $this->encryptedNameId = NULL;
+        $this->encryptedNameId = null;
     }
 
     /**
@@ -176,7 +176,7 @@ public function decryptNameId(XMLSecurityKey $key, array $blacklist = array())
      */
     public function getNameId()
     {
-        if ($this->encryptedNameId !== NULL) {
+        if ($this->encryptedNameId !== null) {
             throw new \Exception('Attempted to retrieve encrypted NameID without decrypting it first.');
         }
 
@@ -221,12 +221,12 @@ public function setSessionIndexes(array $sessionIndexes)
     /**
      * Retrieve the sesion index of the session that should be terminated.
      *
-     * @return string|NULL The sesion index of the session that should be terminated.
+     * @return string|null The sesion index of the session that should be terminated.
      */
     public function getSessionIndex()
     {
         if (empty($this->sessionIndexes)) {
-            return NULL;
+            return null;
         }
 
         return $this->sessionIndexes[0];
@@ -235,7 +235,7 @@ public function getSessionIndex()
     /**
      * Set the sesion index of the session that should be terminated.
      *
-     * @param string|NULL $sessionIndex The sesion index of the session that should be terminated.
+     * @param string|null $sessionIndex The sesion index of the session that should be terminated.
      */
     public function setSessionIndex($sessionIndex)
     {
@@ -257,16 +257,16 @@ public function toUnsignedXML()
     {
         $root = parent::toUnsignedXML();
 
-        if ($this->notOnOrAfter !== NULL) {
+        if ($this->notOnOrAfter !== null) {
             $root->setAttribute('NotOnOrAfter', gmdate('Y-m-d\TH:i:s\Z', $this->notOnOrAfter));
         }
 
-        if ($this->encryptedNameId === NULL) {
+        if ($this->encryptedNameId === null) {
             Utils::addNameId($root, $this->nameId);
         } else {
             $eid = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:' . 'EncryptedID');
             $root->appendChild($eid);
-            $eid->appendChild($root->ownerDocument->importNode($this->encryptedNameId, TRUE));
+            $eid->appendChild($root->ownerDocument->importNode($this->encryptedNameId, true));
         }
 
         foreach ($this->sessionIndexes as $sessionIndex) {
@@ -275,5 +275,4 @@ public function toUnsignedXML()
 
         return $root;
     }
-
 }
diff --git a/src/SAML2/LogoutResponse.php b/src/SAML2/LogoutResponse.php
index cc46c25dd..214e305e0 100644
--- a/src/SAML2/LogoutResponse.php
+++ b/src/SAML2/LogoutResponse.php
@@ -12,13 +12,12 @@ class LogoutResponse extends StatusResponse
     /**
      * Constructor for SAML 2 response messages.
      *
-     * @param \DOMElement|NULL $xml     The input message.
+     * @param \DOMElement|null $xml     The input message.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct('LogoutResponse', $xml);
 
         /* No new fields added by LogoutResponse. */
     }
-
 }
diff --git a/src/SAML2/Message.php b/src/SAML2/Message.php
index 2ea9e8d3f..0db2b8163 100644
--- a/src/SAML2/Message.php
+++ b/src/SAML2/Message.php
@@ -51,28 +51,28 @@ abstract class Message implements SignedElement
     /**
      * The destination URL of this message if it is known.
      *
-     * @var string|NULL
+     * @var string|null
      */
     private $destination;
 
     /**
      * The destination URL of this message if it is known.
      *
-     * @var string|NULL
+     * @var string|null
      */
     private $consent = Constants::CONSENT_UNSPECIFIED;
 
     /**
-     * The entity id of the issuer of this message, or NULL if unknown.
+     * The entity id of the issuer of this message, or null if unknown.
      *
-     * @var string|NULL
+     * @var string|null
      */
     private $issuer;
 
     /**
      * The RelayState associated with this message.
      *
-     * @var string|NULL
+     * @var string|null
      */
     private $relayState;
 
@@ -89,16 +89,16 @@ abstract class Message implements SignedElement
     /**
      * The private key we should use to sign the message.
      *
-     * The private key can be NULL, in which case the message is sent unsigned.
+     * The private key can be null, in which case the message is sent unsigned.
      *
-     * @var XMLSecurityKey|NULL
+     * @var XMLSecurityKey|null
      */
     private $signatureKey;
 
     /**
      * @var bool
      */
-    protected $messageContainedSignatureUponConstruction = FALSE;
+    protected $messageContainedSignatureUponConstruction = false;
 
     /**
      * List of certificates that should be included in the message.
@@ -125,10 +125,10 @@ abstract class Message implements SignedElement
      * default values.
      *
      * @param string          $tagName The tag name of the root element.
-     * @param \DOMElement|NULL $xml     The input message.
+     * @param \DOMElement|null $xml     The input message.
      * @throws \Exception
      */
-    protected function __construct($tagName, \DOMElement $xml = NULL)
+    protected function __construct($tagName, \DOMElement $xml = null)
     {
         assert('is_string($tagName)');
         $this->tagName = $tagName;
@@ -138,7 +138,7 @@ protected function __construct($tagName, \DOMElement $xml = NULL)
         $this->certificates = array();
         $this->validators = array();
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -171,15 +171,14 @@ protected function __construct($tagName, \DOMElement $xml = NULL)
         try {
             $sig = Utils::validateElement($xml);
 
-            if ($sig !== FALSE) {
-                $this->messageContainedSignatureUponConstruction = TRUE;
+            if ($sig !== false) {
+                $this->messageContainedSignatureUponConstruction = true;
                 $this->certificates = $sig['Certificates'];
                 $this->validators[] = array(
                     'Function' => array('\SAML2\Utils', 'validateSignature'),
                     'Data' => $sig,
                     );
             }
-
         } catch (\Exception $e) {
             /* Ignore signature validation errors. */
         }
@@ -209,18 +208,18 @@ public function addValidator($function, $data)
     /**
      * Validate this message against a public key.
      *
-     * TRUE is returned on success, FALSE is returned if we don't have any
+     * true is returned on success, false is returned if we don't have any
      * signature we can validate. An exception is thrown if the signature
      * validation fails.
      *
      * @param  XMLSecurityKey $key The key we should check against.
-     * @return boolean        TRUE on success, FALSE when we don't have a signature.
+     * @return boolean        true on success, false when we don't have a signature.
      * @throws \Exception
      */
     public function validate(XMLSecurityKey $key)
     {
         if (count($this->validators) === 0) {
-            return FALSE;
+            return false;
         }
 
         $exceptions = array();
@@ -233,7 +232,7 @@ public function validate(XMLSecurityKey $key)
                 call_user_func($function, $data, $key);
                 /* We were able to validate the message with this validator. */
 
-                return TRUE;
+                return true;
             } catch (\Exception $e) {
                 $exceptions[] = $e;
             }
@@ -290,7 +289,7 @@ public function setIssueInstant($issueInstant)
     /**
      * Retrieve the destination of this message.
      *
-     * @return string|NULL The destination of this message, or NULL if no destination is given.
+     * @return string|null The destination of this message, or NULL if no destination is given.
      */
     public function getDestination()
     {
@@ -300,7 +299,7 @@ public function getDestination()
     /**
      * Set the destination of this message.
      *
-     * @param string|NULL $destination The new destination of this message.
+     * @param string|null $destination The new destination of this message.
      */
     public function setDestination($destination)
     {
@@ -340,7 +339,7 @@ public function getConsent()
     /**
      * Retrieve the issuer if this message.
      *
-     * @return string|NULL The issuer of this message, or NULL if no issuer is given.
+     * @return string|null The issuer of this message, or NULL if no issuer is given.
      */
     public function getIssuer()
     {
@@ -350,7 +349,7 @@ public function getIssuer()
     /**
      * Set the issuer of this message.
      *
-     * @param string|NULL $issuer The new issuer of this message.
+     * @param string|null $issuer The new issuer of this message.
      */
     public function setIssuer($issuer)
     {
@@ -372,7 +371,7 @@ public function isMessageConstructedWithSignature()
     /**
      * Retrieve the RelayState associated with this message.
      *
-     * @return string|NULL The RelayState, or NULL if no RelayState is given.
+     * @return string|null The RelayState, or NULL if no RelayState is given.
      */
     public function getRelayState()
     {
@@ -382,7 +381,7 @@ public function getRelayState()
     /**
      * Set the RelayState associated with this message.
      *
-     * @param string|NULL $relayState The new RelayState.
+     * @param string|null $relayState The new RelayState.
      */
     public function setRelayState($relayState)
     {
@@ -413,14 +412,14 @@ public function toUnsignedXML()
         $root->setAttribute('Version', '2.0');
         $root->setAttribute('IssueInstant', gmdate('Y-m-d\TH:i:s\Z', $this->issueInstant));
 
-        if ($this->destination !== NULL) {
+        if ($this->destination !== null) {
             $root->setAttribute('Destination', $this->destination);
         }
-        if ($this->consent !== NULL && $this->consent !== Constants::CONSENT_UNSPECIFIED) {
+        if ($this->consent !== null && $this->consent !== Constants::CONSENT_UNSPECIFIED) {
             $root->setAttribute('Consent', $this->consent);
         }
 
-        if ($this->issuer !== NULL) {
+        if ($this->issuer !== null) {
             Utils::addString($root, Constants::NS_SAML, 'saml:Issuer', $this->issuer);
         }
 
@@ -443,7 +442,7 @@ public function toSignedXML()
     {
         $root = $this->toUnsignedXML();
 
-        if ($this->signatureKey === NULL) {
+        if ($this->signatureKey === null) {
             /* We don't have a key to sign it with. */
 
             return $root;
@@ -451,7 +450,7 @@ public function toSignedXML()
 
 
         /* Find the position we should insert the signature node at. */
-        if ($this->issuer !== NULL) {
+        if ($this->issuer !== null) {
             /*
              * We have an issuer node. The signature node should come
              * after the issuer node.
@@ -473,7 +472,7 @@ public function toSignedXML()
     /**
      * Retrieve the private key we should use to sign the message.
      *
-     * @return XMLSecurityKey|NULL The key, or NULL if no key is specified.
+     * @return XMLSecurityKey|null The key, or NULL if no key is specified.
      */
     public function getSignatureKey()
     {
@@ -484,11 +483,11 @@ public function getSignatureKey()
     /**
      * Set the private key we should use to sign the message.
      *
-     * If the key is NULL, the message will be sent unsigned.
+     * If the key is null, the message will be sent unsigned.
      *
-     * @param XMLSecurityKey|NULL $signatureKey
+     * @param XMLSecurityKey|null $signatureKey
      */
-    public function setSignatureKey(XMLsecurityKey $signatureKey = NULL)
+    public function setSignatureKey(XMLsecurityKey $signatureKey = null)
     {
         $this->signatureKey = $signatureKey;
     }
@@ -528,7 +527,7 @@ public function getCertificates()
     public static function fromXML(\DOMElement $xml)
     {
         if ($xml->namespaceURI !== Constants::NS_SAMLP) {
-            throw new \Exception('Unknown namespace of SAML message: ' . var_export($xml->namespaceURI, TRUE));
+            throw new \Exception('Unknown namespace of SAML message: ' . var_export($xml->namespaceURI, true));
         }
 
         switch ($xml->localName) {
@@ -547,9 +546,8 @@ public static function fromXML(\DOMElement $xml)
             case 'ArtifactResolve':
                 return new ArtifactResolve($xml);
             default:
-                throw new \Exception('Unknown SAML message: ' . var_export($xml->localName, TRUE));
+                throw new \Exception('Unknown SAML message: ' . var_export($xml->localName, true));
         }
-
     }
 
     /**
@@ -565,7 +563,7 @@ public function getExtensions()
     /**
      * Set the Extensions.
      *
-     * @param array|NULL $extensions The Extensions.
+     * @param array|null $extensions The Extensions.
      */
     public function setExtensions($extensions)
     {
@@ -573,5 +571,4 @@ public function setExtensions($extensions)
 
         $this->extensions = $extensions;
     }
-
 }
diff --git a/src/SAML2/Response.php b/src/SAML2/Response.php
index 384e35994..d11f9d042 100644
--- a/src/SAML2/Response.php
+++ b/src/SAML2/Response.php
@@ -17,19 +17,19 @@ class Response extends StatusResponse
     /**
      * Constructor for SAML 2 response messages.
      *
-     * @param \DOMElement|NULL $xml The input message.
+     * @param \DOMElement|null $xml The input message.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct('Response', $xml);
 
         $this->assertions = array();
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
-        for ($node = $xml->firstChild; $node !== NULL; $node = $node->nextSibling) {
+        for ($node = $xml->firstChild; $node !== null; $node = $node->nextSibling) {
             if ($node->namespaceURI !== Constants::NS_SAML) {
                 continue;
             }
@@ -73,11 +73,9 @@ public function toUnsignedXML()
 
         /** @var \SAML2\Assertion|\SAML2\EncryptedAssertion $assertion */
         foreach ($this->assertions as $assertion) {
-
             $assertion->toXML($root);
         }
 
         return $root;
     }
-
 }
diff --git a/src/SAML2/Response/Processor.php b/src/SAML2/Response/Processor.php
index 198349c9e..7424f954f 100644
--- a/src/SAML2/Response/Processor.php
+++ b/src/SAML2/Response/Processor.php
@@ -45,7 +45,7 @@ class Processor
      *
      * @var bool
      */
-    private $responseIsSigned = FALSE;
+    private $responseIsSigned = false;
 
     /**
      * @param \Psr\Log\LoggerInterface        $logger
@@ -124,7 +124,7 @@ private function verifySignature(
             $response->getId()
         ));
 
-        $this->responseIsSigned = TRUE;
+        $this->responseIsSigned = true;
 
         if (!$this->signatureValidator->hasValidSignature($response, $identityProviderConfiguration)) {
             throw new InvalidResponseException();
diff --git a/src/SAML2/SOAP.php b/src/SAML2/SOAP.php
index e10c3c9cb..291e47ee8 100644
--- a/src/SAML2/SOAP.php
+++ b/src/SAML2/SOAP.php
@@ -18,7 +18,7 @@ class SOAP extends Binding
      */
     public function send(Message $message)
     {
-        header('Content-Type: text/xml', TRUE);
+        header('Content-Type: text/xml', true);
         $outputFromIdp = '<?xml version="1.0" encoding="UTF-8"?>';
         $outputFromIdp .= '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">';
         $outputFromIdp .= '<SOAP-ENV:Body>';
@@ -55,5 +55,4 @@ public function receive()
 
         return Message::fromXML($results[0]);
     }
-
 }
diff --git a/src/SAML2/SOAPClient.php b/src/SAML2/SOAPClient.php
index d587d7c95..a45404cec 100644
--- a/src/SAML2/SOAPClient.php
+++ b/src/SAML2/SOAPClient.php
@@ -25,20 +25,20 @@ class SOAPClient
      * @return \SAML2\Message            The response we received.
      * @throws \Exception
      */
-    public function send(Message $msg, SimpleSAML_Configuration $srcMetadata, SimpleSAML_Configuration $dstMetadata = NULL)
+    public function send(Message $msg, SimpleSAML_Configuration $srcMetadata, SimpleSAML_Configuration $dstMetadata = null)
     {
         $issuer = $msg->getIssuer();
 
         $ctxOpts = array(
             'ssl' => array(
-                'capture_peer_cert' => TRUE,
+                'capture_peer_cert' => true,
             ),
         );
 
         // Determine if we are going to do a MutualSSL connection between the IdP and SP  - Shoaib
         if ($srcMetadata->hasValue('saml.SOAPClient.certificate')) {
             $cert = $srcMetadata->getValue('saml.SOAPClient.certificate');
-            if ($cert !== FALSE) {
+            if ($cert !== false) {
                 $ctxOpts['ssl']['local_cert'] = SimpleSAML_Utilities::resolveCert(
                     $srcMetadata->getString('saml.SOAPClient.certificate')
                 );
@@ -50,7 +50,7 @@ public function send(Message $msg, SimpleSAML_Configuration $srcMetadata, Simple
             /* Use the SP certificate and privatekey if it is configured. */
             $privateKey = SimpleSAML_Utilities::loadPrivateKey($srcMetadata);
             $publicKey = SimpleSAML_Utilities::loadPublicKey($srcMetadata);
-            if ($privateKey !== NULL && $publicKey !== NULL && isset($publicKey['PEM'])) {
+            if ($privateKey !== null && $publicKey !== null && isset($publicKey['PEM'])) {
                 $keyCertData = $privateKey['PEM'] . $publicKey['PEM'];
                 $file = SimpleSAML_Utilities::getTempDir() . '/' . sha1($keyCertData) . '.pem';
                 if (!file_exists($file)) {
@@ -64,8 +64,8 @@ public function send(Message $msg, SimpleSAML_Configuration $srcMetadata, Simple
         }
 
         // do peer certificate verification
-        if ($dstMetadata !== NULL) {
-            $peerPublicKeys = $dstMetadata->getPublicKeys('signing', TRUE);
+        if ($dstMetadata !== null) {
+            $peerPublicKeys = $dstMetadata->getPublicKeys('signing', true);
             $certData = '';
             foreach ($peerPublicKeys as $key) {
                 if ($key['type'] !== 'X509Certificate') {
@@ -80,13 +80,13 @@ public function send(Message $msg, SimpleSAML_Configuration $srcMetadata, Simple
                 SimpleSAML_Utilities::writeFile($peerCertFile, $certData);
             }
             // create ssl context
-            $ctxOpts['ssl']['verify_peer'] = TRUE;
+            $ctxOpts['ssl']['verify_peer'] = true;
             $ctxOpts['ssl']['verify_depth'] = 1;
             $ctxOpts['ssl']['cafile'] = $peerCertFile;
         }
 
         $context = stream_context_create($ctxOpts);
-        if ($context === NULL) {
+        if ($context === null) {
             throw new \Exception('Unable to create SSL stream context');
         }
 
@@ -104,7 +104,7 @@ public function send(Message $msg, SimpleSAML_Configuration $srcMetadata, Simple
             $options['proxy_port'] = $srcMetadata->getValue('saml.SOAPClient.proxyport');
         }
 
-        $x = new SoapClient(NULL, $options);
+        $x = new SoapClient(null, $options);
 
         // Add soap-envelopes
         $request = $msg->toSignedXML();
@@ -118,7 +118,7 @@ public function send(Message $msg, SimpleSAML_Configuration $srcMetadata, Simple
 
         /* Perform SOAP Request over HTTP */
         $soapresponsexml = $x->__doRequest($request, $destination, $action, $version);
-        if ($soapresponsexml === NULL || $soapresponsexml === "") {
+        if ($soapresponsexml === null || $soapresponsexml === "") {
             throw new \Exception('Empty SOAP response, check peer certificate.');
         }
 
@@ -145,7 +145,6 @@ public function send(Message $msg, SimpleSAML_Configuration $srcMetadata, Simple
         Utils::getContainer()->getLogger()->debug("Valid ArtifactResponse received from IdP");
 
         return $samlresponse;
-
     }
 
     /**
@@ -165,14 +164,14 @@ private static function addSSLValidator(Message $msg, $context)
         //openssl_x509_export($options['ssl']['peer_certificate'], $out);
 
         $key = openssl_pkey_get_public($options['ssl']['peer_certificate']);
-        if ($key === FALSE) {
+        if ($key === false) {
             Utils::getContainer()->getLogger()->warning('Unable to get public key from peer certificate.');
 
             return;
         }
 
         $keyInfo = openssl_pkey_get_details($key);
-        if ($keyInfo === FALSE) {
+        if ($keyInfo === false) {
             Utils::getContainer()->getLogger()->warning('Unable to get key details from public key.');
 
             return;
@@ -199,7 +198,7 @@ public static function validateSSL($data, XMLSecurityKey $key)
         assert('is_string($data)');
 
         $keyInfo = openssl_pkey_get_details($key->key);
-        if ($keyInfo === FALSE) {
+        if ($keyInfo === false) {
             throw new \Exception('Unable to get key details from XMLSecurityKey.');
         }
 
@@ -219,7 +218,7 @@ public static function validateSSL($data, XMLSecurityKey $key)
     /*
      * Extracts the SOAP Fault from SOAP message
      * @param $soapmessage Soap response needs to be type DOMDocument
-     * @return $soapfaultstring string|NULL
+     * @return $soapfaultstring string|null
      */
     private function getSOAPFault($soapMessage)
     {
@@ -228,7 +227,7 @@ private function getSOAPFault($soapMessage)
         if (empty($soapFault)) {
             /* No fault. */
 
-            return NULL;
+            return null;
         }
         $soapFaultElement = $soapFault[0];
         // There is a fault element but we haven't found out what the fault string is
@@ -241,5 +240,4 @@ private function getSOAPFault($soapMessage)
 
         return $soapFaultString;
     }
-
 }
diff --git a/src/SAML2/Signature/AbstractChainedValidator.php b/src/SAML2/Signature/AbstractChainedValidator.php
index bd6adbab5..be0d871a7 100644
--- a/src/SAML2/Signature/AbstractChainedValidator.php
+++ b/src/SAML2/Signature/AbstractChainedValidator.php
@@ -29,7 +29,7 @@ public function __construct(\Psr\Log\LoggerInterface $logger)
      */
     protected function validateElementWithKeys(SignedElement $element, $pemCandidates)
     {
-        $lastException = NULL;
+        $lastException = null;
         foreach ($pemCandidates as $index => $candidateKey) {
             $key = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'public'));
             $key->loadKey($candidateKey->getCertificate());
@@ -41,7 +41,7 @@ protected function validateElementWithKeys(SignedElement $element, $pemCandidate
                 $result = $element->validate($key);
                 if ($result) {
                     $this->logger->debug(sprintf('Validation with key "#%d" succeeded', $index));
-                    return TRUE;
+                    return true;
                 }
                 $this->logger->debug(sprintf('Validation with key "#%d" failed without exception.', $index));
             } catch (\Exception $e) {
@@ -55,10 +55,10 @@ protected function validateElementWithKeys(SignedElement $element, $pemCandidate
             }
         }
 
-        if ($lastException !== NULL) {
+        if ($lastException !== null) {
             throw $lastException;
         } else {
-            return FALSE;
+            return false;
         }
     }
 }
diff --git a/src/SAML2/Signature/FingerprintValidator.php b/src/SAML2/Signature/FingerprintValidator.php
index a3fa255f8..e0e701852 100644
--- a/src/SAML2/Signature/FingerprintValidator.php
+++ b/src/SAML2/Signature/FingerprintValidator.php
@@ -35,11 +35,11 @@ public function canValidate(
         SignedElement $signedElement,
         CertificateProvider $configuration
     ) {
-        if ($configuration->getCertificateFingerprints() === NULL) {
+        if ($configuration->getCertificateFingerprints() === null) {
             $this->logger->debug(
                 'Configuration does not have "certFingerprint" value, cannot validate signature with fingerprint'
             );
-            return FALSE;
+            return false;
         }
 
         // use internal cache to prevent doing certificate extraction twice.
@@ -48,10 +48,10 @@ public function canValidate(
             $this->logger->debug(
                 'Signed element does not have certificates, cannot validate signature with fingerprint'
             );
-            return FALSE;
+            return false;
         }
 
-        return TRUE;
+        return true;
     }
 
     /**
@@ -84,7 +84,7 @@ public function hasValidSignature(
                 'Unable to match a certificate of the SignedElement matching a configured fingerprint'
             );
 
-            return FALSE;
+            return false;
         }
 
         return $this->validateElementWithKeys($signedElement, $pemCandidates);
diff --git a/src/SAML2/Signature/PublicKeyValidator.php b/src/SAML2/Signature/PublicKeyValidator.php
index a98b5433c..513913f80 100644
--- a/src/SAML2/Signature/PublicKeyValidator.php
+++ b/src/SAML2/Signature/PublicKeyValidator.php
@@ -56,15 +56,15 @@ public function hasValidSignature(
         $pemCandidates = $this->configuredKeys->filter(function (Key $key) use ($logger) {
             if (!$key instanceof X509) {
                 $logger->debug(sprintf('Skipping unknown key type: "%s"', $key['type']));
-                return FALSE;
+                return false;
             }
-            return TRUE;
+            return true;
         });
 
         if (!count($pemCandidates)) {
             $this->logger->debug('No configured X509 certificate found to verify the signature with');
 
-            return FALSE;
+            return false;
         }
 
         return $this->validateElementWithKeys($signedElement, $pemCandidates);
diff --git a/src/SAML2/SignedElement.php b/src/SAML2/SignedElement.php
index a7fa26046..93dfa2e56 100644
--- a/src/SAML2/SignedElement.php
+++ b/src/SAML2/SignedElement.php
@@ -14,11 +14,11 @@ interface SignedElement
     /**
      * Validate this element against a public key.
      *
-     * If no signature is present, FALSE is returned. If a signature is present,
+     * If no signature is present, false is returned. If a signature is present,
      * but cannot be verified, an exception will be thrown.
      *
      * @param  XMLSecurityKey $key The key we should check against.
-     * @return boolean        TRUE if successful, FALSE if we don't have a signature that can be verified.
+     * @return boolean        true if successful, false if we don't have a signature that can be verified.
      */
     public function validate(XMLSecurityKey $key);
 
@@ -41,16 +41,16 @@ public function getCertificates();
     /**
      * Retrieve the private key we should use to sign the element.
      *
-     * @return XMLSecurityKey|NULL The key, or NULL if no key is specified.
+     * @return XMLSecurityKey|null The key, or NULL if no key is specified.
      */
     public function getSignatureKey();
 
     /**
      * Set the private key we should use to sign the element.
      *
-     * If the key is NULL, the message will be sent unsigned.
+     * If the key is null, the message will be sent unsigned.
      *
-     * @param XMLSecurityKey|NULL $signatureKey
+     * @param XMLSecurityKey|null $signatureKey
      */
-    public function setSignatureKey(XMLsecurityKey $signatureKey = NULL);
+    public function setSignatureKey(XMLsecurityKey $signatureKey = null);
 }
diff --git a/src/SAML2/SignedElementHelper.php b/src/SAML2/SignedElementHelper.php
index 476a63687..5ba069890 100644
--- a/src/SAML2/SignedElementHelper.php
+++ b/src/SAML2/SignedElementHelper.php
@@ -16,9 +16,9 @@ class SignedElementHelper implements SignedElement
     /**
      * The private key we should use to sign the message.
      *
-     * The private key can be NULL, in which case the message is sent unsigned.
+     * The private key can be null, in which case the message is sent unsigned.
      *
-     * @var XMLSecurityKey|NULL
+     * @var XMLSecurityKey|null
      */
     private $signatureKey;
 
@@ -39,14 +39,14 @@ class SignedElementHelper implements SignedElement
     /**
      * Initialize the helper class.
      *
-     * @param \DOMElement|NULL $xml The XML element which may be signed.
+     * @param \DOMElement|null $xml The XML element which may be signed.
      */
-    protected function __construct(\DOMElement $xml = NULL)
+    protected function __construct(\DOMElement $xml = null)
     {
         $this->certificates = array();
         $this->validators = array();
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -54,14 +54,13 @@ protected function __construct(\DOMElement $xml = NULL)
         try {
             $sig = Utils::validateElement($xml);
 
-            if ($sig !== FALSE) {
+            if ($sig !== false) {
                 $this->certificates = $sig['Certificates'];
                 $this->validators[] = array(
                     'Function' => array('\SAML2\Utils', 'validateSignature'),
                     'Data' => $sig,
                 );
             }
-
         } catch (\Exception $e) {
             /* Ignore signature validation errors. */
         }
@@ -88,18 +87,18 @@ public function addValidator($function, $data)
     /**
      * Validate this element against a public key.
      *
-     * TRUE is returned on success, FALSE is returned if we don't have any
+     * true is returned on success, false is returned if we don't have any
      * signature we can validate. An exception is thrown if the signature
      * validation fails.
      *
      * @param  XMLSecurityKey $key The key we should check against.
-     * @return boolean        TRUE on success, FALSE when we don't have a signature.
+     * @return boolean        true on success, false when we don't have a signature.
      * @throws \Exception
      */
     public function validate(XMLSecurityKey $key)
     {
         if (count($this->validators) === 0) {
-            return FALSE;
+            return false;
         }
 
         $exceptions = array();
@@ -112,7 +111,7 @@ public function validate(XMLSecurityKey $key)
                 call_user_func($function, $data, $key);
                 /* We were able to validate the message with this validator. */
 
-                return TRUE;
+                return true;
             } catch (\Exception $e) {
                 $exceptions[] = $e;
             }
@@ -125,7 +124,7 @@ public function validate(XMLSecurityKey $key)
     /**
      * Retrieve the private key we should use to sign the message.
      *
-     * @return XMLSecurityKey|NULL The key, or NULL if no key is specified.
+     * @return XMLSecurityKey|null The key, or NULL if no key is specified.
      */
     public function getSignatureKey()
     {
@@ -135,11 +134,11 @@ public function getSignatureKey()
     /**
      * Set the private key we should use to sign the message.
      *
-     * If the key is NULL, the message will be sent unsigned.
+     * If the key is null, the message will be sent unsigned.
      *
-     * @param XMLSecurityKey|NULL $signatureKey
+     * @param XMLSecurityKey|null $signatureKey
      */
-    public function setSignatureKey(XMLsecurityKey $signatureKey = NULL)
+    public function setSignatureKey(XMLsecurityKey $signatureKey = null)
     {
         $this->signatureKey = $signatureKey;
     }
@@ -202,20 +201,19 @@ public function getValidatingCertificates()
      * Sign the given XML element.
      *
      * @param \DOMElement      $root         The element we should sign.
-     * @param \DOMElement|NULL $insertBefore The element we should insert the signature node before.
-     * @return \DOMElement|NULL
+     * @param \DOMElement|null $insertBefore The element we should insert the signature node before.
+     * @return \DOMElement|null
      */
-    protected function signElement(\DOMElement $root, \DOMElement $insertBefore = NULL)
+    protected function signElement(\DOMElement $root, \DOMElement $insertBefore = null)
     {
-        if ($this->signatureKey === NULL) {
+        if ($this->signatureKey === null) {
             /* We cannot sign this element. */
 
-            return NULL;
+            return null;
         }
 
         Utils::insertSignature($this->signatureKey, $this->certificates, $root, $insertBefore);
 
         return $root;
     }
-
 }
diff --git a/src/SAML2/StatusResponse.php b/src/SAML2/StatusResponse.php
index f7af9de21..433a3c59b 100644
--- a/src/SAML2/StatusResponse.php
+++ b/src/SAML2/StatusResponse.php
@@ -17,7 +17,7 @@
  *   'Message' => '<status message>',
  * )
  *
- * Only the 'Code' field is required. The others will be set to NULL if they
+ * Only the 'Code' field is required. The others will be set to null if they
  * aren't present.
  *
  * @package SimpleSAMLphp
@@ -25,9 +25,9 @@
 abstract class StatusResponse extends Message
 {
     /**
-     * The ID of the request this is a response to, or NULL if this is an unsolicited response.
+     * The ID of the request this is a response to, or null if this is an unsolicited response.
      *
-     * @var string|NULL
+     * @var string|null
      */
     private $inResponseTo;
 
@@ -44,20 +44,20 @@ abstract class StatusResponse extends Message
      * Constructor for SAML 2 response messages.
      *
      * @param string          $tagName The tag name of the root element.
-     * @param \DOMElement|NULL $xml     The input message.
+     * @param \DOMElement|null $xml     The input message.
      * @throws \Exception
      */
-    protected function __construct($tagName, \DOMElement $xml = NULL)
+    protected function __construct($tagName, \DOMElement $xml = null)
     {
         parent::__construct($tagName, $xml);
 
         $this->status = array(
             'Code' => Constants::STATUS_SUCCESS,
-            'SubCode' => NULL,
-            'Message' => NULL,
+            'SubCode' => null,
+            'Message' => null,
             );
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -94,24 +94,24 @@ protected function __construct($tagName, \DOMElement $xml = NULL)
     /**
      * Determine whether this is a successful response.
      *
-     * @return boolean TRUE if the status code is success, FALSE if not.
+     * @return boolean true if the status code is success, false if not.
      */
     public function isSuccess()
     {
         assert('array_key_exists("Code", $this->status)');
 
         if ($this->status['Code'] === Constants::STATUS_SUCCESS) {
-            return TRUE;
+            return true;
         }
 
-        return FALSE;
+        return false;
     }
 
 
     /**
      * Retrieve the ID of the request this is a response to.
      *
-     * @return string|NULL The ID of the request.
+     * @return string|null The ID of the request.
      */
     public function getInResponseTo()
     {
@@ -122,7 +122,7 @@ public function getInResponseTo()
     /**
      * Set the ID of the request this is a response to.
      *
-     * @param string|NULL $inResponseTo The ID of the request.
+     * @param string|null $inResponseTo The ID of the request.
      */
     public function setInResponseTo($inResponseTo)
     {
@@ -154,10 +154,10 @@ public function setStatus(array $status)
 
         $this->status = $status;
         if (!array_key_exists('SubCode', $status)) {
-            $this->status['SubCode'] = NULL;
+            $this->status['SubCode'] = null;
         }
         if (!array_key_exists('Message', $status)) {
-            $this->status['Message'] = NULL;
+            $this->status['Message'] = null;
         }
     }
 
@@ -171,7 +171,7 @@ public function toUnsignedXML()
     {
         $root = parent::toUnsignedXML();
 
-        if ($this->inResponseTo !== NULL) {
+        if ($this->inResponseTo !== null) {
             $root->setAttribute('InResponseTo', $this->inResponseTo);
         }
 
@@ -194,5 +194,4 @@ public function toUnsignedXML()
 
         return $root;
     }
-
 }
diff --git a/src/SAML2/SubjectQuery.php b/src/SAML2/SubjectQuery.php
index cff29d5dd..7be76af97 100644
--- a/src/SAML2/SubjectQuery.php
+++ b/src/SAML2/SubjectQuery.php
@@ -27,13 +27,13 @@ abstract class SubjectQuery extends Request
      * Constructor for SAML 2 subject query messages.
      *
      * @param string          $tagName The tag name of the root element.
-     * @param \DOMElement|NULL $xml     The input message.
+     * @param \DOMElement|null $xml     The input message.
      */
-    protected function __construct($tagName, \DOMElement $xml = NULL)
+    protected function __construct($tagName, \DOMElement $xml = null)
     {
         parent::__construct($tagName, $xml);
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -75,7 +75,7 @@ private function parseSubject(\DOMElement $xml)
      * The returned NameId is in the format used by \SAML2\Utils::addNameId().
      *
      * @see \SAML2\Utils::addNameId()
-     * @return array|NULL The name identifier of the assertion.
+     * @return array|null The name identifier of the assertion.
      */
     public function getNameId()
     {
@@ -89,7 +89,7 @@ public function getNameId()
      * The NameId must be in the format accepted by \SAML2\Utils::addNameId().
      *
      * @see \SAML2\Utils::addNameId()
-     * @param array|NULL $nameId The name identifier of the assertion.
+     * @param array|null $nameId The name identifier of the assertion.
      */
     public function setNameId($nameId)
     {
@@ -115,5 +115,4 @@ public function toUnsignedXML()
 
         return $root;
     }
-
 }
diff --git a/src/SAML2/Utilities/ArrayCollection.php b/src/SAML2/Utilities/ArrayCollection.php
index 04273ece2..d1ce1fabd 100644
--- a/src/SAML2/Utilities/ArrayCollection.php
+++ b/src/SAML2/Utilities/ArrayCollection.php
@@ -28,7 +28,7 @@ public function add($element)
 
     public function get($key)
     {
-        return isset($this->elements[$key]) ? $this->elements[$key] : NULL;
+        return isset($this->elements[$key]) ? $this->elements[$key] : null;
     }
 
     public function filter(\Closure $f)
@@ -45,8 +45,8 @@ public function remove($element)
     {
         $key = array_search($element, $this->elements);
 
-        if ($key === FALSE) {
-            return FALSE;
+        if ($key === false) {
+            return false;
         }
 
         $removed = $this->elements[$key];
diff --git a/src/SAML2/Utilities/File.php b/src/SAML2/Utilities/File.php
index ff4de21d0..6f782081b 100644
--- a/src/SAML2/Utilities/File.php
+++ b/src/SAML2/Utilities/File.php
@@ -29,7 +29,7 @@ public static function getFileContents($file)
         }
 
         $contents = file_get_contents($file);
-        if ($contents === FALSE) {
+        if ($contents === false) {
             throw new RuntimeException(sprintf(
                 'Could not read from existing and readable file "%s"',
                 $file
diff --git a/src/SAML2/Utils.php b/src/SAML2/Utils.php
index 8be5c101d..10de6933d 100644
--- a/src/SAML2/Utils.php
+++ b/src/SAML2/Utils.php
@@ -29,7 +29,7 @@ class Utils
      * Note that this function only validates the element itself. It does not
      * check this against any local keys.
      *
-     * If no Signature-element is located, this function will return FALSE. All
+     * If no Signature-element is located, this function will return false. All
      * other validation errors result in an exception. On successful validation
      * an array will be returned. This array contains the information required to
      * check the signature against a public key.
@@ -51,7 +51,7 @@ public static function validateElement(\DOMElement $root)
         if (count($signatureElement) === 0) {
             /* We don't have a signature element ot validate. */
 
-            return FALSE;
+            return false;
         } elseif (count($signatureElement) > 1) {
             throw new \Exception('XMLSec: more than one signature element in root.');
         }
@@ -67,15 +67,15 @@ public static function validateElement(\DOMElement $root)
         }
 
         /* Check that $root is one of the signed nodes. */
-        $rootSigned = FALSE;
+        $rootSigned = false;
         /** @var \DOMNode $signedNode */
         foreach ($objXMLSecDSig->getValidatedNodes() as $signedNode) {
             if ($signedNode->isSameNode($root)) {
-                $rootSigned = TRUE;
+                $rootSigned = true;
                 break;
             } elseif ($root->parentNode instanceof \DOMDocument && $signedNode->isSameNode($root->ownerDocument)) {
                 /* $root is the root element of a signed document. */
-                $rootSigned = TRUE;
+                $rootSigned = true;
                 break;
             }
         }
@@ -120,7 +120,7 @@ public static function castKey(XMLSecurityKey $key, $algorithm, $type = 'public'
         }
 
         $keyInfo = openssl_pkey_get_details($key->key);
-        if ($keyInfo === FALSE) {
+        if ($keyInfo === false) {
             throw new \Exception('Unable to get key details from XMLSecurityKey.');
         }
         if (!isset($keyInfo['key'])) {
@@ -181,7 +181,7 @@ public static function validateSignature(array $info, XMLSecurityKey $key)
     public static function xpQuery(\DOMNode $node, $query)
     {
         assert('is_string($query)');
-        static $xpCache = NULL;
+        static $xpCache = null;
 
         if ($node instanceof \DOMDocument) {
             $doc = $node;
@@ -189,7 +189,7 @@ public static function xpQuery(\DOMNode $node, $query)
             $doc = $node->ownerDocument;
         }
 
-        if ($xpCache === NULL || !$xpCache->document->isSameNode($doc)) {
+        if ($xpCache === null || !$xpCache->document->isSameNode($doc)) {
             $xpCache = new \DOMXPath($doc);
             $xpCache->registerNamespace('soap-env', Constants::NS_SOAP);
             $xpCache->registerNamespace('saml_protocol', Constants::NS_SAMLP);
@@ -213,19 +213,19 @@ public static function xpQuery(\DOMNode $node, $query)
      * Make an exact copy the specific \DOMElement.
      *
      * @param  \DOMElement      $element The element we should copy.
-     * @param  \DOMElement|NULL $parent  The target parent element.
+     * @param  \DOMElement|null $parent  The target parent element.
      * @return \DOMElement      The copied element.
      */
-    public static function copyElement(\DOMElement $element, \DOMElement $parent = NULL)
+    public static function copyElement(\DOMElement $element, \DOMElement $parent = null)
     {
-        if ($parent === NULL) {
+        if ($parent === null) {
             $document = DOMDocumentFactory::create();
         } else {
             $document = $parent->ownerDocument;
         }
 
         $namespaces = array();
-        for ($e = $element; $e !== NULL; $e = $e->parentNode) {
+        for ($e = $element; $e !== null; $e = $e->parentNode) {
             foreach (Utils::xpQuery($e, './namespace::*') as $ns) {
                 $prefix = $ns->localName;
                 if ($prefix === 'xml' || $prefix === 'xmlns') {
@@ -239,8 +239,8 @@ public static function copyElement(\DOMElement $element, \DOMElement $parent = N
         }
 
         /** @var \DOMElement $newElement */
-        $newElement = $document->importNode($element, TRUE);
-        if ($parent !== NULL) {
+        $newElement = $document->importNode($element, true);
+        if ($parent !== null) {
             /* We need to append the child to the parent before we add the namespaces. */
             $parent->appendChild($newElement);
         }
@@ -263,7 +263,7 @@ public static function copyElement(\DOMElement $element, \DOMElement $parent = N
      * @return bool|mixed The value of the attribute, or $default if the attribute doesn't exist.
      * @throws \Exception
      */
-    public static function parseBoolean(\DOMElement $node, $attributeName, $default = NULL)
+    public static function parseBoolean(\DOMElement $node, $attributeName, $default = null)
     {
         assert('is_string($attributeName)');
 
@@ -274,12 +274,12 @@ public static function parseBoolean(\DOMElement $node, $attributeName, $default
         switch (strtolower($value)) {
             case '0':
             case 'false':
-                return FALSE;
+                return false;
             case '1':
             case 'true':
-                return TRUE;
+                return true;
             default:
-                throw new \Exception('Invalid value of boolean attribute ' . var_export($attributeName, TRUE) . ': ' . var_export($value, TRUE));
+                throw new \Exception('Invalid value of boolean attribute ' . var_export($attributeName, true) . ': ' . var_export($value, true));
         }
     }
 
@@ -301,13 +301,13 @@ public static function addNameId(\DOMElement $node, array $nameId)
 
         $xml = Utils::addString($node, Constants::NS_SAML, 'saml:NameID', $nameId['Value']);
 
-        if (array_key_exists('NameQualifier', $nameId) && $nameId['NameQualifier'] !== NULL) {
+        if (array_key_exists('NameQualifier', $nameId) && $nameId['NameQualifier'] !== null) {
             $xml->setAttribute('NameQualifier', $nameId['NameQualifier']);
         }
-        if (array_key_exists('SPNameQualifier', $nameId) && $nameId['SPNameQualifier'] !== NULL) {
+        if (array_key_exists('SPNameQualifier', $nameId) && $nameId['SPNameQualifier'] !== null) {
             $xml->setAttribute('SPNameQualifier', $nameId['SPNameQualifier']);
         }
-        if (array_key_exists('Format', $nameId) && $nameId['Format'] !== NULL) {
+        if (array_key_exists('Format', $nameId) && $nameId['Format'] !== null) {
             $xml->setAttribute('Format', $nameId['Format']);
         }
     }
@@ -343,7 +343,7 @@ public static function insertSignature(
         XMLSecurityKey $key,
         array $certificates,
         \DOMElement $root,
-        \DOMNode $insertBefore = NULL
+        \DOMNode $insertBefore = null
     ) {
         $objXMLSecDSig = new XMLSecurityDSig();
         $objXMLSecDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N);
@@ -366,17 +366,16 @@ public static function insertSignature(
             array($root),
             $type,
             array('http://www.w3.org/2000/09/xmldsig#enveloped-signature', XMLSecurityDSig::EXC_C14N),
-            array('id_name' => 'ID', 'overwrite' => FALSE)
+            array('id_name' => 'ID', 'overwrite' => false)
         );
 
         $objXMLSecDSig->sign($key);
 
         foreach ($certificates as $certificate) {
-            $objXMLSecDSig->add509Cert($certificate, TRUE);
+            $objXMLSecDSig->add509Cert($certificate, true);
         }
 
         $objXMLSecDSig->insertSignature($root, $insertBefore);
-
     }
 
     /**
@@ -411,8 +410,8 @@ private static function doDecryptElement(\DOMElement $encryptedData, XMLSecurity
         if ($symmetricKeyInfo->isEncrypted) {
             $symKeyInfoAlgo = $symmetricKeyInfo->getAlgorith();
 
-            if (in_array($symKeyInfoAlgo, $blacklist, TRUE)) {
-                throw new \Exception('Algorithm disabled: ' . var_export($symKeyInfoAlgo, TRUE));
+            if (in_array($symKeyInfoAlgo, $blacklist, true)) {
+                throw new \Exception('Algorithm disabled: ' . var_export($symKeyInfoAlgo, true));
             }
 
             if ($symKeyInfoAlgo === XMLSecurityKey::RSA_OAEP_MGF1P && $inputKeyAlgo === XMLSecurityKey::RSA_1_5) {
@@ -430,8 +429,8 @@ private static function doDecryptElement(\DOMElement $encryptedData, XMLSecurity
                 throw new \Exception(
                     'Algorithm mismatch between input key and key used to encrypt ' .
                     ' the symmetric key for the message. Key was: ' .
-                    var_export($inputKeyAlgo, TRUE) . '; message was: ' .
-                    var_export($symKeyInfoAlgo, TRUE)
+                    var_export($inputKeyAlgo, true) . '; message was: ' .
+                    var_export($symKeyInfoAlgo, true)
                 );
             }
 
@@ -440,11 +439,11 @@ private static function doDecryptElement(\DOMElement $encryptedData, XMLSecurity
             $symmetricKeyInfo->key = $inputKey->key;
 
             $keySize = $symmetricKey->getSymmetricKeySize();
-            if ($keySize === NULL) {
+            if ($keySize === null) {
                 /* To protect against "key oracle" attacks, we need to be able to create a
                  * symmetric key, and for that we need to know the key size.
                  */
-                throw new \Exception('Unknown key size for encryption algorithm: ' . var_export($symmetricKey->type, TRUE));
+                throw new \Exception('Unknown key size for encryption algorithm: ' . var_export($symmetricKey->type, true));
             }
 
             try {
@@ -452,7 +451,7 @@ private static function doDecryptElement(\DOMElement $encryptedData, XMLSecurity
                 if (strlen($key) != $keySize) {
                     throw new \Exception(
                         'Unexpected key size (' . strlen($key) * 8 . 'bits) for encryption algorithm: ' .
-                        var_export($symmetricKey->type, TRUE)
+                        var_export($symmetricKey->type, true)
                     );
                 }
             } catch (\Exception $e) {
@@ -465,8 +464,8 @@ private static function doDecryptElement(\DOMElement $encryptedData, XMLSecurity
                  */
                 $encryptedKey = $encKey->getCipherValue();
                 $pkey = openssl_pkey_get_details($symmetricKeyInfo->key);
-                $pkey = sha1(serialize($pkey), TRUE);
-                $key = sha1($encryptedKey . $pkey, TRUE);
+                $pkey = sha1(serialize($pkey), true);
+                $key = sha1($encryptedKey . $pkey, true);
 
                 /* Make sure that the key has the correct length. */
                 if (strlen($key) > $keySize) {
@@ -476,27 +475,26 @@ private static function doDecryptElement(\DOMElement $encryptedData, XMLSecurity
                 }
             }
             $symmetricKey->loadkey($key);
-
         } else {
             $symKeyAlgo = $symmetricKey->getAlgorith();
             /* Make sure that the input key has the correct format. */
             if ($inputKeyAlgo !== $symKeyAlgo) {
                 throw new \Exception(
                     'Algorithm mismatch between input key and key in message. ' .
-                    'Key was: ' . var_export($inputKeyAlgo, TRUE) . '; message was: ' .
-                    var_export($symKeyAlgo, TRUE)
+                    'Key was: ' . var_export($inputKeyAlgo, true) . '; message was: ' .
+                    var_export($symKeyAlgo, true)
                 );
             }
             $symmetricKey = $inputKey;
         }
 
         $algorithm = $symmetricKey->getAlgorith();
-        if (in_array($algorithm, $blacklist, TRUE)) {
-            throw new \Exception('Algorithm disabled: ' . var_export($algorithm, TRUE));
+        if (in_array($algorithm, $blacklist, true)) {
+            throw new \Exception('Algorithm disabled: ' . var_export($algorithm, true));
         }
 
         /** @var string $decrypted */
-        $decrypted = $enc->decryptNode($symmetricKey, FALSE);
+        $decrypted = $enc->decryptNode($symmetricKey, false);
 
         /*
          * This is a workaround for the case where only a subset of the XML
@@ -515,7 +513,7 @@ private static function doDecryptElement(\DOMElement $encryptedData, XMLSecurity
         }
 
         $decryptedElement = $newDoc->firstChild->firstChild;
-        if ($decryptedElement === NULL) {
+        if ($decryptedElement === null) {
             throw new \Exception('Missing encrypted element.');
         }
 
@@ -563,7 +561,7 @@ public static function extractLocalizedStrings(\DOMElement $parent, $namespaceUR
         assert('is_string($localName)');
 
         $ret = array();
-        for ($node = $parent->firstChild; $node !== NULL; $node = $node->nextSibling) {
+        for ($node = $parent->firstChild; $node !== null; $node = $node->nextSibling) {
             if ($node->namespaceURI !== $namespaceURI || $node->localName !== $localName) {
                 continue;
             }
@@ -593,7 +591,7 @@ public static function extractStrings(\DOMElement $parent, $namespaceURI, $local
         assert('is_string($localName)');
 
         $ret = array();
-        for ($node = $parent->firstChild; $node !== NULL; $node = $node->nextSibling) {
+        for ($node = $parent->firstChild; $node !== null; $node = $node->nextSibling) {
             if ($node->namespaceURI !== $namespaceURI || $node->localName !== $localName) {
                 continue;
             }
diff --git a/src/SAML2/XML/ds/KeyInfo.php b/src/SAML2/XML/ds/KeyInfo.php
index b0e2ae4e8..5fefdf17d 100644
--- a/src/SAML2/XML/ds/KeyInfo.php
+++ b/src/SAML2/XML/ds/KeyInfo.php
@@ -15,9 +15,9 @@ class KeyInfo
     /**
      * The Id attribute on this element.
      *
-     * @var string|NULL
+     * @var string|null
      */
-    public $Id = NULL;
+    public $Id = null;
 
     /**
      * The various key information elements.
@@ -32,11 +32,11 @@ class KeyInfo
     /**
      * Initialize a KeyInfo element.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -44,7 +44,7 @@ public function __construct(\DOMElement $xml = NULL)
             $this->Id = $xml->getAttribute('Id');
         }
 
-        for ($n = $xml->firstChild; $n !== NULL; $n = $n->nextSibling) {
+        for ($n = $xml->firstChild; $n !== null; $n = $n->nextSibling) {
             if (!($n instanceof \DOMElement)) {
                 continue;
             }
@@ -94,5 +94,4 @@ public function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/ds/KeyName.php b/src/SAML2/XML/ds/KeyName.php
index 7a5ae791a..e0b782bbd 100644
--- a/src/SAML2/XML/ds/KeyName.php
+++ b/src/SAML2/XML/ds/KeyName.php
@@ -22,11 +22,11 @@ class KeyName
     /**
      * Initialize a KeyName element.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -45,5 +45,4 @@ public function toXML(\DOMElement $parent)
 
         return Utils::addString($parent, XMLSecurityDSig::XMLDSIGNS, 'ds:KeyName', $this->name);
     }
-
 }
diff --git a/src/SAML2/XML/ds/X509Certificate.php b/src/SAML2/XML/ds/X509Certificate.php
index b851af149..01d2752fb 100644
--- a/src/SAML2/XML/ds/X509Certificate.php
+++ b/src/SAML2/XML/ds/X509Certificate.php
@@ -22,11 +22,11 @@ class X509Certificate
     /**
      * Initialize an X509Certificate element.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -45,5 +45,4 @@ public function toXML(\DOMElement $parent)
 
         return Utils::addString($parent, XMLSecurityDSig::XMLDSIGNS, 'ds:X509Certificate', $this->certificate);
     }
-
 }
diff --git a/src/SAML2/XML/ds/X509Data.php b/src/SAML2/XML/ds/X509Data.php
index 2c69a560b..4a8df0734 100644
--- a/src/SAML2/XML/ds/X509Data.php
+++ b/src/SAML2/XML/ds/X509Data.php
@@ -25,15 +25,15 @@ class X509Data
     /**
      * Initialize a X509Data.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
-        for ($n = $xml->firstChild; $n !== NULL; $n = $n->nextSibling) {
+        for ($n = $xml->firstChild; $n !== null; $n = $n->nextSibling) {
             if (!($n instanceof \DOMElement)) {
                 continue;
             }
@@ -75,5 +75,4 @@ public function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/AdditionalMetadataLocation.php b/src/SAML2/XML/md/AdditionalMetadataLocation.php
index 03e622531..3bac73930 100644
--- a/src/SAML2/XML/md/AdditionalMetadataLocation.php
+++ b/src/SAML2/XML/md/AdditionalMetadataLocation.php
@@ -29,12 +29,12 @@ class AdditionalMetadataLocation
     /**
      * Initialize an AdditionalMetadataLocation element.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -62,5 +62,4 @@ public function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/AffiliationDescriptor.php b/src/SAML2/XML/md/AffiliationDescriptor.php
index de17b7c0e..2225bad2f 100644
--- a/src/SAML2/XML/md/AffiliationDescriptor.php
+++ b/src/SAML2/XML/md/AffiliationDescriptor.php
@@ -23,21 +23,21 @@ class AffiliationDescriptor extends SignedElementHelper
     /**
      * The ID of this element.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $ID;
 
     /**
      * How long this element is valid, as a unix timestamp.
      *
-     * @var int|NULL
+     * @var int|null
      */
     public $validUntil;
 
     /**
      * The length of time this element can be cached, as string.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $cacheDuration;
 
@@ -71,14 +71,14 @@ class AffiliationDescriptor extends SignedElementHelper
     /**
      * Initialize a AffiliationDescriptor.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct($xml);
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -147,7 +147,7 @@ public function toXML(\DOMElement $parent)
 
         Extensions::addList($e, $this->Extensions);
 
-        Utils::addStrings($e, Constants::NS_MD, 'md:AffiliateMember', FALSE, $this->AffiliateMember);
+        Utils::addStrings($e, Constants::NS_MD, 'md:AffiliateMember', false, $this->AffiliateMember);
 
         foreach ($this->KeyDescriptor as $kd) {
             $kd->toXML($e);
@@ -157,5 +157,4 @@ public function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/AttributeAuthorityDescriptor.php b/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
index 749c0b32c..41dbfd8d2 100644
--- a/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
+++ b/src/SAML2/XML/md/AttributeAuthorityDescriptor.php
@@ -61,14 +61,14 @@ class AttributeAuthorityDescriptor extends RoleDescriptor
     /**
      * Initialize an IDPSSODescriptor.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct('md:AttributeAuthorityDescriptor', $xml);
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -117,9 +117,9 @@ public function toXML(\DOMElement $parent)
             $ep->toXML($e, 'md:AssertionIDRequestService');
         }
 
-        Utils::addStrings($e, Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
+        Utils::addStrings($e, Constants::NS_MD, 'md:NameIDFormat', false, $this->NameIDFormat);
 
-        Utils::addStrings($e, Constants::NS_MD, 'md:AttributeProfile', FALSE, $this->AttributeProfile);
+        Utils::addStrings($e, Constants::NS_MD, 'md:AttributeProfile', false, $this->AttributeProfile);
 
         foreach ($this->Attribute as $a) {
             $a->toXML($e);
@@ -127,5 +127,4 @@ public function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/AttributeConsumingService.php b/src/SAML2/XML/md/AttributeConsumingService.php
index 7de8e49ee..fdc9ac838 100644
--- a/src/SAML2/XML/md/AttributeConsumingService.php
+++ b/src/SAML2/XML/md/AttributeConsumingService.php
@@ -22,9 +22,9 @@ class AttributeConsumingService
     /**
      * Whether this is the default AttributeConsumingService.
      *
-     * @var bool|NULL
+     * @var bool|null
      */
-    public $isDefault = NULL;
+    public $isDefault = null;
 
     /**
      * The ServiceName of this AttributeConsumingService.
@@ -56,12 +56,12 @@ class AttributeConsumingService
     /**
      * Initialize / parse an AttributeConsumingService.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -70,7 +70,7 @@ public function __construct(\DOMElement $xml = NULL)
         }
         $this->index = (int) $xml->getAttribute('index');
 
-        $this->isDefault = Utils::parseBoolean($xml, 'isDefault', NULL);
+        $this->isDefault = Utils::parseBoolean($xml, 'isDefault', null);
 
         $this->ServiceName = Utils::extractLocalizedStrings($xml, Constants::NS_MD, 'ServiceName');
         if (empty($this->ServiceName)) {
@@ -105,14 +105,14 @@ public function toXML(\DOMElement $parent)
 
         $e->setAttribute('index', (string) $this->index);
 
-        if ($this->isDefault === TRUE) {
+        if ($this->isDefault === true) {
             $e->setAttribute('isDefault', 'true');
-        } elseif ($this->isDefault === FALSE) {
+        } elseif ($this->isDefault === false) {
             $e->setAttribute('isDefault', 'false');
         }
 
-        Utils::addStrings($e, Constants::NS_MD, 'md:ServiceName', TRUE, $this->ServiceName);
-        Utils::addStrings($e, Constants::NS_MD, 'md:ServiceDescription', TRUE, $this->ServiceDescription);
+        Utils::addStrings($e, Constants::NS_MD, 'md:ServiceName', true, $this->ServiceName);
+        Utils::addStrings($e, Constants::NS_MD, 'md:ServiceDescription', true, $this->ServiceDescription);
 
         foreach ($this->RequestedAttribute as $ra) {
             $ra->toXML($e);
@@ -120,5 +120,4 @@ public function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/AuthnAuthorityDescriptor.php b/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
index 751c00aa2..3524a34e2 100644
--- a/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
+++ b/src/SAML2/XML/md/AuthnAuthorityDescriptor.php
@@ -42,14 +42,14 @@ class AuthnAuthorityDescriptor extends RoleDescriptor
     /**
      * Initialize an IDPSSODescriptor.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct('md:AuthnAuthorityDescriptor', $xml);
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -90,9 +90,8 @@ public function toXML(\DOMElement $parent)
             $ep->toXML($e, 'md:AssertionIDRequestService');
         }
 
-        Utils::addStrings($e, Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
+        Utils::addStrings($e, Constants::NS_MD, 'md:NameIDFormat', false, $this->NameIDFormat);
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/ContactPerson.php b/src/SAML2/XML/md/ContactPerson.php
index 56e81c53b..107fe0094 100644
--- a/src/SAML2/XML/md/ContactPerson.php
+++ b/src/SAML2/XML/md/ContactPerson.php
@@ -33,21 +33,21 @@ class ContactPerson
      *
      * @var string
      */
-    public $Company = NULL;
+    public $Company = null;
 
     /**
      * The GivenName of this contact.
      *
      * @var string
      */
-    public $GivenName = NULL;
+    public $GivenName = null;
 
     /**
      * The SurName of this contact.
      *
      * @var string
      */
-    public $SurName = NULL;
+    public $SurName = null;
 
     /**
      * The EmailAddresses of this contact.
@@ -66,12 +66,12 @@ class ContactPerson
     /**
      * Initialize a ContactPerson element.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -115,7 +115,7 @@ private static function getStringElements(\DOMElement $parent, $name)
      *
      * @param  \DOMElement  $parent The parent element.
      * @param  string      $name   The name of the child element.
-     * @return string|NULL The value of the child element.
+     * @return string|null The value of the child element.
      * @throws \Exception
      */
     private static function getStringElement(\DOMElement $parent, $name)
@@ -124,7 +124,7 @@ private static function getStringElement(\DOMElement $parent, $name)
 
         $e = self::getStringElements($parent, $name);
         if (empty($e)) {
-            return NULL;
+            return null;
         }
         if (count($e) > 1) {
             throw new \Exception('More than one ' . $name . ' in ' . $parent->tagName);
@@ -168,13 +168,12 @@ public function toXML(\DOMElement $parent)
             Utils::addString($e, Constants::NS_MD, 'md:SurName', $this->SurName);
         }
         if (!empty($this->EmailAddress)) {
-            Utils::addStrings($e, Constants::NS_MD, 'md:EmailAddress', FALSE, $this->EmailAddress);
+            Utils::addStrings($e, Constants::NS_MD, 'md:EmailAddress', false, $this->EmailAddress);
         }
         if (!empty($this->TelephoneNumber)) {
-            Utils::addStrings($e, Constants::NS_MD, 'md:TelephoneNumber', FALSE, $this->TelephoneNumber);
+            Utils::addStrings($e, Constants::NS_MD, 'md:TelephoneNumber', false, $this->TelephoneNumber);
         }
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/EndpointType.php b/src/SAML2/XML/md/EndpointType.php
index 9ab2dd818..a2074641f 100644
--- a/src/SAML2/XML/md/EndpointType.php
+++ b/src/SAML2/XML/md/EndpointType.php
@@ -28,9 +28,9 @@ class EndpointType
     /**
      * The URI where responses can be delivered.
      *
-     * @var string|NULL
+     * @var string|null
      */
-    public $ResponseLocation = NULL;
+    public $ResponseLocation = null;
 
     /**
      * Extra (namespace qualified) attributes.
@@ -42,12 +42,12 @@ class EndpointType
     /**
      * Initialize an EndpointType.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -66,7 +66,7 @@ public function __construct(\DOMElement $xml = NULL)
         }
 
         foreach ($xml->attributes as $a) {
-            if ($a->namespaceURI === NULL) {
+            if ($a->namespaceURI === null) {
                 continue; /* Not namespace-qualified -- skip. */
             }
             $fullName = '{' . $a->namespaceURI . '}' . $a->localName;
@@ -83,7 +83,7 @@ public function __construct(\DOMElement $xml = NULL)
      *
      * @param  string  $namespaceURI The namespace URI.
      * @param  string  $localName    The local name.
-     * @return boolean TRUE if the attribute exists, FALSE if not.
+     * @return boolean true if the attribute exists, false if not.
      */
     public function hasAttributeNS($namespaceURI, $localName)
     {
@@ -187,5 +187,4 @@ public function toXML(\DOMElement $parent, $name)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/EntitiesDescriptor.php b/src/SAML2/XML/md/EntitiesDescriptor.php
index 643e51929..42ee492c3 100644
--- a/src/SAML2/XML/md/EntitiesDescriptor.php
+++ b/src/SAML2/XML/md/EntitiesDescriptor.php
@@ -17,28 +17,28 @@ class EntitiesDescriptor extends SignedElementHelper
     /**
      * The ID of this element.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $ID;
 
     /**
      * How long this element is valid, as a unix timestamp.
      *
-     * @var int|NULL
+     * @var int|null
      */
     public $validUntil;
 
     /**
      * The length of time this element can be cached, as string.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $cacheDuration;
 
     /**
      * The name of this entity collection.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $Name;
 
@@ -61,13 +61,13 @@ class EntitiesDescriptor extends SignedElementHelper
     /**
      * Initialize an EntitiesDescriptor.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct($xml);
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -98,10 +98,10 @@ public function __construct(\DOMElement $xml = NULL)
     /**
      * Convert this EntitiesDescriptor to XML.
      *
-     * @param \DOMElement|NULL $parent The EntitiesDescriptor we should append this EntitiesDescriptor to.
+     * @param \DOMElement|null $parent The EntitiesDescriptor we should append this EntitiesDescriptor to.
      * @return \DOMElement
      */
-    public function toXML(\DOMElement $parent = NULL)
+    public function toXML(\DOMElement $parent = null)
     {
         assert('is_null($this->ID) || is_string($this->ID)');
         assert('is_null($this->validUntil) || is_int($this->validUntil)');
@@ -110,7 +110,7 @@ public function toXML(\DOMElement $parent = NULL)
         assert('is_array($this->Extensions)');
         assert('is_array($this->children)');
 
-        if ($parent === NULL) {
+        if ($parent === null) {
             $doc = DOMDocumentFactory::create();
             $e = $doc->createElementNS(Constants::NS_MD, 'md:EntitiesDescriptor');
             $doc->appendChild($e);
@@ -146,5 +146,4 @@ public function toXML(\DOMElement $parent = NULL)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/EntityDescriptor.php b/src/SAML2/XML/md/EntityDescriptor.php
index 9084e0ab5..f1723193a 100644
--- a/src/SAML2/XML/md/EntityDescriptor.php
+++ b/src/SAML2/XML/md/EntityDescriptor.php
@@ -24,21 +24,21 @@ class EntityDescriptor extends SignedElementHelper
     /**
      * The ID of this element.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $ID;
 
     /**
      * How long this element is valid, as a unix timestamp.
      *
-     * @var int|NULL
+     * @var int|null
      */
     public $validUntil;
 
     /**
      * The length of time this element can be cached, as string.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $cacheDuration;
 
@@ -63,16 +63,16 @@ class EntityDescriptor extends SignedElementHelper
     /**
      * AffiliationDescriptor of this entity.
      *
-     * @var \SAML2\XML\md\AffiliationDescriptor|NULL
+     * @var \SAML2\XML\md\AffiliationDescriptor|null
      */
-    public $AffiliationDescriptor = NULL;
+    public $AffiliationDescriptor = null;
 
     /**
      * Organization of this entity.
      *
-     * @var \SAML2\XML\md\Organization|NULL
+     * @var \SAML2\XML\md\Organization|null
      */
-    public $Organization = NULL;
+    public $Organization = null;
 
     /**
      * ContactPerson elements for this entity.
@@ -91,14 +91,14 @@ class EntityDescriptor extends SignedElementHelper
     /**
      * Initialize an EntitiyDescriptor.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct($xml);
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -119,7 +119,7 @@ public function __construct(\DOMElement $xml = NULL)
 
         $this->Extensions = Extensions::getList($xml);
 
-        for ($node = $xml->firstChild; $node !== NULL; $node = $node->nextSibling) {
+        for ($node = $xml->firstChild; $node !== null; $node = $node->nextSibling) {
             if (!($node instanceof \DOMElement)) {
                 continue;
             }
@@ -182,10 +182,10 @@ public function __construct(\DOMElement $xml = NULL)
     /**
      * Create this EntityDescriptor.
      *
-     * @param \DOMElement|NULL $parent The EntitiesDescriptor we should append this EntityDescriptor to.
+     * @param \DOMElement|null $parent The EntitiesDescriptor we should append this EntityDescriptor to.
      * @return \DOMElement
      */
-    public function toXML(\DOMElement $parent = NULL)
+    public function toXML(\DOMElement $parent = null)
     {
         assert('is_string($this->entityID)');
         assert('is_null($this->ID) || is_string($this->ID)');
@@ -198,7 +198,7 @@ public function toXML(\DOMElement $parent = NULL)
         assert('is_array($this->ContactPerson)');
         assert('is_array($this->AdditionalMetadataLocation)');
 
-        if ($parent === NULL) {
+        if ($parent === null) {
             $doc = DOMDocumentFactory::create();
             $e = $doc->createElementNS(Constants::NS_MD, 'md:EntityDescriptor');
             $doc->appendChild($e);
@@ -248,5 +248,4 @@ public function toXML(\DOMElement $parent = NULL)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/Extensions.php b/src/SAML2/XML/md/Extensions.php
index 758d36172..262e36c75 100644
--- a/src/SAML2/XML/md/Extensions.php
+++ b/src/SAML2/XML/md/Extensions.php
@@ -69,5 +69,4 @@ public static function addList(\DOMElement $parent, array $extensions)
             $ext->toXML($extElement);
         }
     }
-
 }
diff --git a/src/SAML2/XML/md/IDPSSODescriptor.php b/src/SAML2/XML/md/IDPSSODescriptor.php
index 2d4e46b48..8d82aa318 100644
--- a/src/SAML2/XML/md/IDPSSODescriptor.php
+++ b/src/SAML2/XML/md/IDPSSODescriptor.php
@@ -16,9 +16,9 @@ class IDPSSODescriptor extends SSODescriptorType
     /**
      * Whether AuthnRequests sent to this IdP should be signed.
      *
-     * @var bool|NULL
+     * @var bool|null
      */
-    public $WantAuthnRequestsSigned = NULL;
+    public $WantAuthnRequestsSigned = null;
 
     /**
      * List of SingleSignOnService endpoints.
@@ -68,17 +68,17 @@ class IDPSSODescriptor extends SSODescriptorType
     /**
      * Initialize an IDPSSODescriptor.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct('md:IDPSSODescriptor', $xml);
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
-        $this->WantAuthnRequestsSigned = Utils::parseBoolean($xml, 'WantAuthnRequestsSigned', NULL);
+        $this->WantAuthnRequestsSigned = Utils::parseBoolean($xml, 'WantAuthnRequestsSigned', null);
 
         foreach (Utils::xpQuery($xml, './saml_metadata:SingleSignOnService') as $ep) {
             $this->SingleSignOnService[] = new EndpointType($ep);
@@ -116,9 +116,9 @@ public function toXML(\DOMElement $parent)
 
         $e = parent::toXML($parent);
 
-        if ($this->WantAuthnRequestsSigned === TRUE) {
+        if ($this->WantAuthnRequestsSigned === true) {
             $e->setAttribute('WantAuthnRequestsSigned', 'true');
-        } elseif ($this->WantAuthnRequestsSigned === FALSE) {
+        } elseif ($this->WantAuthnRequestsSigned === false) {
             $e->setAttribute('WantAuthnRequestsSigned', 'false');
         }
 
@@ -134,7 +134,7 @@ public function toXML(\DOMElement $parent)
             $ep->toXML($e, 'md:AssertionIDRequestService');
         }
 
-        Utils::addStrings($e, Constants::NS_MD, 'md:AttributeProfile', FALSE, $this->AttributeProfile);
+        Utils::addStrings($e, Constants::NS_MD, 'md:AttributeProfile', false, $this->AttributeProfile);
 
         foreach ($this->Attribute as $a) {
             $a->toXML($e);
@@ -142,5 +142,4 @@ public function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/IndexedEndpointType.php b/src/SAML2/XML/md/IndexedEndpointType.php
index f6523cb3e..958c96b07 100644
--- a/src/SAML2/XML/md/IndexedEndpointType.php
+++ b/src/SAML2/XML/md/IndexedEndpointType.php
@@ -21,21 +21,21 @@ class IndexedEndpointType extends EndpointType
     /**
      * Whether this endpoint is the default.
      *
-     * @var bool|NULL
+     * @var bool|null
      */
-    public $isDefault = NULL;
+    public $isDefault = null;
 
     /**
      * Initialize an IndexedEndpointType.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct($xml);
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -44,7 +44,7 @@ public function __construct(\DOMElement $xml = NULL)
         }
         $this->index = (int) $xml->getAttribute('index');
 
-        $this->isDefault = Utils::parseBoolean($xml, 'isDefault', NULL);
+        $this->isDefault = Utils::parseBoolean($xml, 'isDefault', null);
     }
 
     /**
@@ -63,13 +63,12 @@ public function toXML(\DOMElement $parent, $name)
         $e = parent::toXML($parent, $name);
         $e->setAttribute('index', (string) $this->index);
 
-        if ($this->isDefault === TRUE) {
+        if ($this->isDefault === true) {
             $e->setAttribute('isDefault', 'true');
-        } elseif ($this->isDefault === FALSE) {
+        } elseif ($this->isDefault === false) {
             $e->setAttribute('isDefault', 'false');
         }
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/KeyDescriptor.php b/src/SAML2/XML/md/KeyDescriptor.php
index 2e04a9197..324b1070f 100644
--- a/src/SAML2/XML/md/KeyDescriptor.php
+++ b/src/SAML2/XML/md/KeyDescriptor.php
@@ -17,9 +17,9 @@ class KeyDescriptor
     /**
      * What this key can be used for.
      *
-     * 'encryption', 'signing' or NULL.
+     * 'encryption', 'signing' or null.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $use;
 
@@ -42,12 +42,12 @@ class KeyDescriptor
     /**
      * Initialize an KeyDescriptor.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -66,7 +66,6 @@ public function __construct(\DOMElement $xml = NULL)
         foreach (Utils::xpQuery($xml, './saml_metadata:EncryptionMethod') as $em) {
             $this->EncryptionMethod[] = new Chunk($em);
         }
-
     }
 
     /**
@@ -98,5 +97,4 @@ public function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/Organization.php b/src/SAML2/XML/md/Organization.php
index 010dc81a6..75715fa6f 100644
--- a/src/SAML2/XML/md/Organization.php
+++ b/src/SAML2/XML/md/Organization.php
@@ -45,11 +45,11 @@ class Organization
     /**
      * Initialize an Organization element.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -94,11 +94,10 @@ public function toXML(\DOMElement $parent)
 
         Extensions::addList($e, $this->Extensions);
 
-        Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationName', TRUE, $this->OrganizationName);
-        Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationDisplayName', TRUE, $this->OrganizationDisplayName);
-        Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationURL', TRUE, $this->OrganizationURL);
+        Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationName', true, $this->OrganizationName);
+        Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationDisplayName', true, $this->OrganizationDisplayName);
+        Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationURL', true, $this->OrganizationURL);
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/PDPDescriptor.php b/src/SAML2/XML/md/PDPDescriptor.php
index 21890e81d..64c273c40 100644
--- a/src/SAML2/XML/md/PDPDescriptor.php
+++ b/src/SAML2/XML/md/PDPDescriptor.php
@@ -42,14 +42,14 @@ class PDPDescriptor extends RoleDescriptor
     /**
      * Initialize an IDPSSODescriptor.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct('md:PDPDescriptor', $xml);
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -90,9 +90,8 @@ public function toXML(\DOMElement $parent)
             $ep->toXML($e, 'md:AssertionIDRequestService');
         }
 
-        Utils::addStrings($e, Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
+        Utils::addStrings($e, Constants::NS_MD, 'md:NameIDFormat', false, $this->NameIDFormat);
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/RequestedAttribute.php b/src/SAML2/XML/md/RequestedAttribute.php
index bbe727f13..a2abcd4a8 100644
--- a/src/SAML2/XML/md/RequestedAttribute.php
+++ b/src/SAML2/XML/md/RequestedAttribute.php
@@ -16,24 +16,24 @@ class RequestedAttribute extends Attribute
     /**
      * Whether this attribute is required.
      *
-     * @var bool|NULL
+     * @var bool|null
      */
-    public $isRequired = NULL;
+    public $isRequired = null;
 
     /**
      * Initialize an RequestedAttribute.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct($xml);
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
-        $this->isRequired = Utils::parseBoolean($xml, 'isRequired', NULL);
+        $this->isRequired = Utils::parseBoolean($xml, 'isRequired', null);
     }
 
     /**
@@ -48,13 +48,12 @@ public function toXML(\DOMElement $parent)
 
         $e = $this->toXMLInternal($parent, Constants::NS_MD, 'md:RequestedAttribute');
 
-        if ($this->isRequired === TRUE) {
+        if ($this->isRequired === true) {
             $e->setAttribute('isRequired', 'true');
-        } elseif ($this->isRequired === FALSE) {
+        } elseif ($this->isRequired === false) {
             $e->setAttribute('isRequired', 'false');
         }
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/RoleDescriptor.php b/src/SAML2/XML/md/RoleDescriptor.php
index 51c31c84b..b92b280ab 100644
--- a/src/SAML2/XML/md/RoleDescriptor.php
+++ b/src/SAML2/XML/md/RoleDescriptor.php
@@ -23,21 +23,21 @@ class RoleDescriptor extends SignedElementHelper
     /**
      * The ID of this element.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $ID;
 
     /**
      * How long this element is valid, as a unix timestamp.
      *
-     * @var int|NULL
+     * @var int|null
      */
     public $validUntil;
 
     /**
      * The length of time this element can be cached, as string.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $cacheDuration;
 
@@ -51,7 +51,7 @@ class RoleDescriptor extends SignedElementHelper
     /**
      * Error URL for this role.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $errorURL;
 
@@ -76,9 +76,9 @@ class RoleDescriptor extends SignedElementHelper
     /**
      * Organization of this role.
      *
-     * @var \SAML2\XML\md\Organization|NULL
+     * @var \SAML2\XML\md\Organization|null
      */
-    public $Organization = NULL;
+    public $Organization = null;
 
     /**
      * ContactPerson elements for this role.
@@ -93,17 +93,17 @@ class RoleDescriptor extends SignedElementHelper
      * Initialize a RoleDescriptor.
      *
      * @param string          $elementName The name of this element.
-     * @param \DOMElement|NULL $xml         The XML element we should load.
+     * @param \DOMElement|null $xml         The XML element we should load.
      * @throws \Exception
      */
-    protected function __construct($elementName, \DOMElement $xml = NULL)
+    protected function __construct($elementName, \DOMElement $xml = null)
     {
         assert('is_string($elementName)');
 
         parent::__construct($xml);
         $this->elementName = $elementName;
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -199,5 +199,4 @@ protected function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/SPSSODescriptor.php b/src/SAML2/XML/md/SPSSODescriptor.php
index 3f765d6fb..7b0f7b7db 100644
--- a/src/SAML2/XML/md/SPSSODescriptor.php
+++ b/src/SAML2/XML/md/SPSSODescriptor.php
@@ -14,16 +14,16 @@ class SPSSODescriptor extends SSODescriptorType
     /**
      * Whether this SP signs authentication requests.
      *
-     * @var bool|NULL
+     * @var bool|null
      */
-    public $AuthnRequestsSigned = NULL;
+    public $AuthnRequestsSigned = null;
 
     /**
      * Whether this SP wants the Assertion elements to be signed.
      *
-     * @var bool|NULL
+     * @var bool|null
      */
-    public $WantAssertionsSigned = NULL;
+    public $WantAssertionsSigned = null;
 
     /**
      * List of AssertionConsumerService endpoints for this SP.
@@ -46,18 +46,18 @@ class SPSSODescriptor extends SSODescriptorType
     /**
      * Initialize a SPSSODescriptor.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct('md:SPSSODescriptor', $xml);
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
-        $this->AuthnRequestsSigned = Utils::parseBoolean($xml, 'AuthnRequestsSigned', NULL);
-        $this->WantAssertionsSigned = Utils::parseBoolean($xml, 'WantAssertionsSigned', NULL);
+        $this->AuthnRequestsSigned = Utils::parseBoolean($xml, 'AuthnRequestsSigned', null);
+        $this->WantAssertionsSigned = Utils::parseBoolean($xml, 'WantAssertionsSigned', null);
 
         foreach (Utils::xpQuery($xml, './saml_metadata:AssertionConsumerService') as $ep) {
             $this->AssertionConsumerService[] = new IndexedEndpointType($ep);
@@ -83,15 +83,15 @@ public function toXML(\DOMElement $parent)
 
         $e = parent::toXML($parent);
 
-        if ($this->AuthnRequestsSigned === TRUE) {
+        if ($this->AuthnRequestsSigned === true) {
             $e->setAttribute('AuthnRequestsSigned', 'true');
-        } elseif ($this->AuthnRequestsSigned === FALSE) {
+        } elseif ($this->AuthnRequestsSigned === false) {
             $e->setAttribute('AuthnRequestsSigned', 'false');
         }
 
-        if ($this->WantAssertionsSigned === TRUE) {
+        if ($this->WantAssertionsSigned === true) {
             $e->setAttribute('WantAssertionsSigned', 'true');
-        } elseif ($this->WantAssertionsSigned === FALSE) {
+        } elseif ($this->WantAssertionsSigned === false) {
             $e->setAttribute('WantAssertionsSigned', 'false');
         }
 
@@ -103,5 +103,4 @@ public function toXML(\DOMElement $parent)
             $acs->toXML($e);
         }
     }
-
 }
diff --git a/src/SAML2/XML/md/SSODescriptorType.php b/src/SAML2/XML/md/SSODescriptorType.php
index c043a6fec..f0ee16a8d 100644
--- a/src/SAML2/XML/md/SSODescriptorType.php
+++ b/src/SAML2/XML/md/SSODescriptorType.php
@@ -52,15 +52,15 @@ abstract class SSODescriptorType extends RoleDescriptor
      * Initialize a SSODescriptor.
      *
      * @param string          $elementName The name of this element.
-     * @param \DOMElement|NULL $xml         The XML element we should load.
+     * @param \DOMElement|null $xml         The XML element we should load.
      */
-    protected function __construct($elementName, \DOMElement $xml = NULL)
+    protected function __construct($elementName, \DOMElement $xml = null)
     {
         assert('is_string($elementName)');
 
         parent::__construct($elementName, $xml);
 
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -106,9 +106,8 @@ protected function toXML(\DOMElement $parent)
             $ep->toXML($e, 'md:ManageNameIDService');
         }
 
-        Utils::addStrings($e, Constants::NS_MD, 'md:NameIDFormat', FALSE, $this->NameIDFormat);
+        Utils::addStrings($e, Constants::NS_MD, 'md:NameIDFormat', false, $this->NameIDFormat);
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/md/UnknownRoleDescriptor.php b/src/SAML2/XML/md/UnknownRoleDescriptor.php
index 37447cae0..6656d4efa 100644
--- a/src/SAML2/XML/md/UnknownRoleDescriptor.php
+++ b/src/SAML2/XML/md/UnknownRoleDescriptor.php
@@ -40,5 +40,4 @@ public function toXML(\DOMElement $parent)
     {
         $this->xml->toXML($parent);
     }
-
 }
diff --git a/src/SAML2/XML/mdattr/EntityAttributes.php b/src/SAML2/XML/mdattr/EntityAttributes.php
index 3e3a50172..92612bafe 100644
--- a/src/SAML2/XML/mdattr/EntityAttributes.php
+++ b/src/SAML2/XML/mdattr/EntityAttributes.php
@@ -31,11 +31,11 @@ class EntityAttributes
     /**
      * Create a EntityAttributes element.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -46,7 +46,6 @@ public function __construct(\DOMElement $xml = NULL)
                 $this->children[] = new Chunk($node);
             }
         }
-
     }
 
     /**
@@ -71,5 +70,4 @@ public function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/mdrpi/Common.php b/src/SAML2/XML/mdrpi/Common.php
index 98fc43e84..264112012 100644
--- a/src/SAML2/XML/mdrpi/Common.php
+++ b/src/SAML2/XML/mdrpi/Common.php
@@ -11,5 +11,4 @@
 class Common
 {
     const NS_MDRPI = 'urn:oasis:names:tc:SAML:metadata:rpi';
-
 }
diff --git a/src/SAML2/XML/mdrpi/PublicationInfo.php b/src/SAML2/XML/mdrpi/PublicationInfo.php
index ee7da3279..8cc9bada2 100644
--- a/src/SAML2/XML/mdrpi/PublicationInfo.php
+++ b/src/SAML2/XML/mdrpi/PublicationInfo.php
@@ -22,14 +22,14 @@ class PublicationInfo
     /**
      * The creation timestamp for the metadata, as a UNIX timestamp.
      *
-     * @var int|NULL
+     * @var int|null
      */
     public $creationInstant;
 
     /**
      * Identifier for this metadata publication.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $publicationId;
 
@@ -45,12 +45,12 @@ class PublicationInfo
     /**
      * Create/parse a mdrpi:PublicationInfo element.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -90,17 +90,16 @@ public function toXML(\DOMElement $parent)
 
         $e->setAttribute('publisher', $this->publisher);
 
-        if ($this->creationInstant !== NULL) {
+        if ($this->creationInstant !== null) {
             $e->setAttribute('creationInstant', gmdate('Y-m-d\TH:i:s\Z', $this->creationInstant));
         }
 
-        if ($this->publicationId !== NULL) {
+        if ($this->publicationId !== null) {
             $e->setAttribute('publicationId', $this->publicationId);
         }
 
-        Utils::addStrings($e, Common::NS_MDRPI, 'mdrpi:UsagePolicy', TRUE, $this->UsagePolicy);
+        Utils::addStrings($e, Common::NS_MDRPI, 'mdrpi:UsagePolicy', true, $this->UsagePolicy);
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/mdrpi/RegistrationInfo.php b/src/SAML2/XML/mdrpi/RegistrationInfo.php
index 611a8654f..f3a7ca745 100644
--- a/src/SAML2/XML/mdrpi/RegistrationInfo.php
+++ b/src/SAML2/XML/mdrpi/RegistrationInfo.php
@@ -22,7 +22,7 @@ class RegistrationInfo
     /**
      * The registration timestamp for the metadata, as a UNIX timestamp.
      *
-     * @var int|NULL
+     * @var int|null
      */
     public $registrationInstant;
 
@@ -38,12 +38,12 @@ class RegistrationInfo
     /**
      * Create/parse a mdrpi:RegistrationInfo element.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -82,13 +82,12 @@ public function toXML(\DOMElement $parent)
 
         $e->setAttribute('registrationAuthority', $this->registrationAuthority);
 
-        if ($this->registrationInstant !== NULL) {
+        if ($this->registrationInstant !== null) {
             $e->setAttribute('registrationInstant', gmdate('Y-m-d\TH:i:s\Z', $this->registrationInstant));
         }
 
-        Utils::addStrings($e, Common::NS_MDRPI, 'mdrpi:RegistrationPolicy', TRUE, $this->RegistrationPolicy);
+        Utils::addStrings($e, Common::NS_MDRPI, 'mdrpi:RegistrationPolicy', true, $this->RegistrationPolicy);
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/mdui/DiscoHints.php b/src/SAML2/XML/mdui/DiscoHints.php
index c566bfad2..0a0291142 100644
--- a/src/SAML2/XML/mdui/DiscoHints.php
+++ b/src/SAML2/XML/mdui/DiscoHints.php
@@ -51,11 +51,11 @@ class DiscoHints
     /**
      * Create a DiscoHints element.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -72,7 +72,7 @@ public function __construct(\DOMElement $xml = NULL)
      * Convert this DiscoHints to XML.
      *
      * @param \DOMElement $parent The element we should append to.
-     * @return \DOMElement|NULL
+     * @return \DOMElement|null
      */
     public function toXML(\DOMElement $parent)
     {
@@ -96,14 +96,13 @@ public function toXML(\DOMElement $parent)
                 }
             }
 
-            Utils::addStrings($e, self::NS, 'mdui:IPHint', FALSE, $this->IPHint);
-            Utils::addStrings($e, self::NS, 'mdui:DomainHint', FALSE, $this->DomainHint);
-            Utils::addStrings($e, self::NS, 'mdui:GeolocationHint', FALSE, $this->GeolocationHint);
+            Utils::addStrings($e, self::NS, 'mdui:IPHint', false, $this->IPHint);
+            Utils::addStrings($e, self::NS, 'mdui:DomainHint', false, $this->DomainHint);
+            Utils::addStrings($e, self::NS, 'mdui:GeolocationHint', false, $this->GeolocationHint);
 
             return $e;
         }
 
-        return NULL;
+        return null;
     }
-
 }
diff --git a/src/SAML2/XML/mdui/Keywords.php b/src/SAML2/XML/mdui/Keywords.php
index 1acca098b..7e4cb3b83 100644
--- a/src/SAML2/XML/mdui/Keywords.php
+++ b/src/SAML2/XML/mdui/Keywords.php
@@ -27,12 +27,12 @@ class Keywords
     /**
      * Initialize a Keywords.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -67,7 +67,7 @@ public function toXML(\DOMElement $parent)
         $e->setAttribute('xml:lang', $this->lang);
         $value = '';
         foreach ($this->Keywords as $keyword) {
-            if (strpos($keyword, "+") !== FALSE) {
+            if (strpos($keyword, "+") !== false) {
                 throw new \Exception('Keywords may not contain a "+" character.');
             }
             $value .= str_replace(' ', '+', $keyword) . ' ';
@@ -78,5 +78,4 @@ public function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/mdui/Logo.php b/src/SAML2/XML/mdui/Logo.php
index aa5a0e2fb..e31a5a12d 100644
--- a/src/SAML2/XML/mdui/Logo.php
+++ b/src/SAML2/XML/mdui/Logo.php
@@ -41,12 +41,12 @@ class Logo
     /**
      * Initialize a Logo.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -62,7 +62,7 @@ public function __construct(\DOMElement $xml = NULL)
         $this->url = $xml->textContent;
         $this->width = (int) $xml->getAttribute('width');
         $this->height = (int) $xml->getAttribute('height');
-        $this->lang = $xml->hasAttribute('xml:lang') ? $xml->getAttribute('xml:lang') : NULL;
+        $this->lang = $xml->hasAttribute('xml:lang') ? $xml->getAttribute('xml:lang') : null;
     }
 
     /**
@@ -90,5 +90,4 @@ public function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/mdui/UIInfo.php b/src/SAML2/XML/mdui/UIInfo.php
index 324760724..aa52b9d3d 100644
--- a/src/SAML2/XML/mdui/UIInfo.php
+++ b/src/SAML2/XML/mdui/UIInfo.php
@@ -72,11 +72,11 @@ class UIInfo
     /**
      * Create a UIInfo element.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -105,7 +105,7 @@ public function __construct(\DOMElement $xml = NULL)
      * Convert this UIInfo to XML.
      *
      * @param \DOMElement $parent The element we should append to.
-     * @return \DOMElement|NULL
+     * @return \DOMElement|null
      */
     public function toXML(\DOMElement $parent)
     {
@@ -116,7 +116,7 @@ public function toXML(\DOMElement $parent)
         assert('is_array($this->Logo)');
         assert('is_array($this->children)');
 
-        $e = NULL;
+        $e = null;
         if (!empty($this->DisplayName)
          || !empty($this->Description)
          || !empty($this->InformationURL)
@@ -129,10 +129,10 @@ public function toXML(\DOMElement $parent)
             $e = $doc->createElementNS(self::NS, 'mdui:UIInfo');
             $parent->appendChild($e);
 
-            Utils::addStrings($e, self::NS, 'mdui:DisplayName', TRUE, $this->DisplayName);
-            Utils::addStrings($e, self::NS, 'mdui:Description', TRUE, $this->Description);
-            Utils::addStrings($e, self::NS, 'mdui:InformationURL', TRUE, $this->InformationURL);
-            Utils::addStrings($e, self::NS, 'mdui:PrivacyStatementURL', TRUE, $this->PrivacyStatementURL);
+            Utils::addStrings($e, self::NS, 'mdui:DisplayName', true, $this->DisplayName);
+            Utils::addStrings($e, self::NS, 'mdui:Description', true, $this->Description);
+            Utils::addStrings($e, self::NS, 'mdui:InformationURL', true, $this->InformationURL);
+            Utils::addStrings($e, self::NS, 'mdui:PrivacyStatementURL', true, $this->PrivacyStatementURL);
 
             if (!empty($this->Keywords)) {
                 foreach ($this->Keywords as $child) {
@@ -155,5 +155,4 @@ public function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/saml/Attribute.php b/src/SAML2/XML/saml/Attribute.php
index a126de1ea..6425e4a4c 100644
--- a/src/SAML2/XML/saml/Attribute.php
+++ b/src/SAML2/XML/saml/Attribute.php
@@ -22,16 +22,16 @@ class Attribute
     /**
      * The NameFormat of this attribute.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $NameFormat;
 
     /**
      * The FriendlyName of this attribute.
      *
-     * @var string|NULL
+     * @var string|null
      */
-    public $FriendlyName = NULL;
+    public $FriendlyName = null;
 
     /**
      * List of attribute values.
@@ -45,12 +45,12 @@ class Attribute
     /**
      * Initialize an Attribute.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -120,5 +120,4 @@ public function toXML(\DOMElement $parent)
     {
         return $this->toXMLInternal($parent, Constants::NS_SAML, 'saml:Attribute');
     }
-
 }
diff --git a/src/SAML2/XML/saml/NameID.php b/src/SAML2/XML/saml/NameID.php
index 77fe7a185..04678f94a 100644
--- a/src/SAML2/XML/saml/NameID.php
+++ b/src/SAML2/XML/saml/NameID.php
@@ -15,28 +15,28 @@ class NameID
     /**
      * The NameQualifier or the NameID.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $NameQualifier;
 
     /**
      * The SPNameQualifier or the NameID.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $SPNameQualifier;
 
     /**
      * The Format or the NameID.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $Format;
 
     /**
      * The SPProvidedID or the NameID.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $SPProvidedID;
 
@@ -50,11 +50,11 @@ class NameID
     /**
      * Initialize a saml:NameID.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -80,10 +80,10 @@ public function __construct(\DOMElement $xml = NULL)
     /**
      * Convert this NameID to XML.
      *
-     * @param  \DOMElement|NULL $parent The element we should append to.
+     * @param  \DOMElement|null $parent The element we should append to.
      * @return \DOMElement      This AdditionalMetadataLocation-element.
      */
-    public function toXML(\DOMElement $parent = NULL)
+    public function toXML(\DOMElement $parent = null)
     {
         assert('is_string($this->NameQualifier) || is_null($this->NameQualifier)');
         assert('is_string($this->SPNameQualifier) || is_null($this->SPNameQualifier)');
@@ -91,7 +91,7 @@ public function toXML(\DOMElement $parent = NULL)
         assert('is_string($this->SPProvidedID) || is_null($this->SPProvidedID)');
         assert('is_string($this->value)');
 
-        if ($parent === NULL) {
+        if ($parent === null) {
             $parent = DOMDocumentFactory::create();
             $doc = $parent;
         } else {
@@ -100,19 +100,19 @@ public function toXML(\DOMElement $parent = NULL)
         $e = $doc->createElementNS(Constants::NS_SAML, 'saml:NameID');
         $parent->appendChild($e);
 
-        if ($this->NameQualifier !== NULL) {
+        if ($this->NameQualifier !== null) {
             $e->setAttribute('NameQualifier', $this->NameQualifier);
         }
 
-        if ($this->SPNameQualifier !== NULL) {
+        if ($this->SPNameQualifier !== null) {
             $e->setAttribute('SPNameQualifier', $this->SPNameQualifier);
         }
 
-        if ($this->Format !== NULL) {
+        if ($this->Format !== null) {
             $e->setAttribute('Format', $this->Format);
         }
 
-        if ($this->SPProvidedID !== NULL) {
+        if ($this->SPProvidedID !== null) {
             $e->setAttribute('SPProvidedID', $this->SPProvidedID);
         }
 
@@ -121,5 +121,4 @@ public function toXML(\DOMElement $parent = NULL)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/saml/SubjectConfirmation.php b/src/SAML2/XML/saml/SubjectConfirmation.php
index a08f62497..cf561c16a 100644
--- a/src/SAML2/XML/saml/SubjectConfirmation.php
+++ b/src/SAML2/XML/saml/SubjectConfirmation.php
@@ -22,26 +22,26 @@ class SubjectConfirmation
     /**
      * The NameID of the entity that can use this element to verify the Subject.
      *
-     * @var \SAML2\XML\saml\NameID|NULL
+     * @var \SAML2\XML\saml\NameID|null
      */
     public $NameID;
 
     /**
      * SubjectConfirmationData element with extra data for verification of the Subject.
      *
-     * @var \SAML2\XML\saml\SubjectConfirmationData|NULL
+     * @var \SAML2\XML\saml\SubjectConfirmationData|null
      */
     public $SubjectConfirmationData;
 
     /**
      * Initialize (and parse? a SubjectConfirmation element.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      * @throws \Exception
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -91,5 +91,4 @@ public function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/saml/SubjectConfirmationData.php b/src/SAML2/XML/saml/SubjectConfirmationData.php
index 3628c5658..43d58a405 100644
--- a/src/SAML2/XML/saml/SubjectConfirmationData.php
+++ b/src/SAML2/XML/saml/SubjectConfirmationData.php
@@ -18,35 +18,35 @@ class SubjectConfirmationData
     /**
      * The time before this element is valid, as an unix timestamp.
      *
-     * @var int|NULL
+     * @var int|null
      */
     public $NotBefore;
 
     /**
      * The time after which this element is invalid, as an unix timestamp.
      *
-     * @var int|NULL
+     * @var int|null
      */
     public $NotOnOrAfter;
 
     /**
      * The Recipient this Subject is valid for. Either an entity or a location.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $Recipient;
 
     /**
      * The ID of the AuthnRequest this is a response to.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $InResponseTo;
 
     /**
      * The IP(v6) address of the user.
      *
-     * @var string|NULL
+     * @var string|null
      */
     public $Address;
 
@@ -63,11 +63,11 @@ class SubjectConfirmationData
     /**
      * Initialize (and parse) a SubjectConfirmationData element.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
@@ -86,7 +86,7 @@ public function __construct(\DOMElement $xml = NULL)
         if ($xml->hasAttribute('Address')) {
             $this->Address = $xml->getAttribute('Address');
         }
-        for ($n = $xml->firstChild; $n !== NULL; $n = $n->nextSibling) {
+        for ($n = $xml->firstChild; $n !== null; $n = $n->nextSibling) {
             if (!($n instanceof \DOMElement)) {
                 continue;
             }
@@ -144,5 +144,4 @@ public function toXML(\DOMElement $parent)
 
         return $e;
     }
-
 }
diff --git a/src/SAML2/XML/samlp/Extensions.php b/src/SAML2/XML/samlp/Extensions.php
index 45c9d5a8e..9f6db1f8c 100644
--- a/src/SAML2/XML/samlp/Extensions.php
+++ b/src/SAML2/XML/samlp/Extensions.php
@@ -48,5 +48,4 @@ public static function addList(\DOMElement $parent, array $extensions)
             $ext->toXML($extElement);
         }
     }
-
 }
diff --git a/src/SAML2/XML/shibmd/Scope.php b/src/SAML2/XML/shibmd/Scope.php
index 29a15c5e0..d3d1ca32c 100644
--- a/src/SAML2/XML/shibmd/Scope.php
+++ b/src/SAML2/XML/shibmd/Scope.php
@@ -27,23 +27,23 @@ class Scope
     /**
      * Whether this is a regexp scope.
      *
-     * @var bool|NULL
+     * @var bool|null
      */
-    public $regexp = NULL;
+    public $regexp = null;
 
     /**
      * Create a Scope.
      *
-     * @param \DOMElement|NULL $xml The XML element we should load.
+     * @param \DOMElement|null $xml The XML element we should load.
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
-        if ($xml === NULL) {
+        if ($xml === null) {
             return;
         }
 
         $this->scope = $xml->textContent;
-        $this->regexp = Utils::parseBoolean($xml, 'regexp', NULL);
+        $this->regexp = Utils::parseBoolean($xml, 'regexp', null);
     }
 
     /**
@@ -64,13 +64,12 @@ public function toXML(\DOMElement $parent)
 
         $e->appendChild($doc->createTextNode($this->scope));
 
-        if ($this->regexp === TRUE) {
+        if ($this->regexp === true) {
             $e->setAttribute('regexp', 'true');
-        } elseif ($this->regexp === FALSE) {
+        } elseif ($this->regexp === false) {
             $e->setAttribute('regexp', 'false');
         }
 
         return $e;
     }
-
 }
diff --git a/tests/SAML2/AssertionTest.php b/tests/SAML2/AssertionTest.php
index 606f1c323..57bf65c40 100644
--- a/tests/SAML2/AssertionTest.php
+++ b/tests/SAML2/AssertionTest.php
@@ -41,7 +41,6 @@ public function testMarshalling()
         );
         $this->assertCount(1, $authnContextElements);
         $this->assertEquals('someAuthnContext', $authnContextElements[0]->textContent);
-
     }
 
     public function testUnmarshalling()
@@ -161,8 +160,8 @@ public function testAuthnContextDeclAndRefConstraint()
         try {
             $assertion->setAuthnContextDecl(new Chunk($document->documentElement));
             $assertion->setAuthnContextDeclRef('/relative/path/to/document.xml');
+        } catch (\Exception $e) {
         }
-        catch (\Exception $e) {}
         $this->assertNotEmpty($e);
 
         // Try again in reverse order for good measure.
@@ -172,8 +171,8 @@ public function testAuthnContextDeclAndRefConstraint()
         try {
             $assertion->setAuthnContextDeclRef('/relative/path/to/document.xml');
             $assertion->setAuthnContextDecl(new Chunk($document->documentElement));
+        } catch (\Exception $e) {
         }
-        catch (\Exception $e) {}
         $this->assertNotEmpty($e);
 
         // Try with unmarshalling
@@ -202,8 +201,8 @@ public function testAuthnContextDeclAndRefConstraint()
         $e = null;
         try {
             new Assertion($document->documentElement);
+        } catch (\Exception $e) {
         }
-        catch (\Exception $e) {}
         $this->assertNotEmpty($e);
     }
 
@@ -229,8 +228,7 @@ public function testMustHaveClassRefOrDeclOrDeclRef()
         $e = null;
         try {
             $assertion = new Assertion($document->firstChild);
-        }
-        catch (\Exception $e) {
+        } catch (\Exception $e) {
         }
         $this->assertNotEmpty($e);
     }
@@ -329,4 +327,3 @@ public function testHasEncryptedAttributes()
         $this->assertTrue($assertion->hasEncryptedAttributes());
     }
 }
-
diff --git a/tests/SAML2/Certificate/FingerprintTest.php b/tests/SAML2/Certificate/FingerprintTest.php
index 4e9b58101..57ddf3b80 100644
--- a/tests/SAML2/Certificate/FingerprintTest.php
+++ b/tests/SAML2/Certificate/FingerprintTest.php
@@ -17,6 +17,6 @@ class FingerprintTest extends \PHPUnit_Framework_TestCase
      */
     public function fails_on_invalid_fingerprint_data()
     {
-        $this->fingerprint = new Fingerprint(NULL);
+        $this->fingerprint = new Fingerprint(null);
     }
 }
diff --git a/tests/SAML2/DOMDocumentFactoryTest.php b/tests/SAML2/DOMDocumentFactoryTest.php
index 25bcf4a79..b97a6dba6 100644
--- a/tests/SAML2/DOMDocumentFactoryTest.php
+++ b/tests/SAML2/DOMDocumentFactoryTest.php
@@ -136,8 +136,8 @@ public function nonStringProvider()
             'integer' => array(1),
             'float'   => array(1.234),
             'object'  => array(new \stdClass()),
-            'null'    => array(NULL),
-            'boolean' => array(FALSE),
+            'null'    => array(null),
+            'boolean' => array(false),
             'array'   => array(array()),
         );
     }
diff --git a/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php b/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
index 0cf5a160d..2359877f7 100644
--- a/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
+++ b/tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
@@ -57,5 +57,4 @@ public function an_unsuccessful_response_is_not_valid_and_generates_a_proper_err
         $this->assertCount(1, $errors);
         $this->assertEquals('foo/bar this is a test message', $errors[0]);
     }
-
 }
diff --git a/tests/SAML2/Signature/MockChainedValidator.php b/tests/SAML2/Signature/MockChainedValidator.php
index 39f3f323a..012a7af86 100644
--- a/tests/SAML2/Signature/MockChainedValidator.php
+++ b/tests/SAML2/Signature/MockChainedValidator.php
@@ -48,5 +48,4 @@ public function hasValidSignature(
     ) {
         return $this->isValid;
     }
-
 }
diff --git a/tests/SAML2/SignedElementHelperMock.php b/tests/SAML2/SignedElementHelperMock.php
index 6a3a04516..2eab3cc98 100644
--- a/tests/SAML2/SignedElementHelperMock.php
+++ b/tests/SAML2/SignedElementHelperMock.php
@@ -10,7 +10,7 @@ class SignedElementHelperMock extends SignedElementHelper
     /**
      * @param \DOMElement $xml
      */
-    public function __construct(\DOMElement $xml = NULL)
+    public function __construct(\DOMElement $xml = null)
     {
         parent::__construct($xml);
     }
diff --git a/tests/SAML2/Utilities/FileTest.php b/tests/SAML2/Utilities/FileTest.php
index be04f7944..d679939f9 100644
--- a/tests/SAML2/Utilities/FileTest.php
+++ b/tests/SAML2/Utilities/FileTest.php
@@ -23,7 +23,7 @@ public function when_loading_a_non_existant_file_an_exception_is_thrown()
      */
     public function passing_nonstring_filename_throws_exception()
     {
-        File::getFileContents(NULL);
+        File::getFileContents(null);
     }
 
     /**
diff --git a/tests/SAML2/UtilsTest.php b/tests/SAML2/UtilsTest.php
index 8760cdef0..f818b1549 100644
--- a/tests/SAML2/UtilsTest.php
+++ b/tests/SAML2/UtilsTest.php
@@ -71,7 +71,7 @@ public function testGetAddStrings()
             $document->firstChild,
             'testns',
             'ns:somenode',
-            FALSE,
+            false,
             array('value1', 'value2')
         );
         $this->assertEquals(
@@ -87,7 +87,7 @@ public function testGetAddStrings()
             $document->firstChild,
             'testns',
             'ns:somenode',
-            FALSE,
+            false,
             array('value1', 'value2')
         );
         $this->assertEquals(
@@ -103,7 +103,7 @@ public function testGetAddStrings()
             $document->firstChild,
             'testns',
             'ns:somenode',
-            TRUE,
+            true,
             array('en' => 'value (en)', 'no' => 'value (no)')
         );
         $this->assertEquals(
@@ -119,7 +119,7 @@ public function testGetAddStrings()
             $document->firstChild,
             'testns',
             'ns:somenode',
-            TRUE,
+            true,
             array('en' => 'value (en)', 'no' => 'value (no)')
         );
         $this->assertEquals(
diff --git a/tests/SAML2/XML/md/AffiliationDescriptorTest.php b/tests/SAML2/XML/md/AffiliationDescriptorTest.php
index 0972ea0b9..723a6f85f 100644
--- a/tests/SAML2/XML/md/AffiliationDescriptorTest.php
+++ b/tests/SAML2/XML/md/AffiliationDescriptorTest.php
@@ -91,6 +91,4 @@ public function testUnmarshallingWithoutOwner()
         $this->setExpectedException('Exception', 'Missing affiliationOwnerID on AffiliationDescriptor.');
         new AffiliationDescriptor($document->firstChild);
     }
-
-
 }
diff --git a/tests/SAML2/XML/md/EndpointTypeTest.php b/tests/SAML2/XML/md/EndpointTypeTest.php
index 1bb5f5cff..288d97d9d 100644
--- a/tests/SAML2/XML/md/EndpointTypeTest.php
+++ b/tests/SAML2/XML/md/EndpointTypeTest.php
@@ -49,13 +49,13 @@ public function testUnmarshalling()
 XML
         );
         $endpointType = new EndpointType($document->firstChild);
-        $this->assertEquals(TRUE, $endpointType->hasAttributeNS('urn:test', 'attr'));
+        $this->assertEquals(true, $endpointType->hasAttributeNS('urn:test', 'attr'));
         $this->assertEquals('value', $endpointType->getAttributeNS('urn:test', 'attr'));
-        $this->assertEquals(FALSE, $endpointType->hasAttributeNS('urn:test', 'invalid'));
+        $this->assertEquals(false, $endpointType->hasAttributeNS('urn:test', 'invalid'));
         $this->assertEquals('', $endpointType->getAttributeNS('urn:test', 'invalid'));
 
         $endpointType->removeAttributeNS('urn:test', 'attr');
-        $this->assertEquals(FALSE, $endpointType->hasAttributeNS('urn:test', 'attr'));
+        $this->assertEquals(false, $endpointType->hasAttributeNS('urn:test', 'attr'));
         $this->assertEquals('', $endpointType->getAttributeNS('urn:test', 'attr'));
 
         $endpointType->setAttributeNS('urn:test2', 'test2:attr2', 'value2');
@@ -68,7 +68,6 @@ public function testUnmarshalling()
         $endpointTypeElement = $endpointTypeElements[0];
 
         $this->assertEquals('value2', $endpointTypeElement->getAttributeNS('urn:test2', 'attr2'));
-        $this->assertEquals(FALSE, $endpointTypeElement->hasAttributeNS('urn:test', 'attr'));
-
+        $this->assertEquals(false, $endpointTypeElement->hasAttributeNS('urn:test', 'attr'));
     }
 }
diff --git a/tests/SAML2/XML/md/IndexedEndpointTypeTest.php b/tests/SAML2/XML/md/IndexedEndpointTypeTest.php
index 1f3404dbe..ab396571c 100644
--- a/tests/SAML2/XML/md/IndexedEndpointTypeTest.php
+++ b/tests/SAML2/XML/md/IndexedEndpointTypeTest.php
@@ -16,7 +16,7 @@ public function testMarshalling()
         $indexedEndpointType->Binding = 'TestBinding';
         $indexedEndpointType->Location = 'TestLocation';
         $indexedEndpointType->index = 42;
-        $indexedEndpointType->isDefault = FALSE;
+        $indexedEndpointType->isDefault = false;
 
         $document = DOMDocumentFactory::fromString('<root />');
         $indexedEndpointTypeElement = $indexedEndpointType->toXML($document->firstChild, 'md:Test');
@@ -30,14 +30,14 @@ public function testMarshalling()
         $this->assertEquals('42', $indexedEndpointElement->getAttribute('index'));
         $this->assertEquals('false', $indexedEndpointElement->getAttribute('isDefault'));
 
-        $indexedEndpointType->isDefault = TRUE;
+        $indexedEndpointType->isDefault = true;
         $document->loadXML('<root />');
         $indexedEndpointTypeElement = $indexedEndpointType->toXML($document->firstChild, 'md:Test');
         $indexedEndpointTypeElement = Utils::xpQuery($indexedEndpointTypeElement, '/root/saml_metadata:Test');
         $this->assertCount(1, $indexedEndpointTypeElement);
         $this->assertEquals('true', $indexedEndpointTypeElement[0]->getAttribute('isDefault'));
 
-        $indexedEndpointType->isDefault = NULL;
+        $indexedEndpointType->isDefault = null;
         $document->loadXML('<root />');
         $indexedEndpointTypeElement = $indexedEndpointType->toXML($document->firstChild, 'md:Test');
         $indexedEndpointTypeElement = Utils::xpQuery($indexedEndpointTypeElement, '/root/saml_metadata:Test');
diff --git a/tests/SAML2/XML/md/RoleDescriptorMock.php b/tests/SAML2/XML/md/RoleDescriptorMock.php
index d98caa20e..a9df29edd 100644
--- a/tests/SAML2/XML/md/RoleDescriptorMock.php
+++ b/tests/SAML2/XML/md/RoleDescriptorMock.php
@@ -4,12 +4,15 @@
 
 use SAML2\Constants;
 
-class RoleDescriptorMock extends RoleDescriptor {
-    public function __construct(\DOMElement $xml = NULL) {
+class RoleDescriptorMock extends RoleDescriptor
+{
+    public function __construct(\DOMElement $xml = null)
+    {
         parent::__construct('md:RoleDescriptor', $xml);
     }
 
-    public function toXML(\DOMElement $parent) {
+    public function toXML(\DOMElement $parent)
+    {
         $xml = parent::toXML($parent);
         $xml->setAttributeNS(Constants::NS_XSI, 'xsi:type', 'myns:MyElement');
         $xml->setAttributeNS('http://example.org/mynsdefinition', 'myns:tmp', 'tmp');
diff --git a/tests/SAML2/XML/saml/AttributeTest.php b/tests/SAML2/XML/saml/AttributeTest.php
index 5ba8e73e1..a1891613f 100644
--- a/tests/SAML2/XML/saml/AttributeTest.php
+++ b/tests/SAML2/XML/saml/AttributeTest.php
@@ -54,7 +54,6 @@ public function testUnmarshalling()
         $this->assertCount(2, $attribute->AttributeValue);
         $this->assertEquals('FirstValue', (string)$attribute->AttributeValue[0]);
         $this->assertEquals('SecondValue', (string)$attribute->AttributeValue[1]);
-
     }
 
     public function testUnmarshallingFailure()
diff --git a/tests/SAML2/XML/saml/NameIDTest.php b/tests/SAML2/XML/saml/NameIDTest.php
index f66234464..fb92cac8c 100644
--- a/tests/SAML2/XML/saml/NameIDTest.php
+++ b/tests/SAML2/XML/saml/NameIDTest.php
@@ -49,7 +49,3 @@ public function testUnmarshalling()
         $this->assertEquals('TheNameIDValue', $nameId->value);
     }
 }
-
-
-
-

From 17734d625a9da8e795999eba12225eeb9702021e Mon Sep 17 00:00:00 2001
From: Charles Bell <cb8@users.noreply.github.com>
Date: Sun, 29 Nov 2015 22:12:28 +0100
Subject: [PATCH 12/17] Update PHP_CodeSniffer configuration for PSR-2

---
 tools/phpcs/ruleset.xml | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/tools/phpcs/ruleset.xml b/tools/phpcs/ruleset.xml
index 8986c216c..e0ef3904b 100644
--- a/tools/phpcs/ruleset.xml
+++ b/tools/phpcs/ruleset.xml
@@ -11,28 +11,12 @@
     <!-- This is the rule we inherit from. If you want to exlude some specific rules, see the docs on how to do that -->
     <rule ref="PSR2"/>
 
-    <rule ref="Generic.PHP.LowerCaseConstant">
-        <exclude name="Generic.PHP.LowerCaseConstant" />
-    </rule>
-
-    <rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
-        <exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
-    </rule>
-    <rule ref="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody">
-        <exclude name="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody" />
-    </rule>
-    <rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
-        <exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
-    </rule>
-
     <rule ref="Generic.NamingConventions.UpperCaseConstantName.ConstantNotUpperCase">
         <exclude-pattern>**/Assertion.php</exclude-pattern>
         <exclude-pattern>**/LogoutRequest.php</exclude-pattern>
         <exclude-pattern>**/EncryptedAssertion.php</exclude-pattern>
     </rule>
 
-    <rule ref="Generic.PHP.UpperCaseConstant"/>
-
     <!-- Lines can be a little bit longer before they break the build -->
     <rule ref="Generic.Files.LineLength">
         <properties>

From 93c43d0c530e51600f89272014ebb56d88235595 Mon Sep 17 00:00:00 2001
From: Charles Bell <cb8@users.noreply.github.com>
Date: Sun, 29 Nov 2015 22:29:19 +0100
Subject: [PATCH 13/17] Fix LoggerInterface usage

---
 src/SAML2/Assertion/Decrypter.php                            | 3 ++-
 src/SAML2/Assertion/Processor.php                            | 3 ++-
 src/SAML2/Assertion/ProcessorBuilder.php                     | 5 +++--
 .../Assertion/Transformer/NameIdDecryptionTransformer.php    | 3 ++-
 src/SAML2/Compat/AbstractContainer.php                       | 2 +-
 src/SAML2/Compat/MockContainer.php                           | 2 +-
 src/SAML2/Compat/Ssp/Container.php                           | 2 +-
 src/SAML2/Compat/Ssp/Logger.php                              | 4 +++-
 src/SAML2/Response/Processor.php                             | 3 ++-
 src/SAML2/Signature/AbstractChainedValidator.php             | 3 ++-
 src/SAML2/Signature/FingerprintValidator.php                 | 3 ++-
 src/SAML2/Signature/PublicKeyValidator.php                   | 3 ++-
 src/SAML2/Signature/Validator.php                            | 3 ++-
 src/SAML2/Signature/ValidatorChain.php                       | 3 ++-
 14 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/src/SAML2/Assertion/Decrypter.php b/src/SAML2/Assertion/Decrypter.php
index 38892a4d1..4a5a646d5 100644
--- a/src/SAML2/Assertion/Decrypter.php
+++ b/src/SAML2/Assertion/Decrypter.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\Assertion;
 
+use Psr\Log\LoggerInterface;
 use SAML2\Assertion\Exception\NotDecryptedException;
 use SAML2\Certificate\PrivateKeyLoader;
 use SAML2\Configuration\IdentityProvider;
@@ -31,7 +32,7 @@ class Decrypter
     private $logger;
 
     public function __construct(
-        \Psr\Log\LoggerInterface $logger,
+        LoggerInterface $logger,
         IdentityProvider $identityProvider,
         ServiceProvider $serviceProvider,
         PrivateKeyLoader $privateKeyLoader
diff --git a/src/SAML2/Assertion/Processor.php b/src/SAML2/Assertion/Processor.php
index 452662174..882d73c30 100644
--- a/src/SAML2/Assertion/Processor.php
+++ b/src/SAML2/Assertion/Processor.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\Assertion;
 
+use Psr\Log\LoggerInterface;
 use SAML2\Assertion;
 use SAML2\Assertion\Exception\InvalidAssertionException;
 use SAML2\Assertion\Exception\InvalidSubjectConfirmationException;
@@ -61,7 +62,7 @@ public function __construct(
         SubjectConfirmationValidator $subjectConfirmationValidator,
         Transformer $transformer,
         IdentityProvider $identityProviderConfiguration,
-        \Psr\Log\LoggerInterface $logger
+        LoggerInterface $logger
     ) {
         $this->assertionValidator            = $assertionValidator;
         $this->signatureValidator            = $signatureValidator;
diff --git a/src/SAML2/Assertion/ProcessorBuilder.php b/src/SAML2/Assertion/ProcessorBuilder.php
index 7fd0dbe3d..a2b4baf9f 100644
--- a/src/SAML2/Assertion/ProcessorBuilder.php
+++ b/src/SAML2/Assertion/ProcessorBuilder.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\Assertion;
 
+use Psr\Log\LoggerInterface;
 use SAML2\Assertion\Transformer\DecodeBase64Transformer;
 use SAML2\Assertion\Transformer\NameIdDecryptionTransformer;
 use SAML2\Assertion\Transformer\TransformerChain;
@@ -33,7 +34,7 @@
 class ProcessorBuilder
 {
     public static function build(
-        Psr\Log\LoggerInterface $logger,
+        LoggerInterface $logger,
         Validator $signatureValidator,
         Destination $currentDestination,
         IdentityProvider $identityProvider,
@@ -112,7 +113,7 @@ private static function createSubjectConfirmationValidator(
     }
 
     private static function createAssertionTransformerChain(
-        \Psr\Log\LoggerInterface $logger,
+        LoggerInterface $logger,
         PrivateKeyLoader $keyloader,
         IdentityProvider $identityProvider,
         ServiceProvider $serviceProvider
diff --git a/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php b/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
index 93bc2063a..95c6c94b0 100644
--- a/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
+++ b/src/SAML2/Assertion/Transformer/NameIdDecryptionTransformer.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\Assertion\Transformer;
 
+use Psr\Log\LoggerInterface;
 use SAML2\Assertion;
 use SAML2\Assertion\Exception\NotDecryptedException;
 use SAML2\Certificate\PrivateKeyLoader;
@@ -36,7 +37,7 @@ class NameIdDecryptionTransformer implements
     private $logger;
 
     public function __construct(
-        \Psr\Log\LoggerInterface $logger,
+        LoggerInterface $logger,
         PrivateKeyLoader $privateKeyLoader
     ) {
         $this->privateKeyLoader = $privateKeyLoader;
diff --git a/src/SAML2/Compat/AbstractContainer.php b/src/SAML2/Compat/AbstractContainer.php
index a96120429..cdda031dd 100644
--- a/src/SAML2/Compat/AbstractContainer.php
+++ b/src/SAML2/Compat/AbstractContainer.php
@@ -6,7 +6,7 @@ abstract class AbstractContainer
 {
     /**
      * Get a PSR-3 compatible logger.
-     * @return Psr\Log\LoggerInterface
+     * @return \Psr\Log\LoggerInterface
      */
     abstract public function getLogger();
 
diff --git a/src/SAML2/Compat/MockContainer.php b/src/SAML2/Compat/MockContainer.php
index df512d8d6..c63473a0c 100644
--- a/src/SAML2/Compat/MockContainer.php
+++ b/src/SAML2/Compat/MockContainer.php
@@ -39,7 +39,7 @@ class MockContainer extends AbstractContainer
 
     /**
      * Get a PSR-3 compatible logger.
-     * @return Psr\Log\LoggerInterface
+     * @return \Psr\Log\LoggerInterface
      */
     public function getLogger()
     {
diff --git a/src/SAML2/Compat/Ssp/Container.php b/src/SAML2/Compat/Ssp/Container.php
index ea9cc77ff..4f9324f46 100644
--- a/src/SAML2/Compat/Ssp/Container.php
+++ b/src/SAML2/Compat/Ssp/Container.php
@@ -7,7 +7,7 @@
 class Container extends AbstractContainer
 {
     /**
-     * @var Psr\Log\LoggerInterface
+     * @var \Psr\Log\LoggerInterface
      */
     protected $logger;
 
diff --git a/src/SAML2/Compat/Ssp/Logger.php b/src/SAML2/Compat/Ssp/Logger.php
index 8bc25f276..7b495cd1f 100644
--- a/src/SAML2/Compat/Ssp/Logger.php
+++ b/src/SAML2/Compat/Ssp/Logger.php
@@ -2,7 +2,9 @@
 
 namespace SAML2\Compat\Ssp;
 
-class Logger implements Psr\Log\LoggerInterface
+use Psr\Log\LoggerInterface;
+
+class Logger implements LoggerInterface
 {
     /**
      * System is unusable.
diff --git a/src/SAML2/Response/Processor.php b/src/SAML2/Response/Processor.php
index 7424f954f..03ad14d93 100644
--- a/src/SAML2/Response/Processor.php
+++ b/src/SAML2/Response/Processor.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\Response;
 
+use Psr\Log\LoggerInterface;
 use SAML2\Assertion\ProcessorBuilder;
 use SAML2\Configuration\Destination;
 use SAML2\Configuration\IdentityProvider;
@@ -51,7 +52,7 @@ class Processor
      * @param \Psr\Log\LoggerInterface        $logger
      *
      */
-    public function __construct(\Psr\Log\LoggerInterface $logger)
+    public function __construct(LoggerInterface $logger)
     {
         $this->logger = $logger;
 
diff --git a/src/SAML2/Signature/AbstractChainedValidator.php b/src/SAML2/Signature/AbstractChainedValidator.php
index be0d871a7..1be459e20 100644
--- a/src/SAML2/Signature/AbstractChainedValidator.php
+++ b/src/SAML2/Signature/AbstractChainedValidator.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\Signature;
 
+use Psr\Log\LoggerInterface;
 use RobRichards\XMLSecLibs\XMLSecurityKey;
 use SAML2\SignedElement;
 
@@ -12,7 +13,7 @@ abstract class AbstractChainedValidator implements ChainedValidator
      */
     protected $logger;
 
-    public function __construct(\Psr\Log\LoggerInterface $logger)
+    public function __construct(LoggerInterface $logger)
     {
         $this->logger = $logger;
     }
diff --git a/src/SAML2/Signature/FingerprintValidator.php b/src/SAML2/Signature/FingerprintValidator.php
index e0e701852..1bb8b3185 100644
--- a/src/SAML2/Signature/FingerprintValidator.php
+++ b/src/SAML2/Signature/FingerprintValidator.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\Signature;
 
+use Psr\Log\LoggerInterface;
 use SAML2\Certificate\FingerprintLoader;
 use SAML2\Certificate\X509;
 use SAML2\Configuration\CertificateProvider;
@@ -23,7 +24,7 @@ class FingerprintValidator extends AbstractChainedValidator
     private $fingerprintLoader;
 
     public function __construct(
-        \Psr\Log\LoggerInterface $logger,
+        LoggerInterface $logger,
         FingerprintLoader $fingerprintLoader
     ) {
         $this->fingerprintLoader = $fingerprintLoader;
diff --git a/src/SAML2/Signature/PublicKeyValidator.php b/src/SAML2/Signature/PublicKeyValidator.php
index 513913f80..081219286 100644
--- a/src/SAML2/Signature/PublicKeyValidator.php
+++ b/src/SAML2/Signature/PublicKeyValidator.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\Signature;
 
+use Psr\Log\LoggerInterface;
 use SAML2\Certificate\Key;
 use SAML2\Certificate\KeyLoader;
 use SAML2\Certificate\X509;
@@ -20,7 +21,7 @@ class PublicKeyValidator extends AbstractChainedValidator
      */
     private $keyLoader;
 
-    public function __construct(\Psr\Log\LoggerInterface $logger, KeyLoader $keyLoader)
+    public function __construct(LoggerInterface $logger, KeyLoader $keyLoader)
     {
         $this->keyLoader = $keyLoader;
 
diff --git a/src/SAML2/Signature/Validator.php b/src/SAML2/Signature/Validator.php
index c74f284a8..179b4d36f 100644
--- a/src/SAML2/Signature/Validator.php
+++ b/src/SAML2/Signature/Validator.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\Signature;
 
+use Psr\Log\LoggerInterface;
 use SAML2\Certificate\FingerprintLoader;
 use SAML2\Certificate\KeyLoader;
 use SAML2\Configuration\CertificateProvider;
@@ -17,7 +18,7 @@ class Validator
      */
     private $logger;
 
-    public function __construct(\Psr\Log\LoggerInterface $logger)
+    public function __construct(LoggerInterface $logger)
     {
         $this->logger = $logger;
     }
diff --git a/src/SAML2/Signature/ValidatorChain.php b/src/SAML2/Signature/ValidatorChain.php
index 9d437e81f..9a31077b1 100644
--- a/src/SAML2/Signature/ValidatorChain.php
+++ b/src/SAML2/Signature/ValidatorChain.php
@@ -2,6 +2,7 @@
 
 namespace SAML2\Signature;
 
+use Psr\Log\LoggerInterface;
 use SAML2\Configuration\CertificateProvider;
 use SAML2\SignedElement;
 
@@ -27,7 +28,7 @@ class ValidatorChain implements ValidatorInterface
      * @param \Psr\Log\LoggerInterface           $logger
      * @param \SAML2\Signature\ChainedValidator[] $validators
      */
-    public function __construct(\Psr\Log\LoggerInterface $logger, array $validators)
+    public function __construct(LoggerInterface $logger, array $validators)
     {
         $this->logger = $logger;
 

From 3c57e67d0c165d6a6b2f12f8d32e4ef03741534b Mon Sep 17 00:00:00 2001
From: Charles Bell <cb8@users.noreply.github.com>
Date: Sun, 29 Nov 2015 23:18:06 +0100
Subject: [PATCH 14/17] Fix SimpleSAML usage

---
 src/SAML2/Compat/Ssp/Container.php              |  1 +
 src/SAML2/Compat/Ssp/Logger.php                 |  1 +
 src/SAML2/Configuration/SimpleSAMLConverter.php | 14 ++++++++------
 src/SAML2/HTTPArtifact.php                      |  8 ++++++--
 src/SAML2/SOAPClient.php                        |  6 ++++--
 5 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/SAML2/Compat/Ssp/Container.php b/src/SAML2/Compat/Ssp/Container.php
index 4f9324f46..57a32959b 100644
--- a/src/SAML2/Compat/Ssp/Container.php
+++ b/src/SAML2/Compat/Ssp/Container.php
@@ -3,6 +3,7 @@
 namespace SAML2\Compat\Ssp;
 
 use SAML2\Compat\AbstractContainer;
+use SimpleSAML_Utilities;
 
 class Container extends AbstractContainer
 {
diff --git a/src/SAML2/Compat/Ssp/Logger.php b/src/SAML2/Compat/Ssp/Logger.php
index 7b495cd1f..877c4cb4f 100644
--- a/src/SAML2/Compat/Ssp/Logger.php
+++ b/src/SAML2/Compat/Ssp/Logger.php
@@ -3,6 +3,7 @@
 namespace SAML2\Compat\Ssp;
 
 use Psr\Log\LoggerInterface;
+use SimpleSAML_Logger;
 
 class Logger implements LoggerInterface
 {
diff --git a/src/SAML2/Configuration/SimpleSAMLConverter.php b/src/SAML2/Configuration/SimpleSAMLConverter.php
index 14f563ab7..7cbd93c4e 100644
--- a/src/SAML2/Configuration/SimpleSAMLConverter.php
+++ b/src/SAML2/Configuration/SimpleSAMLConverter.php
@@ -2,14 +2,16 @@
 
 namespace SAML2\Configuration;
 
+use SimpleSAML_Configuration;
+
 /**
  * Backwards compatibility helper for SimpleSAMLphp
  */
 class SimpleSAMLConverter
 {
     /**
-     * @param SimpleSAML_Configuration $configuration
-     * @param string                   $certificatePrefix
+     * @param \SimpleSAML_Configuration $configuration
+     * @param string                    $certificatePrefix
      *
      * @return \SAML2\Configuration\IdentityProvider
      */
@@ -25,8 +27,8 @@ public static function convertToIdentityProvider(
     }
 
     /**
-     * @param SimpleSAML_Configuration $configuration
-     * @param string                   $certificatePrefix
+     * @param \SimpleSAML_Configuration $configuration
+     * @param string                    $certificatePrefix
      *
      * @return \SAML2\Configuration\ServiceProvider
      */
@@ -42,8 +44,8 @@ public static function convertToServiceProvider(
     }
 
     /**
-     * @param SimpleSAML_Configuration $configuration
-     * @param string                   $prefix
+     * @param \SimpleSAML_Configuration $configuration
+     * @param string                    $prefix
      *
      * @return array
      */
diff --git a/src/SAML2/HTTPArtifact.php b/src/SAML2/HTTPArtifact.php
index aea96f403..bb02e5837 100644
--- a/src/SAML2/HTTPArtifact.php
+++ b/src/SAML2/HTTPArtifact.php
@@ -4,6 +4,10 @@
 
 use RobRichards\XMLSecLibs\XMLSecurityKey;
 use SAML2\Utilities\Temporal;
+use SimpleSAML_Configuration;
+use SimpleSAML_Metadata_MetaDataStorageHandler;
+use SimpleSAML_Store;
+use SimpleSAML_Utilities;
 
 /**
  * Class which implements the HTTP-Artifact binding.
@@ -16,7 +20,7 @@
 class HTTPArtifact extends Binding
 {
     /**
-     * @var SimpleSAML_Configuration
+     * @var \SimpleSAML_Configuration
      */
     private $spMetadata;
 
@@ -145,7 +149,7 @@ public function receive()
     }
 
     /**
-     * @param SimpleSAML_Configuration $sp
+     * @param \SimpleSAML_Configuration $sp
      */
     public function setSPMetadata(SimpleSAML_Configuration $sp)
     {
diff --git a/src/SAML2/SOAPClient.php b/src/SAML2/SOAPClient.php
index a45404cec..a08753684 100644
--- a/src/SAML2/SOAPClient.php
+++ b/src/SAML2/SOAPClient.php
@@ -4,6 +4,8 @@
 
 use RobRichards\XMLSecLibs\XMLSecurityKey;
 use SAML2\Exception\RuntimeException;
+use SimpleSAML_Configuration;
+use SimpleSAML_Utilities;
 
 /**
  * Implementation of the SAML 2.0 SOAP binding.
@@ -20,8 +22,8 @@ class SOAPClient
      * This function sends the SOAP message to the service location and returns SOAP response
      *
      * @param  \SAML2\Message            $msg         The request that should be sent.
-     * @param  SimpleSAML_Configuration $srcMetadata The metadata of the issuer of the message.
-     * @param  SimpleSAML_Configuration $dstMetadata The metadata of the destination of the message.
+     * @param  \SimpleSAML_Configuration $srcMetadata The metadata of the issuer of the message.
+     * @param  \SimpleSAML_Configuration $dstMetadata The metadata of the destination of the message.
      * @return \SAML2\Message            The response we received.
      * @throws \Exception
      */

From a63db6749c859def8fe3d18c1b6f98fa5f728ca3 Mon Sep 17 00:00:00 2001
From: DRvanR <dvrenterghem@ibuildings.nl>
Date: Mon, 21 Dec 2015 16:22:14 +0100
Subject: [PATCH 15/17] Adapt last part of testsuite to namespaces

---
 tests/SAML2/AuthnRequestTest.php |  4 +-
 tests/SAML2/BindingTest.php      | 64 ++++++++++++++++----------------
 tests/SAML2/HTTPRedirectTest.php | 44 +++++++++++-----------
 3 files changed, 57 insertions(+), 55 deletions(-)

diff --git a/tests/SAML2/AuthnRequestTest.php b/tests/SAML2/AuthnRequestTest.php
index 4f616a535..18e7d174e 100644
--- a/tests/SAML2/AuthnRequestTest.php
+++ b/tests/SAML2/AuthnRequestTest.php
@@ -2,6 +2,8 @@
 
 namespace SAML2;
 
+use DOMDocument;
+
 /**
  * Class \SAML2\AuthnRequestTest
  */
@@ -292,7 +294,7 @@ public function testIDPlistAttributes()
     public function testRequesterId()
     {
         // basic AuthnRequest
-        $request = new SAML2_AuthnRequest();
+        $request = new AuthnRequest();
         $request->setIssuer('https://gateway.example.org/saml20/sp/metadata');
         $request->setDestination('https://tiqr.example.org/idp/profile/saml2/Redirect/SSO');
         $request->setRequesterID(array(
diff --git a/tests/SAML2/BindingTest.php b/tests/SAML2/BindingTest.php
index acf79eed9..6cd3273a1 100644
--- a/tests/SAML2/BindingTest.php
+++ b/tests/SAML2/BindingTest.php
@@ -1,27 +1,27 @@
 <?php
 
-/**
- * Class SAML2_BindingTest
- */
-class SAML2_BindingTest extends PHPUnit_Framework_TestCase
-{
+namespace SAML2;
+
+use PHPUnit_Framework_TestCase;
 
+class BindingTest extends PHPUnit_Framework_TestCase
+{
     /**
      * Test getting binding objects from string.
      */
     public function testGetBinding()
     {
-        $bind = SAML2_Binding::getBinding(SAML2_Const::BINDING_HTTP_POST);
-        $this->assertInstanceOf('SAML2_HTTPPost', $bind);
-        $bind = SAML2_Binding::getBinding(SAML2_Const::BINDING_HTTP_REDIRECT);
-        $this->assertInstanceOf('SAML2_HTTPRedirect', $bind);
-        $bind = SAML2_Binding::getBinding(SAML2_Const::BINDING_HTTP_ARTIFACT);
-        $this->assertInstanceOf('SAML2_HTTPArtifact', $bind);
-        $bind = SAML2_Binding::getBinding(SAML2_Const::BINDING_HOK_SSO);
-        $this->assertInstanceOf('SAML2_HTTPPost', $bind);
+        $bind = Binding::getBinding(Constants::BINDING_HTTP_POST);
+        $this->assertInstanceOf('SAML2\HTTPPost', $bind);
+        $bind = Binding::getBinding(Constants::BINDING_HTTP_REDIRECT);
+        $this->assertInstanceOf('SAML2\HTTPRedirect', $bind);
+        $bind = Binding::getBinding(Constants::BINDING_HTTP_ARTIFACT);
+        $this->assertInstanceOf('SAML2\HTTPArtifact', $bind);
+        $bind = Binding::getBinding(Constants::BINDING_HOK_SSO);
+        $this->assertInstanceOf('SAML2\HTTPPost', $bind);
 
         $this->setExpectedException('Exception', 'Unsupported binding:');
-        $bind = SAML2_Binding::getBinding('nonsense');
+        $bind = Binding::getBinding('nonsense');
     }
 
     /**
@@ -31,20 +31,20 @@ public function testBindingGuesserGET()
     {
         $_SERVER['REQUEST_METHOD'] = 'GET';
         $_GET = array('SAMLRequest' => 'pVJNjxMxDP0ro9yn88FOtRu1lcpWiEoLVNvCgQtKE6eNlHGG2IHl35OZLmLZQy%2BcrNh%2Bz88vXpDq%2FSDXic%2F4CN8TEBdPvUeSU2EpUkQZFDmSqHogyVru1x8eZDur5RADBx28eAG5jlBEENkFFMV2sxTfzO0dmKa11namPuoc39hba%2BfqpqlbM6%2Fb5mZ%2B1LWtj6L4ApEycikyUYYTJdgisULOqbrpyqYt67tD28iulV33VRSbvI1DxRPqzDyQrCrAk0OYUYpWB4QnnqGvVN4fkJ2emitnhoocnjyU5E5YjnrXf6TfB6TUQ9xD%2FOE0fH58%2BEueHbHOv2Yn1w8eRneqPpiU68M5DxjfdIltqTRNWQNWJc8lDaLYPfv71qHJaq5be7w0kXx%2FOOzK3af9QawWI7ecrIqr%2F9HYAyujWL2SuKheDlhcbuljlrbd7IJ3%2BlfxLsRe8XXlY8aZ0k6tkqNCcvkzsuXeh5%2F3ERTDUnBMIKrVZeS%2FF7v6DQ%3D%3D');
-        $bind = SAML2_Binding::getCurrentBinding();
-        $this->assertInstanceOf('SAML2_HTTPRedirect', $bind);
+        $bind = Binding::getCurrentBinding();
+        $this->assertInstanceOf('SAML2\HTTPRedirect', $bind);
 
         $_GET = array('SAMLResponse' => 'vVdbc6rIGn2fX2G5H1MJd0RrJ1UgKmDQIIiXl1NANzcRCA2i%2FvppNLpNJsnMnqo5T9qL%2Fq7r62bxEznbJO%2FNIMqzFMHWfpukqHcCH9tVkfYyB0WolzpbiHql1zNF%2FblHP5C9vMjKzMuS9o3J9xYOQrAooyxtt1T5sd2fzqxplxVIhoIMCbkuIEnehSRJ0xRJdroU1fFc6HWA4Hiw3bJhgbDtYxu7wg4QqqCaotJJSwyRFHdP0fcUb1Fsj2V7pLBut2SIyih1ypNVWJY56hFEGW6iexSBh7y8Z4WHqiweUFX4XpJV4CFNiC1Mkiwl8gyVl57gaOnlv5U9tv9HdzsSTQ4GlCB0hqQ8xD84XYHmOzxFMkOh%2FfSz6UbvlGTxdAkN0yBK4UOJ0zrHzFK4L5ugTlWGMC0j75QsEYEc51E6wCmdn8Stq59ntszSKSv0ftXPAGzZTlLB71lAp909s%2FI8iFCbeDpHeO%2B0J164emN3j6JzD3EddV0%2F1MxDVgQETZIUsdSfTS%2BEW%2Bc%2BOhHSsHWx%2Bnuj22HoMgwA0KV53GHKFQTHcR2PZT0SQEHgfAggECB0%2F8Uw%2FHeMANzLKMBjVhWX0wO%2BKpskyC6B9wAUBT%2FaT3%2B0WhdzCNTUz07e%2Bk6apThwEh1PwXVYhhloiUmQFVEZbr9sKUU2vu%2Fh3rv3KDb9gbnFEX7FOKX4D729y7RAzj0KHerssHE3gz4sIGa6NZ%2Bpj%2B0fv0ffqUyrcFLkZ8UWvV%2F%2BXmow3cEkyyHAZ%2Fqtwmakf8vhp537Sfw1RzkK8KT8mw6%2Bde%2BXk9NBfdou75YRhJU%2FUXO3XN7ZQjh2p%2FmwFsXHUwK3m0%2FAtfHn5YfRubJ8tuhXCeETSyl2wWg%2BX5aA3K4SL6ZhcjciFlLVCUcCKUOKMRcSuwfiRCIPSyXNd5bvktb%2BTkUvuwUi2CWnOgdt42XqgZ75x2dIB0p3bB61VyllUn4Z18mEu6P8TjGtzLkrBfOIOGp70Y6D9apEu1gJkklHFgVlM1TvFra%2FP2SvSubm0kE6slSaB%2FPHazk3%2Bf%2FR1DSGh2t9S47syvgIXhf95pLym1MKn3RV7d8d%2B31xawZirUpioGrii7Z7jg00m7GRLpKjvvk6MlWXkY2BJBlzUR%2BS%2B%2F5R1KRgYkviyhI3nK7PxFoOVrJtGOqgBjZQtGRFh%2BQNrnyBjzFu2bY2crc2xoN6eMblQd0l18sJqUfScbWgkDqaJF5q1EroTXRrXutHldQtA%2F8OmEWDxSdsf8ViCegGqvvGyd9oUGtTSx4YusiORGo%2B6Eu6Yi9nh%2FVikoEbXNp%2FjvdDXZlTtjnbcgnGV7q0OuHiXn8BI%2FsIZDXw6GHp9qV4vdRIXR35H%2Fsn4v5hdxNR7kuRMZYCo78fr4p0IUzqVzCrZ7WjVJjGZ74bGENLc4GfieZzuIog7U6jTDtoNeXfeeIuj1HCmvYq3w0QVGG5VITnIN90xh3mZSNrzwIYBiwaxMMhHwfbuJgOTCbbE0FpgS4g7PpFUYndi%2BqNDhRybY3NB%2Fow4YAwmorHTNtMFuAl7tY2W%2BzYasdwunMQalUWDVHKWKWPayN0iWzqB3JgLCTJslTnpc7HOSZYgKpuHiez9Tw2SzeKcUNqzMGMjCV1pGDbQfDd%2FtdhmA%2BFemkNnnVxc%2BYk1PvWpt4PZHF6nrvAkiib9LZ27CjGDe59gWcYn9jzzbpaL439SBYXZ1y3ZGaWeIxxUJVJ6C7qYEXbB6B%2BPAf1qdZBbQx1UZdEX6hlY6WNs7Ua7ryJaAyGkiHikR6IY2Gws%2Bbkc6BoyKzwhTeF22CW5LnuayKcbqtqPQlNfUUbYbUdTte5I7rCZKjW8%2FHcPhy01Mw6G35TKv2x2mWRgbodnmbp0JLl1aBeaHJXCUUkvk4zmpo7QrC2GIGotzwNmXFQjJe7NIlFd%2FyylJeazjqbY%2BfAK3y926kji%2FdJn4y0hfLKsHFdn2%2BQj5fCFTxfG8TthfLuxnkTCGblxtAr31YTrJ5UuTXEbwCn%2FF5WNUgE7v3T1l7ZvDgiLCDaT6TDsb7LdEm%2Bi2Uiw3DAYSDLkKxP%2BRzPOMDlXZ73%2BTdZcQ75Ppt%2BlvpR47fRY%2BfXz%2FfJeNueC50CFu2vHTUNaU2ycppOC9EvYfEX5dQ9y%2BgZ9KK8qeX%2FLKIvyvSz5D88eqsS7wBR8xg1hUkQkwE%2F04MdXNU%2FqPwihSsQNW9cnH1ZRN45%2FLsnT7%2FZlw9K8urmw%2FpdQOJDhdcUyjBtlDvcYoZap%2BVXSpjucRyu3MSyH3v4sgE03WOZHi382qqmAO4xZZwLuC5Pczzrk5zHeRTPAMahXExcx6V8yDGMA7sQeKB9mx5OusSy%2BhOon%2BBvQixpnr79bPR6XrMPwy%2F4p84KcG3UJ65%2BRbno9zRoVo1YO1yZwpIxxaL%2BwceHFj6k2Y3Hz8w%2BCfgOuzJwRS%2FfT9fPq8vwP%2F0J');
-        $bind = SAML2_Binding::getCurrentBinding();
-        $this->assertInstanceOf('SAML2_HTTPRedirect', $bind);
+        $bind = Binding::getCurrentBinding();
+        $this->assertInstanceOf('SAML2\HTTPRedirect', $bind);
 
         $_GET = array('SAMLart' => 'AAQAAI4sWYpfoDDYJrHzsMnG%2BjyNM94p5ejn49a%2BnZ0s3ylY7knQ6tkLMDE%3D');
-        $bind = SAML2_Binding::getCurrentBinding();
-        $this->assertInstanceOf('SAML2_HTTPArtifact', $bind);
+        $bind = Binding::getCurrentBinding();
+        $this->assertInstanceOf('SAML2\HTTPArtifact', $bind);
 
         $_GET = array('aap' => 'noot');
         $this->setExpectedException('Exception', 'Unable to find the current binding.');
-        $bind = SAML2_Binding::getCurrentBinding();
+        $bind = Binding::getCurrentBinding();
     }
     /**
      * Test binding guessing functionality.
@@ -53,26 +53,26 @@ public function testBindingGuesserPOST()
     {
         $_SERVER['REQUEST_METHOD'] = 'POST';
         $_POST = array('SAMLRequest' => 'lZLBbtswDIZfxdDddpw0TiYkAZK4BQJ0RZGsO+wyCDKTCJMpT6S69u0nOejaXVr0JIDkT/L7xQWpzvZyHfiMe/gdgDh76iySHBJLETxKp8iQRNUBSdbysP56K8fFSPbesdPOijeS9xWKCDwbhyLbNUvxcz6bbLeT8WjeNLPpzea6qjbr2WZyVdXX9WZWVyL7Dp5i/VJEeRQRBdghsUKOoVE1zatxXtXfqlpOvsjp6IfImshgUPGgOjP3JMsS8GQQCo65goI/aofwxAXaUkV0QDZ6UJSm7UsyeLKQkzlhnlbdOiRIA99D05ciqYP38c1N11ujDYvsxnkNg8NLcVSWIHHcRyvMI/yLrF+cScNCB/4A/tFoeNjfvlLw+ZeJa7VFz/nVvAjsLzDWhTaxdGBtZOgd8R6oTxuJ1SJ9ixyc86tPduqAVatYLcq3TRaXo7mLHuyaexcxnxNkpz6wKEVMmx+HUsleIZloVYSPw/5sPSiOhrAPIMrVZeT/p7n6Cw==');
-        $bind = SAML2_Binding::getCurrentBinding();
-        $this->assertInstanceOf('SAML2_HTTPPost', $bind);
+        $bind = Binding::getCurrentBinding();
+        $this->assertInstanceOf('SAML2\HTTPPost', $bind);
 
         $_POST = array('SAMLResponse' => 'PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphc3NlcnRpb24iIElEPSJDT1JUT2Y1MmFhMTA5NDQ3MWVkODJmYTRiM2QzZDBmNTcxNDE2MGNlMWEyMDciIFZlcnNpb249IjIuMCIgSXNzdWVJbnN0YW50PSIyMDE1LTEyLTE2VDE2OjM5OjU3WiIgRGVzdGluYXRpb249Imh0dHBzOi8vdGhraS1zaWQucHQtNDgudXRyLnN1cmZjbG91ZC5ubC9tZWxsb24vcG9zdFJlc3BvbnNlIiBJblJlc3BvbnNlVG89Il84NzNDQzMyMDhERDc1RkJFMTFCQTdCMzQxNkU2Qjc2MSI+PHNhbWw6SXNzdWVyPmh0dHBzOi8vZW5naW5lLnRlc3Quc3VyZmNvbmV4dC5ubC9hdXRoZW50aWNhdGlvbi9pZHAvbWV0YWRhdGE8L3NhbWw6SXNzdWVyPjxzYW1scDpTdGF0dXM+PHNhbWxwOlN0YXR1c0NvZGUgVmFsdWU9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDpzdGF0dXM6U3VjY2VzcyIvPjwvc2FtbHA6U3RhdHVzPjxzYW1sOkFzc2VydGlvbiB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIiB4bWxuczp4cz0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIElEPSJDT1JUTzkxZDViNWI0OWJiOGVlMTY2YzlkNDFjNmEwMWE3Zjk2MzcwOTUyNTQiIFZlcnNpb249IjIuMCIgSXNzdWVJbnN0YW50PSIyMDE1LTEyLTE2VDE2OjM5OjU3WiI+PHNhbWw6SXNzdWVyPmh0dHBzOi8vZW5naW5lLnRlc3Quc3VyZmNvbmV4dC5ubC9hdXRoZW50aWNhdGlvbi9pZHAvbWV0YWRhdGE8L3NhbWw6SXNzdWVyPjxkczpTaWduYXR1cmUgeG1sbnM6ZHM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvMDkveG1sZHNpZyMiPgogIDxkczpTaWduZWRJbmZvPjxkczpDYW5vbmljYWxpemF0aW9uTWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS8xMC94bWwtZXhjLWMxNG4jIi8+CiAgICA8ZHM6U2lnbmF0dXJlTWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnI3JzYS1zaGExIi8+CiAgPGRzOlJlZmVyZW5jZSBVUkk9IiNDT1JUTzkxZDViNWI0OWJiOGVlMTY2YzlkNDFjNmEwMWE3Zjk2MzcwOTUyNTQiPjxkczpUcmFuc2Zvcm1zPjxkczpUcmFuc2Zvcm0gQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjZW52ZWxvcGVkLXNpZ25hdHVyZSIvPjxkczpUcmFuc2Zvcm0gQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzEwL3htbC1leGMtYzE0biMiLz48L2RzOlRyYW5zZm9ybXM+PGRzOkRpZ2VzdE1ldGhvZCBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvMDkveG1sZHNpZyNzaGExIi8+PGRzOkRpZ2VzdFZhbHVlPmZGVzdzQW1KLzFNbTUxWWlIcUxTOE1QUHlsMD08L2RzOkRpZ2VzdFZhbHVlPjwvZHM6UmVmZXJlbmNlPjwvZHM6U2lnbmVkSW5mbz48ZHM6U2lnbmF0dXJlVmFsdWU+Wjh2WGQ2MTZaT0d0YmFIdytRWjJkUUVGYlVWdEg5Rmg5SmZHbFdLNzN3dHNmNVpjZGhsa2lJejA4UzE4K201TkZZS3pZaVpOeVZLWTRqZDZ2Q0gva3BIbVo1b3FXUzhmazhZU2dxYTZ6Q3UzTnVrN2NYZWZQQVB5QWtaUDZwb0pwcUM5QTc4T2c3Z3BzQ0VLaVE5WVhrMFpudFQ5TGdZSjg5R21HdnFialFVPTwvZHM6U2lnbmF0dXJlVmFsdWU+CjxkczpLZXlJbmZvPjxkczpYNTA5RGF0YT48ZHM6WDUwOUNlcnRpZmljYXRlPk1JSUMrekNDQW1TZ0F3SUJBZ0lKQVBKdkxqUXNSUjRpTUEwR0NTcUdTSWIzRFFFQkJRVUFNRjB4Q3pBSkJnTlZCQVlUQWs1TU1SQXdEZ1lEVlFRSUV3ZFZkSEpsWTJoME1SQXdEZ1lEVlFRSEV3ZFZkSEpsWTJoME1SQXdEZ1lEVlFRS0V3ZFRWVkpHYm1WME1SZ3dGZ1lEVlFRREV3OTBaWE4wTWlCellXMXNJR05sY25Rd0hoY05NVFV3TXpJME1UUXdNekUzV2hjTk1qVXdNekl4TVRRd016RTNXakJkTVFzd0NRWURWUVFHRXdKT1RERVFNQTRHQTFVRUNCTUhWWFJ5WldOb2RERVFNQTRHQTFVRUJ4TUhWWFJ5WldOb2RERVFNQTRHQTFVRUNoTUhVMVZTUm01bGRERVlNQllHQTFVRUF4TVBkR1Z6ZERJZ2MyRnRiQ0JqWlhKME1JR2ZNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0R05BRENCaVFLQmdRQ3hLWXJuVzhOd3FkUndSd2FIdWx1ZUw2OWdRRlRKYmRmb0FTTGhZaWUyYk9pb0p5SncxZitjQXZwanNsNFNWWXB2RXNlSWV0WEg4TGdwazdLNzNQa0RKTDhkRmc0c0VqRkY2amdtanJPRVMzb3gvZ3RUZDlkL1Z3UEhJL3ZQSWNHeTFzYlZKNHBFTUZsNWQ4R09Bem9Ka05XZFBqOXdWNHJ2NHV2MzVNYXk4d0lEQVFBQm80SENNSUcvTUIwR0ExVWREZ1FXQkJUVElhUHdwS3BKbFk4ZUlNU3pOUlpValN0YmlqQ0Jqd1lEVlIwakJJR0hNSUdFZ0JUVElhUHdwS3BKbFk4ZUlNU3pOUlpValN0YmlxRmhwRjh3WFRFTE1Ba0dBMVVFQmhNQ1Rrd3hFREFPQmdOVkJBZ1RCMVYwY21WamFIUXhFREFPQmdOVkJBY1RCMVYwY21WamFIUXhFREFPQmdOVkJBb1RCMU5WVWtadVpYUXhHREFXQmdOVkJBTVREM1JsYzNReUlITmhiV3dnWTJWeWRJSUpBUEp2TGpRc1JSNGlNQXdHQTFVZEV3UUZNQU1CQWY4d0RRWUpLb1pJaHZjTkFRRUZCUUFEZ1lFQUs4RXZUVTBMZ0hKc1N1Z29yT2VtZ1JscHBNZkpBZU9tdXVaTmhTTVkyUWh1bUZPWnBhQWI4TkZJd1VLVVZ5eUpuU283azZrdEhDS0k5NHNRczk3NjI0MmhURERZRXdXSkQ5SGhBc0FxT28yMVVhOGdaVDM4L3dtNjJlM0tncktYdm5sakFiS1BYRFhKTTRha3o3eTZINnd2dklHVDZmMGYwaUpXSHEzNGp3dz08L2RzOlg1MDlDZXJ0aWZpY2F0ZT48L2RzOlg1MDlEYXRhPjwvZHM6S2V5SW5mbz48L2RzOlNpZ25hdHVyZT48c2FtbDpTdWJqZWN0PjxzYW1sOk5hbWVJRCBGb3JtYXQ9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDpuYW1laWQtZm9ybWF0OnRyYW5zaWVudCI+OGQ0NmIwM2VjNWZlMmZmNmJkNTNlOThhY2E3OTQ3ZjMzMDUzY2MwYjwvc2FtbDpOYW1lSUQ+PHNhbWw6U3ViamVjdENvbmZpcm1hdGlvbiBNZXRob2Q9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDpjbTpiZWFyZXIiPjxzYW1sOlN1YmplY3RDb25maXJtYXRpb25EYXRhIE5vdE9uT3JBZnRlcj0iMjAxNS0xMi0xNlQxNjo0NDo1N1oiIFJlY2lwaWVudD0iaHR0cHM6Ly90aGtpLXNpZC5wdC00OC51dHIuc3VyZmNsb3VkLm5sL21lbGxvbi9wb3N0UmVzcG9uc2UiIEluUmVzcG9uc2VUbz0iXzg3M0NDMzIwOERENzVGQkUxMUJBN0IzNDE2RTZCNzYxIi8+PC9zYW1sOlN1YmplY3RDb25maXJtYXRpb24+PC9zYW1sOlN1YmplY3Q+PHNhbWw6Q29uZGl0aW9ucyBOb3RCZWZvcmU9IjIwMTUtMTItMTZUMTY6Mzk6NTZaIiBOb3RPbk9yQWZ0ZXI9IjIwMTUtMTItMTZUMTY6NDQ6NTdaIj48c2FtbDpBdWRpZW5jZVJlc3RyaWN0aW9uPjxzYW1sOkF1ZGllbmNlPmh0dHBzOi8vdGhraS1zaWQucHQtNDgudXRyLnN1cmZjbG91ZC5ubC9tZWxsb24vbWV0YWRhdGE8L3NhbWw6QXVkaWVuY2U+PC9zYW1sOkF1ZGllbmNlUmVzdHJpY3Rpb24+PC9zYW1sOkNvbmRpdGlvbnM+PHNhbWw6QXV0aG5TdGF0ZW1lbnQgQXV0aG5JbnN0YW50PSIyMDE1LTEyLTE2VDE2OjM5OjU3WiIgU2Vzc2lvbk5vdE9uT3JBZnRlcj0iMjAxNS0xMi0xN1QwMDozOTo1N1oiIFNlc3Npb25JbmRleD0iXzYxMzU1ZTg2NTU3OGJhZDFlYTNkM2U1MzM2MDRhYjY3NjkyNThlOGI4YSI+PHNhbWw6QXV0aG5Db250ZXh0PjxzYW1sOkF1dGhuQ29udGV4dENsYXNzUmVmPnVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphYzpjbGFzc2VzOlBhc3N3b3JkPC9zYW1sOkF1dGhuQ29udGV4dENsYXNzUmVmPjxzYW1sOkF1dGhlbnRpY2F0aW5nQXV0aG9yaXR5Pmh0dHBzOi8vb3BlbmlkcC5mZWlkZS5ubzwvc2FtbDpBdXRoZW50aWNhdGluZ0F1dGhvcml0eT48L3NhbWw6QXV0aG5Db250ZXh0Pjwvc2FtbDpBdXRoblN0YXRlbWVudD48L3NhbWw6QXNzZXJ0aW9uPjwvc2FtbHA6UmVzcG9uc2U+');
-        $bind = SAML2_Binding::getCurrentBinding();
-        $this->assertInstanceOf('SAML2_HTTPPost', $bind);
+        $bind = Binding::getCurrentBinding();
+        $this->assertInstanceOf('SAML2\HTTPPost', $bind);
 
         $_POST = array();
         $_SERVER['CONTENT_TYPE'] = 'text/xml';
-        $bind = SAML2_Binding::getCurrentBinding();
-        $this->assertInstanceOf('SAML2_SOAP', $bind);
+        $bind = Binding::getCurrentBinding();
+        $this->assertInstanceOf('SAML2\SOAP', $bind);
 
         $_POST = array('SAMLart' => 'AAQAAI4sWYpfoDDYJrHzsMnG+jyNM94p5ejn49a+nZ0s3ylY7knQ6tkLMDE=');
-        $bind = SAML2_Binding::getCurrentBinding();
-        $this->assertInstanceOf('SAML2_HTTPArtifact', $bind);
+        $bind = Binding::getCurrentBinding();
+        $this->assertInstanceOf('SAML2\HTTPArtifact', $bind);
 
         $_POST=array('AAP' => 'Noot');
         unset($_SERVER['CONTENT_TYPE']);
         $this->setExpectedException('Exception', 'Unable to find the current binding.');
-        $bind = SAML2_Binding::getCurrentBinding();
+        $bind = Binding::getCurrentBinding();
     }
 
     /**
@@ -83,7 +83,7 @@ public function testBindingGuesserWRONG()
         $_SERVER['REQUEST_METHOD'] = 'PUT';
         $_SERVER['CONTENT_TYPE'] = 'text/xml';
         $this->setExpectedException('Exception', 'Unable to find the current binding.');
-        $bind = SAML2_Binding::getCurrentBinding();
+        $bind = Binding::getCurrentBinding();
     }
 
     /**
@@ -91,7 +91,7 @@ public function testBindingGuesserWRONG()
      */
     public function testGetSetDestination()
     {
-        $bind = SAML2_Binding::getBinding(SAML2_Const::BINDING_HTTP_POST);
+        $bind = Binding::getBinding(Constants::BINDING_HTTP_POST);
         $dest = $bind->getDestination();
         $this->assertNull($dest);
 
diff --git a/tests/SAML2/HTTPRedirectTest.php b/tests/SAML2/HTTPRedirectTest.php
index 4d5453bc0..3145be9c7 100644
--- a/tests/SAML2/HTTPRedirectTest.php
+++ b/tests/SAML2/HTTPRedirectTest.php
@@ -1,11 +1,12 @@
 <?php
 
-/**
- * Class SAML2_HTTPRedirectTest
- */
-class SAML2_HTTPRedirectTest extends PHPUnit_Framework_TestCase
-{
+namespace SAML2;
+
+use PHPUnit_Framework_Error_Warning;
+use PHPUnit_Framework_TestCase;
 
+class HTTPRedirectTest extends PHPUnit_Framework_TestCase
+{
     /**
      * test parsing of basic query string with authnrequest and
      * verify that the correct issuer is found.
@@ -15,9 +16,9 @@ public function testRequestParsing()
         $qs = 'SAMLRequest=pVJNjxMxDP0ro9yn88FOtRu1lcpWiEoLVNvCgQtKE6eNlHGG2IHl35OZLmLZQy%2BcrNh%2Bz88vXpDq%2FSDXic%2F4CN8TEBdPvUeSU2EpUkQZFDmSqHogyVru1x8eZDur5RADBx28eAG5jlBEENkFFMV2sxTfzO0dmKa11namPuoc39hba%2BfqpqlbM6%2Fb5mZ%2B1LWtj6L4ApEycikyUYYTJdgisULOqbrpyqYt67tD28iulV33VRSbvI1DxRPqzDyQrCrAk0OYUYpWB4QnnqGvVN4fkJ2emitnhoocnjyU5E5YjnrXf6TfB6TUQ9xD%2FOE0fH58%2BEueHbHOv2Yn1w8eRneqPpiU68M5DxjfdIltqTRNWQNWJc8lDaLYPfv71qHJaq5be7w0kXx%2FOOzK3af9QawWI7ecrIqr%2F9HYAyujWL2SuKheDlhcbuljlrbd7IJ3%2BlfxLsRe8XXlY8aZ0k6tkqNCcvkzsuXeh5%2F3ERTDUnBMIKrVZeS%2FF7v6DQ%3D%3D';
         $_SERVER['QUERY_STRING'] = $qs;
 
-        $hr = new SAML2_HTTPRedirect();
+        $hr = new HTTPRedirect();
         $request = $hr->receive();
-        $this->assertInstanceOf('SAML2_Request', $request);
+        $this->assertInstanceOf('SAML2\Request', $request);
         $issuer = $request->getIssuer();
         $this->assertEquals('https://profile.surfconext.nl/simplesaml/module.php/saml/sp/metadata.php/default-sp', $issuer);
     }
@@ -31,9 +32,9 @@ public function testResponseParsing()
         $qs = 'SAMLResponse=vVdbc6rIGn2fX2G5H1MJd0RrJ1UgKmDQIIiXl1NANzcRCA2i%2FvppNLpNJsnMnqo5T9qL%2Fq7r62bxEznbJO%2FNIMqzFMHWfpukqHcCH9tVkfYyB0WolzpbiHql1zNF%2FblHP5C9vMjKzMuS9o3J9xYOQrAooyxtt1T5sd2fzqxplxVIhoIMCbkuIEnehSRJ0xRJdroU1fFc6HWA4Hiw3bJhgbDtYxu7wg4QqqCaotJJSwyRFHdP0fcUb1Fsj2V7pLBut2SIyih1ypNVWJY56hFEGW6iexSBh7y8Z4WHqiweUFX4XpJV4CFNiC1Mkiwl8gyVl57gaOnlv5U9tv9HdzsSTQ4GlCB0hqQ8xD84XYHmOzxFMkOh%2FfSz6UbvlGTxdAkN0yBK4UOJ0zrHzFK4L5ugTlWGMC0j75QsEYEc51E6wCmdn8Stq59ntszSKSv0ftXPAGzZTlLB71lAp909s%2FI8iFCbeDpHeO%2B0J164emN3j6JzD3EddV0%2F1MxDVgQETZIUsdSfTS%2BEW%2Bc%2BOhHSsHWx%2Bnuj22HoMgwA0KV53GHKFQTHcR2PZT0SQEHgfAggECB0%2F8Uw%2FHeMANzLKMBjVhWX0wO%2BKpskyC6B9wAUBT%2FaT3%2B0WhdzCNTUz07e%2Bk6apThwEh1PwXVYhhloiUmQFVEZbr9sKUU2vu%2Fh3rv3KDb9gbnFEX7FOKX4D729y7RAzj0KHerssHE3gz4sIGa6NZ%2Bpj%2B0fv0ffqUyrcFLkZ8UWvV%2F%2BXmow3cEkyyHAZ%2Fqtwmakf8vhp537Sfw1RzkK8KT8mw6%2Bde%2BXk9NBfdou75YRhJU%2FUXO3XN7ZQjh2p%2FmwFsXHUwK3m0%2FAtfHn5YfRubJ8tuhXCeETSyl2wWg%2BX5aA3K4SL6ZhcjciFlLVCUcCKUOKMRcSuwfiRCIPSyXNd5bvktb%2BTkUvuwUi2CWnOgdt42XqgZ75x2dIB0p3bB61VyllUn4Z18mEu6P8TjGtzLkrBfOIOGp70Y6D9apEu1gJkklHFgVlM1TvFra%2FP2SvSubm0kE6slSaB%2FPHazk3%2Bf%2FR1DSGh2t9S47syvgIXhf95pLym1MKn3RV7d8d%2B31xawZirUpioGrii7Z7jg00m7GRLpKjvvk6MlWXkY2BJBlzUR%2BS%2B%2F5R1KRgYkviyhI3nK7PxFoOVrJtGOqgBjZQtGRFh%2BQNrnyBjzFu2bY2crc2xoN6eMblQd0l18sJqUfScbWgkDqaJF5q1EroTXRrXutHldQtA%2F8OmEWDxSdsf8ViCegGqvvGyd9oUGtTSx4YusiORGo%2B6Eu6Yi9nh%2FVikoEbXNp%2FjvdDXZlTtjnbcgnGV7q0OuHiXn8BI%2FsIZDXw6GHp9qV4vdRIXR35H%2Fsn4v5hdxNR7kuRMZYCo78fr4p0IUzqVzCrZ7WjVJjGZ74bGENLc4GfieZzuIog7U6jTDtoNeXfeeIuj1HCmvYq3w0QVGG5VITnIN90xh3mZSNrzwIYBiwaxMMhHwfbuJgOTCbbE0FpgS4g7PpFUYndi%2BqNDhRybY3NB%2Fow4YAwmorHTNtMFuAl7tY2W%2BzYasdwunMQalUWDVHKWKWPayN0iWzqB3JgLCTJslTnpc7HOSZYgKpuHiez9Tw2SzeKcUNqzMGMjCV1pGDbQfDd%2FtdhmA%2BFemkNnnVxc%2BYk1PvWpt4PZHF6nrvAkiib9LZ27CjGDe59gWcYn9jzzbpaL439SBYXZ1y3ZGaWeIxxUJVJ6C7qYEXbB6B%2BPAf1qdZBbQx1UZdEX6hlY6WNs7Ua7ryJaAyGkiHikR6IY2Gws%2Bbkc6BoyKzwhTeF22CW5LnuayKcbqtqPQlNfUUbYbUdTte5I7rCZKjW8%2FHcPhy01Mw6G35TKv2x2mWRgbodnmbp0JLl1aBeaHJXCUUkvk4zmpo7QrC2GIGotzwNmXFQjJe7NIlFd%2FyylJeazjqbY%2BfAK3y926kji%2FdJn4y0hfLKsHFdn2%2BQj5fCFTxfG8TthfLuxnkTCGblxtAr31YTrJ5UuTXEbwCn%2FF5WNUgE7v3T1l7ZvDgiLCDaT6TDsb7LdEm%2Bi2Uiw3DAYSDLkKxP%2BRzPOMDlXZ73%2BTdZcQ75Ppt%2BlvpR47fRY%2BfXz%2FfJeNueC50CFu2vHTUNaU2ycppOC9EvYfEX5dQ9y%2BgZ9KK8qeX%2FLKIvyvSz5D88eqsS7wBR8xg1hUkQkwE%2F04MdXNU%2FqPwihSsQNW9cnH1ZRN45%2FLsnT7%2FZlw9K8urmw%2FpdQOJDhdcUyjBtlDvcYoZap%2BVXSpjucRyu3MSyH3v4sgE03WOZHi382qqmAO4xZZwLuC5Pczzrk5zHeRTPAMahXExcx6V8yDGMA7sQeKB9mx5OusSy%2BhOon%2BBvQixpnr79bPR6XrMPwy%2F4p84KcG3UJ65%2BRbno9zRoVo1YO1yZwpIxxaL%2BwceHFj6k2Y3Hz8w%2BCfgOuzJwRS%2FfT9fPq8vwP%2F0J';
         $_SERVER['QUERY_STRING'] = $qs;
 
-        $hr = new SAML2_HTTPRedirect();
+        $hr = new HTTPRedirect();
         $request = $hr->receive();
-        $this->assertInstanceOf('SAML2_Response', $request);
+        $this->assertInstanceOf('SAML2\Response', $request);
         $issuer = $request->getIssuer();
         $this->assertEquals('https://engine.test.surfconext.nl/authentication/idp/metadata', $issuer);
     }
@@ -46,9 +47,9 @@ public function testRequestParsingMoreParams()
         $request = 'SAMLRequest=pVJNb9swDP0rhu6O7XjeGiEJkDYoGqDbgibboZdCkahEgEx5Ir11%2F36y02FdD7n0JPDjPT4%2BcU6q9Z1c9XzCB%2FjRA3H23HokORYWoo8ogyJHElULJFnL3erzvZxOStnFwEEHL15BLiMUEUR2AUW2WS%2FEUw2NrXRp7NWshEPVzJqm%2BTQzVV1DddC21rUy1tq6norsO0RKyIVIRAlO1MMGiRVySpVVk1fTvKr25ZVsGvnh46PI1mkbh4pH1Im5I1kUgEeHMKE%2BWh0QnnmCvlBpf0B2emwunOkKcnj0kJM7Yj7oXf2VfhOQ%2BhbiDuJPp%2BHbw%2F0%2F8uSIdf4tO7m28zC4U7TB9KnendKAIabzO82VpjFrwKrec06dyLYv%2Fl47NEnNZWsP5yaSd%2Fv9Nt9%2B3e3Fcj5wy9GquHyPxhZYGcXqjcR58XrA%2FHxLX5K0zXobvNO%2Fs9sQW8WXlQ8ZZ3I7tkqOCsmlz0iWex9%2B3URQDAvBsQdRLM8j%2F7%2FY5R8%3D&RelayState=https%3A%2F%2Fprofile.surfconext.nl%2F&SAMLEncoding=urn%3Aoasis%3Anames%3Atc%3ASAML%3A2.0%3Abindings%3AURL-Encoding%3ADEFLATE';
         $_SERVER['QUERY_STRING'] = $request;
 
-        $hr = new SAML2_HTTPRedirect();
+        $hr = new HTTPRedirect();
         $request = $hr->receive();
-        $this->assertInstanceOf('SAML2_Request', $request);
+        $this->assertInstanceOf('SAML2\Request', $request);
         $relaystate = $request->getRelayState();
         $this->assertEquals('https://profile.surfconext.nl/', $relaystate);
     }
@@ -62,9 +63,9 @@ public function testSignedRequestParsing()
         $qs = 'SAMLRequest=nVLBauMwEP0Vo7sjW7FpKpJA2rBsoNuGOruHXhZFHm8EsuRqxtv27yvbWWgvYelFgjfvzbx5zBJVazu56enkHuG5B6TktbUO5VhYsT446RUalE61gJK0rDY%2F7qSYZbILnrz2ln2QXFYoRAhkvGPJbrtiv7VoygJEoTJ9LOusXDSFuJ4vdH6cxwoIEGUjsrqoFUt%2BQcCoXLHYKMoRe9g5JOUoQlleprlI8%2FyQz6W4ksXiiSXbuI1xikbViahDyfkRSM2wD40DmjnL0bSdhcE6Hx7BTd3xqnqoIPw1GmbdqWPJNx80jCGtGIUeWLL5t8mtd9i3EM78n493%2FzWr9XVvx%2B58mj39IlUaR%2FQmKOPq4Dtkyf4c9E1EjPtzOePjREL5%2FXDYp%2FuH6sDWy6G3HDML66%2B5ayO7VlHx2dySf2y9nM7pPprabffeGv02ZNcquux5QEydNiNVUlAODTiKMVvrX24DKIJz8nw9jfx8tOt3&RelayState=https%3A%2F%2Fbeta.surfnet.nl%2Fsimplesaml%2Fmodule.php%2Fcore%2Fauthenticate.php%3Fas%3DBraindrops&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=b%2Bqe%2FXGgICOrEL1v9dwuoy0RJtJ%2FGNAr7gJGYSJzLG0riPKwo7v5CH8GPC2P9IRikaeaNeQrnhBAaf8FCWrO0cLFw4qR6msK9bxRBGk%2BhIaTUYCh54ETrVCyGlmBneMgC5%2FiCRvtEW3ESPXCCqt8Ncu98yZmv9LIVyHSl67Se%2BfbB9sDw3%2FfzwYIHRMqK2aS8jnsnqlgnBGGOXqIqN3%2Bd%2F2dwtCfz14s%2F9odoYzSUv32qfNPiPez6PSNqwhwH7dWE3TlO%2FjZmz0DnOeQ2ft6qdZEi5ZN5KCV6VmNKpkrLMq6DDPnuwPm%2F8oCAoT88R2jG7uf9QZB%2BArWJKMEhDLsCA%3D%3D';
         $_SERVER['QUERY_STRING'] = $qs;
 
-        $hr = new SAML2_HTTPRedirect();
+        $hr = new HTTPRedirect();
         $request = $hr->receive();
-        $this->assertInstanceOf('SAML2_Request', $request);
+        $this->assertInstanceOf('SAML2\Request', $request);
         $relaystate = $request->getRelayState();
         $this->assertEquals('https://beta.surfnet.nl/simplesaml/module.php/core/authenticate.php?as=Braindrops', $relaystate);
     }
@@ -78,7 +79,7 @@ public function testInvalidEncodingSpecified()
         $_SERVER['QUERY_STRING'] = $qs;
 
         $this->setExpectedException('Exception', 'Unknown SAMLEncoding:');
-        $hr = new SAML2_HTTPRedirect();
+        $hr = new HTTPRedirect();
         $request = $hr->receive();
     }
 
@@ -88,7 +89,7 @@ public function testNoSigAlgSpecified()
         $_SERVER['QUERY_STRING'] = $qs;
 
         $this->setExpectedException('Exception', 'Missing signature algorithm');
-        $hr = new SAML2_HTTPRedirect();
+        $hr = new HTTPRedirect();
         $request = $hr->receive();
     }
 
@@ -103,7 +104,7 @@ public function testInvalidRequestData()
         $oldwarning = PHPUnit_Framework_Error_Warning::$enabled;
         PHPUnit_Framework_Error_Warning::$enabled = false;
         $this->setExpectedException('Exception', 'Error while inflating');
-        $hr = new SAML2_HTTPRedirect();
+        $hr = new HTTPRedirect();
         $request = @$hr->receive();
         PHPUnit_Framework_Error_Warning::$enabled = $oldwarning;
     }
@@ -117,7 +118,7 @@ public function testNoRequestOrResponse()
         $_SERVER['QUERY_STRING'] = $qs;
 
         $this->setExpectedException('Exception', 'Missing SAMLRequest or SAMLResponse parameter.');
-        $hr = new SAML2_HTTPRedirect();
+        $hr = new HTTPRedirect();
         $request = $hr->receive();
     }
 
@@ -126,8 +127,8 @@ public function testNoRequestOrResponse()
      */
     public function testSendAuthnrequest()
     {
-        $request = new SAML2_AuthnRequest();
-        $hr = new SAML2_HTTPRedirect();
+        $request = new AuthnRequest();
+        $hr = new HTTPRedirect();
         $hr->send($request);
     }
 
@@ -137,12 +138,11 @@ public function testSendAuthnrequest()
      */
     public function testSendAuthnResponse()
     {
-        $response = new SAML2_Response();
+        $response = new Response();
         $response->setIssuer('testIssuer');
         $response->setRelayState('http://example.org');
         $response->setDestination('http://example.org/login?success=yes');
-        $hr = new SAML2_HTTPRedirect();
+        $hr = new HTTPRedirect();
         $hr->send($response);
     }
-
 }

From 593adad879338fdc860bd5c37adfdd5ade898360 Mon Sep 17 00:00:00 2001
From: DRvanR <dvrenterghem@ibuildings.nl>
Date: Mon, 21 Dec 2015 16:37:30 +0100
Subject: [PATCH 16/17] Change casing to be PSR2 compliant for latest changes

---
 src/SAML2/HTTPRedirect.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/SAML2/HTTPRedirect.php b/src/SAML2/HTTPRedirect.php
index bdd70b709..733c6d0fe 100644
--- a/src/SAML2/HTTPRedirect.php
+++ b/src/SAML2/HTTPRedirect.php
@@ -106,16 +106,16 @@ public function receive()
         }
 
         if (isset($data['SAMLEncoding']) && $data['SAMLEncoding'] !== self::DEFLATE) {
-            throw new \Exception('Unknown SAMLEncoding: ' . var_export($data['SAMLEncoding'], TRUE));
+            throw new \Exception('Unknown SAMLEncoding: ' . var_export($data['SAMLEncoding'], true));
         }
 
         $message = base64_decode($message);
-        if ($message === FALSE) {
+        if ($message === false) {
             throw new \Exception('Error while base64 decoding SAML message.');
         }
 
         $message = gzinflate($message);
-        if ($message === FALSE) {
+        if ($message === false) {
             throw new \Exception('Error while inflating SAML message.');
         }
 

From 0f229ac1b4adedabc8bcac3829fe6ab5e4e5bd00 Mon Sep 17 00:00:00 2001
From: DRvanR <dvrenterghem@ibuildings.nl>
Date: Mon, 21 Dec 2015 16:55:29 +0100
Subject: [PATCH 17/17] Update README with version information

---
 README.md | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 59d36b6d0..70c311b88 100644
--- a/README.md
+++ b/README.md
@@ -23,13 +23,26 @@ So let us know what you would like to see in a PHP SAML2 library.
 
 Note that the **HTTP Artifact Binding and SOAP client do not work** outside of SimpleSAMLphp.
 
+Which version to pick?
+----------------------
+It is **strongly recommended** to use the latest stable version of the `2.x` range as that is the currently supported version. 
+
+The `1.x` range should be considered deprecated. This means it will receive fixes and, if required,
+ functionality may be backported. This version should only be relied on if migrating the project to
+ the `2.x` range cannot be done yet.
+
+The `0.x` range is discontinued and will no longer receive any fixes or features. The `0.x` range however
+ is functionally the same as the `1.x` range. Should your project or a dependency of your project rely on a `0.x` version
+ [composer inline aliasing](https://getcomposer.org/doc/articles/aliases.md#require-inline-alias) will help, by using
+ `composer require "simplesamlphp/saml2:1.7.0 as 0.8"` allows to install 1.7.0 as if 0.8 were installed.
+
 Usage
 -----
 
 * Install with [Composer](https://getcomposer.org/doc/00-intro.md), run the following command in your project:
 
 ```bash
-composer require simplesamlphp/saml2
+composer require simplesamlphp/saml2:^2.0
 ```
 
 * Provide the required external dependencies by extending and implementing the ```SAML2\Compat\AbstractContainer```