+
+string SAMLInternalConfig::hashSHA1(const char* s, bool toHex)
+{
+ return SecurityHelper::doHash("SHA1", s, strlen(s), toHex);
+}
+
+SignableObject::SignableObject()
+{
+}
+
+SignableObject::~SignableObject()
+{
+}
+
+RootObject::RootObject()
+{
+}
+
+RootObject::~RootObject()
+{
+}
+
+Assertion::Assertion()
+{
+}
+
+Assertion::~Assertion()
+{
+}
+
+using namespace saml2p;
+using namespace saml2md;
+
+void opensaml::annotateException(XMLToolingException* e, const EntityDescriptor* entity, const Status* status, bool rethrow)
+{
+ time_t now = time(nullptr);
+ const RoleDescriptor* role = nullptr;
+ static bool (TimeBoundSAMLObject::* isValid)(time_t) const = &TimeBoundSAMLObject::isValid;
+
+ if (entity) {
+ const XMLObject* r = find_if(
+ entity->getOrderedChildren(),
+ (ll_dynamic_cast<const RoleDescriptor*>(_1) != nullptr && lambda::bind(isValid, ll_dynamic_cast<const TimeBoundSAMLObject*>(_1), now))
+ );
+ if (r)
+ role = dynamic_cast<const RoleDescriptor*>(r);
+ }
+
+ annotateException(e, role, status, rethrow);
+}
+
+void opensaml::annotateException(XMLToolingException* e, const RoleDescriptor* role, const Status* status, bool rethrow)
+{
+ if (role) {
+ auto_ptr_char id(dynamic_cast<EntityDescriptor*>(role->getParent())->getEntityID());
+ e->addProperty("entityID",id.get());
+
+ const vector<ContactPerson*>& contacts=role->getContactPersons();
+ for (vector<ContactPerson*>::const_iterator c=contacts.begin(); c!=contacts.end(); ++c) {
+ const XMLCh* ctype=(*c)->getContactType();
+ if (ctype && (XMLString::equals(ctype,ContactPerson::CONTACT_SUPPORT)
+ || XMLString::equals(ctype,ContactPerson::CONTACT_TECHNICAL))) {
+ GivenName* fname=(*c)->getGivenName();
+ SurName* lname=(*c)->getSurName();
+ auto_ptr_char first(fname ? fname->getName() : nullptr);
+ auto_ptr_char last(lname ? lname->getName() : nullptr);
+ if (first.get() && last.get()) {
+ string contact=string(first.get()) + ' ' + last.get();
+ e->addProperty("contactName",contact.c_str());
+ }
+ else if (first.get())
+ e->addProperty("contactName",first.get());
+ else if (last.get())
+ e->addProperty("contactName",last.get());
+ const vector<EmailAddress*>& emails=const_cast<const ContactPerson*>(*c)->getEmailAddresss();
+ if (!emails.empty()) {
+ auto_ptr_char email(emails.front()->getAddress());
+ if (email.get())
+ e->addProperty("contactEmail",email.get());
+ }
+ break;
+ }
+ }
+
+ auto_ptr_char eurl(role->getErrorURL());
+ if (eurl.get()) {
+ e->addProperty("errorURL",eurl.get());
+ }
+ }
+
+ if (status) {
+ auto_ptr_char sc(status->getStatusCode() ? status->getStatusCode()->getValue() : nullptr);
+ if (sc.get() && *sc.get())
+ e->addProperty("statusCode", sc.get());
+ if (status->getStatusCode()->getStatusCode()) {
+ auto_ptr_char sc2(status->getStatusCode()->getStatusCode()->getValue());
+ if (sc2.get() && *sc.get())
+ e->addProperty("statusCode2", sc2.get());
+ }
+ if (status->getStatusMessage()) {
+ auto_ptr_char msg(status->getStatusMessage()->getMessage());
+ if (msg.get() && *msg.get())
+ e->addProperty("statusMessage", msg.get());
+ }
+ }
+
+ if (rethrow)
+ e->raise();
+}