-rw-r--r-- | acinclude.m4 | 17 | ||||
-rw-r--r-- | configure.ac | 32 | ||||
-rw-r--r-- | include/Makefile.am | 3 | ||||
-rw-r--r-- | include/opkele/consumer.h | 6 | ||||
-rw-r--r-- | include/opkele/server.h | 4 | ||||
-rw-r--r-- | include/opkele/types.h | 7 |
6 files changed, 59 insertions, 10 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index 80defc7..fbb4cdc 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,166 +1,183 @@ dnl AC_WITH_DOXYGEN([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) dnl Outputs: dnl AC_SUBST: DOXYGEN HAVE_DOXYGEN dnl AM_CONDTIONAL: HAVE_DOXYGEN AC_DEFUN([AC_WITH_DOXYGEN],[ HAVE_DOXYGEN="no" AC_PATH_PROG([DOXYGEN],[doxygen],[false]) if test "${DOXYGEN}" = "false" ; then ifelse([$2], , :, [$2]) else HAVE_DOXYGEN="yes" AC_SUBST([DOXYGEN]) $1 fi AC_SUBST([HAVE_DOXYGEN]) AM_CONDITIONAL([HAVE_DOXYGEN],[test "${HAVE_DOXYGEN}" = "yes"]) ]) dnl AC_WITH_DOT([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) dnl Outputs: dnl AC_SUBST: DOT HAVE_DOT dnl AM_CONDITIONAL: HAVE_DOT AC_DEFUN([AC_WITH_DOT],[ HAVE_DOT="no" AC_PATH_PROG([DOT],[dot],[false]) if test "${DOT}" = "false" ; then ifelse([$2], , :, [$2]) else HAVE_DOT="yes" AC_SUBST([DOT]) $1 fi AC_SUBST([HAVE_DOT]) AM_CONDITIONAL([HAVE_DOT],[test "${HAVE_DOT}" = "yes"]) ]) dnl AC_WITH_PCRE([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) dnl Outputs: dnl AC_SUBST: PCRE_CONFIG PCRE_PREFIX PCRE_EXEC_PREFIX dnl PCRE_VERSION PCRE_CFLAGS PCRE_LIBS dnl PCRE_LIBS_POSIX PCRE_CFLAGS_POSIX dnl AC_DEFINE: HAVE_PCRE PCRE_VERSION dnl env: HAVE_PCRE=yes|no AC_DEFUN([AC_WITH_PCRE],[ HAVE_PCRE="no" PCRE_CONFIG="" PCRE_PREFIX="" PCRE_EXEC_PREFIX="" PCRE_VERSION="" PCRE_CFLAGS="" PCRE_LIBS="" PCRE_LOCATIONS="${PATH}:/usr/local/bin:/usr/bin" test -z "$WANT_PCRE" && WANT_PCRE="" AC_ARG_WITH([pcre], AC_HELP_STRING([--with-pcre=location],[Look for pcre in specified locations]), [ if test "${withval}" = "no" ; then WANT_PCRE="no" else if test -x "${withval}" ; then PCRE_CONFIG="${withval}" elif test -x "${withval}/pcre-config" ; then PCRE_CONFIG="${withval}/pcre-config" elif test -x "${withval}/bin/pcre-config" ; then PCRE_CONFIG="${withval}/bin/pcre-config" fi fi ] ) if test "${WANT_PCRE}" = "no" ; then ifelse([$2], , :, [$2]) else if test -z "${PCRE_CONFIG}" ; then AC_PATH_PROG(PCRE_CONFIG,[pcre-config],false,[${PCRE_LOCATIONS}]) if test "${PCRE_CONFIG}" = "false" ; then ifelse([$2], , :, [$2]) else HAVE_PCRE="yes" PCRE_PREFIX="`${PCRE_CONFIG} --prefix`" PCRE_EXEC_PREFIX="`${PCRE_CONFIG} --exec-prefix`" PCRE_VERSION="`${PCRE_CONFIG} --version`" PCRE_CFLAGS="`${PCRE_CONFIG} --cflags`" PCRE_LIBS="`${PCRE_CONFIG} --libs`" PCRE_CFLAGS_POSIX="`${PCRE_CONFIG} --cflags-posix`" PCRE_LIBS_POSIX="`${PCRE_CONFIG} --libs-posix`" AC_SUBST([PCRE_CONFIG]) AC_SUBST([PCRE_PREFIX]) AC_SUBST([PCRE_EXEC_PREFIX]) AC_SUBST([PCRE_VERSION]) AC_SUBST([PCRE_CFLAGS]) AC_SUBST([PCRE_LIBS]) AC_SUBST([PCRE_CFLAGS_POSIX]) AC_SUBST([PCRE_LIBS_POSIX]) AC_DEFINE([HAVE_PCRE],,[pcre support]) AC_DEFINE_UNQUOTED([PCRE_VERSION],["${PCRE_VERSION}"],[pcre version]) $1 fi fi fi ]) dnl AC_WITH_PCREPP([ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) dnl Outputs: dnl AC_SUBST: PCREPP_CONFIG PCREPP_PREFIX PCREPP_EXEC_PREFIX dnl PCREPP_VERSION PCREPP_CFLAGS PCREPP_LIBS dnl AC_DEFINE: HAVE_PCREPP PCREPP_VERSION dnl env: HAVE_PCREPP=yes|no AC_DEFUN([AC_WITH_PCREPP],[ HAVE_PCREPP="no" PCREPP_CONFIG="" PCREPP_PREFIX="" PCREPP_EXEC_PREFIX="" PCREPP_VERSION="" PCREPP_CFLAGS="" PCREPP_LIBS="" PCREPP_LOCATIONS="${PATH}:/usr/local/bin:/usr/bin" test -z "$WANT_PCREPP" && WANT_PCREPP="" AC_ARG_WITH([pcrepp], AC_HELP_STRING([--with-pcrepp=location],[Look for pcre++ in specified locations]), [ if test "${withval}" = "no" ; then WANT_PCREPP="no" else if test -x "${withval}" ; then PCREPP_CONFIG="${withval}" elif test -x "${withval}/pcre++-config" ; then PCREPP_CONFIG="${withval}/pcre++-config" elif test -x "${withval}/bin/pcre++-config" ; then PCREPP_CONFIG="${withval}/bin/pcre++-config" fi fi ] ) if test "${WANT_PCREPP}" = "no" ; then ifelse([$2], , :, [$2]) else if test "${HAVE_PCRE}" != "yes" ; then ifelse([$2], , :, [$2]) else if test -z "${PCREPP_CONFIG}" ; then AC_PATH_PROG([PCREPP_CONFIG],[pcre++-config],false,[${PCREPP_LOCATIONS}]) if test "${PCREPP_CONFIG}" = "false" ; then ifelse([$2], , :, [$2]) else HAVE_PCREPP="yes" PCREPP_PREFIX="`${PCREPP_CONFIG} --prefix`" PCREPP_EXEC_PREFIX="`${PCREPP_CONFIG} --exec-prefix`" PCREPP_VERSION="`${PCREPP_CONFIG} --version`" PCREPP_CFLAGS="`${PCREPP_CONFIG} --cflags` ${PCRE_CFLAGS}" PCREPP_LIBS="`${PCREPP_CONFIG} --libs` ${PCRE_LIBS}" AC_SUBST([PCREPP_CONFIG]) AC_SUBST([PCREPP_PREFIX]) AC_SUBST([PCREPP_EXEC_PREFIX]) AC_SUBST([PCREPP_VERSION]) AC_SUBST([PCREPP_CFLAGS]) AC_SUBST([PCREPP_LIBS]) AC_DEFINE([HAVE_PCREPP],,[pcre++ support]) AC_DEFINE_UNQUOTED([PCREPP_VERSION],["${PCREPP_VERSION}"],[pcre++ version]) $1 fi fi fi fi ]) +dnl AC_CHECK_SHAREDPTR(NS,HEADER[,ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]) +AC_DEFUN([AC_CHECK_SHAREDPTR],[ + AC_LANG_PUSH([C++]) + AC_MSG_CHECKING([for $1::shared_ptr<> in $2]) + AC_COMPILE_IFELSE([ + #include <$2> + int main(int c,char**v) { $1::shared_ptr<int> spi(new int(0)); return *spi; } + ],[ + AC_MSG_RESULT([found]) + $3 + ],[ + AC_MSG_RESULT([not found]) + $4 + ]) + AC_LANG_POP([C++]) +]) + m4_include([acinclude.d/libcurl.m4]) diff --git a/configure.ac b/configure.ac index 1bd1873..c4e9a74 100644 --- a/configure.ac +++ b/configure.ac @@ -1,150 +1,182 @@ AC_INIT([libopkele], [0.4], [libopkele-bugs@klever.net]) AC_CONFIG_SRCDIR([include/opkele/opkele-config.h]) AC_CONFIG_HEADERS([config.h include/opkele/acconfig.h]) AM_INIT_AUTOMAKE([dist-bzip2]) AC_PROG_INSTALL AC_PROG_CXX AC_PROG_CC AC_PROG_LIBTOOL PKG_PROG_PKG_CONFIG AC_HEADER_STDC AC_PATH_PROG([XSLTPROC],[xsltproc],[true]) AC_MSG_CHECKING([for source tree version]) if headrev=$(cd $srcdir && git rev-parse --verify HEAD 2>/dev/null) ; then PACKAGE_SRC_VERSION="$(cd $srcdir && git describe --tags $headrev)" test "$PACKAGE_SRC_VERSION" = "$PACKAGE_VERSION" \ -o "${PACKAGE_SRC_VERSION#${PACKAGE_VERSION}-}" != "$PACKAGE_SRC_VERSION" || PACKAGE_SRC_VERSION="${PACKAGE_VERSION}:${PACKAGE_SRC_VERSION}" ( cd $srcdir && git diff-index $headrev | read dirt ) && PACKAGE_SRC_VERSION="${PACKAGE_SRC_VERSION}-dirty" else PACKAGE_SRC_VERSION="$PACKAGE_VERSION" fi AC_MSG_RESULT([$PACKAGE_SRC_VERSION]) AC_SUBST([PACKAGE_SRC_VERSION]) AC_DEFINE_UNQUOTED([PACKAGE_SRC_VERSION],["$PACKAGE_SRC_VERSION"],[more or less precise source tree version]) +tr1_mem_std="false" +tr1_mem_boost="false" +AC_CHECK_SHAREDPTR(std::tr1,tr1/memory,[ tr1_mem_std=true ]) +AC_CHECK_SHAREDPTR(boost,boost/shared_ptr.hpp,[ tr1_mem_boost=true ]) +tr1_mem="" +AC_ARG_WITH([tr1-memory], + AC_HELP_STRING([--with-tr1-memory=<boost|std>],[select tr1/memory (shared_ptr<>) implementation to use]), + [ tr1_mem="$withval" ] +) +AC_MSG_CHECKING([for tr1/memory implementation to use]) +test -z "$tr1_mem" && $tr1_mem_std && tr1_mem=std +test -z "$tr1_mem" && $tr1_mem_boost && tr1_mem=boost +test -z "$tr1_mem" && AC_MSG_RESULT([none found]) || AC_MSG_RESULT([$tr1_mem]) +case "$tr1_mem" in + std) + $tr1_mem_std || AC_MSG_ERROR([std implementation requested, but not found]) + OPKELE_TR1_MEM_NS=std::tr1 + OPKELE_TR1_MEM_HEADER=tr1/memory + ;; + boost) + $tr1_mem_boost || AC_MSG_ERROR([boost implementation requested, but not found]) + OPKELE_TR1_MEM_NS=boost + OPKELE_TR1_MEM_HEADER=boost/shared_ptr.hpp + ;; + *) + AC_MSG_ERROR([no shared_ptr<> implementation found]) + ;; +esac +AC_SUBST([OPKELE_TR1_MEM_NS]) +AC_SUBST([OPKELE_TR1_MEM_HEADER]) + PKG_CHECK_MODULES([OPENSSL],[openssl],,[ AC_MSG_ERROR([no openssl library found. get one from http://www.openssl.org/]) ]) WANT_KONFORKA="yes" AC_ARG_ENABLE([konforka], AC_HELP_STRING([--disable-konforka],[do not use konforka library (default: use if found)]), [ test "${enableval}" = "no" && WANT_KONFORKA="no" ] ) if test "${WANT_KONFORKA}" = "yes" ; then PKG_CHECK_MODULES([KONFORKA],[konforka],[ AC_SUBST([KONFORKA_CFLAGS]) AC_SUBST([KONFORKA_LIBS]) AC_DEFINE([HAVE_KONFORKA],,[defined in presence of konforka library]) AC_DEFINE([OPKELE_HAVE_KONFORKA],,[defined in presence of konforka library]) AC_SUBST([KONFORKA_KONFORKA],[konforka]) ],[true]) fi WANT_DOXYGEN="yes" AC_ARG_ENABLE([doxygen], AC_HELP_STRING([--disable-doxygen],[do not generate documentation]), [ test "${enableval}" = "no" && WANT_DOXYGEN="no" ] ) if test "${WANT_DOXYGEN}" = "yes" ; then AC_WITH_DOXYGEN AC_WITH_DOT else AM_CONDITIONAL([HAVE_DOXYGEN],[false]) AM_CONDITIONAL([HAVE_DOT],[false]) fi LIBCURL_CHECK_CONFIG(,,,[ AC_MSG_ERROR([no required libcurl library. get one from http://curl.haxx.se/]) ]) AC_CHECK_HEADER([expat.h],[ AC_CHECK_LIB([expat],[XML_ParserCreate],[ EXPAT_LIBS=-lexpat EXPAT_CFLAGS= AC_SUBST([EXPAT_LIBS]) AC_SUBST([EXPAT_CFLAGS]) ],[ AC_MSG_ERROR([no required expat library. get one from http://expat.sourceforge.net/]) ]) ],[ AC_MSG_ERROR([no required expat library. get one from http://expat.sourceforge.net/]) ]) if test -n "$PCRE_LIBS" -a -n "$PCRE_CFLAGS" ; then AC_SUBST([PCRE_CFLAGS]) AC_SUBST([PCRE_LIBS]) : else PKG_CHECK_MODULES([PCRE],[libpcre],,[ AC_MSG_ERROR([no libpcre found, go get it at http://www.pcre.org/]) ]) fi curl_ssl_verify_host="true" AC_ARG_ENABLE([ssl-verify-host], AC_HELP_STRING([--disable-ssl-verify-host],[disable cURL cert/host relationships verification]), [ test "${enableval}" = "no" && curl_ssl_verify_host="false" ] ) ${curl_ssl_verify_host} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYHOST],,[defined if cURL is not to verify cert/host]) curl_ssl_verify_peer="true" AC_ARG_ENABLE([ssl-verify-peer], AC_HELP_STRING([--disable-ssl-verify-peer],[disable cURL cert validity verification]), [ test "${enableval}" = "no" && curl_ssl_verify_peer="false" ] ) ${curl_ssl_verify_peer} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYPEER],,[defined if cURL is not to verify cert validity]) postels_law=true AC_ARG_ENABLE([postels-law], AC_HELP_STRING([--disable-postels-law],[Be strict, do not adhere to Postel's Law ("be conservative in what you do, be liberal in what you accept from others", RFC 793)]), [ test "${enableval}" = "no" && postels_law=false ] ) $postels_law && AC_DEFINE([POSTELS_LAW],,[defined if we want to adhere to Postel's Law]) AC_DEFINE_UNQUOTED([OPKELE_SRC_DIR],["$PWD"],[source directory]) nitpick=false AC_ARG_ENABLE([nitpicking], AC_HELP_STRING([--enable-nitpicking],[make compiler somewhat overly fastidious about the code it deals with]), [ test "$enableval" = "no" || nitpick=true ] ) if $nitpick ; then CPP_NITPICK="-pedantic -Wall -Wextra -Wundef -Wshadow \ -Wunsafe-loop-optimizations -Wconversion -Wmissing-format-attribute \ -Wredundant-decls -ansi" # -Wlogical-op -Wmissing-noreturn C_NITPICK="$CPP_NITPICK" CXX_NITPICK="$C_NITPICK" CPPFLAGS="$CPPFLAGS $CPP_NITPICK" CFLAGS="$CFLAGS $C_NITPICK" CXXFLAGS="$CXXFLAGS $CXX_NITPICK" fi xri_proxy_url="http://beta.xri.net/" AC_MSG_CHECKING([for XRI resolver proxy]) AC_ARG_ENABLE([xri-proxy], AC_HELP_STRING([--with-xri-proxy=url],[set xri proxy for use when resolving xri identities, default is http://xr_proxy_url]), [ xri_proxy_url="$withval" ] ) AC_MSG_RESULT([$xri_proxy_url]) AC_DEFINE_UNQUOTED([XRI_PROXY_URL],["$xri_proxy_url"],[XRI proxy resolver URL]) AC_CONFIG_FILES([ Makefile libopkele.pc Doxyfile include/Makefile + include/opkele/tr1-mem.h lib/Makefile test/Makefile ]) AC_OUTPUT diff --git a/include/Makefile.am b/include/Makefile.am index 078c6dc..26cb614 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,19 +1,20 @@ nobase_include_HEADERS = \ opkele/acconfig.h \ opkele/opkele-config.h \ opkele/types.h \ opkele/association.h \ opkele/exception.h \ opkele/server.h \ opkele/consumer.h \ opkele/extension.h \ opkele/sreg.h \ opkele/extension_chain.h \ opkele/xconsumer.h \ opkele/xserver.h \ opkele/discovery.h \ - opkele/uris.h + opkele/uris.h \ + opkele/tr1-mem.h EXTRA_DIST = \ opkele/data.h \ opkele/curl.h opkele/expat.h \ opkele/util.h diff --git a/include/opkele/consumer.h b/include/opkele/consumer.h index c463787..3c1d318 100644 --- a/include/opkele/consumer.h +++ b/include/opkele/consumer.h @@ -1,174 +1,174 @@ #ifndef __OPKELE_CONSUMER_H #define __OPKELE_CONSUMER_H #include <opkele/types.h> #include <opkele/extension.h> /** * @file * @brief OpenID consumer-side functionality */ namespace opkele { /** * implementation of basic consumer functionality * * @note * The consumer uses libcurl internally, which means that if you're using * libopkele in multithreaded environment you should call curl_global_init * yourself before spawning any threads. */ class consumer_t { public: virtual ~consumer_t() { } /** * store association. The function should be overridden in the real * implementation to provide persistent associations store. * @param server the OpenID server * @param handle association handle * @param secret the secret associated with the server and handle * @param expires_in the number of seconds until the handle is expired - * @return the auto_ptr<> for the newly allocated association_t object + * @return the assoc_t for the newly allocated association_t object */ virtual assoc_t store_assoc(const string& server,const string& handle,const secret_t& secret,int expires_in) = 0; /** * retrieve stored association. The function should be overridden * in the real implementation to provide persistent assocations * store. * * @note * The user is responsible for handling associations expiry and * this function should never return an expired or invalidated * association. * * @param server the OpenID server * @param handle association handle * @return the autho_ptr<> for the newly allocated association_t object * @throw failed_lookup if no unexpired association found */ virtual assoc_t retrieve_assoc(const string& server,const string& handle) = 0; /** * invalidate stored association. The function should be overridden * in the real implementation of the consumer. * @param server the OpenID server * @param handle association handle */ virtual void invalidate_assoc(const string& server,const string& handle) = 0; /** * retrieve any unexpired association for the server. If the * function is not overridden in the real implementation, the new * association will be established for each request. * * @note * The user is responsible for handling associations and this * function should never return an expired or invalidated * association. * * @note * It may be a good idea to pre-expire associations shortly before * their time is really up to avoid association expiry in the * middle of negotiations. * * @param server the OpenID server - * @return the auto_ptr<> for the newly allocated association_t object + * @return the assoc_t for the newly allocated association_t object * @throw failed_lookup in case of absence of the handle */ virtual assoc_t find_assoc(const string& server); /** * retrieve the metainformation contained in link tags from the * page pointed by url. the function may implement caching of the * information. * @param url url to harvest for link tags * @param server reference to the string object where to put * openid.server value * @param delegate reference to the string object where to put the * openid.delegate value (if any) */ virtual void retrieve_links(const string& url,string& server,string& delegate); /** * perform the associate request to OpenID server. * @param server the OpenID server - * @return the auto_ptr<> for the newly allocated association_t + * @return the assoc_t for the newly allocated association_t * object, representing established association * @throw exception in case of error */ assoc_t associate(const string& server); /** * prepare the parameters for the checkid_immediate * request. * @param identity the identity to verify * @param return_to the return_to url to pass with the request * @param trust_root the trust root to advertise with the request * @param ext pointer to an extension(s) hooks object * @return the location string * @throw exception in case of error */ virtual string checkid_immediate(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); /** * prepare the parameters for the checkid_setup * request. * @param identity the identity to verify * @param return_to the return_to url to pass with the request * @param trust_root the trust root to advertise with the request * @param ext pointer to an extension(s) hooks object * @return the location string * @throw exception in case of error */ virtual string checkid_setup(const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); /** * the actual implementation behind checkid_immediate() and * checkid_setup() functions. * @param mode checkid_* mode - either mode_checkid_immediate or mode_checkid_setup * @param identity the identity to verify * @param return_to the return_to url to pass with the request * @param trust_root the trust root to advertise with the request * @param ext pointer to an extension(s) hooks object * @return the location string * @throw exception in case of error */ virtual string checkid_(mode_t mode,const string& identity,const string& return_to,const string& trust_root="",extension_t *ext=0); /** * verify the id_res response * @param pin the response parameters * @param identity the identity being checked (if not specified, * @param ext pointer to an extension(s) hooks object * extracted from the openid.identity parameter * @throw id_res_mismatch in case of signature mismatch * @throw id_res_setup in case of openid.user_setup_url failure * (supposedly checkid_immediate only) * @throw id_res_failed in case of failure * @throw id_res_expired_on_delivery if the association expired before it could've been verified * @throw exception in case of other failures */ virtual void id_res(const params_t& pin,const string& identity="",extension_t *ext=0); /** * perform a check_authentication request. * @param server the OpenID server * @param p request parameters */ void check_authentication(const string& server,const params_t& p); /** * normalize URL by adding http:// and trailing slash if needed. * @param url * @return normalized url */ static string normalize(const string& url); /** * Canonicalize URL, by normalizing its appearance and following redirects. * @param url * @return canonicalized url */ virtual string canonicalize(const string& url); }; } #endif /* __OPKELE_CONSUMER_H */ diff --git a/include/opkele/server.h b/include/opkele/server.h index dd7fc41..3c25646 100644 --- a/include/opkele/server.h +++ b/include/opkele/server.h @@ -1,98 +1,98 @@ #ifndef __OPKELE_SERVER_H #define __OPKELE_SERVER_H /** * @file * @brief OpenID server-side functionality */ #include <opkele/types.h> #include <opkele/extension.h> namespace opkele { /** * implementation of basic server functionality */ class server_t { public: virtual ~server_t() { } /** * allocate the new association. The function should be overridden * in the real implementation to provide persistent assocations * store. * @param mode the mode of request being processed to base the * statelessness of the association upon - * @return the auto_ptr<> for the newly allocated association_t object + * @return the assoc_t for the newly allocated association_t object */ virtual assoc_t alloc_assoc(mode_t mode) = 0; /** * retrieve the association. The function should be overridden in * the reqal implementation to provide persistent assocations * store. * @param h association handle - * @return the auto_ptr<> for the newly allocated association_t object + * @return the assoc_t for the newly allocated association_t object * @throw failed_lookup in case of failure */ virtual assoc_t retrieve_assoc(const string& h) = 0; /** * validate the identity. * @param assoc association object * @param pin incoming request parameters * @param identity being verified * @param trust_root presented in the request * @throw exception if identity can not be confirmed */ virtual void validate(const association_t& assoc,const params_t& pin,const string& identity,const string& trust_root) = 0; /** * process the associate request. * @param pin the incoming request parameters * @param pout the store for the response parameters */ void associate(const params_t& pin,params_t& pout); /** * process the checkid_immediate request. * @param pin the incoming request parameters * @param return_to reference to the object to store return_to url to * @param pout the response parameters * @param ext pointer to the extension hooks object * @throw exception in case of errors or negative reply */ virtual void checkid_immediate(const params_t& pin,string& return_to,params_t& pout,extension_t *ext=0); /** * process the checkid_setup request. * @param pin the incoming request parameters * @param return_to reference to the object to store return_to url to * @param pout the response parameters * @param ext pointer to the extension hooks object * @throw exception in case of errors or negative reply */ virtual void checkid_setup(const params_t& pin,string& return_to,params_t& pout,extension_t *ext=0); /** * the actual functionality behind checkid_immediate() and * checkid_setup() * @param mode the request being processed (either * mode_checkid_immediate or mode_checkid_setup) * @param pin the incoming request parameters * @param return_to reference to the object to store return_to url to * @param pout the response parameters * @param ext pointer to the extension hooks object * @throw exception in case of errors or negative reply */ virtual void checkid_(mode_t mode,const params_t& pin,string& return_to,params_t& pout,extension_t *ext=0); /** * process the check_authentication request. * @param pin incoming request parameters * @param pout response parameters */ void check_authentication(const params_t& pin,params_t& pout); }; } #endif /* __OPKELE_SERVER_H */ diff --git a/include/opkele/types.h b/include/opkele/types.h index ca07df5..d959021 100644 --- a/include/opkele/types.h +++ b/include/opkele/types.h @@ -1,243 +1,242 @@ #ifndef __OPKELE_TYPES_H #define __OPKELE_TYPES_H /** * @file * @brief various types declarations */ #include <ostream> #include <vector> #include <string> #include <map> -#include <memory> #include <set> +#include <opkele/tr1-mem.h> namespace opkele { using std::vector; using std::string; using std::map; using std::ostream; - using std::auto_ptr; using std::multimap; using std::set; /** * the OpenID operation mode */ typedef enum _mode_t { mode_associate, mode_checkid_immediate, mode_checkid_setup, mode_check_association } mode_t; /** * the association secret container */ class secret_t : public vector<unsigned char> { public: /** * xor the secret and hmac together and encode, using base64 * @param key_d pointer to the message digest * @param rv reference to the return value */ void enxor_to_base64(const unsigned char *key_d,string& rv) const; /** * decode base64-encoded secret and xor it with the message digest * @param key_d pointer to the message digest * @param b64 base64-encoded secret value */ void enxor_from_base64(const unsigned char *key_d,const string& b64); /** * plainly encode to base64 representation * @param rv reference to the return value */ void to_base64(string& rv) const; /** * decode cleartext secret from base64 * @param b64 base64-encoded representation of the secret value */ void from_base64(const string& b64); }; /** * Interface to the association. */ class association_t { public: virtual ~association_t() { } /** * retrieve the server with which association was established. * @return server name */ virtual string server() const = 0; /** * retrieve the association handle. * @return handle */ virtual string handle() const = 0; /** * retrieve the association type. * @return association type */ virtual string assoc_type() const = 0; /** * retrieve the association secret. * @return association secret */ virtual secret_t secret() const = 0; /** * retrieve the number of seconds the association expires in. * @return seconds till expiration */ virtual int expires_in() const = 0; /** * check whether the association is stateless. * @return true if stateless */ virtual bool stateless() const = 0; /** * check whether the association is expired. * @return true if expired */ virtual bool is_expired() const = 0; }; /** - * the auto_ptr<> for association_t object type + * the shared_ptr<> for association_t object type */ - typedef auto_ptr<association_t> assoc_t; + typedef tr1mem::shared_ptr<association_t> assoc_t; /** * request/response parameters map */ class params_t : public map<string,string> { public: /** * check whether the parameter is present. * @param n the parameter name * @return true if yes */ bool has_param(const string& n) const; /** * retrieve the parameter (const version) * @param n the parameter name * @return the parameter value * @throw failed_lookup if there is no such parameter */ const string& get_param(const string& n) const; /** * retrieve the parameter. * @param n the parameter name * @return the parameter value * @throw failed_lookup if there is no such parameter */ string& get_param(const string& n); /** * parse the OpenID key/value data. * @param kv the OpenID key/value data */ void parse_keyvalues(const string& kv); /** * sign the fields. * @param secret the secret used for signing * @param sig reference to the string, containing base64-encoded * result * @param slist the comma-separated list of fields to sign * @param prefix the string to prepend to parameter names */ void sign(secret_t secret,string& sig,const string& slist,const char *prefix=0) const; /** * append parameters to the URL as a GET-request parameters. * @param url the base URL * @param prefix the string to prepend to parameter names * @return the ready-to-use location */ string append_query(const string& url,const char *prefix = "openid.") const; /** * make up a query string suitable for use in GET and POST * requests. * @param prefix string to prened to parameter names * @return query string */ string query_string(const char *prefix = "openid.") const; }; /** * dump the key/value pairs for the parameters to the stream. * @param o output stream * @param p the parameters */ ostream& operator << (ostream& o,const params_t& p); namespace xrd { struct priority_compare { inline bool operator()(long a,long b) const { return (a<0) ? false : (b<0) ? false : (a<b); } }; template <typename _DT> class priority_map : public multimap<long,_DT,priority_compare> { typedef multimap<long,_DT,priority_compare> map_type; public: inline _DT& add(long priority,const _DT& d) { return insert(typename map_type::value_type(priority,d))->second; } }; typedef priority_map<string> canonical_ids_t; typedef priority_map<string> local_ids_t; typedef set<string> types_t; typedef priority_map<string> uris_t; class service_t { public: types_t types; uris_t uris; local_ids_t local_ids; void clear() { types.clear(); uris.clear(); local_ids.clear(); } }; typedef priority_map<service_t> services_t; class XRD_t { public: time_t expires; canonical_ids_t canonical_ids; local_ids_t local_ids; services_t services; void clear() { expires = 0; canonical_ids.clear(); local_ids.clear(); services.clear(); } bool empty() const { return canonical_ids.empty() && local_ids.empty() && services.empty(); } }; } } #endif /* __OPKELE_TYPES_H */ |