/*
* Copyright 2001-2007 Internet2
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
/**
* shibsp/attribute/Attribute.cpp
- *
+ *
* A resolved attribute.
*/
-
#include "internal.h"
+#include "SPConfig.h"
+#ifndef SHIBSP_LITE
+# include "attribute/AttributeDecoder.h"
+#endif
#include "attribute/SimpleAttribute.h"
#include "attribute/ScopedAttribute.h"
#include "attribute/NameIDAttribute.h"
+#include "util/SPConstants.h"
+
+#include <xercesc/util/XMLUniDefs.hpp>
using namespace shibsp;
+using namespace xmltooling;
using namespace std;
namespace shibsp {
- Attribute* SimpleAttributeFactory(DDF& in) {
+ SHIBSP_DLLLOCAL Attribute* SimpleAttributeFactory(DDF& in) {
return new SimpleAttribute(in);
}
-
- Attribute* ScopedAttributeFactory(DDF& in) {
+
+ SHIBSP_DLLLOCAL Attribute* ScopedAttributeFactory(DDF& in) {
return new ScopedAttribute(in);
}
-
- Attribute* NameIDAttributeFactory(DDF& in) {
+
+ SHIBSP_DLLLOCAL Attribute* NameIDAttributeFactory(DDF& in) {
return new NameIDAttribute(in);
}
-
+
+#ifndef SHIBSP_LITE
+ SHIBSP_DLLLOCAL PluginManager<AttributeDecoder,xmltooling::QName,const DOMElement*>::Factory StringAttributeDecoderFactory;
+ SHIBSP_DLLLOCAL PluginManager<AttributeDecoder,xmltooling::QName,const DOMElement*>::Factory ScopedAttributeDecoderFactory;
+ SHIBSP_DLLLOCAL PluginManager<AttributeDecoder,xmltooling::QName,const DOMElement*>::Factory NameIDAttributeDecoderFactory;
+ SHIBSP_DLLLOCAL PluginManager<AttributeDecoder,xmltooling::QName,const DOMElement*>::Factory NameIDFromScopedAttributeDecoderFactory;
+
+ static const XMLCh _StringAttributeDecoder[] = UNICODE_LITERAL_22(S,t,r,i,n,g,A,t,t,r,i,b,u,t,e,D,e,c,o,d,e,r);
+ static const XMLCh _ScopedAttributeDecoder[] = UNICODE_LITERAL_22(S,c,o,p,e,d,A,t,t,r,i,b,u,t,e,D,e,c,o,d,e,r);
+ static const XMLCh _NameIDAttributeDecoder[] = UNICODE_LITERAL_22(N,a,m,e,I,D,A,t,t,r,i,b,u,t,e,D,e,c,o,d,e,r);
+ static const XMLCh _NameIDFromScopedAttributeDecoder[] = UNICODE_LITERAL_32(N,a,m,e,I,D,F,r,o,m,S,c,o,p,e,d,A,t,t,r,i,b,u,t,e,D,e,c,o,d,e,r);
+
+ static const XMLCh caseSensitive[] = UNICODE_LITERAL_13(c,a,s,e,S,e,n,s,i,t,i,v,e);
+#endif
};
+#ifndef SHIBSP_LITE
+xmltooling::QName shibsp::StringAttributeDecoderType(shibspconstants::SHIB2ATTRIBUTEMAP_NS, _StringAttributeDecoder);
+xmltooling::QName shibsp::ScopedAttributeDecoderType(shibspconstants::SHIB2ATTRIBUTEMAP_NS, _ScopedAttributeDecoder);
+xmltooling::QName shibsp::NameIDAttributeDecoderType(shibspconstants::SHIB2ATTRIBUTEMAP_NS, _NameIDAttributeDecoder);
+xmltooling::QName shibsp::NameIDFromScopedAttributeDecoderType(shibspconstants::SHIB2ATTRIBUTEMAP_NS, _NameIDFromScopedAttributeDecoder);
+
+void shibsp::registerAttributeDecoders()
+{
+ SPConfig& conf = SPConfig::getConfig();
+ conf.AttributeDecoderManager.registerFactory(StringAttributeDecoderType, StringAttributeDecoderFactory);
+ conf.AttributeDecoderManager.registerFactory(ScopedAttributeDecoderType, ScopedAttributeDecoderFactory);
+ conf.AttributeDecoderManager.registerFactory(NameIDAttributeDecoderType, NameIDAttributeDecoderFactory);
+ conf.AttributeDecoderManager.registerFactory(NameIDFromScopedAttributeDecoderType, NameIDFromScopedAttributeDecoderFactory);
+}
+
+AttributeDecoder::AttributeDecoder(const DOMElement *e) : m_caseSensitive(true)
+{
+ if (e) {
+ const XMLCh* flag = e->getAttributeNS(NULL,caseSensitive);
+ if (flag && (*flag == chLatin_f || *flag == chDigit_0))
+ m_caseSensitive = false;
+ }
+}
+#endif
+
void shibsp::registerAttributeFactories()
{
Attribute::registerFactory("", SimpleAttributeFactory);
- Attribute::registerFactory("simple", SimpleAttributeFactory);
- Attribute::registerFactory("scoped", ScopedAttributeFactory);
- Attribute::registerFactory("nameid", NameIDAttributeFactory);
+ Attribute::registerFactory("Simple", SimpleAttributeFactory);
+ Attribute::registerFactory("Scoped", ScopedAttributeFactory);
+ Attribute::registerFactory("NameID", NameIDAttributeFactory);
}
std::map<std::string,Attribute::AttributeFactory*> Attribute::m_factoryMap;