TEST_F(TaskTest, CreateAndDelete) { auto start_time = ews::date_time("2015-01-17T12:00:00Z"); auto end_time = ews::date_time("2015-01-17T12:30:00Z"); auto task = ews::task(); task.set_subject("Something really important to do"); task.set_body(ews::body("Some descriptive body text")); task.set_start_date(start_time); task.set_due_date(end_time); task.set_reminder_enabled(true); task.set_reminder_due_by(start_time); const auto item_id = service().create_item(task); auto created_task = service().get_task(item_id); // Check properties EXPECT_STREQ("Something really important to do", created_task.get_subject().c_str()); EXPECT_EQ(start_time, created_task.get_start_date()); EXPECT_EQ(end_time, created_task.get_due_date()); EXPECT_TRUE(created_task.is_reminder_enabled()); EXPECT_EQ(start_time, created_task.get_reminder_due_by()); ASSERT_NO_THROW({ service().delete_task( std::move(created_task), // Sink argument ews::delete_type::hard_delete, ews::affected_task_occurrences::all_occurrences); });
TEST(OfflineTaskTest, FromXMLElement) { const auto task = make_fake_task(); EXPECT_STREQ("abcde", task.get_item_id().id().c_str()); EXPECT_STREQ("edcba", task.get_item_id().change_key().c_str()); EXPECT_STREQ("Write poem", task.get_subject().c_str()); }
bool NamespacesPolicy::Match(const X509_NAME* subject) { error_.resize(0); if(!file_) return false; std::string subject_str; std::string s; std::string policy_ca_subject; std::string policy_right; std::list<std::string> policy_patterns; bool right = false; bool failure = false; X509_NAME_to_string(subject_str, subject); bool permit = false; for(;;) { right = false; failure = false; get_one_rule(*file_, s); if(s.empty()) break; //logger.msg(INFO, "Get rule from namespaces file: %s", s.c_str()); policy_ca_subject.resize(0); if(!get_issuer(s, policy_ca_subject, error_)) failure = true; //If the "SELF" token is contained. //According to the specification: //The (quoted) issuerDirectoryName may be replaced by the single //token “SELF”, in which case this policy applies to the issuer //whose hash corresponds to the hash contained in the namespaces file name if(memicmp(policy_ca_subject.c_str(), selfissuer.c_str(), policy_ca_subject.length()) == 0) { policy_ca_subject.resize(0); policy_ca_subject = issuer_; } policy_right.resize(0); if(!get_right(s, policy_right, error_)) failure = true; else { right = (policy_right == "permit"); } policy_patterns.resize(0); if(!get_subject(s, policy_patterns, error_)) failure = true; if((!policy_ca_subject.empty()) && (!failure)) { //According to eugridpma's namespaces format specification: //The policy can either permit or deny the issuer the right //to issue subjects with specific names. A denial overrides //any permissive statements in the same file. bool r = match_all(issuer_, subject_str, policy_ca_subject, policy_patterns); if(r && right) { //logger.msg(INFO, "The issuer: %s is permitted to sign the subject: %s", issuer_.c_str(), subject_str.c_str()); permit = true; } else if(r && !right) { //Denial overrides //logger.msg(INFO, "The issuer: %s is explicitly denied to sign the subject: %s", issuer_.c_str(), subject_str.c_str()); return false; } else { //logger.msg(INFO, "The subject: %s and issuer: %s in the verified certificate does not match any namespaces policies files", subject_str.c_str(), issuer_.c_str()); } }; }; return permit; }
int main() { int res = EXIT_SUCCESS; ews::set_up(); try { const auto env = ews::test::environment(); auto service = ews::service(env.server_uri, env.domain, env.username, env.password); // First create a draft message ews::distinguished_folder_id drafts = ews::standard_folder::drafts; auto message = ews::message(); message.set_subject("This is an e-mail message for our Contains query"); std::vector<ews::mailbox> recipients; recipients.push_back(ews::mailbox("*****@*****.**")); message.set_to_recipients(recipients); auto item_id = service.create_item(message, ews::message_disposition::save_only); // Then search for it auto search_expression = ews::contains(ews::item_property_path::subject, "ess", ews::containment_mode::substring, ews::containment_comparison::ignore_case); auto item_ids = service.find_item(drafts, search_expression); if (item_ids.empty()) { std::cout << "No messages found!\n"; } else { for (const auto& id : item_ids) { auto msg = service.get_message(id); std::cout << msg.get_subject() << std::endl; } } } catch (std::exception& exc) { std::cout << exc.what() << std::endl; res = EXIT_FAILURE; } ews::tear_down(); return res; }
void Mail::set_subject(const std::wstring& subject) { TextHeaderPtr hd = get_subject(); if (!hd) { TextHeaderPtr new_hd(new TextHeader(L"subject")); headers.add(new_hd); hd = new_hd; } hd->parse_value(subject); }
int main(int argc, char *argv[]) { int error_code = 0; if(2 > argc) { printf("args is error\n"); error_code = 2; goto end; } char *certfile = argv[1]; FILE *fpem = NULL; X509 *cert = NULL; if( !( fpem = fopen( certfile, "r" ))) { printf("Couldn't open the PEM file: %s\n", certfile); error_code = 3; goto end; } if( !( cert = PEM_read_X509( fpem, NULL, NULL, NULL ))) { printf( "Failed to read the PEM file: %s\n",certfile ); error_code = 4; goto end; } if(fpem) { fclose(fpem); } error_code = get_subject(cert); error_code = get_subjectAltName(cert); end: if(cert) { X509_free(cert); } return error_code; }
void TableObserve::show_view() { cout<<"refresh table view to"<<get_subject()->get_data()<<endl; }
void TableObserve::operate(int data) { get_subject()->set_data(data); }
/* If we only have a bindpw then try to join in a bit of a degraded mode. * This is going to duplicate some of the server-side code to determine * the state of the entry. */ static int join_ldap(const char *ipaserver, char *hostname, char ** binddn, const char *bindpw, const char *basedn, const char **princ, const char **subject, int quiet) { LDAP *ld; char *filter = NULL; int rval = 0; char *oidresult = NULL; struct berval valrequest; struct berval *valresult = NULL; int rc, ret; char *ldap_base = NULL; char *search_base = NULL; *binddn = NULL; *princ = NULL; *subject = NULL; if (NULL != basedn) { ldap_base = strdup(basedn); if (!ldap_base) { if (!quiet) fprintf(stderr, _("Out of memory!\n")); rval = 3; goto done; } } else { if (get_root_dn(ipaserver, &ldap_base) != 0) { if (!quiet) fprintf(stderr, _("Unable to determine root DN of %s\n"), ipaserver); rval = 14; goto done; } } ret = asprintf(binddn, "fqdn=%s,cn=computers,cn=accounts,%s", hostname, ldap_base); if (ret == -1) { if (!quiet) fprintf(stderr, _("Out of memory!\n")); rval = 3; goto done; } ld = connect_ldap(ipaserver, *binddn, bindpw); if (!ld) { if (!quiet) fprintf(stderr, _("Incorrect password.\n")); rval = 15; goto done; } if (get_subject(ld, ldap_base, subject, quiet) != 0) { if (!quiet) fprintf(stderr, _("Unable to determine certificate subject of %s\n"), ipaserver); /* Not a critical failure */ } valrequest.bv_val = (char *)hostname; valrequest.bv_len = strlen(hostname); if ((rc = ldap_extended_operation_s(ld, JOIN_OID, &valrequest, NULL, NULL, &oidresult, &valresult)) != LDAP_SUCCESS) { char *s = NULL; #ifdef LDAP_OPT_DIAGNOSTIC_MESSAGE ldap_get_option(ld, LDAP_OPT_DIAGNOSTIC_MESSAGE, &s); #else ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &s); #endif if (!quiet) fprintf(stderr, _("Enrollment failed. %s\n"), s); if (debug) { fprintf(stderr, "ldap_extended_operation_s failed: %s", ldap_err2string(rc)); } rval = 13; goto ldap_done; } /* Get the value from the result returned by the server. */ *princ = strdup(valresult->bv_val); ldap_done: free(filter); free(search_base); free(ldap_base); if (ld != NULL) { ldap_unbind_ext(ld, NULL, NULL); } done: if (valresult) ber_bvfree(valresult); if (oidresult) free(oidresult); return rval; }