author | Michael Krelin <hacker@klever.net> | 2007-12-09 17:22:06 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-12-09 22:08:24 (UTC) |
commit | c34adc6e274c3dbb63af99ca566000e7d218244c (patch) (unidiff) | |
tree | 705624c208deb4eaf8d07c119a883e6f4f35236e /test | |
parent | 60fdaff7888b455b4d07eadc905cefd20f1ddd3c (diff) | |
download | libopkele-c34adc6e274c3dbb63af99ca566000e7d218244c.zip libopkele-c34adc6e274c3dbb63af99ca566000e7d218244c.tar.gz libopkele-c34adc6e274c3dbb63af99ca566000e7d218244c.tar.bz2 |
reworked identity resolution and service discovery
The discovery, which does both XRDS-based (Yadis, XRI, for XRI, using proxy)
and HTML-based search, now returns results in opkele:idiscovery_t structure.
It uses expat-based parser idigger_t, which itself is not exposed via any
header files, but hidden in lib/discovery.cc, the discovery testing program is
renamed from openid_resolve to idiscover.
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | test/.gitignore | 2 | ||||
-rw-r--r-- | test/Makefile.am | 6 | ||||
-rw-r--r-- | test/idiscover.cc | 49 | ||||
-rw-r--r-- | test/openid_resolve.cc | 36 |
4 files changed, 53 insertions, 40 deletions
diff --git a/test/.gitignore b/test/.gitignore index 5ce4dc9..31ae686 100644 --- a/test/.gitignore +++ b/test/.gitignore | |||
@@ -4,2 +4,2 @@ | |||
4 | *.o | 4 | *.o |
5 | /openid_resolve | 5 | /idiscover |
diff --git a/test/Makefile.am b/test/Makefile.am index 5aa87b3..13c4cd2 100644 --- a/test/Makefile.am +++ b/test/Makefile.am | |||
@@ -1,2 +1,2 @@ | |||
1 | noinst_PROGRAMS = test openid_resolve | 1 | noinst_PROGRAMS = test idiscover |
2 | 2 | ||
@@ -13,3 +13,3 @@ EXTRA_DIST=$(addsuffix .html,$(addprefix html/, \ | |||
13 | 13 | ||
14 | openid_resolve_SOURCES = openid_resolve.cc | 14 | idiscover_SOURCES = idiscover.cc |
15 | openid_resolve_LDADD = ${top_builddir}/lib/libopkele.la | 15 | idiscover_LDADD = ${top_builddir}/lib/libopkele.la |
diff --git a/test/idiscover.cc b/test/idiscover.cc new file mode 100644 index 0000000..2abedc9 --- a/dev/null +++ b/test/idiscover.cc | |||
@@ -0,0 +1,49 @@ | |||
1 | #include <iostream> | ||
2 | #include <stdexcept> | ||
3 | #include <iterator> | ||
4 | #include <algorithm> | ||
5 | using namespace std; | ||
6 | #include <opkele/exception.h> | ||
7 | #include <opkele/discovery.h> | ||
8 | |||
9 | template<typename _PDT> | ||
10 | ostream& operator<<(ostream& o,const opkele::xrd::priority_map<_PDT>& pm) { | ||
11 | for(typename opkele::xrd::priority_map<_PDT>::const_iterator i=pm.begin(); | ||
12 | i!=pm.end();++i) | ||
13 | o << ' ' << i->second << '[' << i->first << ']'; | ||
14 | return o; | ||
15 | } | ||
16 | |||
17 | ostream& operator<<(ostream& o,const opkele::xrd::service_t s) { | ||
18 | o << "{" << endl | ||
19 | << " Type: "; | ||
20 | copy(s.types.begin(),s.types.end(), | ||
21 | ostream_iterator<string>(o," ")); | ||
22 | o << endl | ||
23 | << " URI: " << s.uris << endl | ||
24 | << " LocalID: " << s.local_ids << endl; | ||
25 | o << "}"; | ||
26 | } | ||
27 | |||
28 | int main(int argc,char **argv) { | ||
29 | try { | ||
30 | if(argc<2) | ||
31 | throw opkele::exception(OPKELE_CP_ "Please, give me something to resolve"); | ||
32 | for(int a=1;a<argc;++a) { | ||
33 | opkele::idiscovery_t discovery(argv[a]); | ||
34 | clog | ||
35 | << "===============================================================" << endl | ||
36 | << "User-supplied ID: " << argv[a] << endl | ||
37 | << "Normalized ID: " << discovery.normalized_id << endl | ||
38 | << "Canonicalized ID: " << discovery.canonicalized_id << endl | ||
39 | << endl | ||
40 | << "CanonicalID: " << discovery.xrd.canonical_ids << endl | ||
41 | << "LocalID: " << discovery.xrd.local_ids << endl | ||
42 | << "Services: " << discovery.xrd.services << endl; | ||
43 | } | ||
44 | }catch(exception& e) { | ||
45 | cerr << "oops: " << e.what() << endl; | ||
46 | _exit(1); | ||
47 | } | ||
48 | _exit(0); | ||
49 | } | ||
diff --git a/test/openid_resolve.cc b/test/openid_resolve.cc deleted file mode 100644 index 31c7a6a..0000000 --- a/test/openid_resolve.cc +++ b/dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | #include <iostream> | ||
2 | #include <stdexcept> | ||
3 | #include <iterator> | ||
4 | #include <algorithm> | ||
5 | using namespace std; | ||
6 | #include <opkele/exception.h> | ||
7 | #include <opkele/openid_service_resolver.h> | ||
8 | |||
9 | int main(int argc,char **argv) { | ||
10 | try { | ||
11 | if(argc<2) | ||
12 | throw opkele::exception(OPKELE_CP_ "Please, give me something to resolve"); | ||
13 | opkele::openid_service_resolver_t resolver; | ||
14 | for(int a=1;a<argc;++a) { | ||
15 | const opkele::openid_auth_info_t& iai = resolver.resolve(argv[a]); | ||
16 | clog | ||
17 | << "====================" << endl | ||
18 | << "canonical id is " << iai.canonical_id << endl | ||
19 | << endl | ||
20 | << "service priority is " << iai.auth_SEP.priority << endl | ||
21 | << "service types are " ; | ||
22 | copy( | ||
23 | iai.auth_SEP.xrd_Type.begin(), iai.auth_SEP.xrd_Type.end(), | ||
24 | ostream_iterator<string>(clog," ") ); | ||
25 | clog << endl | ||
26 | << "service URI is " << iai.auth_SEP.xrd_URI << endl; | ||
27 | if(!iai.auth_SEP.openid_Delegate.empty()) | ||
28 | clog << "openid:Delegate is " << iai.auth_SEP.openid_Delegate << endl; | ||
29 | clog << endl; | ||
30 | } | ||
31 | }catch(exception& e) { | ||
32 | cerr << "oops: " << e.what() << endl; | ||
33 | _exit(1); | ||
34 | } | ||
35 | _exit(0); | ||
36 | } | ||