From 39d4734ecee017fbe156d09b5f361afa4f5fd81b Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Tue, 24 Jun 2008 06:45:34 +0000
Subject: [PATCH] Add support for wsfed discovery service.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@698 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/XHTML/IdPDisco.php |  3 +++
 www/wsfed/sp/idpdisco.php         | 21 +++++++++++++++++++++
 www/wsfed/sp/initSSO.php          |  3 ---
 3 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100644 www/wsfed/sp/idpdisco.php

diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php
index bd9e13484..57c968e84 100644
--- a/lib/SimpleSAML/XHTML/IdPDisco.php
+++ b/lib/SimpleSAML/XHTML/IdPDisco.php
@@ -20,6 +20,9 @@ class SimpleSAML_XHTML_IdPDisco {
 		'shib13' => array(
 			'metadata' => 'shib13-idp-remote',
 			),
+		'wsfed' => array(
+			'metadata' => 'wsfed-idp-remote',
+			),
 		);
 
 
diff --git a/www/wsfed/sp/idpdisco.php b/www/wsfed/sp/idpdisco.php
new file mode 100644
index 000000000..ab83d6d6e
--- /dev/null
+++ b/www/wsfed/sp/idpdisco.php
@@ -0,0 +1,21 @@
+<?php
+
+require_once('../../_include.php');
+
+$session = SimpleSAML_Session::getInstance();
+
+try {
+	$discoHandler = new SimpleSAML_XHTML_IdPDisco('wsfed');
+} catch (Exception $exception) {
+	/* An error here should be caused by invalid query parameters. */
+	SimpleSAML_Utilities::fatalError($session->getTrackID(), 'DISCOPARAMS', $exception);
+}
+
+try {
+	$discoHandler->handleRequest();
+} catch(Exception $exception) {
+	/* An error here should be caused by metadata. */
+	SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception);
+}
+
+?>
\ No newline at end of file
diff --git a/www/wsfed/sp/initSSO.php b/www/wsfed/sp/initSSO.php
index fce752e48..0e27ff448 100644
--- a/www/wsfed/sp/initSSO.php
+++ b/www/wsfed/sp/initSSO.php
@@ -37,9 +37,6 @@ try {
 
 if ($idpentityid == null) {
 
-	throw new Exception('IdP discovery for WS-Fed is currently unsupported.');
-	/* TODO: Add idpdisco.php */
-
 	SimpleSAML_Logger::info('WS-Fed - SP.initSSO: No chosen or default IdP, go to WSFeddisco');
 
 	SimpleSAML_Utilities::redirect('/' . $config->getBaseURL() . 'wsfed/sp/idpdisco.php', array(
-- 
GitLab