Change license header.
[shibboleth/cpp-sp.git] / shibsp / util / TemplateParameters.cpp
index eee522d..3f12f7d 100644 (file)
@@ -1,17 +1,21 @@
-/*
- *  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
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ * UCAID licenses this file to you 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
  *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
  */
 
 /**
@@ -21,6 +25,7 @@
  */
 
 #include "internal.h"
+#include "util/PropertySet.h"
 #include "util/TemplateParameters.h"
 
 #include <ctime>
@@ -31,20 +36,38 @@ using namespace shibsp;
 using namespace xmltooling;
 using namespace std;
 
+TemplateParameters::TemplateParameters(const exception* e, const PropertySet* props)
+    : m_exception(e), m_toolingException(dynamic_cast<const XMLToolingException*>(e))
+{
+    setPropertySet(props);
+}
+
+TemplateParameters::~TemplateParameters()
+{
+}
+
 void TemplateParameters::setPropertySet(const PropertySet* props)
 {
     m_props = props;
 
     // Create a timestamp.
-    time_t now = time(NULL);
-#ifdef HAVE_CTIME_R
+    time_t now = time(nullptr);
+#if defined(HAVE_CTIME_R_2)
     char timebuf[32];
     m_map["now"] = ctime_r(&now,timebuf);
+#elif defined(HAVE_CTIME_R_3)
+    char timebuf[32];
+    m_map["now"] = ctime_r(&now,timebuf,sizeof(timebuf));
 #else
     m_map["now"] = ctime(&now);
 #endif
 }
 
+const XMLToolingException* TemplateParameters::getRichException() const
+{
+    return m_toolingException;
+}
+
 const char* TemplateParameters::getParameter(const char* name) const
 {
     if (m_exception) {
@@ -58,7 +81,7 @@ const char* TemplateParameters::getParameter(const char* name) const
     if (pch || !m_props)
         return pch;
     pair<bool,const char*> p = m_props->getString(name);
-    return p.first ? p.second : NULL;
+    return p.first ? p.second : nullptr;
 }
 
 string TemplateParameters::toQueryString() const