- const char* file;
- const char* data;
- int flags,line;
-
- unsigned long code=ERR_get_error_line_data(&file,&line,&data,&flags);
- while (code) {
- Category& log=Category::getInstance("OpenSSL");
- log.errorStream() << "error code: " << code << " in " << file << ", line " << line << CategoryStream::ENDLINE;
- if (data && (flags & ERR_TXT_STRING))
- log.errorStream() << "error data: " << data << CategoryStream::ENDLINE;
- code=ERR_get_error_line_data(&file,&line,&data,&flags);
+ const RoleDescriptor* role = NULL;
+ if (entity) {
+ const list<XMLObject*>& roles=entity->getOrderedChildren();
+ for (list<XMLObject*>::const_iterator child=roles.begin(); !role && child!=roles.end(); ++child) {
+ role=dynamic_cast<RoleDescriptor*>(*child);
+ if (role && !role->isValid())
+ role = NULL;
+ }
+ }
+ 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() : NULL);
+ auto_ptr_char last(lname ? lname->getName() : NULL);
+ 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());
+ }