From 1167740db52fe5575aa253209c9b8d534cc5f478 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Tue, 29 Jun 2010 10:34:52 +0000
Subject: [PATCH] saml: Move Message-class from saml2 to saml module.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2372 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SAML2/HTTPArtifact.php                    |  2 +-
 .../www/attributeserver.php                   |  6 ++---
 modules/saml/lib/Auth/Source/SP.php           |  8 +++----
 modules/saml/lib/IdP/SAML2.php                | 24 +++++++++----------
 modules/{saml2 => saml}/lib/Message.php       |  2 +-
 modules/saml/www/sp/saml2-acs.php             |  2 +-
 modules/saml/www/sp/saml2-logout.php          |  8 +++----
 www/example-simple/attributequery.php         |  4 ++--
 www/saml2/sp/AssertionConsumerService.php     |  2 +-
 www/saml2/sp/SingleLogoutService.php          |  6 ++---
 www/saml2/sp/initSLO.php                      |  4 ++--
 www/saml2/sp/initSSO.php                      |  4 ++--
 12 files changed, 36 insertions(+), 36 deletions(-)
 rename modules/{saml2 => saml}/lib/Message.php (99%)

diff --git a/lib/SAML2/HTTPArtifact.php b/lib/SAML2/HTTPArtifact.php
index 962a1633b..958d61b00 100644
--- a/lib/SAML2/HTTPArtifact.php
+++ b/lib/SAML2/HTTPArtifact.php
@@ -98,7 +98,7 @@ class SAML2_HTTPArtifact extends SAML2_Binding {
 		$ar->setDestination($endpoint['Location']);
 
 		/* Sign the request */
-		sspmod_saml2_Message::addSign($this->spMetadata, $idpmetadata, $ar); // Shoaib - moved from the SOAPClient.
+		sspmod_saml_Message::addSign($this->spMetadata, $idpmetadata, $ar); // Shoaib - moved from the SOAPClient.
 
 		$soap = new SAML2_SOAPClient();
 
diff --git a/modules/exampleattributeserver/www/attributeserver.php b/modules/exampleattributeserver/www/attributeserver.php
index 4fcfa9805..5099e7bef 100644
--- a/modules/exampleattributeserver/www/attributeserver.php
+++ b/modules/exampleattributeserver/www/attributeserver.php
@@ -72,7 +72,7 @@ $assertion->setInResponseTo($query->getId());
 $assertion->setValidAudiences(array($spEntityId));
 $assertion->setAttributes($returnAttributes);
 $assertion->setAttributeNameFormat($attributeNameFormat);
-sspmod_saml2_Message::addSign($idpMetadata, $spMetadata, $assertion);
+sspmod_saml_Message::addSign($idpMetadata, $spMetadata, $assertion);
 
 $response = new SAML2_Response();
 $response->setRelayState($query->getRelayState());
@@ -80,8 +80,8 @@ $response->setDestination($endpoint);
 $response->setIssuer($idpEntityId);
 $response->setInResponseTo($query->getId());
 $response->setAssertions(array($assertion));
-sspmod_saml2_Message::addSign($idpMetadata, $spMetadata, $response);
+sspmod_saml_Message::addSign($idpMetadata, $spMetadata, $response);
 
 $binding = new SAML2_HTTPPost();
-$binding->setDestination(sspmod_saml2_Message::getDebugDestination());
+$binding->setDestination(sspmod_saml_Message::getDebugDestination());
 $binding->send($response);
diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php
index 8d209cff2..7ff0fa96b 100644
--- a/modules/saml/lib/Auth/Source/SP.php
+++ b/modules/saml/lib/Auth/Source/SP.php
@@ -180,7 +180,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source {
 			SimpleSAML_Auth_State::throwException($state, new SimpleSAML_Error_ProxyCountExceeded("ProxyCountExceeded"));
 		}
 
-		$ar = sspmod_saml2_Message::buildAuthnRequest($this->metadata, $idpMetadata);
+		$ar = sspmod_saml_Message::buildAuthnRequest($this->metadata, $idpMetadata);
 
 		$ar->setAssertionConsumerServiceURL(SimpleSAML_Module::getModuleURL('saml/sp/saml2-acs.php/' . $this->authId));
 
@@ -242,7 +242,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source {
 
 		SimpleSAML_Logger::debug('Sending SAML 2 AuthnRequest to ' . var_export($idpMetadata->getString('entityid'), TRUE));
 		$b = new SAML2_HTTPRedirect();
-		$b->setDestination(sspmod_SAML2_Message::getDebugDestination());
+		$b->setDestination(sspmod_saml_Message::getDebugDestination());
 		$b->send($ar);
 
 		assert('FALSE');
@@ -366,13 +366,13 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source {
 			return;
 		}
 
-		$lr = sspmod_saml2_Message::buildLogoutRequest($this->metadata, $idpMetadata);
+		$lr = sspmod_saml_Message::buildLogoutRequest($this->metadata, $idpMetadata);
 		$lr->setNameId($nameId);
 		$lr->setSessionIndex($sessionIndex);
 		$lr->setRelayState($id);
 
 		$b = new SAML2_HTTPRedirect();
-		$b->setDestination(sspmod_SAML2_Message::getDebugDestination());
+		$b->setDestination(sspmod_saml_Message::getDebugDestination());
 		$b->send($lr);
 
 		assert('FALSE');
diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php
index d3ae2037a..611a4d88e 100644
--- a/modules/saml/lib/IdP/SAML2.php
+++ b/modules/saml/lib/IdP/SAML2.php
@@ -45,7 +45,7 @@ class sspmod_saml_IdP_SAML2 {
 
 		$idpMetadata = $idp->getConfig();
 
-		$assertion = sspmod_saml2_Message::buildAssertion($idpMetadata, $spMetadata, $state);
+		$assertion = sspmod_saml_Message::buildAssertion($idpMetadata, $spMetadata, $state);
 		$assertion->setInResponseTo($requestId);
 		
 		if (isset($state['saml:AuthenticatingAuthority'])) {
@@ -63,10 +63,10 @@ class sspmod_saml_IdP_SAML2 {
 		);
 
 		/* Maybe encrypt the assertion. */
-		$assertion = sspmod_saml2_Message::encryptAssertion($idpMetadata, $spMetadata, $assertion);
+		$assertion = sspmod_saml_Message::encryptAssertion($idpMetadata, $spMetadata, $assertion);
 
 		/* Create the response. */
-		$ar = sspmod_saml2_Message::buildResponse($idpMetadata, $spMetadata, $consumerURL);
+		$ar = sspmod_saml_Message::buildResponse($idpMetadata, $spMetadata, $consumerURL);
 		$ar->setInResponseTo($requestId);
 		$ar->setRelayState($relayState);
 		$ar->setAssertions(array($assertion));
@@ -76,7 +76,7 @@ class sspmod_saml_IdP_SAML2 {
 
 		/* Send the response. */
 		$binding = SAML2_Binding::getBinding($protocolBinding);
-		$binding->setDestination(sspmod_SAML2_Message::getDebugDestination());
+		$binding->setDestination(sspmod_saml_Message::getDebugDestination());
 		$binding->send($ar);
 	}
 
@@ -121,7 +121,7 @@ class sspmod_saml_IdP_SAML2 {
 		SimpleSAML_Logger::warning('Returning error to sp: ' . var_export($spEntityId, TRUE));
 		$error->logWarning();
 
-		$ar = sspmod_saml2_Message::buildResponse($idpMetadata, $spMetadata, $consumerURL);
+		$ar = sspmod_saml_Message::buildResponse($idpMetadata, $spMetadata, $consumerURL);
 		$ar->setInResponseTo($requestId);
 		$ar->setRelayState($relayState);
 
@@ -132,7 +132,7 @@ class sspmod_saml_IdP_SAML2 {
 		));
 
 		$binding = SAML2_Binding::getBinding($protocolBinding);
-		$binding->setDestination(sspmod_SAML2_Message::getDebugDestination());
+		$binding->setDestination(sspmod_saml_Message::getDebugDestination());
 		$binding->send($ar);
 	}
 
@@ -246,7 +246,7 @@ class sspmod_saml_IdP_SAML2 {
 			}
 			$spMetadata = $metadata->getMetaDataConfig($spEntityId, 'saml20-sp-remote');
 
-			sspmod_saml2_Message::validateMessage($spMetadata, $idpMetadata, $request);
+			sspmod_saml_Message::validateMessage($spMetadata, $idpMetadata, $request);
 
 			$relayState = $request->getRelayState();
 
@@ -360,7 +360,7 @@ class sspmod_saml_IdP_SAML2 {
 		$idpMetadata = $idp->getConfig();
 		$spMetadata = $metadata->getMetaDataConfig($spEntityId, 'saml20-sp-remote');
 
-		$lr = sspmod_saml2_Message::buildLogoutResponse($idpMetadata, $spMetadata);
+		$lr = sspmod_saml_Message::buildLogoutResponse($idpMetadata, $spMetadata);
 		$lr->setInResponseTo($state['saml:RequestId']);
 		$lr->setRelayState($state['saml:RelayState']);
 
@@ -375,7 +375,7 @@ class sspmod_saml_IdP_SAML2 {
 		}
 
 		$binding = new SAML2_HTTPRedirect();
-		$binding->setDestination(sspmod_SAML2_Message::getDebugDestination());
+		$binding->setDestination(sspmod_saml_Message::getDebugDestination());
 		$binding->send($lr);
 	}
 
@@ -400,7 +400,7 @@ class sspmod_saml_IdP_SAML2 {
 		$idpMetadata = $idp->getConfig();
 		$spMetadata = $metadata->getMetaDataConfig($spEntityId, 'saml20-sp-remote');
 
-		sspmod_saml2_Message::validateMessage($spMetadata, $idpMetadata, $message);
+		sspmod_saml_Message::validateMessage($spMetadata, $idpMetadata, $message);
 
 		if ($message instanceof SAML2_LogoutResponse) {
 
@@ -409,7 +409,7 @@ class sspmod_saml_IdP_SAML2 {
 			$relayState = $message->getRelayState();
 
 			if (!$message->isSuccess()) {
-				$logoutError = sspmod_saml2_Message::getResponseError($message);
+				$logoutError = sspmod_saml_Message::getResponseError($message);
 				SimpleSAML_Logger::warning('Unsuccessful logout. Status was: ' . $logoutError);
 			} else {
 				$logoutError = NULL;
@@ -460,7 +460,7 @@ class sspmod_saml_IdP_SAML2 {
 		$idpMetadata = $idp->getConfig();
 		$spMetadata = $metadata->getMetaDataConfig($association['saml:entityID'], 'saml20-sp-remote');
 
-		$lr = sspmod_saml2_Message::buildLogoutRequest($idpMetadata, $spMetadata);
+		$lr = sspmod_saml_Message::buildLogoutRequest($idpMetadata, $spMetadata);
 		$lr->setRelayState($relayState);
 		$lr->setSessionIndex($association['saml:SessionIndex']);
 		$lr->setNameId($association['saml:NameID']);
diff --git a/modules/saml2/lib/Message.php b/modules/saml/lib/Message.php
similarity index 99%
rename from modules/saml2/lib/Message.php
rename to modules/saml/lib/Message.php
index 5b46fcdf5..6184d2482 100644
--- a/modules/saml2/lib/Message.php
+++ b/modules/saml/lib/Message.php
@@ -8,7 +8,7 @@
  * @package simpleSAMLphp
  * @version $Id$
  */
-class sspmod_saml2_Message {
+class sspmod_saml_Message {
 
 	/**
 	 * Retrieve the destination we should send the message to.
diff --git a/modules/saml/www/sp/saml2-acs.php b/modules/saml/www/sp/saml2-acs.php
index 4c7160169..d95c7eb49 100644
--- a/modules/saml/www/sp/saml2-acs.php
+++ b/modules/saml/www/sp/saml2-acs.php
@@ -47,7 +47,7 @@ SimpleSAML_Logger::debug('Received SAML2 Response from ' . var_export($idp, TRUE
 $idpMetadata = $source->getIdPmetadata($idp);
 
 try {
-	$assertion = sspmod_saml2_Message::processResponse($spMetadata, $idpMetadata, $response);
+	$assertion = sspmod_saml_Message::processResponse($spMetadata, $idpMetadata, $response);
 } catch (sspmod_saml2_Error $e) {
 	/* The status of the response wasn't "success". */
 	$e = $e->toException();
diff --git a/modules/saml/www/sp/saml2-logout.php b/modules/saml/www/sp/saml2-logout.php
index 0ec6704c4..e1777157c 100644
--- a/modules/saml/www/sp/saml2-logout.php
+++ b/modules/saml/www/sp/saml2-logout.php
@@ -35,7 +35,7 @@ $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 $idpMetadata = $source->getIdPMetadata($idpEntityId);
 $spMetadata = $source->getMetadata();
 
-sspmod_saml2_Message::validateMessage($idpMetadata, $spMetadata, $message);
+sspmod_saml_Message::validateMessage($idpMetadata, $spMetadata, $message);
 
 if ($message instanceof SAML2_LogoutResponse) {
 
@@ -46,7 +46,7 @@ if ($message instanceof SAML2_LogoutResponse) {
 	}
 
 	if (!$message->isSuccess()) {
-		SimpleSAML_Logger::warning('Unsuccessful logout. Status was: ' . sspmod_saml2_Message::getResponseError($message));
+		SimpleSAML_Logger::warning('Unsuccessful logout. Status was: ' . sspmod_saml_Message::getResponseError($message));
 	}
 
 	$state = SimpleSAML_Auth_State::loadState($relayState, 'saml:slosent');
@@ -61,12 +61,12 @@ if ($message instanceof SAML2_LogoutResponse) {
 	$source->handleLogout($idpEntityId);
 
 	/* Create an send response. */
-	$lr = sspmod_saml2_Message::buildLogoutResponse($spMetadata, $idpMetadata);
+	$lr = sspmod_saml_Message::buildLogoutResponse($spMetadata, $idpMetadata);
 	$lr->setRelayState($message->getRelayState());
 	$lr->setInResponseTo($message->getId());
 
 	$binding = new SAML2_HTTPRedirect();
-	$binding->setDestination(sspmod_SAML2_Message::getDebugDestination());
+	$binding->setDestination(sspmod_saml_Message::getDebugDestination());
 	$binding->send($lr);
 } else {
 	throw new SimpleSAML_Error_BadRequest('Unknown message received on logout endpoint: ' . get_class($message));
diff --git a/www/example-simple/attributequery.php b/www/example-simple/attributequery.php
index 94e6a9d7b..1bd04410d 100644
--- a/www/example-simple/attributequery.php
+++ b/www/example-simple/attributequery.php
@@ -21,7 +21,7 @@ function sendQuery($dataId, $url, $nameId) {
 	$query->setNameId($nameId);
 
 	$binding = new SAML2_HTTPRedirect();
-	$binding->setDestination(sspmod_saml2_Message::getDebugDestination());
+	$binding->setDestination(sspmod_saml_Message::getDebugDestination());
 	$binding->send($query);
 }
 
@@ -47,7 +47,7 @@ function handleResponse() {
 	$idpMetadata = $GLOBALS['metadata']->getMetaDataConfig($idpEntityId, 'saml20-idp-remote');
 	$spMetadata =  $GLOBALS['metadata']->getMetaDataConfig($GLOBALS['spEntityId'], 'saml20-sp-hosted');
 
-	$assertion = sspmod_saml2_Message::processResponse($spMetadata, $idpMetadata, $response);
+	$assertion = sspmod_saml_Message::processResponse($spMetadata, $idpMetadata, $response);
 
 	$dataId = $response->getRelayState();
 	if ($dataId === NULL) {
diff --git a/www/saml2/sp/AssertionConsumerService.php b/www/saml2/sp/AssertionConsumerService.php
index bfe0c7766..2446a26e8 100644
--- a/www/saml2/sp/AssertionConsumerService.php
+++ b/www/saml2/sp/AssertionConsumerService.php
@@ -104,7 +104,7 @@ try {
 
 
 	try {
-		$assertion = sspmod_saml2_Message::processResponse($spMetadata, $idpMetadata, $response);
+		$assertion = sspmod_saml_Message::processResponse($spMetadata, $idpMetadata, $response);
 	} catch (sspmod_saml2_Error $e) {
 		/* The status of the response wasn't "success". */
 
diff --git a/www/saml2/sp/SingleLogoutService.php b/www/saml2/sp/SingleLogoutService.php
index bd870327b..9a07973e0 100644
--- a/www/saml2/sp/SingleLogoutService.php
+++ b/www/saml2/sp/SingleLogoutService.php
@@ -34,7 +34,7 @@ $spEntityId = $metadata->getMetaDataCurrentEntityId('saml20-sp-hosted');
 $idpMetadata = $metadata->getMetaDataConfig($idpEntityId, 'saml20-idp-remote');
 $spMetadata = $metadata->getMetaDataConfig($spEntityId, 'saml20-sp-hosted');
 
-sspmod_saml2_Message::validateMessage($idpMetadata, $spMetadata, $message);
+sspmod_saml_Message::validateMessage($idpMetadata, $spMetadata, $message);
 
 if ($message instanceof SAML2_LogoutRequest) {
 
@@ -47,7 +47,7 @@ if ($message instanceof SAML2_LogoutRequest) {
 		SimpleSAML_Logger::stats('saml20-idp-SLO idpinit ' . $spEntityId . ' ' . $idpEntityId);
 
 		/* Create response. */
-		$lr = sspmod_saml2_Message::buildLogoutResponse($spMetadata, $idpMetadata);
+		$lr = sspmod_saml_Message::buildLogoutResponse($spMetadata, $idpMetadata);
 		$lr->setRelayState($message->getRelayState());
 		$lr->setInResponseTo($message->getId());
 
@@ -55,7 +55,7 @@ if ($message instanceof SAML2_LogoutRequest) {
 
 		/* Send response. */
 		$binding = new SAML2_HTTPRedirect();
-		$binding->setDestination(sspmod_SAML2_Message::getDebugDestination());
+		$binding->setDestination(sspmod_saml_Message::getDebugDestination());
 		$binding->send($lr);
 	} catch (Exception $exception) {
 		SimpleSAML_Utilities::fatalError($session->getTrackID(), 'LOGOUTREQUEST', $exception);
diff --git a/www/saml2/sp/initSLO.php b/www/saml2/sp/initSLO.php
index 7228d5769..16b188ccd 100644
--- a/www/saml2/sp/initSLO.php
+++ b/www/saml2/sp/initSLO.php
@@ -40,7 +40,7 @@ try {
 
 	$nameId = $session->getNameId();
 
-	$lr = sspmod_saml2_Message::buildLogoutRequest($spMetadata, $idpMetadata);
+	$lr = sspmod_saml_Message::buildLogoutRequest($spMetadata, $idpMetadata);
 	$lr->setNameId($nameId);
 	$lr->setSessionIndex($session->getSessionIndex());
 
@@ -52,7 +52,7 @@ try {
 	SimpleSAML_Logger::info('SAML2.0 - SP.initSLO: SP (' . $spEntityId . ') is sending logout request to IdP (' . $idpEntityId . ')');
 
 	$b = new SAML2_HTTPRedirect();
-	$b->setDestination(sspmod_SAML2_Message::getDebugDestination());
+	$b->setDestination(sspmod_saml_Message::getDebugDestination());
 	$b->send($lr);
 
 
diff --git a/www/saml2/sp/initSSO.php b/www/saml2/sp/initSSO.php
index 4146d103f..a75a4b441 100644
--- a/www/saml2/sp/initSSO.php
+++ b/www/saml2/sp/initSSO.php
@@ -132,7 +132,7 @@ try {
 	$spMetadata = $metadata->getMetaDataConfig($spentityid, 'saml20-sp-hosted');
 	$idpMetadata = $metadata->getMetaDataConfig($idpentityid, 'saml20-idp-remote');
 
-	$ar = sspmod_saml2_Message::buildAuthnRequest($spMetadata, $idpMetadata);
+	$ar = sspmod_saml_Message::buildAuthnRequest($spMetadata, $idpMetadata);
 
 	$assertionConsumerServiceURL = $metadata->getGenerated('AssertionConsumerService', 'saml20-sp-hosted');
 	$ar->setAssertionConsumerServiceURL($assertionConsumerServiceURL);
@@ -165,7 +165,7 @@ try {
 	$session->setData('SAML2:SP:SSO:Info', $ar->getId(), $info);
 
 	$b = new SAML2_HTTPRedirect();
-	$b->setDestination(sspmod_SAML2_Message::getDebugDestination());
+	$b->setDestination(sspmod_saml_Message::getDebugDestination());
 	$b->send($ar);
 
 } catch(Exception $exception) {
-- 
GitLab