summaryrefslogtreecommitdiffabout
path: root/test/kingate_openid_message.h
authorMichael Krelin <hacker@klever.net>2008-01-31 23:54:44 (UTC)
committer Michael Krelin <hacker@klever.net>2008-01-31 23:54:44 (UTC)
commit61e6da06804f98d0cbb9d27eeb335351b3e05d4d (patch) (side-by-side diff)
tree51469cb82808da57cb696a858d65840b9b5d02dd /test/kingate_openid_message.h
parent0a90a7791bd329afd8955df78b8ae358adc897a8 (diff)
downloadlibopkele-61e6da06804f98d0cbb9d27eeb335351b3e05d4d.zip
libopkele-61e6da06804f98d0cbb9d27eeb335351b3e05d4d.tar.gz
libopkele-61e6da06804f98d0cbb9d27eeb335351b3e05d4d.tar.bz2
fixed kingate_openid_message code in test area
rethrow kingate's notfound exceptions as opkele ones. Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'test/kingate_openid_message.h') (more/less context) (ignore whitespace changes)
-rw-r--r--test/kingate_openid_message.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/test/kingate_openid_message.h b/test/kingate_openid_message.h
index b3a2c9d..37dcdfa 100644
--- a/test/kingate_openid_message.h
+++ b/test/kingate_openid_message.h
@@ -29,80 +29,81 @@ class join_iterator : public iterator<
return ranges!=x.ranges; }
typename IT::reference operator*() const {
assert(!ranges.empty());
assert(ranges.front().first!=ranges.front().second);
return *ranges.front().first; }
typename IT::pointer operator->() const {
assert(!ranges.empty());
assert(ranges.front().first!=ranges.front().second);
return ranges.front().first.operator->(); }
join_iterator<IT>& operator++() {
cleanup();
if(ranges.empty()) return *this;
do {
++ranges.front().first;
}while(cleanup() && !ranges.empty());
return *this;
}
join_iterator<IT> operator++(int) {
join_iterator<IT> rv(*this);
++(*this); return rv; }
};
template<typename IT>
class cut_prefix_filterator : public opkele::util::basic_filterator<IT> {
public:
string pfx;
mutable string tmp;
cut_prefix_filterator() { }
cut_prefix_filterator(const IT& bi,const IT&ei,const string& pfx)
: opkele::util::basic_filterator<IT>(bi,ei), pfx(pfx) {
this->prepare();
}
bool is_interesting() const {
return pfx.length()==0 || !strncmp(this->it->c_str(),pfx.c_str(),pfx.length());
}
typename IT::reference operator*() const {
assert(!this->empty);
tmp = *this->it; tmp.erase(0,pfx.length());
return tmp; }
typename IT::pointer operator->() const {
assert(!this->empty);
return &this->operator*(); }
};
class kingate_openid_message_t : public opkele::basic_openid_message {
typedef join_iterator<kingate::cgi_gateway::params_t::const_iterator> jitterator;
typedef opkele::util::map_keys_iterator<
jitterator,
fields_iterator::value_type,
fields_iterator::reference,
fields_iterator::pointer> keys_iterator;
typedef cut_prefix_filterator<keys_iterator> pfilterator;
public:
const kingate::cgi_gateway& gw;
kingate_openid_message_t(const kingate::cgi_gateway& g) : gw(g) { }
bool has_field(const string& n) const {
return gw.has_param("openid."+n); }
- const string& get_field(const string& n) const {
- return gw.get_param("openid."+n); }
+ const string& get_field(const string& n) const try {
+ return gw.get_param("openid."+n); }catch(kingate::exception_notfound& nf) {
+ throw opkele::failed_lookup(OPKELE_CP_ nf.what()); }
fields_iterator fields_begin() const {
return
pfilterator( keys_iterator(
jitterator()
.add_range( gw.get.begin(), gw.get.end() )
.add_range( gw.post.begin(), gw.post.end() ),
jitterator()
), keys_iterator(), "openid." );
}
fields_iterator fields_end() const {
return pfilterator();
}
};