#include <SubjectName.h>
Public Member Functions | |
SubjectName () | |
SubjectName (const char *, bool permissive=false) | |
SubjectName (const std::string &, bool permissive=false) | |
int | parse (const char *, bool permissive=false) |
int | parse (const std::string &, bool permissive=false) |
bool | operator== (const SubjectName &) const |
bool | operator!= (const SubjectName &) const |
Protected Types | |
typedef std::map< std::string, std::string > | AttrMap |
Protected Member Functions | |
int | parse_permissive (const char *) |
int | parse_dce (const char *) |
int | parse_ldap_v3 (const char *) |
int | simple_avp_seq_parse (const char *in, const char *s_del, const char *a_del, const char *s_trim, const char *a_trim, bool push_back) |
Protected Attributes | |
AttrMap | map_ |
Definition at line 21 of file SubjectName.h.
typedef std::map<std::string, std::string> OpenDDS::Security::SSL::SubjectName::AttrMap [protected] |
Definition at line 61 of file SubjectName.h.
OpenDDS::Security::SSL::SubjectName::SubjectName | ( | ) |
Definition at line 11 of file SubjectName.cpp.
OpenDDS::Security::SSL::SubjectName::SubjectName | ( | const char * | in, | |
bool | permissive = false | |||
) |
Definition at line 18 of file SubjectName.cpp.
References parse().
00019 { 00020 parse(in, permissive); 00021 }
OpenDDS::Security::SSL::SubjectName::SubjectName | ( | const std::string & | in, | |
bool | permissive = false | |||
) |
Definition at line 13 of file SubjectName.cpp.
References parse().
00014 { 00015 parse(in, permissive); 00016 }
bool OpenDDS::Security::SSL::SubjectName::operator!= | ( | const SubjectName & | rhs | ) | const |
Definition at line 165 of file SubjectName.cpp.
bool OpenDDS::Security::SSL::SubjectName::operator== | ( | const SubjectName & | rhs | ) | const |
Definition at line 151 of file SubjectName.cpp.
References map_.
00152 { 00153 bool result = (map_.size() == rhs.map_.size()); 00154 for (AttrMap::const_iterator i1 = map_.begin(), i2 = rhs.map_.begin(); 00155 result == true && i1 != map_.end() && i2 != rhs.map_.end(); 00156 ++i1, ++i2) { 00157 if (i1->first.compare(i2->first) != 0 || 00158 i1->second.compare(i2->second) != 0) { 00159 result = false; 00160 } 00161 } 00162 return result; 00163 }
int OpenDDS::Security::SSL::SubjectName::parse | ( | const std::string & | in, | |
bool | permissive = false | |||
) |
Definition at line 23 of file SubjectName.cpp.
References parse().
00024 { 00025 return parse(in.data(), permissive); 00026 }
int OpenDDS::Security::SSL::SubjectName::parse | ( | const char * | in, | |
bool | permissive = false | |||
) |
Definition at line 28 of file SubjectName.cpp.
References parse_dce(), parse_ldap_v3(), and parse_permissive().
Referenced by parse(), SubjectName(), OpenDDS::Security::AccessControlBuiltInImpl::validate_local_permissions(), and OpenDDS::Security::AccessControlBuiltInImpl::validate_remote_permissions().
00029 { 00030 if (in == NULL) { 00031 return -1; 00032 } 00033 00034 // For now, assume ASCII encoding and not UTF-8 00035 if (permissive) { 00036 return parse_permissive(in); 00037 } else { 00038 if (in[0] == '/') { 00039 return parse_dce(in); 00040 } else { 00041 return parse_ldap_v3(in); 00042 } 00043 } 00044 }
int OpenDDS::Security::SSL::SubjectName::parse_dce | ( | const char * | in | ) | [protected] |
Definition at line 141 of file SubjectName.cpp.
References simple_avp_seq_parse().
Referenced by parse().
00142 { 00143 return simple_avp_seq_parse(in, "/", "=", " ", " ", true); 00144 }
int OpenDDS::Security::SSL::SubjectName::parse_ldap_v3 | ( | const char * | in | ) | [protected] |
Definition at line 146 of file SubjectName.cpp.
References simple_avp_seq_parse().
Referenced by parse().
00147 { 00148 return simple_avp_seq_parse(in, ",", "=", " ", " ", false); 00149 }
int OpenDDS::Security::SSL::SubjectName::parse_permissive | ( | const char * | in | ) | [protected] |
Definition at line 136 of file SubjectName.cpp.
References simple_avp_seq_parse().
Referenced by parse().
00137 { 00138 return simple_avp_seq_parse(in, ",/", "=", " ", " ", false); 00139 }
int OpenDDS::Security::SSL::SubjectName::simple_avp_seq_parse | ( | const char * | in, | |
const char * | s_del, | |||
const char * | a_del, | |||
const char * | s_trim, | |||
const char * | a_trim, | |||
bool | push_back | |||
) | [protected] |
Definition at line 46 of file SubjectName.cpp.
Referenced by parse_dce(), parse_ldap_v3(), and parse_permissive().
00049 { 00050 std::string input(in); 00051 size_t input_end = input.size() - 1; 00052 map_.clear(); 00053 00054 ACE_UNUSED_ARG(push_back); 00055 00056 // This parser is meant only to cover basic cases, more advanced cases 00057 // will need something different Specifically, this won't correctly handle 00058 // all escaped characters or all UTF-8 strings 00059 00060 // Use size_t variables to mark positions of token beginnings and ends 00061 00062 // We'll use "st" to mark positions for sequence tokens 00063 size_t st_begin = 0; 00064 size_t st_end = input.find_first_of(s_del); 00065 00066 // Loop over all the sequence tokens 00067 while (st_begin != std::string::npos) { 00068 std::string st = input.substr( 00069 st_begin, 00070 (st_end == std::string::npos ? input_end + 1 : st_end) - st_begin); 00071 00072 // Use once we've found a sequnce token, trim the beginning and end to 00073 // get a clean token 00074 size_t st_begin_clean = st.find_first_not_of(s_trim); 00075 size_t st_end_clean = st.find_last_not_of(s_trim); 00076 00077 // If we've found a clean sequence token 00078 if (st_begin_clean != std::string::npos && 00079 st_end_clean != std::string::npos) { 00080 std::string st_clean = 00081 st.substr(st_begin_clean, st_end_clean - st_begin_clean + 1); 00082 00083 // We'll use "nt" to mark positions for name tokens 00084 size_t nt_begin = 0; 00085 size_t nt_end = st_clean.find_first_of(a_del); 00086 00087 // If we actually found a delimiter 00088 if (nt_end != std::string::npos) { 00089 --nt_end; 00090 00091 std::string nt = st_clean.substr(nt_begin, nt_end - nt_begin + 1); 00092 00093 size_t nt_begin_clean = nt.find_first_not_of(a_trim); 00094 size_t nt_end_clean = nt.find_last_not_of(a_trim); 00095 00096 // If we found a clean name token 00097 if (nt_begin_clean != std::string::npos && 00098 nt_end_clean != std::string::npos) { 00099 std::string nt_clean = 00100 nt.substr(nt_begin_clean, nt_end_clean - nt_begin_clean + 1); 00101 00102 // We'll use "vt" to mark positions for value tokens 00103 size_t vt_begin = nt_end + 2; // Skip over the (single) delimiter 00104 size_t vt_end = st_clean.size() - 1; 00105 00106 std::string vt = st_clean.substr(vt_begin, vt_end - vt_begin + 1); 00107 00108 size_t vt_begin_clean = vt.find_first_not_of(a_trim); 00109 size_t vt_end_clean = vt.find_last_not_of(a_trim); 00110 00111 // If we found a clean value token 00112 if (vt_begin_clean != std::string::npos && 00113 vt_end_clean != std::string::npos) { 00114 std::string vt_clean = 00115 vt.substr(vt_begin_clean, vt_end_clean - vt_begin_clean + 1); 00116 00117 // Push our clean pair into the map 00118 map_[nt_clean] = vt_clean; 00119 } 00120 } 00121 } 00122 } 00123 00124 // Prepare for next iteration of loop 00125 if (st_end == std::string::npos) { 00126 st_begin = std::string::npos; 00127 } else { 00128 st_begin = st_end + 1; 00129 st_end = input.find_first_of(s_del, st_begin); 00130 } 00131 } 00132 00133 return map_.empty() ? 1 : 0; 00134 }
AttrMap OpenDDS::Security::SSL::SubjectName::map_ [protected] |
Definition at line 62 of file SubjectName.h.
Referenced by operator==(), and simple_avp_seq_parse().