Initial Win32 project
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Mon, 17 Jun 2002 17:42:36 +0000 (17:42 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Mon, 17 Jun 2002 17:42:36 +0000 (17:42 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2 cb58f699-b61c-0410-a6fe-9272a202ed29

12 files changed:
Shibboleth.dsw [new file with mode: 0644]
eduPerson/ScopedAttribute.cpp [new file with mode: 0644]
eduPerson/eduPerson.dsp [new file with mode: 0644]
include/eduPerson.h [new file with mode: 0644]
include/shib.h [new file with mode: 0644]
shib/Constants.cpp [new file with mode: 0644]
shib/SAMLBindingFactory.cpp [new file with mode: 0644]
shib/ShibConfig.cpp [new file with mode: 0644]
shib/XML.cpp [new file with mode: 0644]
shib/shib.dsp [new file with mode: 0644]
shibtest/shibtest.cpp [new file with mode: 0644]
shibtest/shibtest.dsp [new file with mode: 0644]

diff --git a/Shibboleth.dsw b/Shibboleth.dsw
new file mode 100644 (file)
index 0000000..a6b3bc8
--- /dev/null
@@ -0,0 +1,60 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "eduPerson"=.\eduPerson\eduPerson.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+    begin source code control
+    "$/Shibboleth/eduPerson", EYIAAAAA
+    .\eduperson
+    end source code control
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name shib
+    End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "shib"=.\shib\shib.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "shibtest"=.\shibtest\shibtest.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/eduPerson/ScopedAttribute.cpp b/eduPerson/ScopedAttribute.cpp
new file mode 100644 (file)
index 0000000..eaee76d
--- /dev/null
@@ -0,0 +1,114 @@
+/* ScopedAttribute.cpp - eduPerson scoped attribute base class
+
+   Scott Cantor
+   6/4/02
+
+   $History:$
+*/
+
+#ifdef WIN32
+# define EDUPERSON_EXPORTS __declspec(dllexport)
+#endif
+
+#include <eduPerson.h>
+#include <shib.h>
+using namespace saml;
+using namespace shibboleth;
+using namespace eduPerson;
+using namespace std;
+
+ScopedAttribute::ScopedAttribute(const XMLCh* name, const XMLCh* ns, const XMLCh* defaultScope,
+                                 const saml::QName* type, long lifetime, const XMLCh* scopes[],
+                                 const XMLCh* values[])
+    : SAMLAttribute(name,ns,type,lifetime,values)
+{
+    if (defaultScope)
+        m_defaultScope=defaultScope;
+
+    for (unsigned int i=0; scopes && i<(sizeof(scopes)/sizeof(const XMLCh*)); i++)
+        m_values.push_back(scopes[i]);
+}
+
+ScopedAttribute::ScopedAttribute(IDOM_Element* e) : SAMLAttribute(e)
+{
+    // Default scope comes from subject.
+    IDOM_NodeList* nlist=
+        static_cast<IDOM_Element*>(e->getParentNode())->getElementsByTagNameNS(saml::XML::SAML_NS,L(NameIdentifier));
+    if (!nlist || nlist->getLength() != 1)
+        throw InvalidAssertionException(SAMLException.RESPONDER,"ScopedAttribute() can't find saml:NameIdentifier in enclosing statement");
+    m_defaultScope=static_cast<IDOM_Element*>(nlist->item(0))->getAttributeNS(NULL,L(NameQualifier));
+}
+
+ScopedAttribute::~ScopedAttribute() {}
+
+bool ScopedAttribute::addValue(IDOM_Element* e)
+{
+    static XMLCh empty[] = {chNull};
+    if (accept(e) && SAMLAttribute::addValue(e))
+    {
+        IDOM_Attr* scope=e->getAttributeNodeNS(NULL,Scope);
+        m_scopes.push_back(scope ? scope->getNodeValue() : empty);
+        return true;
+    }
+    return false;
+}
+
+bool ScopedAttribute::accept(IDOM_Element* e) const
+{
+    IOriginSiteMapper* mapper=ShibConfig::getConfig()->origin_mapper;
+
+    return true;
+}
+
+Iterator<xstring> ScopedAttribute::getValues() const
+{
+    if (m_scopedValues.empty())
+    {
+        vector<xstring>::const_iterator j=m_scopes.begin();
+        for (vector<xstring>::const_iterator i=m_values.begin(); i!=m_values.end(); i++, j++)
+            m_scopedValues.push_back((*i) + chAt + ((*j)!=m_defaultScope && !j->empty() ? (*j) : m_defaultScope));
+    }
+    return Iterator<xstring>(m_scopedValues);
+}
+
+SAMLObject* ScopedAttribute::clone() const
+{
+    ScopedAttribute* dest=new ScopedAttribute(m_name,m_namespace,m_defaultScope.c_str(),m_type,m_lifetime);
+    dest->m_values.assign(m_values.begin(),m_values.end());
+    dest->m_scopes.assign(m_scopes.begin(),m_scopes.end());
+    dest->m_scopedValues.assign(m_scopedValues.begin(),m_scopedValues.end());
+    return dest;
+}
+
+IDOM_Node* ScopedAttribute::toDOM(IDOM_Document* doc)
+{
+    // Already built?
+    if (m_root)
+        return m_root;
+
+    // If no document provided, build a new one for our use.
+    if (!doc)
+    {
+        IDOM_DOMImplementation* impl=IDOM_DOMImplementation::getImplementation();
+        doc=m_document=impl->createDocument();
+    }
+
+    SAMLAttribute::toDOM(doc);
+
+    int i=0;
+    IDOM_Node* n=m_root->getFirstChild();
+    while (n)
+    {
+        if (n->getNodeType()==IDOM_Node::ELEMENT_NODE)
+        {
+            if (!m_scopes[i].empty() && m_scopes[i]!=m_defaultScope)
+                static_cast<IDOM_Element*>(n)->setAttributeNS(NULL,Scope,m_scopes[i].c_str());
+            i++;
+        }
+        n=n->getNextSibling();
+    }
+
+    return m_root;
+}
+
+const XMLCh ScopedAttribute::Scope[] = { chLatin_S, chLatin_c, chLatin_o, chLatin_p, chLatin_e, chNull };
diff --git a/eduPerson/eduPerson.dsp b/eduPerson/eduPerson.dsp
new file mode 100644 (file)
index 0000000..f11d91b
--- /dev/null
@@ -0,0 +1,98 @@
+# Microsoft Developer Studio Project File - Name="eduPerson" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=eduPerson - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "eduPerson.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "eduPerson.mak" CFG="eduPerson - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "eduPerson - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "eduPerson - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""$/Shibboleth/eduPerson", EYIAAAAA"
+# PROP Scc_LocalPath "."
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "eduPerson - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EDUPERSON_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "C:\curl-7.9.4\include" /I "C:\xerces-c1_7_0-win32\include" /I "..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 xerces-c_1.lib /nologo /dll /machine:I386 /libpath:"C:\xerces-c1_7_0-win32\lib"
+
+!ELSEIF  "$(CFG)" == "eduPerson - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EDUPERSON_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /vd1 /GR /GX /ZI /Od /I "C:\curl-7.9.4\include" /I "C:\xerces-c1_7_0-win32\include" /I "..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /FR /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 xerces-c_1D.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"C:\xerces-c1_7_0-win32\lib"
+
+!ENDIF 
+
+# Begin Target
+
+# Name "eduPerson - Win32 Release"
+# Name "eduPerson - Win32 Debug"
+# Begin Source File
+
+SOURCE=..\include\eduPerson.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ScopedAttribute.cpp
+# End Source File
+# End Target
+# End Project
diff --git a/include/eduPerson.h b/include/eduPerson.h
new file mode 100644 (file)
index 0000000..8b26a9c
--- /dev/null
@@ -0,0 +1,60 @@
+/* eduPerson.h - Shibboleth eduPerson attribute extensions
+
+   Scott Cantor
+   6/4/02
+
+   $History:$
+*/
+
+#ifndef __eduPerson_h__
+#define __eduPerson_h__
+
+#include <saml.h>
+
+#ifdef WIN32
+# ifndef EDUPERSON_EXPORTS
+#  define EDUPERSON_EXPORTS __declspec(dllimport)
+# endif
+#else
+# define EDUPERSON_EXPORTS
+#endif
+
+namespace eduPerson
+{
+    class EDUPERSON_EXPORTS ScopedAttribute : public saml::SAMLAttribute
+    {
+    public:
+        ScopedAttribute(const XMLCh* name, const XMLCh* ns, const XMLCh* defaultScope, const saml::QName* type=NULL,
+                        long lifetime=0, const XMLCh* scopes[]=NULL, const XMLCh* values[]=NULL);
+        ScopedAttribute(IDOM_Element* e);
+        virtual ~ScopedAttribute();
+
+        virtual IDOM_Node* toDOM(IDOM_Document* doc=NULL);
+        virtual saml::SAMLObject* clone() const;
+
+        virtual saml::Iterator<saml::xstring> getValues() const;
+
+        static const XMLCh Scope[];
+
+    protected:
+        virtual bool accept(IDOM_Element* e) const;
+        virtual bool addValue(IDOM_Element* e);
+
+        saml::xstring m_defaultScope;
+        std::vector<saml::xstring> m_scopes;
+        mutable std::vector<saml::xstring> m_scopedValues;
+    };
+
+    static const XMLCh EDUPERSON_NS[] = // urn:mace:eduPerson:1.0
+    { chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_m, chLatin_a, chLatin_c, chLatin_e, chColon,
+      chLatin_e, chLatin_d, chLatin_u, chLatin_P, chLatin_e, chLatin_r, chLatin_s, chLatin_o, chLatin_n, chColon,
+      chDigit_1, chPeriod, chDigit_0, chNull
+    };
+
+    static const XMLCh EDUPERSON_SCHEMA_ID[] = // eduPerson.xsd
+    { chLatin_e, chLatin_d, chLatin_u, chLatin_P, chLatin_e, chLatin_r, chLatin_s, chLatin_o, chLatin_n, chPeriod,
+      chLatin_x, chLatin_s, chLatin_d, chNull
+    };
+}
+
+#endif
diff --git a/include/shib.h b/include/shib.h
new file mode 100644 (file)
index 0000000..93a6287
--- /dev/null
@@ -0,0 +1,89 @@
+/* shib.h - Shibboleth header file
+
+   Scott Cantor
+   6/4/02
+
+   $History:$
+*/
+
+#ifndef __shib_h__
+#define __shib_h__
+
+#include <saml.h>
+
+#ifdef WIN32
+# ifndef SHIB_EXPORTS
+#  define SHIB_EXPORTS __declspec(dllimport)
+# endif
+#else
+# define SHIB_EXPORTS
+#endif
+
+namespace shibboleth
+{
+    class SHIB_EXPORTS UnsupportedProtocolException : public saml::SAMLException
+    {
+    public:
+        explicit UnsupportedProtocolException(const std::string& msg) : saml::SAMLException(msg) {}
+        explicit UnsupportedProtocolException(saml::QName codes[], const std::string& msg) : saml::SAMLException(codes, msg) {}
+    };
+
+    struct SHIB_EXPORTS Constants
+    {
+        static const XMLCh POLICY_CLUBSHIB[];
+        static const XMLCh SHIB_ATTRIBUTE_NAMESPACE_URI[];
+    };
+
+    
+    struct SHIB_EXPORTS IOriginSiteMapper
+    {
+        virtual saml::Iterator<saml::xstring> getHandleServiceNames(const XMLCh* originSite)=0;
+        virtual void* getHandleServiceKey(const XMLCh* handleService)=0;
+        virtual saml::Iterator<saml::xstring> getSecurityDomains(const XMLCh* originSite)=0;
+        virtual saml::Iterator<void*> getTrustedRoots()=0;
+    };
+
+    class SHIB_EXPORTS ShibConfig
+    {
+    public:
+        // global per-process setup and shutdown of Shibboleth runtime
+        static bool init(ShibConfig* pconfig);
+        static void term();
+
+        // enables runtime and clients to access configuration
+        static const ShibConfig* getConfig();
+
+    /* start of external configuration */
+        IOriginSiteMapper* origin_mapper;
+    /* end of external configuration */
+
+    private:
+        static const ShibConfig* g_config;
+    };
+
+
+    class SHIB_EXPORTS XML
+    {
+    public:
+        // URI constants
+        static const XMLCh SHIB_NS[];
+        static const XMLCh SHIB_SCHEMA_ID[];
+
+        struct SHIB_EXPORTS Literals
+        {
+            // Shibboleth vocabulary
+
+            // XML vocabulary
+            static const XMLCh xmlns_shib[];
+        };
+    };
+
+
+    class SHIB_EXPORTS SAMLBindingFactory
+    {
+    public:
+        static saml::SAMLBinding* getInstance(const XMLCh* protocol=saml::SAMLBinding::SAML_SOAP_HTTPS);
+    };
+}
+
+#endif
diff --git a/shib/Constants.cpp b/shib/Constants.cpp
new file mode 100644 (file)
index 0000000..cbd6cbe
--- /dev/null
@@ -0,0 +1,33 @@
+/* Constants.cpp - Shibboleth URI constants
+
+   Scott Cantor
+   2/20/02
+
+   $History:$
+*/
+
+#ifdef WIN32
+# define SHIB_EXPORTS __declspec(dllexport)
+#endif
+
+#include <shib.h>
+
+const XMLCh shibboleth::Constants::POLICY_CLUBSHIB[] = // http://middleware.internet2.edu/shibboleth/clubs/clubshib/2002/05/
+{ chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, chForwardSlash,
+  chLatin_m, chLatin_i, chLatin_d, chLatin_d, chLatin_l, chLatin_e, chLatin_w, chLatin_a, chLatin_r, chLatin_e, chPeriod,
+      chLatin_i, chLatin_n, chLatin_t, chLatin_e, chLatin_r, chLatin_n, chLatin_e, chLatin_t, chDigit_2, chPeriod,
+      chLatin_e, chLatin_d, chLatin_u, chForwardSlash,
+  chLatin_s, chLatin_h, chLatin_i, chLatin_b, chLatin_b, chLatin_o, chLatin_l, chLatin_e, chLatin_t, chLatin_h, chForwardSlash,
+  chLatin_c, chLatin_l, chLatin_u, chLatin_b, chLatin_s, chForwardSlash,
+  chLatin_c, chLatin_l, chLatin_u, chLatin_b, chLatin_s, chLatin_h, chLatin_i, chLatin_b, chForwardSlash,
+  chDigit_2, chDigit_0, chDigit_0, chDigit_2, chForwardSlash, chDigit_0, chDigit_5, chForwardSlash, chNull
+};
+
+const XMLCh shibboleth::Constants::SHIB_ATTRIBUTE_NAMESPACE_URI[] = // urn:mace:shibboleth:1.0:attributeNamespace:uri
+{
+  chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_m, chLatin_a, chLatin_c, chLatin_e, chColon,
+  chLatin_s, chLatin_h, chLatin_i, chLatin_b, chLatin_b, chLatin_o, chLatin_l, chLatin_e, chLatin_t, chLatin_h, chColon,
+  chDigit_1, chPeriod, chDigit_0, chColon,
+  chLatin_a, chLatin_t, chLatin_t, chLatin_r, chLatin_i, chLatin_b, chLatin_u, chLatin_t, chLatin_e, chLatin_N, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chLatin_p, chLatin_a, chLatin_c, chLatin_e, chColon,
+  chLatin_u, chLatin_r, chLatin_i, chNull
+};
diff --git a/shib/SAMLBindingFactory.cpp b/shib/SAMLBindingFactory.cpp
new file mode 100644 (file)
index 0000000..bb3ea71
--- /dev/null
@@ -0,0 +1,23 @@
+/* SAMLBindingFactory.cpp - SAML binding factory implementation
+
+   Scott Cantor
+   6/4/02
+   
+   $History:$
+*/
+
+#ifdef WIN32
+# define SHIB_EXPORTS __declspec(dllexport)
+#endif
+
+#include <shib.h>
+using namespace shibboleth;
+using namespace saml;
+
+SAMLBinding* SAMLBindingFactory::getInstance(const XMLCh* protocol)
+{
+    if (!protocol || XMLString::compareString(protocol,SAMLBinding::SAML_SOAP_HTTPS))
+        throw UnsupportedProtocolException("SAMLBindingFactory::getInstance() unable to find binding implementation for specified protocol");
+
+    return new SAMLSOAPBinding();
+}
diff --git a/shib/ShibConfig.cpp b/shib/ShibConfig.cpp
new file mode 100644 (file)
index 0000000..aef19f9
--- /dev/null
@@ -0,0 +1,39 @@
+/* ShibConfig.cpp - Shibboleth runtime configuration
+
+   Scott Cantor
+   6/4/02
+
+   $History:$
+*/
+
+#ifdef WIN32
+# define SHIB_EXPORTS __declspec(dllexport)
+#endif
+
+#include <shib.h>
+using namespace shibboleth;
+
+// This is currently *NOT* threadsafe code.
+
+const ShibConfig* ShibConfig::g_config=NULL;
+
+bool ShibConfig::init(ShibConfig* pconfig)
+{
+    if (!pconfig)
+        return false;
+    g_config=pconfig;
+
+    // Register extension schema.
+    saml::XML::registerSchema(XML::SHIB_NS,XML::SHIB_SCHEMA_ID);
+
+    return true;
+}
+
+void ShibConfig::term()
+{
+}
+
+const ShibConfig* ShibConfig::getConfig()
+{
+    return g_config;
+}
diff --git a/shib/XML.cpp b/shib/XML.cpp
new file mode 100644 (file)
index 0000000..e888061
--- /dev/null
@@ -0,0 +1,34 @@
+/* XML.cpp - XML constants
+
+   Scott Cantor
+   6/4/02
+
+   $History:$
+*/
+
+#ifdef WIN32
+# define SHIB_EXPORTS __declspec(dllexport)
+#endif
+
+#include <shib.h>
+using namespace shibboleth;
+
+
+// Namespace and schema string literals
+
+const XMLCh XML::SHIB_NS[] = // urn:mace:shibboleth:1.0
+{ chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_m, chLatin_a, chLatin_c, chLatin_e, chColon,
+  chLatin_s, chLatin_h, chLatin_i, chLatin_b, chLatin_b, chLatin_o, chLatin_l, chLatin_e, chLatin_t, chLatin_h, 
+  chColon, chDigit_1, chPeriod, chDigit_0, chNull
+};
+
+const XMLCh XML::SHIB_SCHEMA_ID[] = // shibboleth.xsd
+{ chLatin_s, chLatin_h, chLatin_i, chLatin_b, chLatin_b, chLatin_o, chLatin_l, chLatin_e, chLatin_t, chLatin_h, 
+  chPeriod, chLatin_x, chLatin_s, chLatin_d, chNull
+};
+
+
+// Shibboleth vocabulary literals
+
+const XMLCh XML::Literals::xmlns_shib[]=
+{ chLatin_x, chLatin_m, chLatin_l, chLatin_n, chLatin_s, chColon, chLatin_s, chLatin_h, chLatin_i, chLatin_b, chNull };
diff --git a/shib/shib.dsp b/shib/shib.dsp
new file mode 100644 (file)
index 0000000..88284ca
--- /dev/null
@@ -0,0 +1,111 @@
+# Microsoft Developer Studio Project File - Name="shib" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=shib - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "shib.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "shib.mak" CFG="shib - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "shib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "shib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "shib - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHIB_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "C:\curl-7.9.4\include" /I "C:\openssl-0.9.6c\inc32" /I "C:\xerces-c1_7_0-win32\include" /I "..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 xerces-c_1.lib /nologo /dll /machine:I386 /libpath:"C:\xerces-c1_7_0-win32\lib"
+
+!ELSEIF  "$(CFG)" == "shib - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHIB_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I "C:\curl-7.9.4\include" /I "C:\openssl-0.9.6c\inc32" /I "C:\xerces-c1_7_0-win32\include" /I "..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /FR /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 xerces-c_1D.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"C:\xerces-c1_7_0-win32\lib"
+
+!ENDIF 
+
+# Begin Target
+
+# Name "shib - Win32 Release"
+# Name "shib - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\Constants.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\SAMLBindingFactory.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\shib.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ShibConfig.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\XML.cpp
+# End Source File
+# End Target
+# End Project
diff --git a/shibtest/shibtest.cpp b/shibtest/shibtest.cpp
new file mode 100644 (file)
index 0000000..25f9f21
--- /dev/null
@@ -0,0 +1,183 @@
+#include <shib.h>
+#include <eduPerson.h>
+
+using namespace std;
+using namespace saml;
+using namespace shibboleth;
+using namespace eduPerson;
+
+class MyMapper : public IOriginSiteMapper
+{
+public:
+    MyMapper();
+    Iterator<xstring> getHandleServiceNames(const XMLCh* originSite);
+    void* getHandleServiceKey(const XMLCh* handleService);
+    Iterator<xstring> getSecurityDomains(const XMLCh* originSite);
+    Iterator<void*> getTrustedRoots();
+
+private:
+    vector<xstring> v;
+    vector<void*> v2;
+};
+
+Iterator<xstring> MyMapper::getSecurityDomains(const XMLCh* originSite)
+{
+    return Iterator<xstring>(v);
+}
+
+Iterator<xstring> MyMapper::getHandleServiceNames(const XMLCh* originSite)
+{
+    return Iterator<xstring>(v);
+}
+
+void* MyMapper::getHandleServiceKey(const XMLCh* handleService)
+{
+    return NULL;
+}
+
+Iterator<void*> MyMapper::getTrustedRoots()
+{
+    return Iterator<void*>(v2);
+}
+
+MyMapper::MyMapper()
+{
+}
+
+SAMLAttribute* scopedFactory(IDOM_Element* e)
+{
+    return new ScopedAttribute(e);
+}
+
+int main(int argc,char* argv[])
+{
+    MyMapper mapper;
+    SAMLConfig conf1;
+    ShibConfig conf2;
+    char* h_param=NULL;
+    char* q_param=NULL;
+    char* url_param=NULL;
+    char* r_param=NULL;
+    char* path=NULL;
+
+    for (int i=1; i<argc; i++)
+    {
+        if (!strcmp(argv[i],"-d") && i+1<argc)
+            path=argv[++i];
+        else if (!strcmp(argv[i],"-h") && i+1<argc)
+            h_param=argv[++i];
+        else if (!strcmp(argv[i],"-q") && i+1<argc)
+            q_param=argv[++i];
+        else if (!strcmp(argv[i],"-a") && i+1<argc)
+            url_param=argv[++i];
+        else if (!strcmp(argv[i],"-r") && i+1<argc)
+            r_param=argv[++i];
+    }
+
+    if (!h_param || !q_param || !url_param)
+    {
+        cerr << "usage: shibtest -h <handle> -q <origin_site> -a <AA URL> [-r <resource URL> -d <schema path>]" << endl;
+        exit(0);
+    }
+
+    conf1.schema_dir=path;
+    if (!SAMLConfig::init(&conf1))
+        cerr << "unable to initialize SAML runtime" << endl;
+
+    conf2.origin_mapper=&mapper;
+    if (!ShibConfig::init(&conf2))
+        cerr << "unable to initialize Shibboleth runtime" << endl;
+
+
+    saml::XML::registerSchema(EDUPERSON_NS,EDUPERSON_SCHEMA_ID);
+
+    auto_ptr<XMLCh> ATTRNS(XMLString::transcode("urn:mace:shibboleth:1.0:attributeNamespace:uri"));
+    auto_ptr<XMLCh> EPPN(XMLString::transcode("urn:mace:eduPerson:1.0:eduPersonPrincipalName"));
+    auto_ptr<XMLCh> AFFIL(XMLString::transcode("urn:mace:eduPerson:1.0:eduPersonAffiliation"));
+
+    SAMLAttribute::regFactory(EPPN.get(),ATTRNS.get(),&scopedFactory);
+    SAMLAttribute::regFactory(AFFIL.get(),ATTRNS.get(),&scopedFactory);
+
+    try
+    {
+        auto_ptr<XMLCh> url(XMLString::transcode(url_param));
+        SAMLAuthorityBinding binfo(saml::QName(saml::XML::SAMLP_NS,L(AttributeQuery)),SAMLBinding::SAML_SOAP_HTTPS,url.get());
+        auto_ptr<XMLCh> domain(XMLString::transcode(q_param));
+        auto_ptr<XMLCh> handle(XMLString::transcode(h_param));
+        auto_ptr<XMLCh> resource(XMLString::transcode(r_param));
+        SAMLRequest* req=new SAMLRequest(new SAMLAttributeQuery (new SAMLSubject(handle.get(),domain.get()),resource.get()));
+
+        const XMLCh* policies[]={Constants::POLICY_CLUBSHIB};
+        
+        SAMLBinding* pBinding=SAMLBindingFactory::getInstance(SAMLBinding::SAML_SOAP_HTTPS);
+        SAMLResponse* resp=pBinding->send(binfo,*req);
+        delete pBinding;
+
+        SAMLResponse* r2=dynamic_cast<SAMLResponse*>(resp->clone());
+        delete resp;
+
+        Iterator<SAMLAssertion*> i=r2->getAssertions();
+        if (i.hasNext())
+        {
+            SAMLAssertion* a=i.next();
+            cout << "Issuer: "; xmlout(cout,a->getIssuer()); cout << endl;
+            const XMLDateTime* exp=a->getNotOnOrAfter();
+            cout << "Expires: ";
+            if (exp)
+              xmlout(cout,exp->toString());
+            else
+                cout << "None";
+            cout << endl;
+
+            Iterator<SAMLStatement*> j=a->getStatements();
+            if (j.hasNext())
+            {
+                SAMLAttributeStatement* s=dynamic_cast<SAMLAttributeStatement*>(j.next());
+                if (s)
+                {
+                    const SAMLSubject* sub=s->getSubject();
+                    cout << "Domain: "; xmlout(cout,sub->getNameQualifier()); cout << endl;
+                    cout << "Handle: "; xmlout(cout,sub->getName()); cout << endl;
+
+                    Iterator<SAMLAttribute*> attrs=s->getAttributes();
+                    while (attrs.hasNext())
+                    {
+                        SAMLAttribute* attr=attrs.next();
+                        cout << "Attribute Name: "; xmlout(cout,attr->getName()); cout << endl;
+                        cout << "Attribute Type: {";
+                        xmlout(cout,attr->getType()->getNamespaceURI());
+                        cout << "}:";
+                        xmlout(cout,attr->getType()->getLocalName());
+                        cout << endl;
+                        
+                        Iterator<xstring> vals=attr->getValues();
+                        while (vals.hasNext())
+                        {
+                            cout << "Attribute Value: ";
+                            xmlout(cout,vals.next().c_str());
+                            cout << endl;
+                        }
+                    }
+                }
+            }
+        }
+
+        delete r2;
+    }
+    catch(SAMLException& e)
+    {
+        cerr << "caught a SAML exception: " << e.what() << endl;
+    }
+    catch(XMLException& e)
+    {
+        cerr << "caught an XML exception: "; xmlout(cerr,e.getMessage()); cerr << endl;
+    }
+/*    catch(...)
+    {
+        cerr << "caught an unknown exception" << endl;
+    }*/
+
+    ShibConfig::term();
+    SAMLConfig::term();
+    return 0;
+}
diff --git a/shibtest/shibtest.dsp b/shibtest/shibtest.dsp
new file mode 100644 (file)
index 0000000..47d5b6a
--- /dev/null
@@ -0,0 +1,90 @@
+# Microsoft Developer Studio Project File - Name="shibtest" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=shibtest - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "shibtest.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "shibtest.mak" CFG="shibtest - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "shibtest - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "shibtest - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""$/Shibboleth/shibtest", BYIAAAAA"
+# PROP Scc_LocalPath "."
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "shibtest - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "C:\curl-7.9.4\include" /I "C:\xerces-c1_7_0-win32\include" /I "..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 xerces-c_1.lib /nologo /subsystem:console /machine:I386 /libpath:"C:\xerces-c1_7_0-win32\lib"
+
+!ELSEIF  "$(CFG)" == "shibtest - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I "C:\curl-7.9.4\include" /I "C:\xerces-c1_7_0-win32\include" /I "..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 xerces-c_1D.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"C:\xerces-c1_7_0-win32\lib"
+
+!ENDIF 
+
+# Begin Target
+
+# Name "shibtest - Win32 Release"
+# Name "shibtest - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\shibtest.cpp
+# End Source File
+# End Target
+# End Project