diff options
author | PKI Team <PKI Team@c9f7a03b-bd48-0410-a16d-cbbf54688b0b> | 2008-03-18 22:36:57 +0000 |
---|---|---|
committer | PKI Team <PKI Team@c9f7a03b-bd48-0410-a16d-cbbf54688b0b> | 2008-03-18 22:36:57 +0000 |
commit | d0f2e4efbd3eb0f1d7f5a28e7f97c1fb4ec027bb (patch) | |
tree | 7e7473fae8af5ad7e6cda7eabbef787093fc59a7 /pki/base/tps/src/include | |
parent | 273f8d85df5c31293a908185622b378c8f3cf7e8 (diff) | |
download | pki-d0f2e4efbd3eb0f1d7f5a28e7f97c1fb4ec027bb.tar.gz pki-d0f2e4efbd3eb0f1d7f5a28e7f97c1fb4ec027bb.tar.xz pki-d0f2e4efbd3eb0f1d7f5a28e7f97c1fb4ec027bb.zip |
Initial open source version based upon proprietary Red Hat Certificate System (RHCS) 7.3.
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/trunk@2 c9f7a03b-bd48-0410-a16d-cbbf54688b0b
Diffstat (limited to 'pki/base/tps/src/include')
155 files changed, 15038 insertions, 0 deletions
diff --git a/pki/base/tps/src/include/apdu/APDU.h b/pki/base/tps/src/include/apdu/APDU.h new file mode 100644 index 000000000..e0f778a19 --- /dev/null +++ b/pki/base/tps/src/include/apdu/APDU.h @@ -0,0 +1,116 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef APDU_H +#define APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "pk11func.h" +#include "main/Base.h" +#include "main/Buffer.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +enum APDU_Type { + APDU_UNDEFINED = 0, + APDU_CREATE_OBJECT = 1, + APDU_EXTERNAL_AUTHENTICATE = 2, + APDU_INITIALIZE_UPDATE = 3, + APDU_LIFECYCLE = 4, + APDU_READ_BUFFER = 5, + APDU_SET_PIN = 6, + APDU_UNBLOCK_PIN = 7, + APDU_WRITE_OBJECT = 8, + APDU_GENERATE_KEY = 9, + APDU_PUT_KEY = 10, + APDU_SELECT = 11, + APDU_GET_VERSION = 12, + APDU_DELETE_FILE = 13, + APDU_INSTALL_APPLET = 14, + APDU_FORMAT_MUSCLE_APPLET = 15, + APDU_LOAD_FILE = 16, + APDU_INSTALL_LOAD = 17, + APDU_GET_STATUS = 18 , + APDU_LIST_PINS = 19, + APDU_CREATE_PIN = 20, + APDU_GET_DATA = 21, + APDU_READ_OBJECT = 22, + APDU_LIST_OBJECTS = 23, + APDU_IMPORT_KEY = 24, + APDU_IMPORT_KEY_ENC = 25, + APDU_SET_ISSUERINFO = 26, + APDU_GET_ISSUERINFO = 27 +}; + +class APDU +{ + public: + TPS_PUBLIC APDU(); + TPS_PUBLIC APDU(const APDU &cpy); + TPS_PUBLIC virtual ~APDU(); + public: + TPS_PUBLIC APDU& operator=(const APDU& cpy); + public: + TPS_PUBLIC virtual void SetCLA(BYTE cla); + TPS_PUBLIC virtual void SetINS(BYTE ins); + TPS_PUBLIC virtual void SetP1(BYTE p1); + TPS_PUBLIC virtual void SetP2(BYTE p2); + TPS_PUBLIC virtual void SetData(Buffer &data); + TPS_PUBLIC virtual void SetMAC(Buffer &mac); + TPS_PUBLIC virtual void GetEncoding(Buffer &data); + TPS_PUBLIC virtual void GetDataToMAC(Buffer &data); + TPS_PUBLIC virtual PRStatus SecureMessage(PK11SymKey *encSessionKey); + TPS_PUBLIC virtual APDU_Type GetType(); + TPS_PUBLIC Buffer &GetData(); + TPS_PUBLIC Buffer &GetMAC(); + TPS_PUBLIC BYTE GetCLA(); + TPS_PUBLIC BYTE GetINS(); + TPS_PUBLIC BYTE GetP1(); + TPS_PUBLIC BYTE GetP2(); + protected: + BYTE m_cla; + BYTE m_ins; + BYTE m_p1; + BYTE m_p2; + Buffer m_data; + Buffer m_plainText; + Buffer m_mac; +}; + +#endif /* APDU_H */ diff --git a/pki/base/tps/src/include/apdu/APDU_Response.h b/pki/base/tps/src/include/apdu/APDU_Response.h new file mode 100644 index 000000000..0d5c62b9d --- /dev/null +++ b/pki/base/tps/src/include/apdu/APDU_Response.h @@ -0,0 +1,66 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef APDU_RESPONSE_H +#define APDU_RESPONSE_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/Buffer.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class APDU_Response +{ + public: + APDU_Response(); + TPS_PUBLIC APDU_Response(Buffer &data); + ~APDU_Response(); + APDU_Response(const APDU_Response &cpy); + public: + APDU_Response& operator=(const APDU_Response& cpy); + public: + BYTE GetSW1(); + BYTE GetSW2(); + TPS_PUBLIC Buffer &GetData(); + private: + Buffer m_data; +}; + +#endif /* APDU_Response_H */ diff --git a/pki/base/tps/src/include/apdu/Create_Object_APDU.h b/pki/base/tps/src/include/apdu/Create_Object_APDU.h new file mode 100644 index 000000000..7433e7ceb --- /dev/null +++ b/pki/base/tps/src/include/apdu/Create_Object_APDU.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef CREATE_OBJECT_APDU_H +#define CREATE_OBJECT_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Create_Object_APDU : public APDU +{ + public: + TPS_PUBLIC Create_Object_APDU(BYTE *object_id, BYTE *permissions, int len); + TPS_PUBLIC ~Create_Object_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* CREATE_OBJECT_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Create_Pin_APDU.h b/pki/base/tps/src/include/apdu/Create_Pin_APDU.h new file mode 100644 index 000000000..7f666467d --- /dev/null +++ b/pki/base/tps/src/include/apdu/Create_Pin_APDU.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef CREATE_PIN_APDU_H +#define CREATE_PIN_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Create_Pin_APDU : public APDU +{ + public: + TPS_PUBLIC Create_Pin_APDU(BYTE p1, BYTE p2, Buffer &data); + TPS_PUBLIC ~Create_Pin_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* CREATE_PIN_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Delete_File_APDU.h b/pki/base/tps/src/include/apdu/Delete_File_APDU.h new file mode 100644 index 000000000..9e2eeeeb2 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Delete_File_APDU.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef DELETE_FILE_APDU_H +#define DELETE_FILE_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Delete_File_APDU : public APDU +{ + public: + TPS_PUBLIC Delete_File_APDU(Buffer &AID); + TPS_PUBLIC ~Delete_File_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* DELETE_FILE_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/External_Authenticate_APDU.h b/pki/base/tps/src/include/apdu/External_Authenticate_APDU.h new file mode 100644 index 000000000..ff9a6bee7 --- /dev/null +++ b/pki/base/tps/src/include/apdu/External_Authenticate_APDU.h @@ -0,0 +1,62 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef EXTERNAL_AUTHENTICATE_APDU_H +#define EXTERNAL_AUTHENTICATE_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/Buffer.h" +#include "apdu/APDU.h" +#include "channel/Secure_Channel.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class External_Authenticate_APDU : public APDU +{ + public: + // TPS_PUBLIC External_Authenticate_APDU(Buffer &data); + TPS_PUBLIC External_Authenticate_APDU(Buffer &data, SecurityLevel sl); + TPS_PUBLIC ~External_Authenticate_APDU(); + TPS_PUBLIC APDU_Type GetType(); + public: + TPS_PUBLIC Buffer &GetHostCryptogram(); +}; + +#endif /* EXTERNAL_AUTHENTICATE_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Format_Muscle_Applet_APDU.h b/pki/base/tps/src/include/apdu/Format_Muscle_Applet_APDU.h new file mode 100644 index 000000000..b7fbbbea1 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Format_Muscle_Applet_APDU.h @@ -0,0 +1,65 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef FORMAT_MUSCLE_APPLET_APDU_H +#define FORMAT_MUSCLE_APPLET_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Format_Muscle_Applet_APDU : public APDU +{ + public: + TPS_PUBLIC Format_Muscle_Applet_APDU(unsigned short memSize, + Buffer &PIN0, BYTE pin0Tries, + Buffer &unblockPIN0, BYTE unblock0Tries, + Buffer &PIN1, BYTE pin1Tries, + Buffer &unblockPIN1, BYTE unblock1Tries, + unsigned short objCreationPermissions, + unsigned short keyCreationPermissions, + unsigned short pinCreationPermissions); + TPS_PUBLIC ~Format_Muscle_Applet_APDU(); + TPS_PUBLIC APDU_Type GetType(); + TPS_PUBLIC void GetEncoding(Buffer &data); +}; + +#endif /* FORMAT_MUSCLE_APPLET_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Generate_Key_APDU.h b/pki/base/tps/src/include/apdu/Generate_Key_APDU.h new file mode 100644 index 000000000..d245b8336 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Generate_Key_APDU.h @@ -0,0 +1,60 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef GENERATE_KEY_APDU_H +#define GENERATE_KEY_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/Buffer.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Generate_Key_APDU : public APDU +{ + public: + TPS_PUBLIC Generate_Key_APDU (BYTE p1, BYTE p2, BYTE alg, + int keysize, BYTE option, + BYTE type, Buffer &wrapped_challenge, Buffer &key_check); + TPS_PUBLIC ~Generate_Key_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* GENERATE_KEY_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Get_Data_APDU.h b/pki/base/tps/src/include/apdu/Get_Data_APDU.h new file mode 100644 index 000000000..a4f78634d --- /dev/null +++ b/pki/base/tps/src/include/apdu/Get_Data_APDU.h @@ -0,0 +1,58 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef GET_DATA_APDU_H +#define GET_DATA_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Get_Data_APDU : public APDU +{ + public: + TPS_PUBLIC Get_Data_APDU(); + TPS_PUBLIC ~Get_Data_APDU(); + TPS_PUBLIC APDU_Type GetType(); + TPS_PUBLIC void GetEncoding(Buffer &data); +}; + +#endif /* GET_DATA_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Get_IssuerInfo_APDU.h b/pki/base/tps/src/include/apdu/Get_IssuerInfo_APDU.h new file mode 100644 index 000000000..075acc6d9 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Get_IssuerInfo_APDU.h @@ -0,0 +1,58 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef GET_ISSUERINFO_APDU_H +#define GET_ISSUERINFO_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Get_IssuerInfo_APDU : public APDU +{ + public: + TPS_PUBLIC Get_IssuerInfo_APDU(); + TPS_PUBLIC ~Get_IssuerInfo_APDU(); + TPS_PUBLIC APDU_Type GetType(); + TPS_PUBLIC void GetEncoding(Buffer &data); +}; + +#endif /* GET_ISSUERINFO_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Get_Status_APDU.h b/pki/base/tps/src/include/apdu/Get_Status_APDU.h new file mode 100644 index 000000000..5d047bf16 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Get_Status_APDU.h @@ -0,0 +1,58 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef GET_STATUS_APDU_H +#define GET_STATUS_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Get_Status_APDU : public APDU +{ + public: + TPS_PUBLIC Get_Status_APDU(); + TPS_PUBLIC ~Get_Status_APDU(); + TPS_PUBLIC APDU_Type GetType(); + TPS_PUBLIC void GetEncoding(Buffer &data); +}; + +#endif /* GET_STATUS_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Get_Version_APDU.h b/pki/base/tps/src/include/apdu/Get_Version_APDU.h new file mode 100644 index 000000000..8b6ff3c33 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Get_Version_APDU.h @@ -0,0 +1,58 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef GET_VERSION_APDU_H +#define GET_VERSION_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Get_Version_APDU : public APDU +{ + public: + TPS_PUBLIC Get_Version_APDU(); + TPS_PUBLIC ~Get_Version_APDU(); + TPS_PUBLIC APDU_Type GetType(); + TPS_PUBLIC void GetEncoding(Buffer &data); +}; + +#endif /* GET_VERSION_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Import_Key_APDU.h b/pki/base/tps/src/include/apdu/Import_Key_APDU.h new file mode 100644 index 000000000..e00d97081 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Import_Key_APDU.h @@ -0,0 +1,58 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef IMPORT_KEY_APDU_H +#define IMPORT_KEY_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/Buffer.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Import_Key_APDU : public APDU +{ + public: + TPS_PUBLIC Import_Key_APDU(BYTE p1); + TPS_PUBLIC ~Import_Key_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* IMPORT_KEY_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Import_Key_Enc_APDU.h b/pki/base/tps/src/include/apdu/Import_Key_Enc_APDU.h new file mode 100644 index 000000000..bcc974987 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Import_Key_Enc_APDU.h @@ -0,0 +1,58 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef IMPORT_KEY_ENC_APDU_H +#define IMPORT_KEY_ENC_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/Buffer.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Import_Key_Enc_APDU : public APDU +{ + public: + TPS_PUBLIC Import_Key_Enc_APDU(BYTE p1, BYTE p2, Buffer& data); + TPS_PUBLIC ~Import_Key_Enc_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* IMPORT_KEY_ENC_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Initialize_Update_APDU.h b/pki/base/tps/src/include/apdu/Initialize_Update_APDU.h new file mode 100644 index 000000000..8e20d77ab --- /dev/null +++ b/pki/base/tps/src/include/apdu/Initialize_Update_APDU.h @@ -0,0 +1,60 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef INITIALIZE_UPDATE_APDU_H +#define INITIALIZE_UPDATE_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Initialize_Update_APDU : public APDU +{ + public: + TPS_PUBLIC Initialize_Update_APDU(BYTE key_version, BYTE key_index, Buffer &data); + TPS_PUBLIC ~Initialize_Update_APDU(); + TPS_PUBLIC APDU_Type GetType(); + TPS_PUBLIC void GetEncoding(Buffer &data); + public: + TPS_PUBLIC Buffer &GetHostChallenge(); +}; + +#endif /* INITIALIZE_UPDATE_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Install_Applet_APDU.h b/pki/base/tps/src/include/apdu/Install_Applet_APDU.h new file mode 100644 index 000000000..06bd88072 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Install_Applet_APDU.h @@ -0,0 +1,59 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef INSTALL_APPLET_APDU_H +#define INSTALL_APPLET_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Install_Applet_APDU : public APDU +{ + public: + TPS_PUBLIC Install_Applet_APDU(Buffer &packageAID, Buffer &appletAID, + BYTE appPrivileges, unsigned int instanceSize); + TPS_PUBLIC Install_Applet_APDU(Buffer &data); + TPS_PUBLIC ~Install_Applet_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* INSTALL_APPLET_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Install_Load_APDU.h b/pki/base/tps/src/include/apdu/Install_Load_APDU.h new file mode 100644 index 000000000..7d0ff9761 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Install_Load_APDU.h @@ -0,0 +1,58 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef INSTALL_LOAD_APDU_H +#define INSTALL_LOAD_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Install_Load_APDU : public APDU +{ + public: + TPS_PUBLIC Install_Load_APDU(Buffer& packageAID, Buffer& sdAID, unsigned int fileLen); + TPS_PUBLIC Install_Load_APDU(Buffer& data); + TPS_PUBLIC ~Install_Load_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* INSTALL_LOAD_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Lifecycle_APDU.h b/pki/base/tps/src/include/apdu/Lifecycle_APDU.h new file mode 100644 index 000000000..a3adaf9c4 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Lifecycle_APDU.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef LIFECYCLE_APDU_H +#define LIFECYCLE_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Lifecycle_APDU : public APDU +{ + public: + TPS_PUBLIC Lifecycle_APDU(BYTE lifecycle); + TPS_PUBLIC ~Lifecycle_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* LIFECYCLE_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/List_Objects_APDU.h b/pki/base/tps/src/include/apdu/List_Objects_APDU.h new file mode 100644 index 000000000..7d5b45bff --- /dev/null +++ b/pki/base/tps/src/include/apdu/List_Objects_APDU.h @@ -0,0 +1,59 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef LIST_OBJECTS_APDU_H +#define LIST_OBJECTS_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class List_Objects_APDU : public APDU +{ + public: + TPS_PUBLIC List_Objects_APDU(BYTE ret_size); + TPS_PUBLIC ~List_Objects_APDU(); + TPS_PUBLIC APDU_Type GetType(); + public: + TPS_PUBLIC void GetEncoding(Buffer &data); +}; + +#endif /* LIST_OBJECTS_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/List_Pins_APDU.h b/pki/base/tps/src/include/apdu/List_Pins_APDU.h new file mode 100644 index 000000000..04d1102c9 --- /dev/null +++ b/pki/base/tps/src/include/apdu/List_Pins_APDU.h @@ -0,0 +1,60 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef LIST_PINS_APDU_H +#define LIST_PINS_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class List_Pins_APDU : public APDU +{ + public: + TPS_PUBLIC List_Pins_APDU(BYTE ret_size); + TPS_PUBLIC ~List_Pins_APDU(); + TPS_PUBLIC APDU_Type GetType(); + public: + BYTE m_ret_size; + TPS_PUBLIC void GetEncoding(Buffer &data); +}; + +#endif /* LIST_PINS_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Load_File_APDU.h b/pki/base/tps/src/include/apdu/Load_File_APDU.h new file mode 100644 index 000000000..ae5f57445 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Load_File_APDU.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef LOAD_FILE_APDU_H +#define LOAD_FILE_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Load_File_APDU : public APDU +{ + public: + TPS_PUBLIC Load_File_APDU(BYTE refControl, BYTE blockNum, Buffer& data); + TPS_PUBLIC ~Load_File_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* LOAD_FILE_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Put_Key_APDU.h b/pki/base/tps/src/include/apdu/Put_Key_APDU.h new file mode 100644 index 000000000..63aa54599 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Put_Key_APDU.h @@ -0,0 +1,58 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef PUT_KEY_APDU_H +#define PUT_KEY_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/Buffer.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Put_Key_APDU : public APDU +{ + public: + TPS_PUBLIC Put_Key_APDU(BYTE p1, BYTE p2, Buffer &data); + TPS_PUBLIC ~Put_Key_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* PUT_KEY_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Read_Buffer_APDU.h b/pki/base/tps/src/include/apdu/Read_Buffer_APDU.h new file mode 100644 index 000000000..3c94b564d --- /dev/null +++ b/pki/base/tps/src/include/apdu/Read_Buffer_APDU.h @@ -0,0 +1,61 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef READ_BUFFER_APDU_H +#define READ_BUFFER_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Read_Buffer_APDU : public APDU +{ + public: + TPS_PUBLIC Read_Buffer_APDU(int len, int offset); + TPS_PUBLIC ~Read_Buffer_APDU(); + TPS_PUBLIC APDU_Type GetType(); + public: + TPS_PUBLIC int GetLen(); + TPS_PUBLIC int GetOffset(); + +}; + +#endif /* READ_BUFFER_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Read_Object_APDU.h b/pki/base/tps/src/include/apdu/Read_Object_APDU.h new file mode 100644 index 000000000..e2357acdd --- /dev/null +++ b/pki/base/tps/src/include/apdu/Read_Object_APDU.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef OBJECT_OBJECT_APDU_H +#define OBJECT_OBJECT_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Read_Object_APDU : public APDU +{ + public: + TPS_PUBLIC Read_Object_APDU(BYTE *object_id, int offset, int len); + TPS_PUBLIC ~Read_Object_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* OBJECT_OBJECT_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Select_APDU.h b/pki/base/tps/src/include/apdu/Select_APDU.h new file mode 100644 index 000000000..92c1c8ee8 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Select_APDU.h @@ -0,0 +1,58 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef SELECT_APDU_H +#define SELECT_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/Buffer.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Select_APDU : public APDU +{ + public: + TPS_PUBLIC Select_APDU(BYTE p1, BYTE p2, Buffer &data); + TPS_PUBLIC ~Select_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* SELECT_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Set_IssuerInfo_APDU.h b/pki/base/tps/src/include/apdu/Set_IssuerInfo_APDU.h new file mode 100644 index 000000000..2507fdc97 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Set_IssuerInfo_APDU.h @@ -0,0 +1,59 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef SET_ISSUERINFO_APDU_H +#define SET_ISSUERINFO_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Set_IssuerInfo_APDU : public APDU +{ + public: + TPS_PUBLIC Set_IssuerInfo_APDU(BYTE p1, BYTE p2, Buffer &data); + TPS_PUBLIC ~Set_IssuerInfo_APDU(); + TPS_PUBLIC APDU_Type GetType(); + public: + TPS_PUBLIC Buffer &GetIssuerInfo(); +}; + +#endif /* SET_ISSUERINFO_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Set_Pin_APDU.h b/pki/base/tps/src/include/apdu/Set_Pin_APDU.h new file mode 100644 index 000000000..f649147a1 --- /dev/null +++ b/pki/base/tps/src/include/apdu/Set_Pin_APDU.h @@ -0,0 +1,59 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef SET_PIN_APDU_H +#define SET_PIN_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Set_Pin_APDU : public APDU +{ + public: + TPS_PUBLIC Set_Pin_APDU(BYTE p1, BYTE p2, Buffer &data); + TPS_PUBLIC ~Set_Pin_APDU(); + TPS_PUBLIC APDU_Type GetType(); + public: + TPS_PUBLIC Buffer &GetNewPIN(); +}; + +#endif /* SET_PIN_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Unblock_Pin_APDU.h b/pki/base/tps/src/include/apdu/Unblock_Pin_APDU.h new file mode 100644 index 000000000..583e7ae7d --- /dev/null +++ b/pki/base/tps/src/include/apdu/Unblock_Pin_APDU.h @@ -0,0 +1,54 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef UNBLOCK_PIN_APDU_H +#define UNBLOCK_PIN_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Unblock_Pin_APDU : public APDU +{ + public: + TPS_PUBLIC Unblock_Pin_APDU(); + TPS_PUBLIC ~Unblock_Pin_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* UNBLOCK_PIN_APDU_H */ diff --git a/pki/base/tps/src/include/apdu/Write_Object_APDU.h b/pki/base/tps/src/include/apdu/Write_Object_APDU.h new file mode 100644 index 000000000..670cd6bbd --- /dev/null +++ b/pki/base/tps/src/include/apdu/Write_Object_APDU.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef WRITE_OBJECT_APDU_H +#define WRITE_OBJECT_APDU_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "apdu/APDU.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Write_Object_APDU : public APDU +{ + public: + TPS_PUBLIC Write_Object_APDU(BYTE *object_id, int offset, Buffer &data); + TPS_PUBLIC ~Write_Object_APDU(); + TPS_PUBLIC APDU_Type GetType(); +}; + +#endif /* WRITE_OBJECT_APDU_H */ diff --git a/pki/base/tps/src/include/authentication/AuthParams.h b/pki/base/tps/src/include/authentication/AuthParams.h new file mode 100644 index 000000000..e0d39a249 --- /dev/null +++ b/pki/base/tps/src/include/authentication/AuthParams.h @@ -0,0 +1,64 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef AUTHPARAMS_H +#define AUTHPARAMS_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/NameValueSet.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class AuthParams : public NameValueSet +{ + public: + TPS_PUBLIC AuthParams(); + virtual ~AuthParams(); + public: + TPS_PUBLIC void SetUID(char *uid); + TPS_PUBLIC char *GetUID(); + TPS_PUBLIC void SetPassword(char *pwd); + TPS_PUBLIC char *GetPassword(); + void SetSecuridValue(char *securidValue); + TPS_PUBLIC char *GetSecuridValue(); + void SetSecuridPin(char *securidPin); + TPS_PUBLIC char *GetSecuridPin(); +}; + +#endif /* AUTHPARAMS_H */ diff --git a/pki/base/tps/src/include/authentication/Authentication.h b/pki/base/tps/src/include/authentication/Authentication.h new file mode 100644 index 000000000..ae2b0c6fb --- /dev/null +++ b/pki/base/tps/src/include/authentication/Authentication.h @@ -0,0 +1,80 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef AUTHENTICATION_H +#define AUTHENTICATION_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Login.h" +#include "main/SecureId.h" +#include "main/RA_Session.h" +#include "authentication/AuthParams.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +#define TPS_AUTH_OK 0 +#define TPS_AUTH_ERROR_LDAP -1 +#define TPS_AUTH_ERROR_USERNOTFOUND -2 +#define TPS_AUTH_ERROR_PASSWORDINCORRECT -3 + + +class Authentication +{ + public: + TPS_PUBLIC Authentication(); + TPS_PUBLIC virtual ~Authentication(); + public: + virtual int Authenticate(AuthParams *params); + virtual void Initialize(int index); + public: + virtual const char *GetTitle(char *locale); + virtual const char *GetDescription(char *locale); + virtual int GetNumOfParamNames(); + virtual char *GetParamID(int index); + virtual const char *GetParamName(int index, char *locale); + virtual char *GetParamType(int index); + virtual const char *GetParamDescription(int index, char *locale); + virtual char *GetParamOption(int index); + int GetNumOfRetries(); // retries if the user entered the wrong password/securid + + protected: + int m_retries; +}; + +#endif /* AUTHENTICATION_H */ diff --git a/pki/base/tps/src/include/authentication/LDAP_Authentication.h b/pki/base/tps/src/include/authentication/LDAP_Authentication.h new file mode 100644 index 000000000..2a8c0a7d5 --- /dev/null +++ b/pki/base/tps/src/include/authentication/LDAP_Authentication.h @@ -0,0 +1,85 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef LDAP_AUTHENTICATION_H +#define LDAP_AUTHENTICATION_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Login.h" +#include "main/SecureId.h" +#include "main/RA_Session.h" +#include "authentication/Authentication.h" + +class LDAP_Authentication : public Authentication +{ + public: + LDAP_Authentication(); + ~LDAP_Authentication(); + public: + int Authenticate(AuthParams *params); + void Initialize(int index); + public: + bool IsSSL(); + char *GetHostPort(); + + public: + void GetHostPort(char **p, char **q); + virtual const char *GetTitle(char *locale); + virtual const char *GetDescription(char *locale); + virtual int GetNumOfParamNames(); + virtual char *GetParamID(int index); + virtual const char *GetParamName(int index, char *locale); + virtual char *GetParamType(int index); + virtual const char *GetParamDescription(int index, char *locale); + virtual char *GetParamOption(int index); + + private: + int m_index; + bool m_isSSL; + char *m_hostport; + char *m_attributes; + char *m_ssl; + char *m_baseDN; + char *m_bindDN; + char *m_bindPwd; + int m_connectRetries; // for failover + ConnectionInfo *m_connInfo; +}; + extern "C" + { + Authentication *GetAuthentication(); + }; + +#endif /* LDAP_AUTHENTICATION_H */ diff --git a/pki/base/tps/src/include/channel/Channel.h b/pki/base/tps/src/include/channel/Channel.h new file mode 100644 index 000000000..a49af8bf1 --- /dev/null +++ b/pki/base/tps/src/include/channel/Channel.h @@ -0,0 +1,55 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef CHANNEL_H +#define CHANNEL_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "pk11func.h" +#include "main/Buffer.h" +#include "main/RA_Session.h" +#include "apdu/APDU.h" +#include "apdu/APDU_Response.h" + +class Channel +{ + public: + Channel(); + ~Channel(); + public: + int Close(); +}; + +#endif /* CHANNEL_H */ diff --git a/pki/base/tps/src/include/channel/Secure_Channel.h b/pki/base/tps/src/include/channel/Secure_Channel.h new file mode 100644 index 000000000..01c06a30b --- /dev/null +++ b/pki/base/tps/src/include/channel/Secure_Channel.h @@ -0,0 +1,158 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef SECURE_CHANNEL_H +#define SECURE_CHANNEL_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "pk11func.h" +#include "main/Buffer.h" +#include "main/RA_Session.h" +#include "apdu/APDU.h" +#include "apdu/APDU_Response.h" +#include "channel/Channel.h" + +enum SecurityLevel { + SECURE_MSG_ANY = 0, + SECURE_MSG_MAC = 1, + SECURE_MSG_NONE = 2, // not yet supported + SECURE_MSG_MAC_ENC = 3 +} ; + +enum TokenKeyType { + KEY_TYPE_ENCRYPTION = 0, + KEY_TYPE_SIGNING = 1, + KEY_TYPE_SIGNING_AND_ENCRYPTION = 2 +}; + +class Secure_Channel : public Channel +{ + public: + + Secure_Channel( + RA_Session *session, + PK11SymKey *session_key, + PK11SymKey *enc_session_key, + char *drm_des_key_s, + char *kek_des_key_s, + char *keycheck_s, + Buffer &key_diversification_data, + Buffer &key_info_data, + Buffer &card_challenge, + Buffer &card_cryptogram, + Buffer &host_challenge, + Buffer &host_cryptogram); + + ~Secure_Channel(); + public: + Buffer &GetKeyDiversificationData(); + Buffer &GetKeyInfoData(); + Buffer &GetCardChallenge(); + Buffer &GetCardCryptogram(); + Buffer &GetHostChallenge(); + Buffer &GetHostCryptogram(); + SecurityLevel GetSecurityLevel(); + void SetSecurityLevel(SecurityLevel level); + char *getDrmWrappedDESKey(); + char *getKekWrappedDESKey(); + char *getKeycheck(); + + public: + int ImportKeyEnc(BYTE priv_key_number, BYTE pub_key_number, Buffer* data); + int ImportKey(BYTE key_number); + int CreatePin(BYTE pin_number, BYTE max_retries, const char *pin); + int ExternalAuthenticate(); + int SetIssuerInfo(Buffer *info); + Buffer GetIssuerInfo(); + int ResetPin(BYTE pin_number, char *pin); + int IsPinPresent(BYTE pin_number); + int SetLifecycleState(BYTE flag); + int StartEnrollment(BYTE p1, BYTE p2, Buffer *wrapped_challenge, + Buffer *key_check, + BYTE alg, int keysize, BYTE option); + int ReadBuffer(BYTE *buf, int buf_len); + int CreateObject(BYTE *object_id, BYTE* permissions, int len); + int WriteObject(BYTE *objid, BYTE *buf, int buf_len); + Buffer *ReadObject(BYTE *objid, int offset, int len); + int PutKeys(RA_Session *session, BYTE key_version, + BYTE key_index, Buffer *key_data); + int LoadFile(RA_Session *session, BYTE refControl, BYTE blockNum, + Buffer *data); + int InstallApplet(RA_Session *session, + Buffer &packageAID, Buffer &appletAID, + BYTE appPrivileges, unsigned int instanceSize); + int InstallLoad(RA_Session *session, + Buffer& packageAID, Buffer& sdAID, unsigned int fileLen); + int DeleteFileX(RA_Session *session, Buffer *aid); + int Close(); + public: + int CreateObject(BYTE *objid, BYTE *perms, Buffer *obj); + int CreateCertificate(const char *id, Buffer *cert); + + Buffer CreatePKCS11CertAttrsBuffer(TokenKeyType type, const char *id, const char *label, Buffer *keyid); + int CreatePKCS11CertAttrs(TokenKeyType type, const char *id, const char *label, Buffer *keyid); + Buffer CreatePKCS11PriKeyAttrsBuffer(TokenKeyType type, const char *id, const char *label, Buffer *keyid, + Buffer *modulus, const char *opType, const char *tokenType, const char *keyTypePrefix); + int CreatePKCS11PriKeyAttrs(TokenKeyType type, const char *id, const char *label, Buffer *keyid, + Buffer *modulus, const char *opType, const char *tokenType, const char *keyTypePrefix); + Buffer CreatePKCS11PubKeyAttrsBuffer(TokenKeyType type, const char *id, const char *label, Buffer *keyid, + Buffer *exponent, Buffer *modulus, const char *opType, const char *tokenType, const char *keyTypePrefix); + int CreatePKCS11PubKeyAttrs(TokenKeyType type, const char *id, const char *label, Buffer *keyid, + Buffer *exponent, Buffer *modulus, const char *opType, const char *tokenType, const char *keyTypePrefix); + APDU_Response *SendTokenAPU(APDU *apdu); + + public: + Buffer *ComputeAPDUMac(APDU *apdu); + int ComputeAPDU(APDU *apdu); + + private: + PK11SymKey *m_session_key; + PK11SymKey *m_enc_session_key; + char *m_drm_wrapped_des_key_s; + char *m_kek_wrapped_des_key_s; + char *m_keycheck_s; + RA_Session *m_session; + Buffer m_icv; + Buffer m_cryptogram; + Buffer m_key_diversification_data; + Buffer m_key_info_data; + Buffer m_card_challenge; + Buffer m_card_cryptogram; + Buffer m_host_challenge; + Buffer m_host_cryptogram; + SecurityLevel m_security_level; +}; + +#endif /* SECURE_CHANNEL_H */ diff --git a/pki/base/tps/src/include/cms/CertEnroll.h b/pki/base/tps/src/include/cms/CertEnroll.h new file mode 100644 index 000000000..07fad00f1 --- /dev/null +++ b/pki/base/tps/src/include/cms/CertEnroll.h @@ -0,0 +1,73 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef CERTENROLL_H +#define CERTENROLL_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Buffer.h" + +#include "httpClient/httpc/response.h" +#include "keythi.h" + +#ifdef XP_WIN32 +#define TOKENDB_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TOKENDB_PUBLIC +#endif /* !XP_WIN32 */ + +class CertEnroll +{ + public: + + TOKENDB_PUBLIC CertEnroll(); + TOKENDB_PUBLIC ~CertEnroll(); + + SECKEYPublicKey *ParsePublicKeyBlob(unsigned char * /*blob*/, + Buffer * /*challenge*/); + Buffer *EnrollCertificate(SECKEYPublicKey * /*pk_parsed*/, + const char *profileId, + const char * /*uid*/, + const char * /*token cuid*/, const char *connid, + SECItem** encodedPublicKeyInfo = NULL); + ReturnStatus verifyProof(SECKEYPublicKey* /*pk*/, SECItem* /*siProof*/, + unsigned short /*pkeyb_len*/, unsigned char* /*pkeyb*/, + Buffer* /*challenge*/); + TOKENDB_PUBLIC int RevokeCertificate(const char *reason, const char *serialno, const char *connid, char *&status); + TOKENDB_PUBLIC int UnrevokeCertificate(const char *serialno, const char *connid, char *&status); + PSHttpResponse * sendReqToCA(const char *servlet, const char *parameters, const char *connid); + Buffer * parseResponse(PSHttpResponse * /*resp*/); +}; +#endif /* CERTENROLL_H */ diff --git a/pki/base/tps/src/include/cms/ConnectionInfo.h b/pki/base/tps/src/include/cms/ConnectionInfo.h new file mode 100644 index 000000000..07e9c3a73 --- /dev/null +++ b/pki/base/tps/src/include/cms/ConnectionInfo.h @@ -0,0 +1,66 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef CONNECTIONINFO_H +#define CONNECTIONINFO_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Buffer.h" +#include "main/NameValueSet.h" +#include "pk11func.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +#define HOST_PORT_MEMBERS 20 + +class ConnectionInfo +{ + public: + TPS_PUBLIC ConnectionInfo(); + TPS_PUBLIC ~ConnectionInfo(); + TPS_PUBLIC void BuildFailoverList(const char *str); + TPS_PUBLIC int GetHostPortListLen(); + TPS_PUBLIC char **GetHostPortList(); + + private: + int m_len; + char *m_hostPortList[HOST_PORT_MEMBERS]; +}; + +#endif /* CONNECTIONINFO_H */ diff --git a/pki/base/tps/src/include/cms/HttpConnection.h b/pki/base/tps/src/include/cms/HttpConnection.h new file mode 100644 index 000000000..da9d3a7fd --- /dev/null +++ b/pki/base/tps/src/include/cms/HttpConnection.h @@ -0,0 +1,88 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef HTTPCONNECTION_H +#define HTTPCONNECTION_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/response.h" +#include "httpClient/httpc/request.h" +#include "httpClient/httpc/engine.h" +#include "httpClient/httpc/http.h" +#include "ConnectionInfo.h" +#include "main/NameValueSet.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class HttpConnection +{ + public: +// HttpConnection(); + TPS_PUBLIC HttpConnection(const char *id, ConnectionInfo *cinfo, int retries, int timeout, + bool isSSL, const char *clientnickname, bool keepAlive, NameValueSet *headers); + TPS_PUBLIC virtual ~HttpConnection(); + + public: + TPS_PUBLIC int GetNumOfRetries(); // failover retries + TPS_PUBLIC int GetTimeout(); + TPS_PUBLIC ConnectionInfo *GetFailoverList(); + TPS_PUBLIC char *GetId(); + TPS_PUBLIC bool IsSSL(); + TPS_PUBLIC char *GetClientNickname(); + TPS_PUBLIC bool IsKeepAlive(); + TPS_PUBLIC PSHttpResponse *getResponse(int index, const char *servletID, const char *body); + TPS_PUBLIC PRLock *GetLock(); + TPS_PUBLIC int GetCurrentIndex(); + TPS_PUBLIC void SetCurrentIndex(int index); + + protected: + int m_max_conn; + ConnectionInfo *m_failoverList; + int m_retries; + int m_timeout; + char *m_Id; + bool m_isSSL; + char *m_clientnickname; + bool m_keepAlive; + NameValueSet *m_headers; + PRLock *m_lock; + int m_curr; +}; + +#endif /* HTTPCONNECTION_H */ diff --git a/pki/base/tps/src/include/engine/RA.h b/pki/base/tps/src/include/engine/RA.h new file mode 100644 index 000000000..beda779d5 --- /dev/null +++ b/pki/base/tps/src/include/engine/RA.h @@ -0,0 +1,290 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_H +#define RA_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "pk11func.h" +#include "ldap.h" +#include "main/Base.h" +#include "main/ConfigStore.h" +#include "main/Buffer.h" +#include "main/PublishEntry.h" +#include "main/AuthenticationEntry.h" +#include "authentication/Authentication.h" +#include "apdu/APDU.h" +#include "main/RA_Context.h" +#include "channel/Secure_Channel.h" +#include "cms/HttpConnection.h" +#include "cms/ConnectionInfo.h" +#include "publisher/IPublisher.h" + + +/* + * + * LL_PER_SERVER = 4 these messages will occur only once during the + * entire invocation of the server, e.g. at startup + * or shutdown time., reading the conf parameters. + * Perhaps other infrequent events relating to + * failing over of CA, TKS, too + * + * LL_PER_CONNECTION = 6 these messages happen once per connection - most + * of the log events will be at this level + * + * LL_PER_PDU = 8 these messages relate to PDU processing. If you + * have something that is done for every PDU, such + * as applying the MAC, it should be logged at this + * level + * + * LL_ALL_DATA_IN_PDU = 9 dump all the data in the PDU - a more chatty + * version of the above + */ +enum RA_Log_Level { + LL_PER_SERVER = 4, + LL_PER_CONNECTION = 6, + LL_PER_PDU = 8, + LL_ALL_DATA_IN_PDU = 9 +}; + + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +/* For now, this value must correspond exactly to the successful exit */ +/* status of RA::Initialize( char *cfg_path, RA_Context *ctx ). */ +#define RA_INITIALIZATION_SUCCESS 1 + +class RA +{ + public: + RA(); + ~RA(); + public: + static int IsTokendbInitialized(); + TPS_PUBLIC static int Initialize(char *cfg_path, RA_Context *ctx); + TPS_PUBLIC static int Shutdown(); + public: + + static PK11SymKey *ComputeSessionKey(RA_Session *session, + Buffer &CUID, + Buffer &keyinfo, + Buffer &card_challenge, + Buffer &host_challenge, + Buffer **host_cryptogram, + Buffer &card_cryptogram, + PK11SymKey **encSymKey, + char** drm_kekSessionKey_s, + char** kek_kekSessionKey_s, + char **keycheck_s, + const char *connId); + static void ServerSideKeyGen(RA_Session *session, const char* cuid, + const char *userid, char* kekSessionKey_s, + char **publickey_s, + char **wrappedPrivateKey_s, + char **ivParam_s, const char *connId, + bool archive, int keysize); + static void RecoverKey(RA_Session *session, const char* cuid, + const char *userid, char* kekSessionKey_s, + char *cert_s, char **publickey_s, + char **wrappedPrivateKey_s, const char *connId); + + static Buffer *ComputeHostCryptogram(Buffer &card_challenge, Buffer &host_challenge); + public: + TPS_PUBLIC static ConfigStore *GetConfigStore(); + public: + TPS_PUBLIC static void Audit(const char *func_name, const char *fmt, ...); + TPS_PUBLIC static void Error(const char *func_name, const char *fmt, ...); + TPS_PUBLIC static void Debug(const char *func_name, const char *fmt, ...); + TPS_PUBLIC static void DebugBuffer(const char *func_name, const char *prefix, Buffer *buf); + TPS_PUBLIC static void Audit(RA_Log_Level level, const char *func_name, const char *fmt, ...); + TPS_PUBLIC static void Error(RA_Log_Level level, const char *func_name, const char *fmt, ...); + TPS_PUBLIC static void Debug(RA_Log_Level level, const char *func_name, const char *fmt, ...); + static void DebugBuffer(RA_Log_Level level, const char *func_name, const char *prefix, Buffer *buf); + private: + static void AuditThis(RA_Log_Level level, const char *func_name, const char *fmt, va_list ap); + static void ErrorThis(RA_Log_Level level, const char *func_name, const char *fmt, va_list ap); + static void DebugThis(RA_Log_Level level, const char *func_name, const char *fmt, va_list ap); + public: + static int InitializeTokendb(char *cfg_path); + static PRLock *GetVerifyLock(); + TPS_PUBLIC static CERTCertificate **ra_get_certificates(LDAPMessage *e); + TPS_PUBLIC static LDAPMessage *ra_get_first_entry(LDAPMessage *e); + TPS_PUBLIC static LDAPMessage *ra_get_next_entry(LDAPMessage *e); + TPS_PUBLIC static char **ra_get_attribute_values(LDAPMessage *e, const char *p); + TPS_PUBLIC static char *ra_get_cert_attr_byname(LDAPMessage *e, char *name); + TPS_PUBLIC static char *ra_get_token_id(LDAPMessage *e); + TPS_PUBLIC static char *ra_get_cert_tokenType(LDAPMessage *entry); + TPS_PUBLIC static char *ra_get_token_status(LDAPMessage *entry); + TPS_PUBLIC static char *ra_get_cert_cn(LDAPMessage *entry); + TPS_PUBLIC static char *ra_get_cert_status(LDAPMessage *entry); + TPS_PUBLIC static char *ra_get_cert_type(LDAPMessage *entry); + TPS_PUBLIC static char *ra_get_cert_serial(LDAPMessage *entry); + TPS_PUBLIC static char *ra_get_cert_issuer(LDAPMessage *entry); + TPS_PUBLIC static int ra_tus_has_active_tokens(char *userid); + TPS_PUBLIC static char *ra_get_token_reason(LDAPMessage *msg); + TPS_PUBLIC static int ra_get_number_of_entries(LDAPMessage *ldapResult); + TPS_PUBLIC static int ra_find_tus_token_entries(char *filter, + int maxReturns, LDAPMessage **ldapResult, int num); + TPS_PUBLIC static int ra_find_tus_token_entries_no_vlv(char *filter, + LDAPMessage **ldapResult, int num); + TPS_PUBLIC static int ra_is_tus_db_entry_disabled(char *cuid); + TPS_PUBLIC static int ra_is_token_pin_resetable(char *cuid); + TPS_PUBLIC static int ra_is_token_present(char *cuid); + TPS_PUBLIC static int ra_allow_token_reenroll(char *cuid); + TPS_PUBLIC static int ra_is_update_pin_resetable_policy(char *cuid); + TPS_PUBLIC static char *ra_get_token_policy(char *cuid); + TPS_PUBLIC static char *ra_get_token_userid(char *cuid); + TPS_PUBLIC static int ra_update_token_policy(char *cuid, char *policy); + TPS_PUBLIC static int ra_update_cert_status(char *cn, const char *status); + TPS_PUBLIC static int ra_find_tus_certificate_entries_by_order( + char *filter, int num, LDAPMessage **msg, int order); + TPS_PUBLIC static int ra_find_tus_certificate_entries_by_order_no_vlv( + char *filter, LDAPMessage **msg, int order); + TPS_PUBLIC static int ra_update_token_status_reason_userid(char *userid, + char *cuid, const char *status, const char *reason, int modifyDateOfCreate); + static int tdb_add_token_entry(char *userid, char* cuid, const char *status); + static int tdb_update(const char *userid, char *cuid, char *applet_version, char *key_info, const char *state, const char *reason); + static int tdb_update_certificates(char *cuid, char **tokentypes, char *userid, CERTCertificate **certificates, char **ktypes, char **origins, int numOfCerts); + static int tdb_activity(char *ip, char *cuid, const char *op, const char *result, const char *msg, const char *userid); + static int testTokendb(); + static int InitializeAuthentication(); + static AuthenticationEntry *GetAuth(const char *id); + public: + static HttpConnection *GetCAConn(const char *id); + static void ReturnCAConn(HttpConnection *conn); + static HttpConnection *GetTKSConn(const char *id); + static void ReturnTKSConn(HttpConnection *conn); + + static HttpConnection *GetDRMConn(const char *id); + static void ReturnDRMConn(HttpConnection *conn); + static int GetCurrentIndex(HttpConnection *conn); + + public: + + static void SetPodIndex(int index); + static int GetPodIndex(); + TPS_PUBLIC static int GetAuthCurrentIndex(); + static void SetAuthCurrentIndex(int index); + TPS_PUBLIC static PRLock *GetAuthLock(); + TPS_PUBLIC static void IncrementAuthCurrentIndex(int len); + static void SetGlobalSecurityLevel(SecurityLevel sl); + static SecurityLevel GetGlobalSecurityLevel(); + public: /* default values */ + static const char *CFG_DEF_CARDMGR_INSTANCE_AID; + static const char *CFG_DEF_NETKEY_INSTANCE_AID; + static const char *CFG_DEF_NETKEY_FILE_AID; + static const char *CFG_DEF_NETKEY_OLD_INSTANCE_AID; + static const char *CFG_DEF_NETKEY_OLD_FILE_AID; + static const char *CFG_DEF_APPLET_SO_PIN; + public: + static const char *CFG_APPLET_DELETE_NETKEY_OLD; + static const char *CFG_APPLET_CARDMGR_INSTANCE_AID; + static const char *CFG_APPLET_NETKEY_INSTANCE_AID; + static const char *CFG_APPLET_NETKEY_FILE_AID; + static const char *CFG_APPLET_NETKEY_OLD_INSTANCE_AID; + static const char *CFG_APPLET_NETKEY_OLD_FILE_AID; + static const char *CFG_APPLET_SO_PIN; + static const char *CFG_DEBUG_ENABLE; + static const char *CFG_DEBUG_FILENAME; + static const char *CFG_DEBUG_LEVEL; + static const char *CFG_AUDIT_ENABLE; + static const char *CFG_AUDIT_FILENAME; + static const char *CFG_AUDIT_LEVEL; + static const char *CFG_ERROR_LEVEL; + static const char *CFG_ERROR_ENABLE; + static const char *CFG_ERROR_FILENAME; + static const char *CFG_CHANNEL_SEC_LEVEL; + static const char *CFG_CHANNEL_ENCRYPTION; + + static const char *CFG_AUTHS_ENABLE; + static const char *CFG_AUTHS_CURRENTIMPL; + static const char *CFG_AUTHS_PLUGINS_NUM; + static const char *CFG_AUTHS_PLUGIN_NAME; + + static const char *CFG_IPUBLISHER_LIB; + static const char *CFG_IPUBLISHER_FACTORY; + + public: + static const char *TKS_RESPONSE_STATUS; + static const char *TKS_RESPONSE_SessionKey; + static const char *TKS_RESPONSE_EncSessionKey; + static const char *TKS_RESPONSE_KEK_DesKey; + static const char *TKS_RESPONSE_DRM_Trans_DesKey; + static const char *TKS_RESPONSE_HostCryptogram; + + public: + static int m_used_tks_conn; + static int m_used_ca_conn; + + static int m_used_drm_conn; + static HttpConnection* m_drmConnection[]; + static int m_drmConns_len; + static int m_pod_curr; + static int m_auth_curr; + static bool m_pod_enable; + static PRLock *m_verify_lock; + static PRLock *m_pod_lock; + static PRLock *m_auth_lock; + static PRLock *m_error_log_lock; + static PRLock *m_audit_log_lock; + static PRLock *m_debug_log_lock; + static int m_audit_log_level; + static int m_debug_log_level; + static int m_error_log_level; + static HttpConnection* m_caConnection[]; + static HttpConnection* m_tksConnection[]; + static int m_caConns_len; + static int m_tksConns_len; + static int m_auth_len; + static AuthenticationEntry *m_auth_list[]; + static SecurityLevel m_global_security_level; + static void SetCurrentIndex(HttpConnection *&conn, int index); + + static PublisherEntry *publisher_list; + static int m_num_publishers; + + + static PublisherEntry *getPublisherById(const char *publisher_id); + static int InitializePublishers(); + static int InitializeHttpConnections(const char *id, int *len, HttpConnection **conn, RA_Context *ctx); + static void CleanupPublishers(); + static int Failover(HttpConnection *&conn, int len); +}; + +#endif /* RA_H */ diff --git a/pki/base/tps/src/include/httpClient/httpc/AccessLogger.h b/pki/base/tps/src/include/httpClient/httpc/AccessLogger.h new file mode 100644 index 000000000..2b600d7e6 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/AccessLogger.h @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __ACCESS_LOGGER_H__ +#define __ACCESS_LOGGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/Logger.h" + +/** + * A singleton class for writing to an access log + */ +class EXPORT_DECL AccessLogger : public Logger { +private: + AccessLogger(); + virtual ~AccessLogger(); + +public: +/** + * Gets a logger object with parameters obtained from the configuration manager + */ +static AccessLogger *GetAccessLogger(); + +/** + * Writes an access log entry + * + * @param hostName The IP address or host name of the requestor + * @param userName The authenticated user name; NULL or "" if not authenticated + * @param requestName The name of the requested function + * @param status The status returned to the client + * @param responseLength The number of bytes returned to the client + * @return 0 on success + */ +int Log( const char *hostName, + const char *userName, + const char *requestName, + int status, + int responseLength ); + +/** + * Initializes the object with parameters from the Config Manager + * + * @param configName The name of the configuration entry to use + * @return 0 on success + */ + int Initialize( const char *configName ); + +/** + * Flush any unwritten buffers + */ +void Flush(); + +protected: +/** + * Gets a formatted timestamp + * + * @param now The current time + * @param buffer Buffer to put time in + * @return A formatted timestamp + */ +char *GetTimeStamp( struct tm *now, char *buffer ); + +private: + char *m_buffer; + int m_bufferIndex; + int m_bufferTime; + int m_bufferSize; + time_t m_lastWrite; + char m_gmtOffset[16]; +}; + +#endif // __ACCESS_LOGGER_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/Auth.h b/pki/base/tps/src/include/httpClient/httpc/Auth.h new file mode 100644 index 000000000..72a5f77ee --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/Auth.h @@ -0,0 +1,155 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_AUTH_H__ +#define __PS_AUTH_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "ldap.h" + +class PSConfig; +class Pool; +class PoolNode; + +/** + * Utility classes for authentication and authorization + * + * @author rweltman@netscape.com + * @version 1.0 + */ + +/** + * Maintains a pool of LDAP connections; not yet implemented as a pool + */ +class LDAPConnectionPool { +public: + LDAPConnectionPool( const char *host, int port, int poolSize ); + virtual ~LDAPConnectionPool() {} + int Initialize(); + PoolNode *GetConnection(); + PoolNode *GetAuthenticatedConnection( const char *binddn, + const char *bindpwd ); + void ReleaseConnection( PoolNode *node ); +protected: +private: + const char* m_host; + int m_port; + int m_size; + Pool *m_pool; + bool m_initialized; +}; + +/** + * Produces an authenticator for an auth domain and authenticates + */ +class EXPORT_DECL Authenticator { +public: + virtual int Authenticate( const char *username, + const char *password, + char *&actualID ) = 0; + static Authenticator *GetAuthenticator( const char *domain ); +}; + +class EXPORT_DECL LDAPAuthenticator:public Authenticator { +public: + LDAPAuthenticator(); + virtual ~LDAPAuthenticator(); + virtual int Authenticate( const char *username, + const char *password, + char *&dn ); + +protected: + static int GetHashSize(); + char *CheckCache( const char *username, + const char *password ); + void UpdateCache( const char *username, + const char *dn, + const char *password ); + char *CreateHash( const char *password, + char *hash, + int maxChars ); + /** + * Returns the DN corresponding to a username, if any + * + * @param username The user name to look up + * @param status The status of an LDAP search, if any + * @return The corresponding DN, or NULL if no DN found + */ + char *GetUserDN( const char *username, int& status ); + +private: + LDAPConnectionPool *m_pool; + const char* m_host; + int m_port; + const char* m_binddn; + const char* m_bindpassword; + const char* m_basedn; + const char* m_searchfilter; + const char* m_searchscope; + int m_nsearchscope; + char* m_attrs[2]; + StringKeyCache *m_cache; +}; + +class EXPORT_DECL LDAPAuthorizer { +public: + LDAPAuthorizer(); + virtual ~LDAPAuthorizer(); + static LDAPAuthorizer *GetAuthorizer(); + virtual int Authorize( const char *dn, + const char *pwd, + const char *methodName ); + +protected: + int GetLdapConnection( LDAP** ld ); + int CheckCache( const char *username, + const char *methodName ); + void UpdateCache( const char *username, + const char *methodName ); + +private: + LDAPConnectionPool *m_pool; + const char* m_binddn; + const char* m_bindpassword; + const char* m_basedn; + const char* m_searchfilter; + const char* m_searchscope; + int m_nsearchscope; + char* m_attrs[2]; + StringKeyCache *m_cache; +}; + +#endif // __PS_HELPER_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/ByteBuffer.h b/pki/base/tps/src/include/httpClient/httpc/ByteBuffer.h new file mode 100644 index 000000000..cd5568c35 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/ByteBuffer.h @@ -0,0 +1,194 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __BYTE_BUFFER_H +#define __BYTE_BUFFER_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * ByteBuffer.h 1.000 06/12/2002 + * + * A byte buffer class + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#define min(a,b) (((a) < (b)) ? (a) : (b)) + +typedef unsigned char Byte; + +class EXPORT_DECL ByteBuffer { +public: + /** + * Constructor + */ + ByteBuffer(); + + /** + * Destructor + */ + virtual ~ByteBuffer(); + +public: + /** + * Reads a single byte from the buffer + * + * @param b byte returned + * @return 0 on success + */ + int GetByte(Byte* b); + + /** + * Reads a number of bytes as specified by size from the buffer + * + * @param size bytes to read + * @param buf bytes read + * @return 0 on success + */ + int GetBytes(int size, Byte* buf); + + /** + * Reads a short value from the buffer + * + * @param s a short value + * @return 0 on success + */ + int GetShort(unsigned short* s); + + /** + * Reads a integer value from the buffer + * + * @param i a integer value + * @return 0 on success + */ + int GetInt(unsigned int* i); + + /** + * Reads a string of given length from the buffer + * + * @param len length of the string + * @param str string value + * @return 0 on success + */ + int GetString(int len, char* str); + + /** + * Writes a single byte to the buffer + * + * @param b byte to set + * @return 0 on success + */ + int SetByte(Byte b); + + /** + * Writes a number of bytes as specified by size to the buffer + * + * @param size number of bytes + * @param buf bytes to write + * @return 0 on success + */ + int SetBytes(int size, Byte* buf); + + /** + * Writes a short value to the buffer + * + * @param s a short value + * @return 0 on success + */ + int SetShort(unsigned short s); + + /** + * Writes an integer value to the buffer + * + * @param i an integer value + * @return 0 on success + */ + int SetInt(unsigned int i); + + /** + * Writes a string to the buffer + * + * @param str a string to write + * @return 0 on success + */ + int SetString(char* str); + + /** + * Gets the current position in the buffer + * + * @param pos position in the buffer + * @return 0 on success + */ + int GetPosition(unsigned long* pos); + + /** + * Sets the pointer to the position specified by pos in the buffer + * + * @param pos position to be set in the buffer + * @return 0 on success + */ + int SetPosition(unsigned long pos); + + /** + * Gets total number of bytes in the buffer + * + * @param total total number of bytes + * @return 0 on success + */ + int GetTotalBytes(unsigned long* total); + + /** + * Dumps the buffer to the debug log + * + * @param logLevel Lowest debug level for which the log should be dumped + */ + void Dump(int logLevel); + +private: + int SetTotalBytes(unsigned long size, unsigned long allocUnit); + int ValidateBuffer(unsigned long increment); + +private: + Byte* m_buffer; + Byte* m_bufferEnd; + Byte* m_bufPtr; + Byte* m_maxPtr; +}; + +#endif // __BYTE_BUFFER_H + diff --git a/pki/base/tps/src/include/httpClient/httpc/CERTUtil.h b/pki/base/tps/src/include/httpClient/httpc/CERTUtil.h new file mode 100644 index 000000000..1f26efbb8 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/CERTUtil.h @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _CERT_UTIL_H +#define _CERT_UTIL_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * NSS CERT utility functions + */ +class EXPORT_DECL CERTUtil { +private: + /** + * Constructor - can't be instantiated + */ + CERTUtil() {} + + /** + * Destructor + */ + ~CERTUtil() {} + +public: + static CERTCertificate* FindCertificate(const char* nickname); + static SECItem* FindExtension(CERTCertificate* cert, const SECItem* oid); + static int GetAsInteger(SECItem* item); + static char* GetAsString(SECItem* item); + static bool IsCertExpired(CERTCertificate* cert); +}; + +#endif // _CERT_UTIL_H + diff --git a/pki/base/tps/src/include/httpClient/httpc/Cache.h b/pki/base/tps/src/include/httpClient/httpc/Cache.h new file mode 100644 index 000000000..bc68f04df --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/Cache.h @@ -0,0 +1,226 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _CACHE_H_ +#define _CACHE_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/Iterator.h" + +/** + * Simple cache implementation + */ + +/** + * Contains a cache entry and housekeeping info + */ +class CacheEntry { +public: + /** + * Constructor + * + * @param key Pointer to the key being cached + * @param data Pointer to the data being cached + */ + CacheEntry( const char *key, void *data ); + /** + * Destructor + */ + virtual ~CacheEntry(); + + /** + * Returns a pointer to the cached key + * + * @return A pointer to the cached key + */ + const char *GetKey(); + + /** + * Returns a pointer to the cached data + * + * @return A pointer to the cached data + */ + void *GetData(); + /** + * Returns the time when the entry was created + * + * @return The time when the entry was created + */ + long GetStartTime(); + +private: + char *m_key; + void *m_data; + time_t m_startTime; +}; + +/** + * Contains a generic cache; this is currently an abstract base class + */ +class Cache { +protected: + /** + * Default constructor + */ + Cache(); + +public: + /** + * Constructor + * + * @param name of the cache + * @param ttl Time to live of each cache entry + * @param implicitLock true if the Cached is to do locking internally + * when required; false if the caller will take responsibility + */ + Cache( const char *name, int ttl, bool implictLock = false ); + + /** + * Destructor + */ + virtual ~Cache(); + + /** + * Returns the number of entries in the cache + * + * @return The number of entries in the cache + */ + virtual int GetCount(); + + /** + * Acquires a read lock on the cache. Multiple threads may simultaneously + * have a read lock, but attempts to acquire a read lock will block + * if another thread already has a write lock. It is illegal to request + * a read lock if the thread already has one. + */ + void ReadLock(); + + /** + * Acquires a write lock on the cache. Only one thread may have a write + * lock at any given time; attempts to acquire a write lock will block + * if another thread already has one. It is illegal to request + * a write lock if the thread already has one. + */ + void WriteLock(); + + /** + * Releases a read or write lock that the thread has on the cache + */ + void Unlock(); + +protected: + /** + * Initializes the object - to be called from the constructor + * + * @param name of the cache + * @param ttl Time to live of each cache entry + * @param implicitLock true if the Cached is to do locking internally + * when required; false if the caller will take responsibility + */ + void Initialize( const char *name, int ttl, bool implictLock ); + +protected: + const char *m_name; + int m_ttl; + PLHashTable* m_cache; + PRRWLock* m_cacheLock; + bool m_implicitLock; +}; + +/** + * Contains a cache where the keys are strings + */ +class StringKeyCache : public Cache { +public: + /** + * Constructor + * + * @param name of the cache + * @param ttl Time to live of each cache entry + * @param implicitLock true if the Cached is to do locking internally + * when required; false if the caller will take responsibility + */ + StringKeyCache( const char *name, int ttl, bool implictLock = false ); + + /** + * Destructor + */ + virtual ~StringKeyCache(); + + /** + * Returns a cache entry + * + * @param key The name of the cache entry + * @return The corresponding cache entry, or NULL if not found + */ + CacheEntry *Get( const char *key ); + + /** + * Adds a cache entry + * + * @param key The name of the cache entry; an internal copy is made + * @param value The value of the cache entry + * @return The corresponding cache entry, or NULL if it couldn't be added + */ + CacheEntry *Put( const char *key, void *value ); + + /** + * Removes a cache entry; does not free the entry object + * + * @param key The name of the cache entry + * @return The corresponding cache entry, or NULL if not found + */ + CacheEntry *Remove( const char *key ); + + /** + * Allocates and returns a list of keys in the cache + * + * @param keys Returns an array of names; each name and also the + * array itself are to be freed by the caller with delete + * @return The number of keys found + */ + int GetKeys( char ***keys ); + + /** + * Returns an iterator over keys in the cache + * + * @return An iterator over keys in the cache + */ + Iterator *GetKeyIterator(); + +}; + +#endif // _CACHE_H_ diff --git a/pki/base/tps/src/include/httpClient/httpc/Connection.h b/pki/base/tps/src/include/httpClient/httpc/Connection.h new file mode 100644 index 000000000..5619d0dff --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/Connection.h @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __CONNECTION_H +#define __CONNECTION_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Connection.h 1.000 06/12/2002 + * + * Base class for all connection types. A user should extend this class + * and provide its protocol specific implementation + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL Connection { + friend class ServerConnection; +public: + /** + * Constructor + */ + Connection(); + + /** + * Destructor + */ + virtual ~Connection(); + +public: + /** + * Initiates a connection to a specified host. + * + * @param host server host name + * @param port server port + * @return 0 on success, negative error code otherwise + */ + int Connect(const char* host, int port); + + /** + * Reads specified number of bytes from the connection. The connection + * is locked for the period it is being read. + * + * @param buf buffer to read into + * @param size number of bytes to read + * @param timeout timeout before the read terminates + * @return number of bytes actually read + */ + int Read(void* buf, int size, long timeout); + + /** + * Writes specified number of bytes to the connection. The connection + * is locked for the period it is being written. + * + * @param buf buffer to write from + * @param size number of bytes to write + * @param timeout timeout before the write terminates + * @return number of bytes actually written + */ + int Write(void* buf, int size, long timeout); + + /** + * Gets the status of the connection + * + * @return true if closed, false otherwise + */ + bool IsClosed(); + + /** + * Closes the connection + */ + void Close(); + +protected: + Socket* m_socket; + +private: + PRLock* m_lock; + bool m_closed; +}; + +#endif // __CONNECTION_H + diff --git a/pki/base/tps/src/include/httpClient/httpc/ConnectionListener.h b/pki/base/tps/src/include/httpClient/httpc/ConnectionListener.h new file mode 100644 index 000000000..0b55900b3 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/ConnectionListener.h @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __CONNECTION_LISTENER_H +#define __CONNECTION_LISTENER_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * ConnectionListener.h 1.000 06/12/2002 + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL ConnectionListener { +public: + virtual int OnConnectionReceived(Connection*) = 0; + virtual int OnDataAvailable(Connection*) = 0; + virtual int OnConnectionClosed(Connection*) = 0; + virtual int OnConnectionError(Connection*, int, const char*) = 0; +}; + +#endif // __CONNECTION_LISTENER_H + + diff --git a/pki/base/tps/src/include/httpClient/httpc/DebugLogger.h b/pki/base/tps/src/include/httpClient/httpc/DebugLogger.h new file mode 100644 index 000000000..37c7971c0 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/DebugLogger.h @@ -0,0 +1,185 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __DEBUG_LOGGER_H__ +#define __DEBUG_LOGGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +struct PLHashTable; + +/** + * The DebugLogger class writes debug log entries conditionally. A single + * instance can be shared among modules or different modules can have + * their own instances. In either case, the log level can be changed + * globally across all instances with a single function call. All instances + * write through a singleton to ensure coordination in writing to a single + * file. + */ +class EXPORT_DECL DebugLogger { +public: +private: + DebugLogger( const char *moduleName ); + virtual ~DebugLogger(); + +public: +/** + * Gets a logger object for a particular module. Provide a module name + * if there will be more than one logger object in use, with each module + * having its own instance. Pass NULL if a single logger object will be + * shared throughout the application. + * + * @param moduleName Name of a module + * @return A logger instance + */ +static DebugLogger *GetDebugLogger( const char *moduleName = NULL ); + +/** + * Sets global default values for loggers; the values are assigned to + * DebugLogger objects created after this call returns + * + * @param configParams A table of key-value pairs to assign configuration + * parameters + */ +static void SetDefaults( PLHashTable *configParams ); + +/** + * Sets the log level for this object + * + * @param logLevel Log level setting for the module + */ +void SetLogLevel( int logLevel ); + +/** + * Gets the log level for this object + * + * @return logLevel Log level setting for the object + */ +int GetLogLevel(); + +/** + * Sets the log level for a particular module or all modules + * in all debug logger objects + * + * @param logLevel Log level setting for the module + * @param moduleName Name of the module (does not need to be known before + * this call); if NULL, the level is applied to all modules + */ +static void SetGlobalLogLevel( int logLevel, + const char *moduleName = NULL ); + +/** + * Gets the log level for a particular module + * + * @param moduleName Name of the module + * @return logLevel Log level setting for the module + */ +static int GetLogLevel( const char *moduleName ); + +/** + * Writes a debug log entry if logLevel is equal to or higher than the + * logLevel setting of the object + * + * @param logLevel One of the log levels defined above + * @param className The name of the class recording the log entry + * @param methodName The name of the method that is calling this log method + * @param fmt A sprintf format string for the remaining arguments + * @param ... A varargs list of things to log + * @return 0 on success + */ +int Log( int logLevel, + const char *className, + const char *methodName, + const char *fmt, ... ); + +/** + * Writes a trace entry if the logLevel setting of the object is FINER or FINEST + * + * @param className The name of the class recording the log entry + * @param methodName The name of the method that is calling this log method + * @param args An optional descriptive string + * @return 0 on success + */ +int Entering( const char *className, + const char *methodName, + const char *args = NULL ); + +/** + * Writes a trace entry if the logLevel setting of the object is FINER or FINEST + * + * @param className The name of the class recording the log entry + * @param methodName The name of the method that is calling this log method + * @param args An optional descriptive string + * @return 0 on success + */ +int Exiting( const char *className, + const char *methodName, + const char *args = NULL ); +/** + * Shut down, flushing any buffers and releasing resources + */ +void Close(); + +/** + * Shut down, flushing any buffers and releasing resources + */ +static void CloseAll(); + +protected: +/** + * Sets the log level for a particular module + * + * @param logLevel Log level setting for the module + * @param moduleName Name of the module (does not need to be known before + * this call) + */ +static void SetOneLogLevel( int logLevel, + const char *moduleName ); + +private: +/** + * Initializes the object with parameters from the Config Manager + * + * @param configName The name of the configuration entry to use + * @return 0 on success + */ +static int Initialize( const char *configName ); + +private: + int m_level; + char *m_module; +}; + +#endif // __DEBUG_LOGGER_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/Defines.h b/pki/base/tps/src/include/httpClient/httpc/Defines.h new file mode 100644 index 000000000..90af8e3d0 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/Defines.h @@ -0,0 +1,219 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __DEFINES_H__ +#define __DEFINES_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Defines.h 1.000 04/30/2002 + * + * This file contains global constants for the Presence Server + * + * @author Rob Weltman + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ + +// ??? SSR till we have server logging functionality +#ifdef _DEBUG +#define PS_LOG_LEVEL PS_LOG_LEVEL_DEBUG +#else +#define PS_LOG_LEVEL PS_LOG_LEVEL_WARN +#endif + +#define PS_SERVER_CONFIG_FILE "psserver.conf" + +// Configuration file for WASP SOAP server +#define SOAP_CONFIG_FILE "config.xml" + +#define CLIENT_DESCRIPTION "Netscape Presence Server" +#define SERVER_VERSION "1.0" + +// Key to SoapAction field in WASP call context +#define HEADER_FIELD_SOAPACTION "SOAP_ACTION" +// Key to status field in WASP call context +#define HEADER_STATUS "HEADER_STATUS" + +// Keys to client parameters passed through the call context + +#define SERVER_URL "SERVER_URL" +#define CERTIFICATE_DIRECTORY "CERTIFICATE_DIRECTORY" +#define CERTIFICATE_NICKNAME "CERTIFICATE_NICKNAME" +#define DO_SERVER_CERT_VALIDATION "DO_SERVER_CERT_VALIDATION" +#define CERTIFICATE_PASSWORD "CERTIFICATE_PASSWORD" + +#define STRING_ON_LINE "ONLINE" +#define STRING_OFF_LINE "OFFLINE" + +#define BATCH_RESULT_SIZE 1000 +#define MAX_ATTR_SIZE 5 + +#define NAME_BUFFER_LENGTH 256 +#define ATTR_BUFFER_LENGTH 256 + +// Static strings for the attributes we support +#define BUDDY_ATTRIBUTE_ON_LINE_STATUS "onlinestatus" +#define BUDDY_ATTRIBUTE_IDLE_TIME "idletime" +#define BUDDY_ATTRIBUTE_ON_LINE_SINCE "onlinesince" +#define BUDDY_ATTRIBUTE_AWAY_MESSAGE "awaymessage" +#define BUDDY_ATTRIBUTE_PROFILE "profile" +#define BUDDY_ATTRIBUTE_CONNECTION_TYPE "connectiontype" +#define BUDDY_ATTRIBUTE_CAPABILITIES "capabilities" + +#define PS_LOG_LEVEL_DEBUG 0 +#define PS_LOG_LEVEL_WARN 1 +#define PS_LOG_LEVEL_ERROR 2 + + +// Presence Server config parameters in the bootstrap configuration file +// psserver.conf +#define INSTANCE_ID "instanceid" +#define HOST_ID "hostid" +#define DOMAIN_NAME "domainname" +#define SERVER_HOST "serverhost" +#define SERVER_PORT "serverport" +#define BINDDN "binddn" +#define BINDPASSWORD "bindpassword" + +// dn, cn constants +#define PS_ATTRIBUTE_DN "dn" +#define PS_ATTRIBUTE_CN "cn" + +// nsPlugin class required attributes +#define PLUGIN_DN "dn" +#define PLUGIN_CN "cn" +#define PLUGIN_ID "nspluginid" +#define PLUGIN_PATH "nspluginpath" +#define PLUGIN_INIT_FUNC "nsplugininitfunc" +#define PLUGIN_ENABLED "nspluginenabled" +#define PLUGIN_VERSION "nspluginversion" +#define PLUGIN_DESC "nsplugindescription" + +// Operations when updating server +#define PS_OPERATION_ADD 1 +#define PS_OPERATION_DELETE 2 +#define PS_OPERATION_REPLACE 4 + +// Names of LDAP attributes for the LDAP data source +#define LDAP_SOURCE_DN "dn" +#define LDAP_SOURCE_CN "cn" +#define LDAP_SOURCE_GROUP_NAME "nspsgroupname" +#define LDAP_SOURCE_SERVER_ADDRESS "nsserveraddress" +#define LDAP_SOURCE_SERVER_PORT "nsserverport" +#define LDAP_SOURCE_BIND_DN "nsbinddn" +#define LDAP_SOURCE_BIND_PASSWORD "nsbindpassword" +#define LDAP_SOURCE_BASE_DN "nsbasedn" +#define LDAP_SOURCE_SEARCH_FILTER "nssearchfilter" +#define LDAP_SOURCE_SEARCH_SCOPE "nssearchscope" +#define LDAP_SOURCE_IM_ID "nsimattributetype" +#define LDAP_SOURCE_SEARCHABLE_ATTRIBUTES "nssearchableattributes" +#define LDAP_SOURCE_ENABLE_SSL "nsenablessl" + + +// Configuration attribute name for max results to return +#define SEARCH_MAX_RESULTS "nsmaxresults" + +// Max results to return if SEARCH_MAX_RESULTS is not defined +#define DEFAULT_MAX_RESULTS 1000 + +// Names of configuration clusters +#define CONFIG_BASE "ConfigBase" +#define CONFIG_AUTHORIZE "ConfigAuthorize" +#define CONFIG_ACCESS_LOG "ConfigAccessLog" +#define CONFIG_ERROR_LOG "ConfigErrorLog" +#define CONFIG_DEBUG_LOG "ConfigDebugLog" +#define CONFIG_SERVER_LOCAL "ConfigServerLocal" + +// Configuration attributes for loggers +#define LOG_ACCESS_DIR "nslogdir" +#define LOG_ERROR_DIR "nslogdir" +#define LOG_DEBUG_DIR "nslogdir" +#define LOG_ACCESS_BUFFER_SIZE "nslogbuffersize" +#define LOG_ACCESS_BUFFER_TIME "nslogbuffertime" +#define LOG_ACCESS_ROTATION_TIME "nslogrotationtime" +#define LOG_ACCESS_ROTATION_SIZE "nslogrotationsize" +#define LOG_ACCESS_MAX_LOGS "nslogmaxlogs" +#define LOG_ERROR_ROTATION_TIME "nslogrotationtime" +#define LOG_ERROR_ROTATION_SIZE "nslogrotationsize" +#define LOG_ERROR_MAX_LOGS "nslogmaxlogs" +#define LOG_DEBUG_LEVEL "nsloglevel" +#define LOG_DEBUG_FORMAT "nslogformat" + +// Static constants for logging +#define LOG_ACCESS_FILENAME "access" +#define LOG_ERROR_FILENAME "error" +#define LOG_DEBUG_FILENAME "debug" + +// Log level definitions + +typedef enum { + LOGLEVEL_OFF = 0, + LOGLEVEL_SEVERE = 1, + LOGLEVEL_WARNING = 2, + LOGLEVEL_INFO = 3, + LOGLEVEL_CONFIG = 4, + LOGLEVEL_FINE = 5, + LOGLEVEL_FINER = 6, + LOGLEVEL_FINEST = 7, + LOGLEVEL_ALL = 100 +} LogLevel; + +// Config params +#define CONFIG_DEFAULT_BUFFER_LEN 2048 +#define BASE_CONFIG_DN "cn=Netscape Presence Server,cn=Server Group,cn=%s,ou=%s,o=NetscapeRoot" + +// COOL Service params +#define COOL_SERVICE_SERVER_HOST "CoolServerHost" +#define COOL_SERVICE_SERVER_PORT "CoolServerPort" +#define COOL_SERVICE_LOGIN_NAME "CoolLoginName" +#define COOL_SERVICE_LOGIN_PSWD "CoolLoginPswd" + +#define COOL_DEFAULT_SERVER_HOST "coolkey.fedora.redhat.com" +#define COOL_DEFAULT_SERVER_PORT "5190" + +// Key to service ID in global config +#define SERVICE_TYPE "service_type" + +#define MODULE_IM_SERVICE "ModuleIMService" +#define MODULE_DATA_SOURCE "ModuleDataSource" + +#define PROVIDER_BATCH_SIZE_ATTR "nsbatchsize" +#define PROVIDER_UPDATE_INTERVAL_ATTR "nsupdateinterval" + +#define THREAD_POOL_TASK_NAME "ThreadPoolTask" + +#endif // __DEFINES_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/ErrorLogger.h b/pki/base/tps/src/include/httpClient/httpc/ErrorLogger.h new file mode 100644 index 000000000..df2617b06 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/ErrorLogger.h @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __ERROR_LOGGER_H__ +#define __ERROR_LOGGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/Logger.h" + +/** + * A singleton class for writing to an error log + */ +class EXPORT_DECL ErrorLogger : public Logger { +private: + ErrorLogger(); + virtual ~ErrorLogger(); + +public: + /** + * Gets a logger object with parameters obtained from the + * configuration manager + */ + static ErrorLogger *GetErrorLogger(); + + /** + * Writes an error log entry + * + * @param level SEVERE, WARNING, or INFO + * @param errorCode An error code + * @param fmt A message to be written to the log + * @return 0 on success + */ + int Log( int level, + int errorCode, + const char *fmt, + ... ); + + /** + * Initializes the object with parameters from the Config Manager + * + * @param configName The name of the configuration entry to use + * @return 0 on success + */ + int Initialize( const char *configName ); + +protected: + /** + * Writes the fixed argument part of an error log entry + * + * @param fp File pointer to write to + * @param level SEVERE, WARNING, or INFO + * @param errorCode An error code + * @return 0 on success + */ + int LogProlog( FILE *fp, + int level, + int errorCode ); +}; + +#endif // __ERROR_LOGGER_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/Iterator.h b/pki/base/tps/src/include/httpClient/httpc/Iterator.h new file mode 100644 index 000000000..9b15a93e2 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/Iterator.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _ITERATOR_H_ +#define _ITERATOR_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Base class for iterators + */ + +class EXPORT_DECL Iterator { +public: + /** + * Returns true if there is at least one more element + * + * @return true if there is at least one more element + */ + virtual bool HasMore() = 0; + + /** + * Returns the next element, if any + * + * @return The next element, if any, or NULL + */ + virtual void *Next() = 0; +}; + +#endif // _ITERATOR_H_ diff --git a/pki/base/tps/src/include/httpClient/httpc/LogRotationTask.h b/pki/base/tps/src/include/httpClient/httpc/LogRotationTask.h new file mode 100644 index 000000000..eed098b6b --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/LogRotationTask.h @@ -0,0 +1,132 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __LOG_ROTATION_TASK_H__ +#define __LOG_ROTATION_TASK_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/ScheduledTask.h" + +/** + * Log rotation task in Presence Server + */ + +class EXPORT_DECL LogRotationTask: public ScheduledTask { +public: + /** + * Constructor - creates an initialized task for log rotation + * + * @param name Name of task + * @param fileName Name of file to rotate + * @param startTime Time when the file is to be rotated + * @param maxLogs Max logs to keep + * @param interval Time between rotations + * @param fp File pointer for log file + * @param lock Lock for writing to log file + */ + LogRotationTask( const char *name, + const char *fileName, + time_t startTime, + int maxLogs, + int interval, + FILE **fp, + PRLock *lock ); + /** + * Destructor + */ + virtual ~LogRotationTask(); + /** + * Returns a copy of the task + * + * @return A copy of the task + */ + virtual ScheduledTask *Clone(); + /** + * Executes the task + * + * @return 0 on successfully starting the task + */ + virtual int Start(); + +protected: + /** + * Composes a file name from a base name and a time value + * + * @param filename The base file name (may be a path) + * @param ltime The time value + * @param outbuf Returns the composed file name + * @return 0 on success + */ + int CreateFilename( const char *filename, + time_t ltime, + char *outbuf ); + /** + * Extracts the folder and base name components of a file path + * + * @param fileName The full file path to examine + * @param dirName A buffer in which to place the folder found + * @param baseName A buffer in which to place the base name found + */ + static void GetPathComponents( const char *fileName, + char *dirName, + char *baseName ); + + /** + * Counts the number of files with the same initial path as fileName + * (the same folder and the same base pattern) + * + * @param fileName The file name to compare (including a folder) + * @return The number of matching files + */ + static int CountFiles( const char *fileName ); + + /** + * Purges (deletes) files with the same initial path as fileName + * (the same folder and the same base pattern) + * + * @param fileName The file name to compare (including a folder) + * @param maxLogs The number of files to purge to + * @return The number of files purged + */ + static int PurgeLogs( const char *fileName, int maxLogs ); + + char *m_fileName; + int m_maxLogs; + FILE **m_fp; + PRLock *m_lock; +}; + +#endif // __LOG_ROTATION_TASK_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/Logger.h b/pki/base/tps/src/include/httpClient/httpc/Logger.h new file mode 100644 index 000000000..b41d5dfbf --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/Logger.h @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __LOGGER_H__ +#define __LOGGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include <time.h> + +struct PRLock; +class LogRotationTask; + +/** + * A base class for writing to a log + */ +class EXPORT_DECL Logger { + +protected: + /** + * Constructor + */ + Logger(); + + /** + * Destructor + */ + virtual ~Logger(); + + /** + * Parses a time string in HH:MM format into a time_t for the next + * occurrence of the time + * + * @param timeString A time string in HH:MM format + * @return A time_t for the next occurrence of the time, or -1 if the + * string is not in a valid format + */ + time_t ParseTime( const char *timeString ); + + /** + * Creates a time-of-day rotation task + * + * @param taskName Name of task + * @param filename Name of log file + * @param rotationTime Time of day to rotate at + * @return Rotation task on success + */ + LogRotationTask *CreateRotationTask( const char *taskName, + const char *filename, + const char *rotationTime ); + +public: + + /** + * Shut down, flushing any buffers and releasing resources + */ + void Close(); + /** + * Gets the local time of day + * + * @param now The current local time of day + */ + static void GetLocalTime( struct tm *now ); + +protected: + int m_rotationSize; + time_t m_rotationTime; + int m_maxLogs; + char *m_dir; + FILE *m_fp; + /** + * Lock for writing to the file + */ + PRLock *m_fileLock; + /** + * Task that rotates a log file + */ + LogRotationTask *m_rotator; + /** + * True if object has been successfully initialized + */ + bool m_initialized; +}; + +#endif // __LOGGER_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/NSPRerrs.h b/pki/base/tps/src/include/httpClient/httpc/NSPRerrs.h new file mode 100644 index 000000000..2e131fd7a --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/NSPRerrs.h @@ -0,0 +1,160 @@ +/** BEGIN COPYRIGHT BLOCK + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1994-2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * END COPYRIGHT BLOCK **/ + +/* Originally obtained from: + * + * CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot + * cvs export -r NSS_3_11_3_RTM -N mozilla/security/nss/cmd/lib/NSPRerrs.h + */ + +/* General NSPR 2.0 errors */ +/* Caller must #include "prerror.h" */ + +ER2( PR_OUT_OF_MEMORY_ERROR, "Memory allocation attempt failed." ) +ER2( PR_BAD_DESCRIPTOR_ERROR, "Invalid file descriptor." ) +ER2( PR_WOULD_BLOCK_ERROR, "The operation would have blocked." ) +ER2( PR_ACCESS_FAULT_ERROR, "Invalid memory address argument." ) +ER2( PR_INVALID_METHOD_ERROR, "Invalid function for file type." ) +ER2( PR_ILLEGAL_ACCESS_ERROR, "Invalid memory address argument." ) +ER2( PR_UNKNOWN_ERROR, "Some unknown error has occurred." ) +ER2( PR_PENDING_INTERRUPT_ERROR,"Operation interrupted by another thread." ) +ER2( PR_NOT_IMPLEMENTED_ERROR, "function not implemented." ) +ER2( PR_IO_ERROR, "I/O function error." ) +ER2( PR_IO_TIMEOUT_ERROR, "I/O operation timed out." ) +ER2( PR_IO_PENDING_ERROR, "I/O operation on busy file descriptor." ) +ER2( PR_DIRECTORY_OPEN_ERROR, "The directory could not be opened." ) +ER2( PR_INVALID_ARGUMENT_ERROR, "Invalid function argument." ) +ER2( PR_ADDRESS_NOT_AVAILABLE_ERROR, "Network address not available (in use?)." ) +ER2( PR_ADDRESS_NOT_SUPPORTED_ERROR, "Network address type not supported." ) +ER2( PR_IS_CONNECTED_ERROR, "Already connected." ) +ER2( PR_BAD_ADDRESS_ERROR, "Network address is invalid." ) +ER2( PR_ADDRESS_IN_USE_ERROR, "Local Network address is in use." ) +ER2( PR_CONNECT_REFUSED_ERROR, "Connection refused by peer." ) +ER2( PR_NETWORK_UNREACHABLE_ERROR, "Network address is presently unreachable." ) +ER2( PR_CONNECT_TIMEOUT_ERROR, "Connection attempt timed out." ) +ER2( PR_NOT_CONNECTED_ERROR, "Network file descriptor is not connected." ) +ER2( PR_LOAD_LIBRARY_ERROR, "Failure to load dynamic library." ) +ER2( PR_UNLOAD_LIBRARY_ERROR, "Failure to unload dynamic library." ) +ER2( PR_FIND_SYMBOL_ERROR, +"Symbol not found in any of the loaded dynamic libraries." ) +ER2( PR_INSUFFICIENT_RESOURCES_ERROR, "Insufficient system resources." ) +ER2( PR_DIRECTORY_LOOKUP_ERROR, +"A directory lookup on a network address has failed." ) +ER2( PR_TPD_RANGE_ERROR, +"Attempt to access a TPD key that is out of range." ) +ER2( PR_PROC_DESC_TABLE_FULL_ERROR, "Process open FD table is full." ) +ER2( PR_SYS_DESC_TABLE_FULL_ERROR, "System open FD table is full." ) +ER2( PR_NOT_SOCKET_ERROR, +"Network operation attempted on non-network file descriptor." ) +ER2( PR_NOT_TCP_SOCKET_ERROR, +"TCP-specific function attempted on a non-TCP file descriptor." ) +ER2( PR_SOCKET_ADDRESS_IS_BOUND_ERROR, "TCP file descriptor is already bound." ) +ER2( PR_NO_ACCESS_RIGHTS_ERROR, "Access Denied." ) +ER2( PR_OPERATION_NOT_SUPPORTED_ERROR, +"The requested operation is not supported by the platform." ) +ER2( PR_PROTOCOL_NOT_SUPPORTED_ERROR, +"The host operating system does not support the protocol requested." ) +ER2( PR_REMOTE_FILE_ERROR, "Access to the remote file has been severed." ) +ER2( PR_BUFFER_OVERFLOW_ERROR, +"The value requested is too large to be stored in the data buffer provided." ) +ER2( PR_CONNECT_RESET_ERROR, "TCP connection reset by peer." ) +ER2( PR_RANGE_ERROR, "Unused." ) +ER2( PR_DEADLOCK_ERROR, "The operation would have deadlocked." ) +ER2( PR_FILE_IS_LOCKED_ERROR, "The file is already locked." ) +ER2( PR_FILE_TOO_BIG_ERROR, +"Write would result in file larger than the system allows." ) +ER2( PR_NO_DEVICE_SPACE_ERROR, "The device for storing the file is full." ) +ER2( PR_PIPE_ERROR, "Unused." ) +ER2( PR_NO_SEEK_DEVICE_ERROR, "Unused." ) +ER2( PR_IS_DIRECTORY_ERROR, +"Cannot perform a normal file operation on a directory." ) +ER2( PR_LOOP_ERROR, "Symbolic link loop." ) +ER2( PR_NAME_TOO_LONG_ERROR, "File name is too long." ) +ER2( PR_FILE_NOT_FOUND_ERROR, "File not found." ) +ER2( PR_NOT_DIRECTORY_ERROR, +"Cannot perform directory operation on a normal file." ) +ER2( PR_READ_ONLY_FILESYSTEM_ERROR, +"Cannot write to a read-only file system." ) +ER2( PR_DIRECTORY_NOT_EMPTY_ERROR, +"Cannot delete a directory that is not empty." ) +ER2( PR_FILESYSTEM_MOUNTED_ERROR, +"Cannot delete or rename a file object while the file system is busy." ) +ER2( PR_NOT_SAME_DEVICE_ERROR, +"Cannot rename a file to a file system on another device." ) +ER2( PR_DIRECTORY_CORRUPTED_ERROR, +"The directory object in the file system is corrupted." ) +ER2( PR_FILE_EXISTS_ERROR, +"Cannot create or rename a filename that already exists." ) +ER2( PR_MAX_DIRECTORY_ENTRIES_ERROR, +"Directory is full. No additional filenames may be added." ) +ER2( PR_INVALID_DEVICE_STATE_ERROR, +"The required device was in an invalid state." ) +ER2( PR_DEVICE_IS_LOCKED_ERROR, "The device is locked." ) +ER2( PR_NO_MORE_FILES_ERROR, "No more entries in the directory." ) +ER2( PR_END_OF_FILE_ERROR, "Encountered end of file." ) +ER2( PR_FILE_SEEK_ERROR, "Seek error." ) +ER2( PR_FILE_IS_BUSY_ERROR, "The file is busy." ) +ER2( PR_IN_PROGRESS_ERROR, +"Operation is still in progress (probably a non-blocking connect)." ) +ER2( PR_ALREADY_INITIATED_ERROR, +"Operation has already been initiated (probably a non-blocking connect)." ) + +#ifdef PR_GROUP_EMPTY_ERROR +ER2( PR_GROUP_EMPTY_ERROR, "The wait group is empty." ) +#endif + +#ifdef PR_INVALID_STATE_ERROR +ER2( PR_INVALID_STATE_ERROR, "Object state improper for request." ) +#endif + +#ifdef PR_NETWORK_DOWN_ERROR +ER2( PR_NETWORK_DOWN_ERROR, "Network is down." ) +#endif + +#ifdef PR_SOCKET_SHUTDOWN_ERROR +ER2( PR_SOCKET_SHUTDOWN_ERROR, "The socket was previously shut down." ) +#endif + +#ifdef PR_CONNECT_ABORTED_ERROR +ER2( PR_CONNECT_ABORTED_ERROR, "TCP Connection aborted." ) +#endif + +#ifdef PR_HOST_UNREACHABLE_ERROR +ER2( PR_HOST_UNREACHABLE_ERROR, "Host is unreachable." ) +#endif + +/* always last */ +ER2( PR_MAX_ERROR, "Placeholder for the end of the list" ) diff --git a/pki/base/tps/src/include/httpClient/httpc/PSBuddy.h b/pki/base/tps/src/include/httpClient/httpc/PSBuddy.h new file mode 100644 index 000000000..4d84b8727 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSBuddy.h @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_BUDDY_H__ +#define __PS_BUDDY_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSBuddy.h 1.000 05/15/2002 + * + * Interface to store buddy online status attributes + * + * @author Surendra Rajam + * @version 1.000, 05/15/2002 + */ +class EXPORT_DECL PSBuddy { +public: + PSBuddy() { }; + virtual ~PSBuddy() { }; + /** + * Gets the buddy name + * + * @return name of the buddy + */ + virtual const char* GetName() = 0; + + /** + * Gets online status of the buddy + * + * @return true if online, false otherwise + */ + virtual bool IsOnline() = 0; + + /** + * Gets the value of the specified online status attribute + * + * @param attribute type + * @param attribute value upon success + * @return 0 on Success, error code otherwise + */ + virtual int GetStatus(const char*, char**) = 0; + + /** + * Returns a copy of the buddy + * + * @return A copy of the buddy + */ + virtual PSBuddy* Clone() = 0; +}; + +#endif // __PS_BUDDY_H__ + + + + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSBuddyCache.h b/pki/base/tps/src/include/httpClient/httpc/PSBuddyCache.h new file mode 100644 index 000000000..3c880074b --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSBuddyCache.h @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_BUDDY_CACHE_H__ +#define __PS_BUDDY_CACHE_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSBuddyCache.h 1.000 04/30/2002 + * + * Cache of PSBuddy objects containing online status + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class PSBuddyCache +{ +public: + + /** + * Constructor - initializes the internal cache + */ + PSBuddyCache(); + + /** + * Destructor + */ + virtual ~PSBuddyCache(); + + /** + * Adds a buddy to the cache. The old entry, if exists, is deleted + * from the cache + * + * @param name name of the new buddy + * @param buddy object containing onlinestatus attributes + * @return 0 on success + */ + int AddBuddy(const char* name, PSBuddy* buddy); + + /** + * Removes a buddy from the cache + * + * @param name name of the buddy to be removed + * @return 0 on success + */ + int RemoveBuddy(const char* name); + + /** + * Gets the buddy object + * + * @param name name of the new buddy + * @return object containing onlinestatus attributes, NULL if not found + */ + PSBuddy* GetBuddy(const char* name); + + /** + * Gets count of buddies in the cache + * + * @return count of buddies + */ + int GetBuddyCount(); + + /** + * Gets all the screen names + * + * @param names On return, contains array of screen names + * @return number of screen names + */ + int GetAllBuddies(char*** names); + + /** + * Acquires a read lock on the cache. Multiple threads may simultaneously + * have a read lock, but attempts to acquire a read lock will block + * if another thread already has a write lock. It is illegal to request + * a read lock if the thread already has one. + */ + void ReadLock(); + + /** + * Releases a read lock that the thread has on the cache + */ + void Unlock(); + +private: + StringKeyCache* m_buddies; +}; + +#endif // __PS_BUDDY_CACHE_H__ + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSBuddyList.h b/pki/base/tps/src/include/httpClient/httpc/PSBuddyList.h new file mode 100644 index 000000000..49155a8a5 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSBuddyList.h @@ -0,0 +1,373 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_BUDDY_LIST_H__ +#define __PS_BUDDY_LIST_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSBuddyList.h 1.000 05/21/2002 + * + * This class maintains users information which are set for + * online status tracking. The online status of users are updated + * through a PSBuddyListener interface implemented by this class. + * + * @author Surendra Rajam + * @version 1.000, 05/21/2002 + */ +class PSBuddyList : + public PSBuddyListener +{ +private: + + /** + * Constructor + */ + PSBuddyList(); + + /** + * Destructor + */ + virtual ~PSBuddyList(); + +public: + + /** + * Gets an instance of the class + */ + static PSBuddyList* GetBuddyList(); + + public: + + /** + * Save the users maintain by an instance of presence server + * to a local file in the BLT format + * + * @return 0 on succcess, negative error code otherwise + */ + int SaveBuddyList(); + + /** + * Loads the users into an instance of presence server + * from a local file + * + * @return 0 on succcess, negative error code otherwise + */ + int LoadBuddyList(); + + /** + * Sets a service provider. We currently support only one service + * provider in a presence server instance. + * + * @return 0 on succcess, negative error code otherwise + */ + int RegisterService(PSBuddyService* service); + + /** + * Gets the online status of a user along with the + * requested additional attributes + * + * @param group group name to which the user belongs + * @param name the screen name of the user to query status for + * @param nAttributes number of attributes + * @param attributes the names of the attributes of the user to return + * @param user upon return, filled with user attributes + * @return 0 on success, a negative error code on failure + */ + int GetUserStatus( const char* group, + const char* name, + int nAttributes, + char** attributes, + PSUser** user ); + + /** + * Gets the online status of multiple users along with the requested + * additional attributes + * + * @param group group name to which the user belongs + * @param nUsers the number of screen names to status query for + * @param names the screen names of the users to query status for + * @param nAttributes number of attributes + * @param attributes the names of the attributes of the user to return + * @param user upon return, filled with user attributes + * @return 0 on success, a negative error code on failure + */ + int GetMultipleUserStatus( const char* group, + int nUsers, + char** names, + int nAttributes, + char** attributes, + PSUser*** users ); + + /** + * Gets the screen names and attributes of users that match + * certain search criteria + * + * @param group group name to query from + * @param filter an LDAP-like search expression on + * presence status attributes + * @param nAttrbiutes number of attributes + * @param attributes the names of the attributes of the user to return + * @param user upon return, an array of users with + * requested attributes + * @return number of users returned, or a negative error code + */ + int GetUsersByFilter( const char* group, + const char* filter, + int nAttributes, + char** attributes, + PSUser*** users ); + + /** + * Gets the screen names and attributes of users that match certain search + * criteria and sorts the results (currently only by entryId) + * + * @param group group name to query from + * @param filter an LDAP-like search expression on presence status + * attributes + * @param sortKey name of attribute to sort on + * @param sortKeyType 1 for numeric, 2 for string + * @param nAttributes number of attributes + * @param attributes the names of the attributes of the user to return + * @param user upon return, an array of users with requested + * attributes + * @return number of users returned, or a negative error code + */ + int GetSortedUsersByFilter( const char* group, + const char* filter, + const char *sortKey, + int sortKeyType, + int nAttributes, + char** attributes, + PSUser*** users ); + + /** + * Gets the number of users who are online or offline in a group + * + * @param group Name of group to query; NULL or empty for all groups + * @param bOnline true to return the count of online users, false for offline + * @return Number of users, or a negative error code on failure + * + * Error Code(s): + * PS_UNKOWN_GROUP + */ + int GetBuddyCount( const char* group, int bOnline ); + + /** + * Add a new group + * + * @param group name of the new group + * @param nAttributes number of attributes + * @param attributes attributes the group will support + * @return 0 on success, a negative error code on failure + */ + int AddGroup( const char* group, int nAttributes, char** attributes ); + + /** + * Adds a user to be tracked. + * + * @param group name of the group to add the user in + * @param name screen name of the user to track + * @param nAttributes number of attributes + * @param attributes the attributes of the users to be stored + * @return on success, 0 or an error code + */ + int AddUser( const char* group, + const char* name, + int nAttributes, + PSAttribute** attributes ); + + /** + * Adds a number of users to track. + * + * @param group name of the group to which the users belong + * @param nUsers number of users + * @param users names and attributes of users to track + * @return number of users added on success, + or a negative error code on failure + */ + int AddUsers( const char* group, + int nUsers, + PSUser** users ); + + /** + * Removes a user to be tracked. + * + * @param group name of the group to which the user belongs + * @param name screen name of the user to be removed + * @return 0 on success, or a negative error code on failure + */ + int RemoveUser( const char* group, const char* name ); + + /** + * Removes a number of users to be tracked. + * + * @param group name of the group to which the users belong + * @param nUsers number of users + * @param names screen name of the users to be removed + * @return number of users removed on success, + * or a negative error code on failure + */ + int RemoveUsers( const char* group, int nUsers, char** names ); + + /** + * Removes a group. + * + * @param group name of the group to be removed + * @return number of users removed on success, + * or a negative error code on failure + * + * Error Code(s): + * PS_UNKNOWN_GROUP + */ + int RemoveGroup(const char* group); + + /** + * Gets the list of groups. + * + * @param groups upon return, array containing group names + * @return number of groups or 0 if no group present + * + * Error Code(s): + * PS_NO_GROUPS + */ + int GetAllGroups(char*** groups); + + /** + * Gets the users in a group(s). + * + * @param group name of the group to query + * @param users upon return, array of User objects + * @return number of users returned, + * or a negative error code on failure + */ + int GetAllUsers( const char* group, PSUser*** users ); + + /** + * Gets the attributes supported by a group(s) + * + * @param group name of the group + * @param attributes upon return, array of attributes + * @return number of users removed on success, + * or a negative error code on failure + */ + int GetSearchableAttributes( const char* group, char*** attributes ); + + // PSBuddyListener interface + /** + * Callback to notify buddy changes + * + * @param service the reporting buddy service + * @param buddy buddy object containing online status attributes + * @return 0 on success + */ + int OnBuddyChanged(PSBuddyService* service, PSBuddy* buddy); + + /** + * Callback to refresh the list of screen names to the buddy queue + * + * @param the reporting buddy service + * @return 0 on success + */ + int OnRefreshList(PSBuddyService* service); + + /** + * Removes a user from a group based on its entry Id + * + * @param group name of the group + * @param entryId user's entry id + * @return 0 + */ + int RemoveUserByEntryId(const char* group, char* entryId); + +protected: + + /** + * Gets the max number of search results to return + * + * @return The max number of search results to return + */ + int GetMaxSearchResults(); + +private: + + /** + * Parses the LDAP like filter and create a map object containing + * filter in the form of name-value pair + * + * @param filter LDAP like filter + * @param map array containing break up of filter into name-value pair + * @return 0 on success + */ + int ParseFilter(const char* filter, PSAttribute*** map); + + /** + * Checks whether a given string is NULL or "" + * + * @param value a string to be tested for NULL or "" + * @return true if NULL, false otherwise + */ + bool IsNull(const char* value); + + /** + * Prints buddy information + * + * @param buddy a buddy object containing online status attributes + * @return 0 on success + */ + int DumpBuddy(PSBuddy* buddy); + + /** + * Sorts a list of users based on a "entryId" + * + * @param users array of users to be sorted + * @param nUsers number of users in the array + * @return 0 on success + */ + int SortUsersByEntryId(PSUser** users, int nUsers); + +private: + PSBuddyCache* m_buddies; + PSGroupCache* m_groups; + PSBuddyService* m_service; + + /* flag indicating if buddy list is loaded from the disk */ + bool m_loadedList; +}; + +#endif // __PS_BUDDY_LIST_H__ + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSBuddyListener.h b/pki/base/tps/src/include/httpClient/httpc/PSBuddyListener.h new file mode 100644 index 000000000..87e701373 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSBuddyListener.h @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_BUDDY_LISTENER_H__ +#define __PS_BUDDY_LISTENER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSBuddyListener.h 1.000 05/15/2002 + * + * A listener interface for getting notifications from a buddy service. + * + * @author Surendra Rajam + * @version 1.000, 05/15/2002 + */ +class PSBuddyListener : + public PSListener +{ +public: + +/** + * Notifies the listener of the buddy status changes + * + * @param the reporting buddy service + * @param buddy object containing online status attributes + * @return 0 on success + */ +virtual int OnBuddyChanged(PSBuddyService*, PSBuddy*) = 0; + +/** + * Notifies the listener of the service to refresh the list + * of screen names to the buddy queue + * + * @param the reporting buddy service + * @return 0 on success + */ +virtual int OnRefreshList(PSBuddyService*) = 0; + +}; + +#endif // __PS_BUDDY_LISTENER_H__ + + + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSBuddyService.h b/pki/base/tps/src/include/httpClient/httpc/PSBuddyService.h new file mode 100644 index 000000000..2556420e9 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSBuddyService.h @@ -0,0 +1,121 @@ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_BUDDY_SERVICE_H__ +#define __PS_BUDDY_SERVICE_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSBuddyService.h 1.000 05/16/2002 + * + * A pure virtual class defining Buddy Service interface + * to be implemented by the various IM presence service providers. + * + * @author Surendra Rajam + * @version 1.000, 05/16/2002 + */ +class EXPORT_DECL PSBuddyService { +public: + +/** + * Registers a listener with this class. The listener + * is notified of any changes to the buddies being tracked. + * + * @param a buddy service listener + * @return 0 on success + */ +virtual int RegisterListener(PSListener*) = 0; + +/** + * An entry point to start the service. This function is responsible + * for authentication with the backend service. + * + * @param config parameters for the service to start + * @return 0 on success + */ +virtual int SignOn(PSConfig*) = 0; + +/** + * Shutdown of the service. + * + * @return 0 on success + */ +virtual int SignOff() = 0; + +/** + * Sets a user name for online status tracking. + * + * @param user name to be tracked + * @return 0 on success + */ +virtual int WatchBuddy(const char*) = 0; + +/** + * Sets a number of users for online status tracking + * + * @param number of users to be tracked + * @param array of user names + * @return 0 on success + */ +virtual int WatchBuddies(int, char**) = 0; + +/** + * Unsets a user name from online status tracking. + * + * @param user name to be tracked + * @return 0 on success + */ +virtual int UnwatchBuddy(const char*) = 0; + +/** + * Unsets a number of users from online status tracking + * + * @param number of users to be tracked + * @param array of user names + * @return 0 on success + */ +virtual int UnwatchBuddies(int, char**) = 0; + +/** + * Gets the service config entry + * + * @return config object + */ +virtual PSConfig* GetServiceConfig() = 0; + +}; + +#endif // __PS_BUDDY_SERVICE_H__ + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSCertExtension.h b/pki/base/tps/src/include/httpClient/httpc/PSCertExtension.h new file mode 100644 index 000000000..f528a54b4 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSCertExtension.h @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _PS_CERT_EXTENSION_H +#define _PS_CERT_EXTENSION_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Presence Server cert extension. This extension contains customer + * specific information as per the contract apart from host and port + * used by BIG service provider to send user updates. + */ + +class EXPORT_DECL PSCertExtension { +public: + /** + * Constructor - + */ + PSCertExtension(); + + /** + * Destructor + */ + ~PSCertExtension(); + +public: + /** + * Loads the extension data from the specified cert. This function + * will also verify the validity these fields : + * HOST_NAME - should not be NULL or "" + * PORT_NUMBER - > 0 and <= 65535 + * MAX_USERS - >= 0 + * + * @param nickname cert nickname which contains the extension + * return 0 on success, + * -1 if nickname is missing from the argument + * -2 if unable to find the cert + * -3 if the presence extension is mising + * -4 if the required values (hostname, port, maxusers) are invalid + * -5 if the cert is expired + */ + int Load(const char* nickname); + + /** + * Gets the service version number from the cert ext + * + * return version number as specified in the cert + */ + int GetVersion(); + + /** + * Gets the street address from the cert + * + * return street address as specified in the cert ext + */ + const char* GetStreetAddress(); + + /** + * Gets the telephone number from the cert + * + * return telephone number as specified in the cert ext + */ + const char* GetTelephoneNumber(); + + /** + * Gets the RFC822 name from the cert + * + * return RFC822 name as specified in the cert ext + */ + const char* GetRFC822Name(); + + /** + * Gets the IM id from the cert + * + * return IM id as specified in the cert ext + */ + const char* GetID(); + + /** + * Gets the hostname from the cert ext + * + * return hostname as specified in the cert ext + */ + const char* GetHostName(); + + /** + * Gets the port number from the cert ext + * + * return port number as specified in the cert ext + */ + int GetPortNumber(); + + /** + * Gets the max users allowed from the cert ext + * + * return max users as specified in the cert ext + */ + int GetMaxUsers(); + + /** + * Gets the service level from the cert ext + * + * return service level as specified in the cert ext + */ + int GetServiceLevel(); + +private: + int m_version; + char* m_streetAddress; + char* m_telephoneNumber; + char* m_rfc822Name; + char* m_id; + char* m_hostName; + int m_portNumber; + int m_maxUsers; + int m_serviceLevel; +}; + +#endif // _PS_CERT_EXTENSION_H + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSCommonLib.h b/pki/base/tps/src/include/httpClient/httpc/PSCommonLib.h new file mode 100644 index 000000000..09903b38f --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSCommonLib.h @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _PS_COMMON_LIB_H_ +#define _PS_COMMON_LIB_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#undef EXPORT_DECL +#ifdef _MSC_VER +#ifdef COMMON_LIB_DLL +#define EXPORT_DECL __declspec( dllexport ) +#else +#define EXPORT_DECL __declspec (dllimport ) +#endif // COMMON_LIB_DLL +#else +#define EXPORT_DECL +#endif // _MSC_VER + +#endif // _PS_COMMON_LIB_H_ diff --git a/pki/base/tps/src/include/httpClient/httpc/PSConfig.h b/pki/base/tps/src/include/httpClient/httpc/PSConfig.h new file mode 100644 index 000000000..897def3c9 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSConfig.h @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_CONFIG_H__ +#define __PS_CONFIG_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSConfig.h 1.000 04/30/2002 + * + * This class provides structure to store and fetch string type data. + * Typical usage of this class would be storing server config data. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PSConfig { +public: + PSConfig(); + PSConfig( const char *name ); + virtual ~PSConfig(); + +public: + void SetAttribute( const char* key, char* value ); + char* GetAttribute( const char* key ); + void SetName( const char *name ); + const char *GetName(); + +private: + PLHashTable* m_entryData; + const char *m_name; +}; + +#endif // __PS_CONFIG_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/PSConfigManager.h b/pki/base/tps/src/include/httpClient/httpc/PSConfigManager.h new file mode 100644 index 000000000..d2f5d3335 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSConfigManager.h @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_CONFIG_MANAGER_H__ +#define __PS_CONFIG_MANAGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSConfigManager.h 1.000 04/30/2002 + * + * This class is a singleton that provides access to configuration parameters + * for the Presence Server. + * + * @author rweltman@netscape.com + * @version 1.0 + */ +class EXPORT_DECL PSConfigManager { +private: + PSConfigManager(); + virtual ~PSConfigManager(); + +public: + static PSConfigManager *GetConfigManager(); + +public: + void SetConfigEntry( PSConfig *entry ); + PSConfig *GetConfigEntry( const char *name ); + +private: + PLHashTable* m_configEntries; +}; + +#endif // __PS_CONFIG_MANAGER_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/PSConfigReader.h b/pki/base/tps/src/include/httpClient/httpc/PSConfigReader.h new file mode 100644 index 000000000..a507a26dc --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSConfigReader.h @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_CONFIG_READER_H__ +#define __PS_CONFIG_READER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSConfigReader.h 1.000 04/30/2002 + * + * This class provides access to the server configuration entries. The + * implementation of the config store is hidden from the user. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PSConfigReader +{ +private: + PSConfigReader(); + virtual ~PSConfigReader(); + +public: + static PSConfigReader* GetConfigReader(); + +public: + int GetSubEntries(const char* root, char*** entries); + int GetEntryConfig(const char* entry, PSConfig** params); + +private: + int Init(); + +private: + LDAP* m_LD; + char* m_bindPassword; +}; + +#endif // __PS_CONFIG_READER_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/PSCrypt.h b/pki/base/tps/src/include/httpClient/httpc/PSCrypt.h new file mode 100644 index 000000000..bfd05788d --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSCrypt.h @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PSCRYPT_H__ +#define __PSCRYPT_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Encrypt/Decrypt + */ + +class EXPORT_DECL PSCrypt { +private: + /** + * Constructor + */ + PSCrypt( ); + /** + * Destructor + */ + virtual ~PSCrypt(); + +public: + /** + * Retuns the decrypted string + * Assumption: The input string is base64 encoded + * Assumption: Caller has to free the returned string using free + * @param base64 encoded string to be decrypted + * @param decrypted upon return, string in ascii + * @return 0 on success, -1 on failure + */ + static int Decrypt (const char* encrypted, char** decrypted); + + /** + * Retuns the encrypted string in base64 + * + * Assumption: Caller has to free the returned string using free + * @param text to encrypt + * @param encrypted upon return, text in base64 + * @return 0 on success, -1 on failure + */ + static int Encrypt(const char* text, char** encrypted); +}; + +#endif /* __PSCRYPT_H__ */ + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSDataSourceListener.h b/pki/base/tps/src/include/httpClient/httpc/PSDataSourceListener.h new file mode 100644 index 000000000..36842904d --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSDataSourceListener.h @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_DATA_SOURCE_LISTENER_H__ +#define __PS_DATA_SOURCE_LISTENER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/PSUser.h" + +/** + * PSDataSourceListener.h 1.000 04/30/2002 + * + * A listener class for data source type plugins. The plugins + * notify the data source service manager through the functions + * provided by this interface. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PSDataSourceListener : + public PSListener +{ +public: + +/** + * Notifies the listener of any errors encountered by + * the data sources + * + * @param sourceId reporting source ID + * @param errCode error code + * @param errString error message + * @return 0 on success + */ +virtual int OnSourceError( const char* sourceId, + int errCode, + const char* errString) = 0; + +/** + * Notifies the listener of any new group + * + * @param group name of the group + * @param nAttrs number of attributes + * @param attrs array of attributes supported by the group + * @return 0 on success + */ +virtual int OnNewGroup( const char* group, int nAttrs, char** attrs ) = 0; + +/** + * Notifies the listener of any new users + * + * @param group name of the group + * @param nUsers number of users + * @param users array containing user objects + * @return 0 on success + */ +virtual int OnNewUsers( const char* group, int nUsers, PSUser** users ) = 0; + +/** + * Notifies the listener of any changes to the user being + * watched + * + * @param op operation to be performed ( add/replace/remove) + * @param group name of the group + * @param user the user object containing modified attributes + * @return 0 on success + */ +virtual int OnUserChanged(int op, const char* group, PSUser* user) = 0; + +}; + +#endif // __PS_DATA_SOURCE_LISTENER_H__ + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSDataSourceManager.h b/pki/base/tps/src/include/httpClient/httpc/PSDataSourceManager.h new file mode 100644 index 000000000..1b0662b69 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSDataSourceManager.h @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_DATA_SOURCE_MANAGER_H__ +#define __PS_DATA_SOURCE_MANAGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSDataSourceManager.h 1.000 05/21/2002 + * + * This class manages presence server data sources plugins. + * + * @author Surendra Rajam + * @version 1.000, 05/21/2002 + */ +class PSDataSourceManager : + public PSDataSourceListener +{ +private: + + /** + * Constructor - creates a data source manager object + */ + PSDataSourceManager(); + + /** + * Destructor + */ + virtual ~PSDataSourceManager(); + +public: + + /** + * Gets an instance of this class. + */ + static PSDataSourceManager* GetDataSourceManager(); + +public: + + /** + * Registers a listener with this class. Only one listener is + * allowed to be registered. If an attempt is made to register + * more than one listener, then an error condition is raised. + * + * @param listener a server listener + * @return 0 on success, negative error upon failure + */ + int RegisterListener(PSServerListener* listener); + + /** + * Loads all data source type plugins. + * + * @return 0 for success, negative error code otherwise + */ + int LoadDataSources(); + + /** + * Unloads all data source type plugins. + * + * @return 0 for success, negative error code otherwise + */ + int UnloadDataSources(); + +// PSDataSourceListener interface +public: + + /** + * Callback function to notify the manager upon data source error. + * + * @param sourceid id of the source calling + * @param errorcode error code + * @param errorstring error string + * @return 0 on success + * + */ + int OnSourceError(const char* sourceid, int errorcode, const char* errorstring); + + /** + * Callback function to notify the manager upon new group. + * + * @param group name of the new group + * @param nAttrs number of attributes + * @param attrs attributes the group will support + * @return 0 on success + * + */ + int OnNewGroup(const char* group, int nAttrs, char** attrs); + + /** + * Callback function to notify the manager of new users + * + * @param group name of the group + * @param nUsers number of users + * @param users array containing user objects + * @return 0 on success, a negative error code on failure + */ + int OnNewUsers(const char* group, int nUsers, PSUser** users); + + /** + * Callback function to notify the manager of changes to a user. + * The valid operations are : + * PS_OPERATION_ADD + * PS_OPERATION_REPLACE + * PS_OPERATION_DELETE + * + * @param op operation to be performed + * @param group name of the group + * @param user the user object containing modified attributes + * @return 0 on success, a negative error code on failure + */ + int OnUserChanged(int op, const char* group, PSUser* user); + +private: + char* m_dataSourceDN; + PSServerListener* m_serverListener; + bool m_dataSourcesLoaded; +}; + +#endif // __PS_DATA_SOURCE_MANAGER_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/PSGroup.h b/pki/base/tps/src/include/httpClient/httpc/PSGroup.h new file mode 100644 index 000000000..8427c39c3 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSGroup.h @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_GROUP_H__ +#define __PS_GROUP_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +class PSUser; + +/** + * PSGroup.h 1.000 04/30/2002 + * + * This class stores information about the users belonging to a group. + * All the users must belong to at least one group in the server. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class PSGroup +{ +public: + PSGroup(const char* name, int nAttributes, char** attributes); + virtual ~PSGroup(); + +public: + char* GetName(); + int GetAttributeCount(); + char** GetAttributes(); + int GetAttributes(int offset, char** & attributes); + + int AddUser(PSUser* user); + int RemoveUser(const char* name); + PSUser* GetUser(const char* name); + bool UserExists(const char* name); + + int GetUserCount(); + int GetAllUsers(int offset, PSUser** & users, int maxcount); + int GetAllUsers(int offset, char** & names, int maxcount); + + int UpdateStatus(const char* name, bool changeToOnline); + int GetOnlineUsers(char*** names); + int GetOfflineUsers(char*** names); + int GetOnlineCount(); + int GetOfflineCount(); + + void ReadLock(); + void Unlock(); + +private: + char* m_name; + int m_count; + char** m_attributes; + + PRRWLock* m_psOnlineLock; + PRRWLock* m_psOfflineLock; + StringList* m_psOnlineUsers; + StringList* m_psOfflineUsers; + + StringKeyCache* m_users; +}; + +#endif // __PS_GROUP_H__ + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSGroupCache.h b/pki/base/tps/src/include/httpClient/httpc/PSGroupCache.h new file mode 100644 index 000000000..6807e50e4 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSGroupCache.h @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_GROUP_CACHE_H__ +#define __PS_GROUP_CACHE_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSGroupCache.h 1.000 04/30/2002 + * + * This class provides caching of various groups maintained in the + * server. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class PSGroupCache +{ +public: + PSGroupCache(); + virtual ~PSGroupCache(); + + int AddGroup(const char* name, PSGroup* group); + int RemoveGroup(const char* name); + PSGroup* GetGroup(const char* name); + bool GroupExists(const char* name); + int GetAllGroups(char*** names); + + int GetAttributeCount(int nGroups, char** groups); + int GetUserCount(int nGroups, char** groups); + int GetOnlineCount(int nGroups, char** groups); + int GetOfflineCount(int nGroups, char** groups); + + void ReadLock(); + void Unlock(); + +private: + StringKeyCache* m_groups; +}; + +#endif // __PS_GROUP_CACHE_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/PSHelper.h b/pki/base/tps/src/include/httpClient/httpc/PSHelper.h new file mode 100644 index 000000000..7b9240b1b --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSHelper.h @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_HELPER_H__ +#define __PS_HELPER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSHelper.h 1.000 04/30/2002 + * + * A utility class used for logging, utility functions + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +// ??? SSR temporary logging solution +class EXPORT_DECL PSLogger +{ +public: + PSLogger(int level); + virtual ~PSLogger(); + +public: + void Log(int level, char* fmt, ...); +private: + int m_Level; +}; + +extern "C" { + EXPORT_DECL PSLogger* getServerLogger(); + EXPORT_DECL void toLower(char* str); + EXPORT_DECL void normalize(char* str); +} + +#endif // __PS_HELPER_H__ + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSListener.h b/pki/base/tps/src/include/httpClient/httpc/PSListener.h new file mode 100644 index 000000000..1d85a9912 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSListener.h @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_LISTENER_H__ +#define __PS_LISTENER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSListener.h 1.000 05/22/2002 + * + * A Generic base class for all listeners. + * + * @author Surendra Rajam + * @version 1.000, 05/22/2002 + */ +class EXPORT_DECL PSListener +{ +}; + +#endif // __PS_LISTENER_H__ + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSPRUtil.h b/pki/base/tps/src/include/httpClient/httpc/PSPRUtil.h new file mode 100644 index 000000000..f3b104cc0 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSPRUtil.h @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _PS_PRUTIL_H +#define _PS_PRUTIL_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * NSPR related Utility functions + */ + +// define a stuct to store the mesasge +struct tuple_str { + PRErrorCode errNum; + const char * errString; +}; + +typedef struct tuple_str tuple_str; + +#define ER2(a,b) {a, b}, +#define ER3(a,b,c) {a, c}, + + +class EXPORT_DECL PSPRUtil { + +private: + /** + * Constructor - can't be instantiated + */ + PSPRUtil() {} + + /** + * Destructor + */ + ~PSPRUtil() {} + +public: + /** + * Returns a string corresponding to an NSPR or NSS error code + * + * @param errNum Error number from PR_GetError() + * @retuns An immutable string, the empty string if the code is not known + */ + static const char * GetErrorString (PRErrorCode errCode); + + + /** + * Returns an error string for the latest NSPR or NSS error + * + * @return An error string, or the empty string if there is no current + * NSPR or NSS error + */ + static const char * GetErrorString(); + + +}; + +#endif // _PS_PRUTIL_H + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSPlugin.h b/pki/base/tps/src/include/httpClient/httpc/PSPlugin.h new file mode 100644 index 000000000..f6655591e --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSPlugin.h @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_PLUGIN_H__ +#define __PS_PLUGIN_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSPlugin.h 1.000 04/30/2002 + * + * Pure virtual class defining the functions to be implemented by + * different types of plugins in the server. The listener object passed + * the Init function is used to notify the server. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PSPlugin { +public: + +/** + * Initialize the plugin. + * + * @param a listener for this plugin + * @return 0 on success + */ +virtual int Init(PSListener*) = 0; + +/** + * Start the plugin. + * + * @param config params for the plugin + * @return 0 on success + */ +virtual int Start(PSConfig*) = 0; + +/** + * Stops the plugin. + * + * @return 0 on success + */ +virtual int Stop() = 0; + +}; + +#endif // __PSPLUGIN_H__ + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSPluginManager.h b/pki/base/tps/src/include/httpClient/httpc/PSPluginManager.h new file mode 100644 index 000000000..7ea12829a --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSPluginManager.h @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_PLUGIN_MANAGER_H__ +#define __PS_PLUGIN_MANAGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSPluginManager.h 1.000 05/21/2002 + * + * This class manages loading and unloading of all server plugin modules. + * + * @author Surendra Rajam + * @version 1.000, 05/21/2002 + */ +class PSPluginManager +{ +private: + +/** + * Constructor - creates an instance of Plugin manager object + */ +PSPluginManager(); + +/** + * Destructor + */ +virtual ~PSPluginManager(); + +public: + +/** + * Gets an instance of the class + */ +static PSPluginManager* GetPluginManager(); + +public: + +/** + * Loads a group of plugins based on the type (dn) specified. If the loading + * is successful the specified listener is registered with the plugin and + * the plugin is started. + * + * @param dn root DN of the plugins + * @param listener listener associated with the specified type of plugins + * @return 0 on success, negative error code otherwise + */ +int LoadPlugin(const char* dn, PSListener* listener); + +/** + * Unloads a group of plugins based on the type ( dn ) specified. + * This function just issues a Stop on all the loaded plugins. + * It doesn't attempt to release any allocated data structures. + * + * @param dn root DN of the plugins + * @return 0 for success or error code for failure + */ +int UnloadPlugin(const char* dn); + +private: + StringKeyCache* m_serverPlugins; +}; + +#endif // __PS_PLUGIN_MANAGER_H__ + + + + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSServer.h b/pki/base/tps/src/include/httpClient/httpc/PSServer.h new file mode 100644 index 000000000..86d2ca326 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSServer.h @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_SERVER_H__ +#define __PS_SERVER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include <stdio.h> +#include <time.h> +#include <ctype.h> + +#include "nspr.h" +#include "plhash.h" +#include "plstr.h" + +#include "ldap.h" + +#define PRESENCESERVER_DLL +#include "httpClient/httpc/PSServerLib.h" +#include "httpClient/httpc/PresenceServer.h" + +#include "httpClient/httpc/Defines.h" +#include "httpClient/httpc/PSError.h" +#include "httpClient/httpc/PSHelper.h" +#include "httpClient/httpc/PSConfig.h" +#include "httpClient/httpc/PSConfigReader.h" +#include "httpClient/httpc/PSConfigManager.h" +#include "httpClient/httpc/Cache.h" +#include "httpClient/httpc/StringList.h" +#include "httpClient/httpc/StringUtil.h" +#include "httpClient/httpc/ScheduledTask.h" +#include "httpClient/httpc/PSCrypt.h" + +#include "httpClient/httpc/PSListener.h" +#include "httpClient/httpc/PSBuddy.h" +#include "httpClient/httpc/PSBuddyService.h" +#include "httpClient/httpc/PSBuddyListener.h" +#include "httpClient/httpc/PSServerListener.h" +#include "httpClient/httpc/PSServiceListener.h" +#include "httpClient/httpc/PSPluginManager.h" +#include "httpClient/httpc/PSServiceManager.h" +#include "httpClient/httpc/PSPlugin.h" +#include "httpClient/httpc/PSUser.h" +#include "httpClient/httpc/PSDataSourceListener.h" +#include "httpClient/httpc/PSDataSourceManager.h" +#include "httpClient/httpc/PSGroup.h" +#include "httpClient/httpc/PSGroupCache.h" +#include "httpClient/httpc/PSBuddyCache.h" +#include "httpClient/httpc/PSBuddyList.h" +#include "httpClient/httpc/PresenceManager.h" +#include "httpClient/httpc/PSServerManager.h" + +#include "httpClient/httpc/ErrorLogger.h" +#include "httpClient/httpc/DebugLogger.h" +#include "httpClient/httpc/ScheduledTask.h" +#include "httpClient/httpc/LogRotationTask.h" +#include "httpClient/httpc/TaskList.h" +#include "httpClient/httpc/Scheduler.h" + +#endif // __PS_SERVER_H__ + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSServerLib.h b/pki/base/tps/src/include/httpClient/httpc/PSServerLib.h new file mode 100644 index 000000000..079134230 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSServerLib.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_SERVER_LIB_H__ +#define __PS_SERVER_LIB_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSServerLib.h 1.000 05/27/2002 + * + * @author Surendra Rajam + * @version 1.000, 05/27/2002 + */ + +#ifdef _MSC_VER + #ifdef PRESENCESERVER_DLL + #define EXPORT_DECL __declspec( dllexport ) + #else + #define EXPORT_DECL __declspec (dllimport ) + #endif // PRESENCESERVER_DLL +#else + #define EXPORT_DECL +#endif // _MSC_VER + +#endif // __PS_SERVER_LIB_H__ + + + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSServerListener.h b/pki/base/tps/src/include/httpClient/httpc/PSServerListener.h new file mode 100644 index 000000000..152fbf58f --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSServerListener.h @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_SERVER_LISTENER_H__ +#define __PS_SERVER_LISTENER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSServerListener.h 1.000 04/30/2002 + * + * A listener class to report back into the server. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PSServerListener : + public PSListener +{ +public: + +/** + * Callback to report startup of a service. + * + * @param reporting module ID + * @return 0 on success + */ +virtual int OnStartup(const char*) = 0; + +/** + * Callback to report shutdown of a service. + * + * @param reporting module ID + * @return 0 on success + */ +virtual int OnShutdown(const char*) = 0; + +/** + * Callback to report any errors encountered during service execution. + * + * @param reporting module ID + * @param error code + * @param error message + * @return 0 on success + */ +virtual int OnCriticalError(const char*, int, const char*) = 0; + +}; + +#endif // __PS_SERVER_LISTENER_H__ + + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSServerManager.h b/pki/base/tps/src/include/httpClient/httpc/PSServerManager.h new file mode 100644 index 000000000..6597ad605 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSServerManager.h @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_SERVER_MANAGER_H__ +#define __PS_SERVER_MANAGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSServerManager.h 1.000 05/21/2002 + * + * This class manages the server execution. It is responsible for loading + * of configurations, starting of services and proper shutdown of services. + * + * @author Surendra Rajam + * @version 1.000, 05/21/2002 + */ +class PSServerManager : + public PSServerListener +{ +private: + +/** + * Constructor - creates an instance of server manager object + */ +PSServerManager(); + +/** + * Destructor + */ +virtual ~PSServerManager(); + +public: + +/** + * Gets an instance of this class. + */ +static PSServerManager* GetServerManager(); + +public: + +/** + * Loads general configuration into the ConfigManager + * + * @return 0 on success, negative error code otherwise + */ +int InitServices(); + +/** + * Starts services after server startup. The presence services are + * started before anything else and if it fails then no attempt is + * made to start other services. + * + * @return 0 on success, negative error code otherwise + */ +int StartServices(); + +/** + * Stops services before server shutdown. + * + * @return 0 on success, negative error code otherwise + */ +int StopServices(); + +private: + +/** + * Loads one configuration entry + * + * @param configdn The DN of the LDAP entry containing the config + * @param configName The name of the config entry + * @param descr A description of the config entry + * @return 0 on success + */ +int LoadOneConfig(const char* configdn, const char* configName, const char* descr); + +// PSServerListener interface +public: + +/** + * Callback to notify server upon a service startup + * + * @param moduleid the notifying service id + * @return 0 on success + */ +int OnStartup(const char* moduleid); + +/** + * Callback to notify server upon a service shutdown + * + * @param moduleid the notifying service id + * @return 0 on success + */ +int OnShutdown(const char* moduleid); + +/** + * Callback to notify server upon a critical errors. The server immediately + * shuts down upon receipt of any such notification. + * + * @param moduleid the notifying service id + * @param errorcode negative error code + * @param errorstring negative error code + * @return 0 on success + */ +int OnCriticalError(const char* moduleid, int errorcode, const char* errorstring); + +private: + bool m_loadServiceDone; +}; + +#endif // __PS_SERVER_MANAGER_H__ + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSServiceListener.h b/pki/base/tps/src/include/httpClient/httpc/PSServiceListener.h new file mode 100644 index 000000000..358f0c295 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSServiceListener.h @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_SERVICE_LISTENER_H__ +#define __PS_SERVICE_LISTENER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSServiceListener.h 1.000 05/16/2002 + * + * A listener interface for all the IM services to report back into + * service manager. + * + * @author Surendra Rajam + * @version 1.000, 05/16/2002 + */ +class EXPORT_DECL PSServiceListener : + public PSListener +{ +public: + +/** + * Callback to report start of a buddy service. + * + * @param reporting module + * @return 0 on success + */ +virtual int OnServiceStart(PSBuddyService*) = 0; + +/** + * Callback to report buddy service errors. + * + * @param reporting module + * @param error code + * @param error message + * @return 0 on success + */ +virtual int OnServiceError(PSBuddyService*, int, const char*) = 0; + + +/** + * Callback to report shutdown of a buddy service. + * + * @param reporting module + * @return 0 on success + */ +virtual int OnServiceStop(PSBuddyService*) = 0; + +}; + +#endif // __PS_SERVICE_LISTENER_H__ + + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSServiceManager.h b/pki/base/tps/src/include/httpClient/httpc/PSServiceManager.h new file mode 100644 index 000000000..1fd755c14 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSServiceManager.h @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PS_SERVICE_MANAGER_H__ +#define __PS_SERVICE_MANAGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * PSServiceManager.h 1.000 05/16/2002 + * + * A Singleton class to manage presence services. Currently we support + * only one service to be loaded. + * + * @author Surendra Rajam + * @version 1.000, 05/16/2002 + */ +class PSServiceManager : + public PSServiceListener +{ +private: + +/** + * Constructor - creates a service manager object + */ +PSServiceManager(); + +/** + * Destructor + */ +virtual ~PSServiceManager(); + +public: + +/** + * Gets an instance of this class. + */ +static PSServiceManager* GetServiceManager(); + +public: + +/** + * Registers a listener with this class. Only one listener is + * allowed to be registered. If an attempt is made to register + * more than one listener, then an error condition is raised. + * + * @param listener a server listener + * @return 0 on success, negative error upon failure + */ +int RegisterListener(PSServerListener* listener); + +/** + * Loads all providers type plugins. + * + * @return 0 for success, negative error code otherwise + */ +int LoadServices(); + +/** + * Unloads all providers type plugins. + * + * @return 0 for success, negative error code otherwise + */ +int UnloadServices(); + +/** + * Gets the service currently loaded. Only one service can + * be configured at a time. + * + * @return an im service + */ +PSBuddyService* GetService(); + +// PSServiceListener interface +public: + +/** + * Callback function to notify the manager of a service being started. + * + * @param service a buddy service + */ +int OnServiceStart(PSBuddyService* service); + +/** + * Callback function to notify the manager of a service error. + * + * @param service a buddy service + * @param errorcode a negative error code + * @param errorstring an error message + */ +int OnServiceError(PSBuddyService* service, int errorcode, const char* errorstring); + +/** + * Callback function to notify the manager of a service being stopped. + * + * @param service a buddy service + */ +int OnServiceStop(PSBuddyService* service); + +private: + char* m_serviceDN; + PSServerListener* m_serverListener; + PSBuddyService* m_service; + + bool m_servicesLoaded; +}; + +#endif // __PS_SERVICE_MANAGER_H__ + + + + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSUser.h b/pki/base/tps/src/include/httpClient/httpc/PSUser.h new file mode 100644 index 000000000..a66c4e32f --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSUser.h @@ -0,0 +1,164 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PSUSER_H__ +#define __PSUSER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "PresenceServer.h" + +/** + * PSUser.h 1.000 04/30/2002 + * + * This class represents one attribute of a user. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PSAttribute +{ +public: + +/** + * Construts a new PSAttribute object. + * + * @param name name of the attribute + * @param value value of the attribute + */ +PSAttribute(const char* name, const char* value); + +/** + * Destructor + */ +virtual ~PSAttribute(); + +/** + * Gets the name of the attribute. + * + * @return name of the attribute + */ +char* GetName(); + +/** + * Gets the value of the specified attribute. + * + * @return value of the attribute + */ +char* GetValue(); + +private: + char* m_name; + char* m_value; +}; + +/** + * PSUser.h 1.000 04/30/2002 + * + * This class represents information about a single user. + * + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PSUser +{ +public: + +/** + * Construts a new PSUser object with just one attribute. + * + * @param name name of the user + * @param attribute a user attribute + */ +PSUser(const char* name, PSAttribute* attribute); + +/** + * Construts a new PSUser object with number of attributes. + * + * @param name name of the user + * @param nAttributes number of attributes + * @param attribute array containing user attributes + */ +PSUser(const char* name, int nAttributes, PSAttribute** attributes); + +/** + * Destructor + */ +virtual ~PSUser(); + +/** + * Gets the name of the user. + * + * @return user name + */ +char* GetName(); + +/** + * Get the count of user attributes. + * + * @return count of user attributes + */ +int GetCount(); + +/** + * Gets a list of attribute objects for the user. + * + * @return array of attribute objects + */ +PSAttribute** GetAttributes(); + +/** + * Gets the user attribute based on the specified attribute name. + * + * @return user attribute object on success, NULL otherwise + */ +PSAttribute* Lookup(char* key); + +/** + * Creates a new copy of the current user object. + * + * @return new user object + */ +void Clone(PSUser** user); + +private: + char* m_name; + int m_attrCount; + PSAttribute** m_attributes; +}; + +#endif + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PSWaspLib.h b/pki/base/tps/src/include/httpClient/httpc/PSWaspLib.h new file mode 100644 index 000000000..8fdea6bcc --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PSWaspLib.h @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _PS_WASP_LIB_H_ +#define _PS_WASP_LIB_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#ifdef _MSC_VER +#undef EXPORT_DECL +#ifdef WASP_LIB_DLL +#define EXPORT_DECL __declspec( dllexport ) +#else +#define EXPORT_DECL __declspec (dllimport ) +#endif // EXPORT_LIB_DLL +#else +#define EXPORT_DECL +#endif // _MSC_VER + +// Key to hostname in WASP CallContext +#define CONTEXT_HOSTNAME_TOKEN "Hostname" + +#endif // _PS_WASP_LIB_H_ diff --git a/pki/base/tps/src/include/httpClient/httpc/Pool.h b/pki/base/tps/src/include/httpClient/httpc/Pool.h new file mode 100644 index 000000000..074b36b3b --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/Pool.h @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __POOL_H__ +#define __POOL_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#define AUTOTOOLS_CONFIG_H +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Utility classes for object pools + * + * @author rweltman@netscape.com + * @version 1.0 + */ + +class PoolNode; +class Pool; + +typedef int (*PoolEnumerator)(PoolNode *node); + +/** + * A node in a pool + */ +class EXPORT_DECL PoolNode { + friend class Pool; +public: + /** + * Constructor + * + * @param data The real data of the node + */ + PoolNode( void *data ); + /** + * Destructor + */ + virtual ~PoolNode(); + /** + * Returns the real data of the node + * + * @return The real data of the node + */ + void *GetData(); + /** + * Returns the next entry in the list + * + * @return The next entry in the list + */ + PoolNode *GetNext(); + /** + * Returns the previous entry in the list + * + * @return The previous entry in the list + */ + PoolNode *GetPrev(); +private: + void *m_data; + PoolNode *m_next; + PoolNode *m_prev; +}; + +/** + * A generic object pool + */ +class EXPORT_DECL Pool { +public: + /** + * Constructor - creates a pool with an internal list of nodes + * + * @param name Name of pool + * @param poolSize Max number of nodes kept + * @param enumerator Optional enumerator to be called on destruction + */ + Pool( const char *name, int poolSize, PoolEnumerator enumerator = NULL ); + /** + * Destructor - Empties the pool + */ + virtual ~Pool(); + /** + * Appends an entry to the end of the internal list + * + * @param node An entry to add + * @return The added entry + */ + PoolNode *Append( PoolNode *node ); + /** + * Retrieves the head of the internal list and removes it + * + * @return The head of the internal list + */ + PoolNode *RemoveHead(); + /** + * Returns true if the pool is empty + * + * @return true if the pool is empty + */ + bool IsEmpty(); + + /** + * Returns the number of entries in the pool + * + * @return The number of entries in the pool + */ + int GetCount(); + +protected: +private: + PoolNode *m_list; + char *m_name; + int m_maxNodes; + int m_count; + PoolEnumerator m_enumerator; + PRRWLock *m_lock; + PRLock *m_conditionLock; + PRCondVar *m_condition; +}; + +#endif // __POOL_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/PresenceManager.h b/pki/base/tps/src/include/httpClient/httpc/PresenceManager.h new file mode 100644 index 000000000..f7f4f753f --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PresenceManager.h @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PRESENCEMANAGER_H__ +#define __PRESENCEMANAGER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#define AUTOTOOLS_CONFIG_H +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/PSUser.h" + +/** + * PresenceManager.h 1.000 04/30/2002 + * + * Wrapper class around the core buddylist management API. + * + * @author Rob Weltman + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ +class EXPORT_DECL PresenceManager { +public: + PresenceManager(); + virtual ~PresenceManager(); + + int GetUserStatus(const char* group, const char* name, int nAttributes, char** attributes, PSUser** user); + int GetMultipleUserStatus(const char* group, + int nUsers, + char** names, + int nAttributes, + char** attributes, + PSUser*** users); + int GetUsersByFilter(const char* group, const char* filter, int nAttributes, char** attributes, PSUser*** users); + int GetSortedUsersByFilter(const char* group, const char* filter, + const char *sortKey, int sortKeyType, + int nAttributes, char** attributes, PSUser*** users); + /** + * Gets the number of users who are online or offline in a group + * + * @param group Name of group to query; NULL or empty for all groups + * @param bOnline true to return the count of online users, false for + * offline + * @return Number of users, or a negative error code on failure + * + * Error Code(s): + * PS_UNKOWN_GROUP + */ + int GetUserCount( const char* group, int bOnline ); + int AddGroup(const char* group, int nAttributes, char** attributes); + int AddUser(const char* group, const char* name, int nAttributes, PSAttribute** attributes); + int AddUsers(const char* group, int nUsers, PSUser** users); + int RemoveUser(const char* group, const char* name); + int RemoveUsers(const char* group, int nUsers, char** names); + int RemoveGroup(const char* group); + int GetAllGroups(char*** groups); + int GetAllUsers(const char* group, PSUser*** users); + int GetSearchableAttributes(const char* group, char*** attributes); + +private: +}; + +#endif // __PRESENCEMANAGER_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/PresenceServer.h b/pki/base/tps/src/include/httpClient/httpc/PresenceServer.h new file mode 100644 index 000000000..1a9b259e9 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PresenceServer.h @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PRESENCE_SERVER_H__ +#define __PRESENCE_SERVER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/PSServerLib.h" + +/** + * PresenceServer.h 1.000 04/30/2002 + * + * Starts and stops presence services + * + * @author Rob Weltman + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ + +extern "C" { +EXPORT_DECL int presence_main( int argc, char* argv[] ); +EXPORT_DECL void presence_exit(); +} + +#endif // __PRESENCE_SERVER_H__ + + diff --git a/pki/base/tps/src/include/httpClient/httpc/PresenceServerImpl.h b/pki/base/tps/src/include/httpClient/httpc/PresenceServerImpl.h new file mode 100644 index 000000000..8c07b9140 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/PresenceServerImpl.h @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __PRESENCE_SERVER_IMPL_H__ +#define __PRESENCE_SERVER_IMPL_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +class PSUser; + +/** + * PresenceServerImpl.h 1.000 04/30/2002 + * + * Interface for WASP implementation of presence service + * + * @author Rob Weltman + * @author Surendra Rajam + * @version 1.000, 04/30/2002 + */ + +class EXPORT_DECL PresenceServerImpl:public PresenceServiceImpl { +public: + PresenceServerImpl() {} + virtual ~PresenceServerImpl() {} + virtual int getAllGroups (ArrayOfstring *& groups); + virtual int getAllUsers (WASP_String * group, ArrayOfstring *& users); + virtual int removeGroup (WASP_String * group); + virtual int getUsersByFilter (WASP_String * group, WASP_String * filter, int nAttributes, ArrayOfstring * attributes, ArrayOfPresenceUser *& users); + virtual int getMultipleUserStatus (WASP_String * group, + int nUsers, + ArrayOfstring * names, + int nAttributes, + ArrayOfstring * attributes, + ArrayOfPresenceUser *& users); + virtual int removeUser (WASP_String * group, WASP_String * name); + virtual int getUserStatus (WASP_String * group, WASP_String * name, int nAttributes, ArrayOfstring * attributes, PresenceUser *& user); + /** + * Gets the number of users who are online or offline in a group + * + * @param group Name of group to query; NULL or empty for all groups + * @param bOnline true to return the count of online users, false for offline + * @return Number of users, or a negative error code on failure + * + * Error Code(s): + * PS_UNKOWN_GROUP + */ + virtual int getUserCount( WASP_String* group, int bOnline ); + virtual int addUsers (WASP_String * group, int nUsers, ArrayOfPresenceUser * users); + virtual int addGroup (WASP_String * group, int nAttributes, ArrayOfstring * attributes); + virtual int getSearchableAttributes (WASP_String * group, ArrayOfstring *& attributes); + virtual int addUser (WASP_String * group, WASP_String * name, int nAttributes, ArrayOfUserAttribute * attributes); + virtual int getSortedUsersByFilter (WASP_String * group, + WASP_String * filter, + WASP_String * sortKey, + int sortKeyType, + int nAttributes, + ArrayOfstring * attributes, + ArrayOfPresenceUser *& users); + virtual int removeUsers (WASP_String * group, int nUsers, ArrayOfstring * names); +protected: + void doLog(const char *func, int status); + static int parseUsers(int nUsers, PSUser** tusers, + ArrayOfPresenceUser*& users); + /** + * Decodes an array of Unicode strings from a WASP string array object; + * the result should be freed by deleting the individual strings as well as + * the array itself; nStrings is set to 0 if wStrings is NULL + * + * @param attributes WASP string array object to convert + * @param nAttributes Number of strings to process + * @return Array of strings + */ + char **DecodeStringArrayObject( ArrayOfstring* wStrings, + int& nStrings ); +}; + +#endif // __PRESENCE_SERVER_IMPL_H__ + + diff --git a/pki/base/tps/src/include/httpClient/httpc/SECerrs.h b/pki/base/tps/src/include/httpClient/httpc/SECerrs.h new file mode 100644 index 000000000..d7495ff28 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/SECerrs.h @@ -0,0 +1,522 @@ +/** BEGIN COPYRIGHT BLOCK + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1994-2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * END COPYRIGHT BLOCK **/ + +/* Originally obtained from: + * + * CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot + * cvs export -r NSS_3_11_3_RTM -N mozilla/security/nss/cmd/lib/SECerrs.h + */ + +/* General security error codes */ +/* Caller must #include "secerr.h" */ + +ER3(SEC_ERROR_IO, SEC_ERROR_BASE + 0, +"An I/O error occurred during security authorization.") + +ER3(SEC_ERROR_LIBRARY_FAILURE, SEC_ERROR_BASE + 1, +"security library failure.") + +ER3(SEC_ERROR_BAD_DATA, SEC_ERROR_BASE + 2, +"security library: received bad data.") + +ER3(SEC_ERROR_OUTPUT_LEN, SEC_ERROR_BASE + 3, +"security library: output length error.") + +ER3(SEC_ERROR_INPUT_LEN, SEC_ERROR_BASE + 4, +"security library has experienced an input length error.") + +ER3(SEC_ERROR_INVALID_ARGS, SEC_ERROR_BASE + 5, +"security library: invalid arguments.") + +ER3(SEC_ERROR_INVALID_ALGORITHM, SEC_ERROR_BASE + 6, +"security library: invalid algorithm.") + +ER3(SEC_ERROR_INVALID_AVA, SEC_ERROR_BASE + 7, +"security library: invalid AVA.") + +ER3(SEC_ERROR_INVALID_TIME, SEC_ERROR_BASE + 8, +"Improperly formatted time string.") + +ER3(SEC_ERROR_BAD_DER, SEC_ERROR_BASE + 9, +"security library: improperly formatted DER-encoded message.") + +ER3(SEC_ERROR_BAD_SIGNATURE, SEC_ERROR_BASE + 10, +"Peer's certificate has an invalid signature.") + +ER3(SEC_ERROR_EXPIRED_CERTIFICATE, SEC_ERROR_BASE + 11, +"Peer's Certificate has expired.") + +ER3(SEC_ERROR_REVOKED_CERTIFICATE, SEC_ERROR_BASE + 12, +"Peer's Certificate has been revoked.") + +ER3(SEC_ERROR_UNKNOWN_ISSUER, SEC_ERROR_BASE + 13, +"Peer's Certificate issuer is not recognized.") + +ER3(SEC_ERROR_BAD_KEY, SEC_ERROR_BASE + 14, +"Peer's public key is invalid.") + +ER3(SEC_ERROR_BAD_PASSWORD, SEC_ERROR_BASE + 15, +"The security password entered is incorrect.") + +ER3(SEC_ERROR_RETRY_PASSWORD, SEC_ERROR_BASE + 16, +"New password entered incorrectly. Please try again.") + +ER3(SEC_ERROR_NO_NODELOCK, SEC_ERROR_BASE + 17, +"security library: no nodelock.") + +ER3(SEC_ERROR_BAD_DATABASE, SEC_ERROR_BASE + 18, +"security library: bad database.") + +ER3(SEC_ERROR_NO_MEMORY, SEC_ERROR_BASE + 19, +"security library: memory allocation failure.") + +ER3(SEC_ERROR_UNTRUSTED_ISSUER, SEC_ERROR_BASE + 20, +"Peer's certificate issuer has been marked as not trusted by the user.") + +ER3(SEC_ERROR_UNTRUSTED_CERT, SEC_ERROR_BASE + 21, +"Peer's certificate has been marked as not trusted by the user.") + +ER3(SEC_ERROR_DUPLICATE_CERT, (SEC_ERROR_BASE + 22), +"Certificate already exists in your database.") + +ER3(SEC_ERROR_DUPLICATE_CERT_NAME, (SEC_ERROR_BASE + 23), +"Downloaded certificate's name duplicates one already in your database.") + +ER3(SEC_ERROR_ADDING_CERT, (SEC_ERROR_BASE + 24), +"Error adding certificate to database.") + +ER3(SEC_ERROR_FILING_KEY, (SEC_ERROR_BASE + 25), +"Error refiling the key for this certificate.") + +ER3(SEC_ERROR_NO_KEY, (SEC_ERROR_BASE + 26), +"The private key for this certificate cannot be found in key database") + +ER3(SEC_ERROR_CERT_VALID, (SEC_ERROR_BASE + 27), +"This certificate is valid.") + +ER3(SEC_ERROR_CERT_NOT_VALID, (SEC_ERROR_BASE + 28), +"This certificate is not valid.") + +ER3(SEC_ERROR_CERT_NO_RESPONSE, (SEC_ERROR_BASE + 29), +"Cert Library: No Response") + +ER3(SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE, (SEC_ERROR_BASE + 30), +"The certificate issuer's certificate has expired. Check your system date and time.") + +ER3(SEC_ERROR_CRL_EXPIRED, (SEC_ERROR_BASE + 31), +"The CRL for the certificate's issuer has expired. Update it or check your system data and time.") + +ER3(SEC_ERROR_CRL_BAD_SIGNATURE, (SEC_ERROR_BASE + 32), +"The CRL for the certificate's issuer has an invalid signature.") + +ER3(SEC_ERROR_CRL_INVALID, (SEC_ERROR_BASE + 33), +"New CRL has an invalid format.") + +ER3(SEC_ERROR_EXTENSION_VALUE_INVALID, (SEC_ERROR_BASE + 34), +"Certificate extension value is invalid.") + +ER3(SEC_ERROR_EXTENSION_NOT_FOUND, (SEC_ERROR_BASE + 35), +"Certificate extension not found.") + +ER3(SEC_ERROR_CA_CERT_INVALID, (SEC_ERROR_BASE + 36), +"Issuer certificate is invalid.") + +ER3(SEC_ERROR_PATH_LEN_CONSTRAINT_INVALID, (SEC_ERROR_BASE + 37), +"Certificate path length constraint is invalid.") + +ER3(SEC_ERROR_CERT_USAGES_INVALID, (SEC_ERROR_BASE + 38), +"Certificate usages field is invalid.") + +ER3(SEC_INTERNAL_ONLY, (SEC_ERROR_BASE + 39), +"**Internal ONLY module**") + +ER3(SEC_ERROR_INVALID_KEY, (SEC_ERROR_BASE + 40), +"The key does not support the requested operation.") + +ER3(SEC_ERROR_UNKNOWN_CRITICAL_EXTENSION, (SEC_ERROR_BASE + 41), +"Certificate contains unknown critical extension.") + +ER3(SEC_ERROR_OLD_CRL, (SEC_ERROR_BASE + 42), +"New CRL is not later than the current one.") + +ER3(SEC_ERROR_NO_EMAIL_CERT, (SEC_ERROR_BASE + 43), +"Not encrypted or signed: you do not yet have an email certificate.") + +ER3(SEC_ERROR_NO_RECIPIENT_CERTS_QUERY, (SEC_ERROR_BASE + 44), +"Not encrypted: you do not have certificates for each of the recipients.") + +ER3(SEC_ERROR_NOT_A_RECIPIENT, (SEC_ERROR_BASE + 45), +"Cannot decrypt: you are not a recipient, or matching certificate and \ +private key not found.") + +ER3(SEC_ERROR_PKCS7_KEYALG_MISMATCH, (SEC_ERROR_BASE + 46), +"Cannot decrypt: key encryption algorithm does not match your certificate.") + +ER3(SEC_ERROR_PKCS7_BAD_SIGNATURE, (SEC_ERROR_BASE + 47), +"Signature verification failed: no signer found, too many signers found, \ +or improper or corrupted data.") + +ER3(SEC_ERROR_UNSUPPORTED_KEYALG, (SEC_ERROR_BASE + 48), +"Unsupported or unknown key algorithm.") + +ER3(SEC_ERROR_DECRYPTION_DISALLOWED, (SEC_ERROR_BASE + 49), +"Cannot decrypt: encrypted using a disallowed algorithm or key size.") + + +/* Fortezza Alerts */ +ER3(XP_SEC_FORTEZZA_BAD_CARD, (SEC_ERROR_BASE + 50), +"Fortezza card has not been properly initialized. \ +Please remove it and return it to your issuer.") + +ER3(XP_SEC_FORTEZZA_NO_CARD, (SEC_ERROR_BASE + 51), +"No Fortezza cards Found") + +ER3(XP_SEC_FORTEZZA_NONE_SELECTED, (SEC_ERROR_BASE + 52), +"No Fortezza card selected") + +ER3(XP_SEC_FORTEZZA_MORE_INFO, (SEC_ERROR_BASE + 53), +"Please select a personality to get more info on") + +ER3(XP_SEC_FORTEZZA_PERSON_NOT_FOUND, (SEC_ERROR_BASE + 54), +"Personality not found") + +ER3(XP_SEC_FORTEZZA_NO_MORE_INFO, (SEC_ERROR_BASE + 55), +"No more information on that Personality") + +ER3(XP_SEC_FORTEZZA_BAD_PIN, (SEC_ERROR_BASE + 56), +"Invalid Pin") + +ER3(XP_SEC_FORTEZZA_PERSON_ERROR, (SEC_ERROR_BASE + 57), +"Couldn't initialize Fortezza personalities.") +/* end fortezza alerts. */ + +ER3(SEC_ERROR_NO_KRL, (SEC_ERROR_BASE + 58), +"No KRL for this site's certificate has been found.") + +ER3(SEC_ERROR_KRL_EXPIRED, (SEC_ERROR_BASE + 59), +"The KRL for this site's certificate has expired.") + +ER3(SEC_ERROR_KRL_BAD_SIGNATURE, (SEC_ERROR_BASE + 60), +"The KRL for this site's certificate has an invalid signature.") + +ER3(SEC_ERROR_REVOKED_KEY, (SEC_ERROR_BASE + 61), +"The key for this site's certificate has been revoked.") + +ER3(SEC_ERROR_KRL_INVALID, (SEC_ERROR_BASE + 62), +"New KRL has an invalid format.") + +ER3(SEC_ERROR_NEED_RANDOM, (SEC_ERROR_BASE + 63), +"security library: need random data.") + +ER3(SEC_ERROR_NO_MODULE, (SEC_ERROR_BASE + 64), +"security library: no security module can perform the requested operation.") + +ER3(SEC_ERROR_NO_TOKEN, (SEC_ERROR_BASE + 65), +"The security card or token does not exist, needs to be initialized, or has been removed.") + +ER3(SEC_ERROR_READ_ONLY, (SEC_ERROR_BASE + 66), +"security library: read-only database.") + +ER3(SEC_ERROR_NO_SLOT_SELECTED, (SEC_ERROR_BASE + 67), +"No slot or token was selected.") + +ER3(SEC_ERROR_CERT_NICKNAME_COLLISION, (SEC_ERROR_BASE + 68), +"A certificate with the same nickname already exists.") + +ER3(SEC_ERROR_KEY_NICKNAME_COLLISION, (SEC_ERROR_BASE + 69), +"A key with the same nickname already exists.") + +ER3(SEC_ERROR_SAFE_NOT_CREATED, (SEC_ERROR_BASE + 70), +"error while creating safe object") + +ER3(SEC_ERROR_BAGGAGE_NOT_CREATED, (SEC_ERROR_BASE + 71), +"error while creating baggage object") + +ER3(XP_JAVA_REMOVE_PRINCIPAL_ERROR, (SEC_ERROR_BASE + 72), +"Couldn't remove the principal") + +ER3(XP_JAVA_DELETE_PRIVILEGE_ERROR, (SEC_ERROR_BASE + 73), +"Couldn't delete the privilege") + +ER3(XP_JAVA_CERT_NOT_EXISTS_ERROR, (SEC_ERROR_BASE + 74), +"This principal doesn't have a certificate") + +ER3(SEC_ERROR_BAD_EXPORT_ALGORITHM, (SEC_ERROR_BASE + 75), +"Required algorithm is not allowed.") + +ER3(SEC_ERROR_EXPORTING_CERTIFICATES, (SEC_ERROR_BASE + 76), +"Error attempting to export certificates.") + +ER3(SEC_ERROR_IMPORTING_CERTIFICATES, (SEC_ERROR_BASE + 77), +"Error attempting to import certificates.") + +ER3(SEC_ERROR_PKCS12_DECODING_PFX, (SEC_ERROR_BASE + 78), +"Unable to import. Decoding error. File not valid.") + +ER3(SEC_ERROR_PKCS12_INVALID_MAC, (SEC_ERROR_BASE + 79), +"Unable to import. Invalid MAC. Incorrect password or corrupt file.") + +ER3(SEC_ERROR_PKCS12_UNSUPPORTED_MAC_ALGORITHM, (SEC_ERROR_BASE + 80), +"Unable to import. MAC algorithm not supported.") + +ER3(SEC_ERROR_PKCS12_UNSUPPORTED_TRANSPORT_MODE,(SEC_ERROR_BASE + 81), +"Unable to import. Only password integrity and privacy modes supported.") + +ER3(SEC_ERROR_PKCS12_CORRUPT_PFX_STRUCTURE, (SEC_ERROR_BASE + 82), +"Unable to import. File structure is corrupt.") + +ER3(SEC_ERROR_PKCS12_UNSUPPORTED_PBE_ALGORITHM, (SEC_ERROR_BASE + 83), +"Unable to import. Encryption algorithm not supported.") + +ER3(SEC_ERROR_PKCS12_UNSUPPORTED_VERSION, (SEC_ERROR_BASE + 84), +"Unable to import. File version not supported.") + +ER3(SEC_ERROR_PKCS12_PRIVACY_PASSWORD_INCORRECT,(SEC_ERROR_BASE + 85), +"Unable to import. Incorrect privacy password.") + +ER3(SEC_ERROR_PKCS12_CERT_COLLISION, (SEC_ERROR_BASE + 86), +"Unable to import. Same nickname already exists in database.") + +ER3(SEC_ERROR_USER_CANCELLED, (SEC_ERROR_BASE + 87), +"The user pressed cancel.") + +ER3(SEC_ERROR_PKCS12_DUPLICATE_DATA, (SEC_ERROR_BASE + 88), +"Not imported, already in database.") + +ER3(SEC_ERROR_MESSAGE_SEND_ABORTED, (SEC_ERROR_BASE + 89), +"Message not sent.") + +ER3(SEC_ERROR_INADEQUATE_KEY_USAGE, (SEC_ERROR_BASE + 90), +"Certificate key usage inadequate for attempted operation.") + +ER3(SEC_ERROR_INADEQUATE_CERT_TYPE, (SEC_ERROR_BASE + 91), +"Certificate type not approved for application.") + +ER3(SEC_ERROR_CERT_ADDR_MISMATCH, (SEC_ERROR_BASE + 92), +"Address in signing certificate does not match address in message headers.") + +ER3(SEC_ERROR_PKCS12_UNABLE_TO_IMPORT_KEY, (SEC_ERROR_BASE + 93), +"Unable to import. Error attempting to import private key.") + +ER3(SEC_ERROR_PKCS12_IMPORTING_CERT_CHAIN, (SEC_ERROR_BASE + 94), +"Unable to import. Error attempting to import certificate chain.") + +ER3(SEC_ERROR_PKCS12_UNABLE_TO_LOCATE_OBJECT_BY_NAME, (SEC_ERROR_BASE + 95), +"Unable to export. Unable to locate certificate or key by nickname.") + +ER3(SEC_ERROR_PKCS12_UNABLE_TO_EXPORT_KEY, (SEC_ERROR_BASE + 96), +"Unable to export. Private Key could not be located and exported.") + +ER3(SEC_ERROR_PKCS12_UNABLE_TO_WRITE, (SEC_ERROR_BASE + 97), +"Unable to export. Unable to write the export file.") + +ER3(SEC_ERROR_PKCS12_UNABLE_TO_READ, (SEC_ERROR_BASE + 98), +"Unable to import. Unable to read the import file.") + +ER3(SEC_ERROR_PKCS12_KEY_DATABASE_NOT_INITIALIZED, (SEC_ERROR_BASE + 99), +"Unable to export. Key database corrupt or deleted.") + +ER3(SEC_ERROR_KEYGEN_FAIL, (SEC_ERROR_BASE + 100), +"Unable to generate public/private key pair.") + +ER3(SEC_ERROR_INVALID_PASSWORD, (SEC_ERROR_BASE + 101), +"Password entered is invalid. Please pick a different one.") + +ER3(SEC_ERROR_RETRY_OLD_PASSWORD, (SEC_ERROR_BASE + 102), +"Old password entered incorrectly. Please try again.") + +ER3(SEC_ERROR_BAD_NICKNAME, (SEC_ERROR_BASE + 103), +"Certificate nickname already in use.") + +ER3(SEC_ERROR_NOT_FORTEZZA_ISSUER, (SEC_ERROR_BASE + 104), +"Peer FORTEZZA chain has a non-FORTEZZA Certificate.") + +ER3(SEC_ERROR_CANNOT_MOVE_SENSITIVE_KEY, (SEC_ERROR_BASE + 105), +"A sensitive key cannot be moved to the slot where it is needed.") + +ER3(SEC_ERROR_JS_INVALID_MODULE_NAME, (SEC_ERROR_BASE + 106), +"Invalid module name.") + +ER3(SEC_ERROR_JS_INVALID_DLL, (SEC_ERROR_BASE + 107), +"Invalid module path/filename") + +ER3(SEC_ERROR_JS_ADD_MOD_FAILURE, (SEC_ERROR_BASE + 108), +"Unable to add module") + +ER3(SEC_ERROR_JS_DEL_MOD_FAILURE, (SEC_ERROR_BASE + 109), +"Unable to delete module") + +ER3(SEC_ERROR_OLD_KRL, (SEC_ERROR_BASE + 110), +"New KRL is not later than the current one.") + +ER3(SEC_ERROR_CKL_CONFLICT, (SEC_ERROR_BASE + 111), +"New CKL has different issuer than current CKL. Delete current CKL.") + +ER3(SEC_ERROR_CERT_NOT_IN_NAME_SPACE, (SEC_ERROR_BASE + 112), +"The Certifying Authority for this certificate is not permitted to issue a \ +certificate with this name.") + +ER3(SEC_ERROR_KRL_NOT_YET_VALID, (SEC_ERROR_BASE + 113), +"The key revocation list for this certificate is not yet valid.") + +ER3(SEC_ERROR_CRL_NOT_YET_VALID, (SEC_ERROR_BASE + 114), +"The certificate revocation list for this certificate is not yet valid.") + +ER3(SEC_ERROR_UNKNOWN_CERT, (SEC_ERROR_BASE + 115), +"The requested certificate could not be found.") + +ER3(SEC_ERROR_UNKNOWN_SIGNER, (SEC_ERROR_BASE + 116), +"The signer's certificate could not be found.") + +ER3(SEC_ERROR_CERT_BAD_ACCESS_LOCATION, (SEC_ERROR_BASE + 117), +"The location for the certificate status server has invalid format.") + +ER3(SEC_ERROR_OCSP_UNKNOWN_RESPONSE_TYPE, (SEC_ERROR_BASE + 118), +"The OCSP response cannot be fully decoded; it is of an unknown type.") + +ER3(SEC_ERROR_OCSP_BAD_HTTP_RESPONSE, (SEC_ERROR_BASE + 119), +"The OCSP server returned unexpected/invalid HTTP data.") + +ER3(SEC_ERROR_OCSP_MALFORMED_REQUEST, (SEC_ERROR_BASE + 120), +"The OCSP server found the request to be corrupted or improperly formed.") + +ER3(SEC_ERROR_OCSP_SERVER_ERROR, (SEC_ERROR_BASE + 121), +"The OCSP server experienced an internal error.") + +ER3(SEC_ERROR_OCSP_TRY_SERVER_LATER, (SEC_ERROR_BASE + 122), +"The OCSP server suggests trying again later.") + +ER3(SEC_ERROR_OCSP_REQUEST_NEEDS_SIG, (SEC_ERROR_BASE + 123), +"The OCSP server requires a signature on this request.") + +ER3(SEC_ERROR_OCSP_UNAUTHORIZED_REQUEST, (SEC_ERROR_BASE + 124), +"The OCSP server has refused this request as unauthorized.") + +ER3(SEC_ERROR_OCSP_UNKNOWN_RESPONSE_STATUS, (SEC_ERROR_BASE + 125), +"The OCSP server returned an unrecognizable status.") + +ER3(SEC_ERROR_OCSP_UNKNOWN_CERT, (SEC_ERROR_BASE + 126), +"The OCSP server has no status for the certificate.") + +ER3(SEC_ERROR_OCSP_NOT_ENABLED, (SEC_ERROR_BASE + 127), +"You must enable OCSP before performing this operation.") + +ER3(SEC_ERROR_OCSP_NO_DEFAULT_RESPONDER, (SEC_ERROR_BASE + 128), +"You must set the OCSP default responder before performing this operation.") + +ER3(SEC_ERROR_OCSP_MALFORMED_RESPONSE, (SEC_ERROR_BASE + 129), +"The response from the OCSP server was corrupted or improperly formed.") + +ER3(SEC_ERROR_OCSP_UNAUTHORIZED_RESPONSE, (SEC_ERROR_BASE + 130), +"The signer of the OCSP response is not authorized to give status for \ +this certificate.") + +ER3(SEC_ERROR_OCSP_FUTURE_RESPONSE, (SEC_ERROR_BASE + 131), +"The OCSP response is not yet valid (contains a date in the future).") + +ER3(SEC_ERROR_OCSP_OLD_RESPONSE, (SEC_ERROR_BASE + 132), +"The OCSP response contains out-of-date information.") + +ER3(SEC_ERROR_DIGEST_NOT_FOUND, (SEC_ERROR_BASE + 133), +"The CMS or PKCS #7 Digest was not found in signed message.") + +ER3(SEC_ERROR_UNSUPPORTED_MESSAGE_TYPE, (SEC_ERROR_BASE + 134), +"The CMS or PKCS #7 Message type is unsupported.") + +ER3(SEC_ERROR_MODULE_STUCK, (SEC_ERROR_BASE + 135), +"PKCS #11 module could not be removed because it is still in use.") + +ER3(SEC_ERROR_BAD_TEMPLATE, (SEC_ERROR_BASE + 136), +"Could not decode ASN.1 data. Specified template was invalid.") + +ER3(SEC_ERROR_CRL_NOT_FOUND, (SEC_ERROR_BASE + 137), +"No matching CRL was found.") + +ER3(SEC_ERROR_REUSED_ISSUER_AND_SERIAL, (SEC_ERROR_BASE + 138), +"You are attempting to import a cert with the same issuer/serial as \ +an existing cert, but that is not the same cert.") + +ER3(SEC_ERROR_BUSY, (SEC_ERROR_BASE + 139), +"NSS could not shutdown. Objects are still in use.") + +ER3(SEC_ERROR_EXTRA_INPUT, (SEC_ERROR_BASE + 140), +"DER-encoded message contained extra unused data.") + +ER3(SEC_ERROR_UNSUPPORTED_ELLIPTIC_CURVE, (SEC_ERROR_BASE + 141), +"Unsupported elliptic curve.") + +ER3(SEC_ERROR_UNSUPPORTED_EC_POINT_FORM, (SEC_ERROR_BASE + 142), +"Unsupported elliptic curve point form.") + +ER3(SEC_ERROR_UNRECOGNIZED_OID, (SEC_ERROR_BASE + 143), +"Unrecognized Object IDentifier.") + +ER3(SEC_ERROR_OCSP_INVALID_SIGNING_CERT, (SEC_ERROR_BASE + 144), +"Invalid OCSP signing certificate in OCSP response.") + +ER3(SEC_ERROR_REVOKED_CERTIFICATE_CRL, (SEC_ERROR_BASE + 145), +"Certificate is revoked in issuer's certificate revocation list.") + +ER3(SEC_ERROR_REVOKED_CERTIFICATE_OCSP, (SEC_ERROR_BASE + 146), +"Issuer's OCSP responder reports certificate is revoked.") + +ER3(SEC_ERROR_CRL_INVALID_VERSION, (SEC_ERROR_BASE + 147), +"Issuer's Certificate Revocation List has an unknown version number.") + +ER3(SEC_ERROR_CRL_V1_CRITICAL_EXTENSION, (SEC_ERROR_BASE + 148), +"Issuer's V1 Certificate Revocation List has a critical extension.") + +ER3(SEC_ERROR_CRL_UNKNOWN_CRITICAL_EXTENSION, (SEC_ERROR_BASE + 149), +"Issuer's V2 Certificate Revocation List has an unknown critical extension.") + +ER3(SEC_ERROR_UNKNOWN_OBJECT_TYPE, (SEC_ERROR_BASE + 150), +"Unknown object type specified.") + +ER3(SEC_ERROR_INCOMPATIBLE_PKCS11, (SEC_ERROR_BASE + 151), +"PKCS #11 driver violates the spec in an incompatible way.") + +ER3(SEC_ERROR_NO_EVENT, (SEC_ERROR_BASE + 152), +"No new slot event is available at this time.") + +ER3(SEC_ERROR_CRL_ALREADY_EXISTS, (SEC_ERROR_BASE + 153), +"CRL already exists.") + +ER3(SEC_ERROR_NOT_INITIALIZED, (SEC_ERROR_BASE + 154), +"NSS is not initialized.") + +ER3(SEC_ERROR_TOKEN_NOT_LOGGED_IN, (SEC_ERROR_BASE + 155), +"The operation failed because the PKCS#11 token is not logged in.") + diff --git a/pki/base/tps/src/include/httpClient/httpc/SSLServerSocket.h b/pki/base/tps/src/include/httpClient/httpc/SSLServerSocket.h new file mode 100644 index 000000000..a059d7279 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/SSLServerSocket.h @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SSL_SERVER_SOCKET_H +#define __SSL_SERVER_SOCKET_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * SSLServerSocket.h 1.000 06/12/2002 + * + * A Secure server socket implementation based on NSPR / NSS + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL SSLServerSocket : public ServerSocket { +public: + /** + * Constructor + */ + SSLServerSocket( const char* host, + int port, + const char* nickname, + int requestcert ); + + /** + * Destructor + */ + virtual ~SSLServerSocket(); + +public: + /** + * Initializes cert and private key before calling base class + * Accept function. + */ + Socket* Accept(); + +private: + /** + * Overrides base class function to create SSL sockets + * + * @return a newly accepted SSL socket + */ + Socket* InternalAccept(PRFileDesc* fd); + +private: + char* m_nickName; + int m_requestCert; + CERTCertificate* m_serverCert; + SECKEYPrivateKey* m_serverPrivKey; + SSLKEAType m_certKEA; +}; + +#endif // __SSL_SERVER_SOCKET_H + + + + + diff --git a/pki/base/tps/src/include/httpClient/httpc/SSLSocket.h b/pki/base/tps/src/include/httpClient/httpc/SSLSocket.h new file mode 100644 index 000000000..14d647c60 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/SSLSocket.h @@ -0,0 +1,132 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SSL_SOCKET_H +#define __SSL_SOCKET_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * SSLSocket.h 1.000 06/12/2002 + * + * A Secure socket implementation based on NSPR / NSS + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL SSLSocket : public Socket { + friend class SSLServerSocket; +public: + /** + * Constructor + */ + SSLSocket(); + + /** + * Destructor + */ + virtual ~SSLSocket(); + +private: + /** + * Sets up this socket to behave as a SSL server + * + * @param cert server certificate object + * @param privKey private key structure + * @param password password to access DB + * @param requestCert whether to request cert from the client + * @return 0 on success, negative error code otherwise + * + */ + int SetupSSLServer( CERTCertificate* serverCert, + SECKEYPrivateKey* privKey, + SSLKEAType certKEA, + int requestCert ); +private: + // server callbacks + /** + * Specifies a certificate authentication callback function called + * to authenticate an incoming certificate + * + * @param arg pointer supplied by the application + * (in the call to SSL_AuthCertificateHook) + * that can be used to pass state information + * @param socket pointer to the file descriptor for the SSL socket + * @param checksig PR_TRUE means signatures are to be checked and + * the certificate chain is to be validated + * @param isServer PR_TRUE means the callback function should + * evaluate the certificate as a server does, + * treating the remote end is a client + * @return SECSuccess on success, SECFailure otherwise + * + */ + static SECStatus AuthCertificate( void* arg, + PRFileDesc* socket, + PRBool checksig, + PRBool isServer ); + + /** + * Sets up a callback function to deal with a situation where the + * SSL_AuthCertificate callback function has failed. This callback + * function allows the application to override the decision made by + * the certificate authorization callback and authorize the certificate + * for use in the SSL connection. + * + * @param arg The arg parameter passed to SSL_BadCertHook + * @param socket pointer to the file descriptor for the SSL socket + * @return SECSuccess on success, SECFailure otherwise + */ + static SECStatus BadCertHandler( void* arg, + PRFileDesc* socket ); + + /** + * Sets up a callback function used by SSL to inform either a client + * application or a server application when the handshake is completed + * + * @param arg The arg parameter passed to SSL_HandshakeCallback + * @param socket pointer to the file descriptor for the SSL socket + * @return SECSuccess on success, SECFailure otherwise + */ + static SECStatus HandshakeCallback( PRFileDesc* socket, + void* arg ); + +private: + bool m_initializedAsServer; +}; + +#endif // __SSL_SOCKET_H + + diff --git a/pki/base/tps/src/include/httpClient/httpc/SSLerrs.h b/pki/base/tps/src/include/httpClient/httpc/SSLerrs.h new file mode 100644 index 000000000..818da3e87 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/SSLerrs.h @@ -0,0 +1,392 @@ +/** BEGIN COPYRIGHT BLOCK + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Netscape security libraries. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1994-2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * END COPYRIGHT BLOCK **/ + +/* Originally obtained from: + * + * CVSROOT=:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot + * cvs export -r NSS_3_11_3_RTM -N mozilla/security/nss/cmd/lib/SSLerrs.h + */ + +/* SSL-specific security error codes */ +/* caller must include "sslerr.h" */ + +ER3(SSL_ERROR_EXPORT_ONLY_SERVER, SSL_ERROR_BASE + 0, +"Unable to communicate securely. Peer does not support high-grade encryption.") + +ER3(SSL_ERROR_US_ONLY_SERVER, SSL_ERROR_BASE + 1, +"Unable to communicate securely. Peer requires high-grade encryption which is not supported.") + +ER3(SSL_ERROR_NO_CYPHER_OVERLAP, SSL_ERROR_BASE + 2, +"Cannot communicate securely with peer: no common encryption algorithm(s).") + +ER3(SSL_ERROR_NO_CERTIFICATE, SSL_ERROR_BASE + 3, +"Unable to find the certificate or key necessary for authentication.") + +ER3(SSL_ERROR_BAD_CERTIFICATE, SSL_ERROR_BASE + 4, +"Unable to communicate securely with peer: peers's certificate was rejected.") + +/* unused (SSL_ERROR_BASE + 5),*/ + +ER3(SSL_ERROR_BAD_CLIENT, SSL_ERROR_BASE + 6, +"The server has encountered bad data from the client.") + +ER3(SSL_ERROR_BAD_SERVER, SSL_ERROR_BASE + 7, +"The client has encountered bad data from the server.") + +ER3(SSL_ERROR_UNSUPPORTED_CERTIFICATE_TYPE, SSL_ERROR_BASE + 8, +"Unsupported certificate type.") + +ER3(SSL_ERROR_UNSUPPORTED_VERSION, SSL_ERROR_BASE + 9, +"Peer using unsupported version of security protocol.") + +/* unused (SSL_ERROR_BASE + 10),*/ + +ER3(SSL_ERROR_WRONG_CERTIFICATE, SSL_ERROR_BASE + 11, +"Client authentication failed: private key in key database does not match public key in certificate database.") + +ER3(SSL_ERROR_BAD_CERT_DOMAIN, SSL_ERROR_BASE + 12, +"Unable to communicate securely with peer: requested domain name does not match the server's certificate.") + +/* SSL_ERROR_POST_WARNING (SSL_ERROR_BASE + 13), + defined in sslerr.h +*/ + +ER3(SSL_ERROR_SSL2_DISABLED, (SSL_ERROR_BASE + 14), +"Peer only supports SSL version 2, which is locally disabled.") + + +ER3(SSL_ERROR_BAD_MAC_READ, (SSL_ERROR_BASE + 15), +"SSL received a record with an incorrect Message Authentication Code.") + +ER3(SSL_ERROR_BAD_MAC_ALERT, (SSL_ERROR_BASE + 16), +"SSL peer reports incorrect Message Authentication Code.") + +ER3(SSL_ERROR_BAD_CERT_ALERT, (SSL_ERROR_BASE + 17), +"SSL peer cannot verify your certificate.") + +ER3(SSL_ERROR_REVOKED_CERT_ALERT, (SSL_ERROR_BASE + 18), +"SSL peer rejected your certificate as revoked.") + +ER3(SSL_ERROR_EXPIRED_CERT_ALERT, (SSL_ERROR_BASE + 19), +"SSL peer rejected your certificate as expired.") + +ER3(SSL_ERROR_SSL_DISABLED, (SSL_ERROR_BASE + 20), +"Cannot connect: SSL is disabled.") + +ER3(SSL_ERROR_FORTEZZA_PQG, (SSL_ERROR_BASE + 21), +"Cannot connect: SSL peer is in another FORTEZZA domain.") + + +ER3(SSL_ERROR_UNKNOWN_CIPHER_SUITE , (SSL_ERROR_BASE + 22), +"An unknown SSL cipher suite has been requested.") + +ER3(SSL_ERROR_NO_CIPHERS_SUPPORTED , (SSL_ERROR_BASE + 23), +"No cipher suites are present and enabled in this program.") + +ER3(SSL_ERROR_BAD_BLOCK_PADDING , (SSL_ERROR_BASE + 24), +"SSL received a record with bad block padding.") + +ER3(SSL_ERROR_RX_RECORD_TOO_LONG , (SSL_ERROR_BASE + 25), +"SSL received a record that exceeded the maximum permissible length.") + +ER3(SSL_ERROR_TX_RECORD_TOO_LONG , (SSL_ERROR_BASE + 26), +"SSL attempted to send a record that exceeded the maximum permissible length.") + +/* + * Received a malformed (too long or short or invalid content) SSL handshake. + */ +ER3(SSL_ERROR_RX_MALFORMED_HELLO_REQUEST , (SSL_ERROR_BASE + 27), +"SSL received a malformed Hello Request handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_CLIENT_HELLO , (SSL_ERROR_BASE + 28), +"SSL received a malformed Client Hello handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_SERVER_HELLO , (SSL_ERROR_BASE + 29), +"SSL received a malformed Server Hello handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_CERTIFICATE , (SSL_ERROR_BASE + 30), +"SSL received a malformed Certificate handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_SERVER_KEY_EXCH , (SSL_ERROR_BASE + 31), +"SSL received a malformed Server Key Exchange handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_CERT_REQUEST , (SSL_ERROR_BASE + 32), +"SSL received a malformed Certificate Request handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_HELLO_DONE , (SSL_ERROR_BASE + 33), +"SSL received a malformed Server Hello Done handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_CERT_VERIFY , (SSL_ERROR_BASE + 34), +"SSL received a malformed Certificate Verify handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_CLIENT_KEY_EXCH , (SSL_ERROR_BASE + 35), +"SSL received a malformed Client Key Exchange handshake message.") + +ER3(SSL_ERROR_RX_MALFORMED_FINISHED , (SSL_ERROR_BASE + 36), +"SSL received a malformed Finished handshake message.") + +/* + * Received a malformed (too long or short) SSL record. + */ +ER3(SSL_ERROR_RX_MALFORMED_CHANGE_CIPHER , (SSL_ERROR_BASE + 37), +"SSL received a malformed Change Cipher Spec record.") + +ER3(SSL_ERROR_RX_MALFORMED_ALERT , (SSL_ERROR_BASE + 38), +"SSL received a malformed Alert record.") + +ER3(SSL_ERROR_RX_MALFORMED_HANDSHAKE , (SSL_ERROR_BASE + 39), +"SSL received a malformed Handshake record.") + +ER3(SSL_ERROR_RX_MALFORMED_APPLICATION_DATA , (SSL_ERROR_BASE + 40), +"SSL received a malformed Application Data record.") + +/* + * Received an SSL handshake that was inappropriate for the state we're in. + * E.g. Server received message from server, or wrong state in state machine. + */ +ER3(SSL_ERROR_RX_UNEXPECTED_HELLO_REQUEST , (SSL_ERROR_BASE + 41), +"SSL received an unexpected Hello Request handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_CLIENT_HELLO , (SSL_ERROR_BASE + 42), +"SSL received an unexpected Client Hello handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_SERVER_HELLO , (SSL_ERROR_BASE + 43), +"SSL received an unexpected Server Hello handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_CERTIFICATE , (SSL_ERROR_BASE + 44), +"SSL received an unexpected Certificate handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_SERVER_KEY_EXCH , (SSL_ERROR_BASE + 45), +"SSL received an unexpected Server Key Exchange handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_CERT_REQUEST , (SSL_ERROR_BASE + 46), +"SSL received an unexpected Certificate Request handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_HELLO_DONE , (SSL_ERROR_BASE + 47), +"SSL received an unexpected Server Hello Done handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_CERT_VERIFY , (SSL_ERROR_BASE + 48), +"SSL received an unexpected Certificate Verify handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_CLIENT_KEY_EXCH , (SSL_ERROR_BASE + 49), +"SSL received an unexpected Cllient Key Exchange handshake message.") + +ER3(SSL_ERROR_RX_UNEXPECTED_FINISHED , (SSL_ERROR_BASE + 50), +"SSL received an unexpected Finished handshake message.") + +/* + * Received an SSL record that was inappropriate for the state we're in. + */ +ER3(SSL_ERROR_RX_UNEXPECTED_CHANGE_CIPHER , (SSL_ERROR_BASE + 51), +"SSL received an unexpected Change Cipher Spec record.") + +ER3(SSL_ERROR_RX_UNEXPECTED_ALERT , (SSL_ERROR_BASE + 52), +"SSL received an unexpected Alert record.") + +ER3(SSL_ERROR_RX_UNEXPECTED_HANDSHAKE , (SSL_ERROR_BASE + 53), +"SSL received an unexpected Handshake record.") + +ER3(SSL_ERROR_RX_UNEXPECTED_APPLICATION_DATA, (SSL_ERROR_BASE + 54), +"SSL received an unexpected Application Data record.") + +/* + * Received record/message with unknown discriminant. + */ +ER3(SSL_ERROR_RX_UNKNOWN_RECORD_TYPE , (SSL_ERROR_BASE + 55), +"SSL received a record with an unknown content type.") + +ER3(SSL_ERROR_RX_UNKNOWN_HANDSHAKE , (SSL_ERROR_BASE + 56), +"SSL received a handshake message with an unknown message type.") + +ER3(SSL_ERROR_RX_UNKNOWN_ALERT , (SSL_ERROR_BASE + 57), +"SSL received an alert record with an unknown alert description.") + +/* + * Received an alert reporting what we did wrong. (more alerts above) + */ +ER3(SSL_ERROR_CLOSE_NOTIFY_ALERT , (SSL_ERROR_BASE + 58), +"SSL peer has closed this connection.") + +ER3(SSL_ERROR_HANDSHAKE_UNEXPECTED_ALERT , (SSL_ERROR_BASE + 59), +"SSL peer was not expecting a handshake message it received.") + +ER3(SSL_ERROR_DECOMPRESSION_FAILURE_ALERT , (SSL_ERROR_BASE + 60), +"SSL peer was unable to succesfully decompress an SSL record it received.") + +ER3(SSL_ERROR_HANDSHAKE_FAILURE_ALERT , (SSL_ERROR_BASE + 61), +"SSL peer was unable to negotiate an acceptable set of security parameters.") + +ER3(SSL_ERROR_ILLEGAL_PARAMETER_ALERT , (SSL_ERROR_BASE + 62), +"SSL peer rejected a handshake message for unacceptable content.") + +ER3(SSL_ERROR_UNSUPPORTED_CERT_ALERT , (SSL_ERROR_BASE + 63), +"SSL peer does not support certificates of the type it received.") + +ER3(SSL_ERROR_CERTIFICATE_UNKNOWN_ALERT , (SSL_ERROR_BASE + 64), +"SSL peer had some unspecified issue with the certificate it received.") + + +ER3(SSL_ERROR_GENERATE_RANDOM_FAILURE , (SSL_ERROR_BASE + 65), +"SSL experienced a failure of its random number generator.") + +ER3(SSL_ERROR_SIGN_HASHES_FAILURE , (SSL_ERROR_BASE + 66), +"Unable to digitally sign data required to verify your certificate.") + +ER3(SSL_ERROR_EXTRACT_PUBLIC_KEY_FAILURE , (SSL_ERROR_BASE + 67), +"SSL was unable to extract the public key from the peer's certificate.") + +ER3(SSL_ERROR_SERVER_KEY_EXCHANGE_FAILURE , (SSL_ERROR_BASE + 68), +"Unspecified failure while processing SSL Server Key Exchange handshake.") + +ER3(SSL_ERROR_CLIENT_KEY_EXCHANGE_FAILURE , (SSL_ERROR_BASE + 69), +"Unspecified failure while processing SSL Client Key Exchange handshake.") + +ER3(SSL_ERROR_ENCRYPTION_FAILURE , (SSL_ERROR_BASE + 70), +"Bulk data encryption algorithm failed in selected cipher suite.") + +ER3(SSL_ERROR_DECRYPTION_FAILURE , (SSL_ERROR_BASE + 71), +"Bulk data decryption algorithm failed in selected cipher suite.") + +ER3(SSL_ERROR_SOCKET_WRITE_FAILURE , (SSL_ERROR_BASE + 72), +"Attempt to write encrypted data to underlying socket failed.") + +ER3(SSL_ERROR_MD5_DIGEST_FAILURE , (SSL_ERROR_BASE + 73), +"MD5 digest function failed.") + +ER3(SSL_ERROR_SHA_DIGEST_FAILURE , (SSL_ERROR_BASE + 74), +"SHA-1 digest function failed.") + +ER3(SSL_ERROR_MAC_COMPUTATION_FAILURE , (SSL_ERROR_BASE + 75), +"MAC computation failed.") + +ER3(SSL_ERROR_SYM_KEY_CONTEXT_FAILURE , (SSL_ERROR_BASE + 76), +"Failure to create Symmetric Key context.") + +ER3(SSL_ERROR_SYM_KEY_UNWRAP_FAILURE , (SSL_ERROR_BASE + 77), +"Failure to unwrap the Symmetric key in Client Key Exchange message.") + +ER3(SSL_ERROR_PUB_KEY_SIZE_LIMIT_EXCEEDED , (SSL_ERROR_BASE + 78), +"SSL Server attempted to use domestic-grade public key with export cipher suite.") + +ER3(SSL_ERROR_IV_PARAM_FAILURE , (SSL_ERROR_BASE + 79), +"PKCS11 code failed to translate an IV into a param.") + +ER3(SSL_ERROR_INIT_CIPHER_SUITE_FAILURE , (SSL_ERROR_BASE + 80), +"Failed to initialize the selected cipher suite.") + +ER3(SSL_ERROR_SESSION_KEY_GEN_FAILURE , (SSL_ERROR_BASE + 81), +"Client failed to generate session keys for SSL session.") + +ER3(SSL_ERROR_NO_SERVER_KEY_FOR_ALG , (SSL_ERROR_BASE + 82), +"Server has no key for the attempted key exchange algorithm.") + +ER3(SSL_ERROR_TOKEN_INSERTION_REMOVAL , (SSL_ERROR_BASE + 83), +"PKCS#11 token was inserted or removed while operation was in progress.") + +ER3(SSL_ERROR_TOKEN_SLOT_NOT_FOUND , (SSL_ERROR_BASE + 84), +"No PKCS#11 token could be found to do a required operation.") + +ER3(SSL_ERROR_NO_COMPRESSION_OVERLAP , (SSL_ERROR_BASE + 85), +"Cannot communicate securely with peer: no common compression algorithm(s).") + +ER3(SSL_ERROR_HANDSHAKE_NOT_COMPLETED , (SSL_ERROR_BASE + 86), +"Cannot initiate another SSL handshake until current handshake is complete.") + +ER3(SSL_ERROR_BAD_HANDSHAKE_HASH_VALUE , (SSL_ERROR_BASE + 87), +"Received incorrect handshakes hash values from peer.") + +ER3(SSL_ERROR_CERT_KEA_MISMATCH , (SSL_ERROR_BASE + 88), +"The certificate provided cannot be used with the selected key exchange algorithm.") + +ER3(SSL_ERROR_NO_TRUSTED_SSL_CLIENT_CA , (SSL_ERROR_BASE + 89), +"No certificate authority is trusted for SSL client authentication.") + +ER3(SSL_ERROR_SESSION_NOT_FOUND , (SSL_ERROR_BASE + 90), +"Client's SSL session ID not found in server's session cache.") + +ER3(SSL_ERROR_DECRYPTION_FAILED_ALERT , (SSL_ERROR_BASE + 91), +"Peer was unable to decrypt an SSL record it received.") + +ER3(SSL_ERROR_RECORD_OVERFLOW_ALERT , (SSL_ERROR_BASE + 92), +"Peer received an SSL record that was longer than is permitted.") + +ER3(SSL_ERROR_UNKNOWN_CA_ALERT , (SSL_ERROR_BASE + 93), +"Peer does not recognize and trust the CA that issued your certificate.") + +ER3(SSL_ERROR_ACCESS_DENIED_ALERT , (SSL_ERROR_BASE + 94), +"Peer received a valid certificate, but access was denied.") + +ER3(SSL_ERROR_DECODE_ERROR_ALERT , (SSL_ERROR_BASE + 95), +"Peer could not decode an SSL handshake message.") + +ER3(SSL_ERROR_DECRYPT_ERROR_ALERT , (SSL_ERROR_BASE + 96), +"Peer reports failure of signature verification or key exchange.") + +ER3(SSL_ERROR_EXPORT_RESTRICTION_ALERT , (SSL_ERROR_BASE + 97), +"Peer reports negotiation not in compliance with export regulations.") + +ER3(SSL_ERROR_PROTOCOL_VERSION_ALERT , (SSL_ERROR_BASE + 98), +"Peer reports incompatible or unsupported protocol version.") + +ER3(SSL_ERROR_INSUFFICIENT_SECURITY_ALERT , (SSL_ERROR_BASE + 99), +"Server requires ciphers more secure than those supported by client.") + +ER3(SSL_ERROR_INTERNAL_ERROR_ALERT , (SSL_ERROR_BASE + 100), +"Peer reports it experienced an internal error.") + +ER3(SSL_ERROR_USER_CANCELED_ALERT , (SSL_ERROR_BASE + 101), +"Peer user canceled handshake.") + +ER3(SSL_ERROR_NO_RENEGOTIATION_ALERT , (SSL_ERROR_BASE + 102), +"Peer does not permit renegotiation of SSL security parameters.") + +ER3(SSL_ERROR_SERVER_CACHE_NOT_CONFIGURED , (SSL_ERROR_BASE + 103), +"SSL server cache not configured and not disabled for this socket.") + +ER3(SSL_ERROR_UNSUPPORTED_EXTENSION_ALERT , (SSL_ERROR_BASE + 104), +"SSL peer does not support requested TLS hello extension.") + +ER3(SSL_ERROR_CERTIFICATE_UNOBTAINABLE_ALERT , (SSL_ERROR_BASE + 105), +"SSL peer could not obtain your certificate from the supplied URL.") + +ER3(SSL_ERROR_UNRECOGNIZED_NAME_ALERT , (SSL_ERROR_BASE + 106), +"SSL peer has no certificate for the requested DNS name.") + +ER3(SSL_ERROR_BAD_CERT_STATUS_RESPONSE_ALERT , (SSL_ERROR_BASE + 107), +"SSL peer was unable to get an OCSP response for its certificate.") + +ER3(SSL_ERROR_BAD_CERT_HASH_VALUE_ALERT , (SSL_ERROR_BASE + 108), +"SSL peer reported bad certificate hash value.") diff --git a/pki/base/tps/src/include/httpClient/httpc/ScheduledTask.h b/pki/base/tps/src/include/httpClient/httpc/ScheduledTask.h new file mode 100644 index 000000000..cbb99ab61 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/ScheduledTask.h @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SCHEDULED_TASK_H__ +#define __SCHEDULED_TASK_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include <time.h> + +class TaskList; + +/** + * Base class for scheduled tasks in Presence Server + */ + +class EXPORT_DECL ScheduledTask { + friend class TaskList; +public: + /** + * Constructor - creates an empty task + */ + ScheduledTask(); + /** + * Constructor - creates an empty task + * + * @param name Name of task + */ + ScheduledTask( const char *name ); + /** + * Destructor + */ + virtual ~ScheduledTask(); + /** + * Returns a copy of the task + * + * @return A copy of the task + */ + virtual ScheduledTask *Clone(); + /** + * Executes the task + * + * @return 0 on successfully starting the task + */ + virtual int Start(); +protected: + char *m_name; + ScheduledTask *m_next; + ScheduledTask *m_prev; + time_t m_time; + int m_interval; +}; + +#endif // __SCHEDULED_TASK_H__ diff --git a/pki/base/tps/src/include/httpClient/httpc/Scheduler.h b/pki/base/tps/src/include/httpClient/httpc/Scheduler.h new file mode 100644 index 000000000..a0e77ffb4 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/Scheduler.h @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SCHEDULER_H__ +#define __SCHEDULER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +class ScheduledTask; +class TaskList; + +/** + * Base class for scheduled tasks in Presence Server + */ + +class EXPORT_DECL Scheduler { +private: + /** + * Constructor - creates a scheduler object + */ + Scheduler(); + /** + * Destructor + */ + ~Scheduler(); +public: + /** + * Returns the single scheduler object + * + * @return The single scheduler object + */ + static Scheduler *GetScheduler(); + /** + * Starts executing a sleep and check task list loop + * + * @return 0 on success + */ + int Run(); + /** + * Shuts down the scheduler + */ + static void Shutdown(); + /** + * Launches a thread that executes Run() + * + * @param interval Interval in seconds between checking for task execution + * time + * @return 0 on success + */ + int Start( int interval ); + /** + * Adds a task to the list + * + * @param task A task to be executed + */ + void AddTask( ScheduledTask *task ); + /** + * Removes a task from the list + * + * @param taskName Name of a task to be removed + */ + void RemoveTask( const char *taskName ); +private: + TaskList *m_taskList; + int m_interval; + bool m_done; + bool m_running; +}; + +#endif /* __SCHEDULER_H__ */ + diff --git a/pki/base/tps/src/include/httpClient/httpc/SecurityHeaders.h b/pki/base/tps/src/include/httpClient/httpc/SecurityHeaders.h new file mode 100644 index 000000000..a54ecb1a2 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/SecurityHeaders.h @@ -0,0 +1,48 @@ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SECURITY_HEADERS_H__ +#define __SECURITY_HEADERS_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +// SOAP header elements defined by WS-SECURITY and used to transfer +// username and password +#define HEADER_FIELD_USERNAME "Username" +#define HEADER_FIELD_PASSWORD "Password" +#define HEADER_FIELD_SECURITY "Security" +#define HEADER_FIELD_NS "http://schemas.xmlsoap.org/ws/2002/04/secext" +#define HEADER_FIELD_TOKEN "UsernameToken" + +#endif /* __SECURITY_HEADERS_H__ */ + diff --git a/pki/base/tps/src/include/httpClient/httpc/ServerConnection.h b/pki/base/tps/src/include/httpClient/httpc/ServerConnection.h new file mode 100644 index 000000000..bc33aa216 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/ServerConnection.h @@ -0,0 +1,179 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SERVER_CONNECTION_H +#define __SERVER_CONNECTION_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * ServerConnection.h 1.000 06/12/2002 + * + * This class handles server side connections. The accept happens on + * a separate thread and newly accepted connection are polled for + * read ready state. Once data is available on one or more connections + * the listeners are notified about it. + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL ServerConnection { + friend class PollThread; + friend class AcceptThread; +public: + /** + * Constructor + */ + ServerConnection(); + + /** + * Destructor + */ + virtual ~ServerConnection(); + +public: + /** + * Registers a listener interface to notify on the connections + * + * @param listener listener object + * @return 0 on success, negative error code otherwise + */ + int RegisterListener(ConnectionListener* listener); + + /** + * Listens for connections on a specified socket + * + * @param host host name / ip + * @param port listen port + * @return 0 on success, negative error code otherwise + */ + + int Start(char* host, int port); + + /** + * Listens for connections on a specified socket for SSL connections + * + * @param host host name / ip + * @param port listen port + * @param nickename name of the server cert + * @param password password for DB + * @param requestCert request client certficate for authentication + * @return 0 on success, negative error code otherwise + */ + int Start( char* host, + int port, + const char* nickname, + int requestcert); + + /** + * Closes the server connection + * + * @return 0 on success, negative error code otherwise + */ + int Shutdown(); + + /** + * Releases the connection to the read pool. + * + * @param conn a connection object + */ + void PollRead(Connection* conn); + + /** + * Releases the connection to the write pool. + * + * @param conn a connection object + */ + void Release(Connection* conn); + + /** + * Gets a connection from the write pool. This connection should be + * returned to the pool after writing. + * + * @return 0 on success, negative error code otherwise + */ + Connection* GetConnection(); + + /** + * Returns the number of connections + * + * @return number of connections + */ + int GetCount(); + + static void Poll(void* arg); + static void Accept(void* arg); + +protected: + /** + * Protocol specific implementations should implement this + * function and return their own connection object + * + * @return a newly created connection + */ + virtual Connection* AcceptedConnection(); + + const char* GetPeerHost(Connection* conn); + int GetPeerPort(Connection* conn); + +private: + int InternalStart(); + void SetServerFlag(Connection* conn); + PRFileDesc* GetFD( Connection* conn ); + void SetSocket(Connection* conn, Socket* socket); + int UpdateWritePool(Connection* conn); + +private: + ServerSocket* m_server; + ConnectionListener* m_connectionListener; + + Pool* m_readPool; + Pool* m_writePool; + + PRLock* m_readLock; + PRLock* m_writeLock; + + PRBool m_threadInitialized; + PRLock* m_threadLock; + PRCondVar* m_threadCondv; + + int m_totalConnections; + bool m_serverRunning; +}; + +#endif // __SERVER_CONNECTION_H + + diff --git a/pki/base/tps/src/include/httpClient/httpc/ServerHeaderProcessor.h b/pki/base/tps/src/include/httpClient/httpc/ServerHeaderProcessor.h new file mode 100644 index 000000000..213d3b13b --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/ServerHeaderProcessor.h @@ -0,0 +1,72 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef __WASP_SERVER_HEADER_PROCESSOR_H +#define __WASP_SERVER_HEADER_PROCESSOR_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include <waspc/config/config.h> +#include <waspc/util/exceptions.h> +#include <waspc/xmlprotocol/header/HeaderProcessor.h> + +class ServerHeaderProcessorItemConfiguration; + +/** + * Creates WS-Security header with a session token + */ +class EXPORT_DECL ServerHeaderProcessor : public WASP_HeaderProcessor { +protected: + virtual ~ServerHeaderProcessor(); +public: + ServerHeaderProcessor(); + + //inherited methods from WASP_Configurable + virtual void load (WASP_Configuration *, EXCENV_DECL); + virtual void init (EXCENV_DECL); + virtual void destroy (); + + //inherited from WASP_HeaderProcessor + virtual void processInput(WASP_XMLProtocolMessage *message, EXCENV_DECL); + virtual void processOutput(WASP_XMLProtocolMessage *message, EXCENV_DECL); + virtual void processInputFault(WASP_XMLProtocolMessage *message, EXCENV_DECL); + virtual void processOutputFault(WASP_XMLProtocolMessage *message, EXCENV_DECL); + virtual WASP_String **getUnderstandHeaders(int &count, EXCENV_DECL); + +protected: + WASP_String **mppsUnderstandHeaderNamesAndNs; + int miUnderstandHeaderCount; +}; + +#endif //__WASP_SERVER_HEADER_PROCESSOR_H diff --git a/pki/base/tps/src/include/httpClient/httpc/ServerSocket.h b/pki/base/tps/src/include/httpClient/httpc/ServerSocket.h new file mode 100644 index 000000000..3cec2444a --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/ServerSocket.h @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SERVER_SOCKET_H +#define __SERVER_SOCKET_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * ServerSocket.h 1.000 06/12/2002 + * + * A NSPR implementation of ServerSocket + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL ServerSocket { +public: + + /** + * Constructor - Creates a new TCP socket + * + * @param host host name / ip + * @param port a listen port + */ + ServerSocket(const char* host, int port); + + /** + * Constructor - Creates a new TCP socket + * + * @param port a listen port + */ + ServerSocket(int port); + + /** + * Desstructor + */ + virtual ~ServerSocket(); + +public: + + /** + * Binds the socket to the specified port and starts listening for + * connections. The first connection is accepted from the queue of + * pending connections and creates a new socket for the newly accepted + * connection. The accept is blocked with no time out in its own thread. + * + * @return a new socket for the newly accepted connection + */ + virtual Socket* Accept(); + + /** + * Closes the server socket + */ + virtual void Shutdown(); + +protected: + /** + * Internal method to call accept. Sub classes should override this + * to provide their own implementation for returned sockets. + * + * @return a newly accepted socket + */ + virtual Socket* InternalAccept(PRFileDesc* fd); + +protected: + bool m_initialized; + +private: + PRFileDesc* m_fd; + PRNetAddr m_addr; + char* m_host; + int m_port; + int m_backlog; +}; + +#endif // __SERVER_SOCKET_H + + + diff --git a/pki/base/tps/src/include/httpClient/httpc/Socket.h b/pki/base/tps/src/include/httpClient/httpc/Socket.h new file mode 100644 index 000000000..c2ef4afd4 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/Socket.h @@ -0,0 +1,157 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __SOCKET_H +#define __SOCKET_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Socket.h 1.000 06/12/2002 + * + * A NSPR implementation of socket + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL Socket { + friend class ServerSocket; + friend class ServerConnection; +public: + + /** + * Constructor + */ + Socket(); + + /** + * Constructor - creates a socket connecting to the host and port + * + * @param host hostname to connect to + * @param port port of the machine + */ + Socket(const char* host, int port); + + /** + * Destructor + */ + virtual ~Socket(); + +public: + + /** + * Reads specified number of bytes from the socket. This is a blocking + * socket read with timeout. + * + * @param buf buffer to read into + * @param size number of bytes to read + * @param timeout timeout before the read terminates + * @return number of bytes actually read + */ + int Read(void* buf, int size, long timeout); + + /** + * Writes specified number of bytes to the socket. This is a blocking + * socket write with timeout. + * + * @param buf buffer to write from + * @param size number of bytes to write + * @param timeout timeout before the write terminates + * @return number of bytes actually written + */ + int Write(void* buf, int size, long timeout); + + /** + * Gets ip address for a specified socket + * + * @return ip address + */ + const char* GetLocalIp(); + + /** + * Gets port for a specified socket + * + * @return port + */ + int GetLocalPort(); + + /** + * Gets ip address of a connected peer + * + * @return ip address + */ + const char* GetPeerIp(); + + /** + * Gets port of a connected peer + * + * @return ip address + */ + int GetPeerPort(); + + /** + * Shuts down part of a full-duplex connection on a specified socket + * + * @param how the kind of disallowed operations on the socket + * the possible values are : + * PR_SHUTDOWN_RCV + * PR_SHUTDOWN_SEND + * PR_SHUTDOWN_BOTH + */ + void Shutdown(PRShutdownHow how); + +protected: + int Init(PRFileDesc* fd); + +private: + void CancelIO(PRInt32 err); + +protected: + PRFileDesc* m_fd; + +private: + char* m_localIp; + char* m_peerIp; + int m_localPort; + int m_peerPort; + bool m_initialized; + PRLock* m_readLock; + PRLock* m_writeLock; +}; + +#endif // __SOCKET_H + + diff --git a/pki/base/tps/src/include/httpClient/httpc/SocketINC.h b/pki/base/tps/src/include/httpClient/httpc/SocketINC.h new file mode 100644 index 000000000..43b36c9a0 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/SocketINC.h @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _SOCKET_INC_H_ +#define _SOCKET_INC_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * SocketINC.h 1.000 06/12/2002 + * + * Public header file for Socket / Connection module + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +/************************************************** + * Imported header files + **************************************************/ +#include <time.h> +#include <string.h> + +#include "nspr.h" +#include "plhash.h" +#include "plstr.h" +#include "private/pprio.h" + +#include "pk11func.h" +#include "secitem.h" +#include "ssl.h" +#include "certt.h" +#include "nss.h" +#include "secrng.h" +#include "secder.h" +#include "key.h" +#include "sslproto.h" + +#include "httpClient/httpc/Defines.h" // ??? SSR should be spilt into respective modules +#include "httpClient/httpc/Pool.h" +#include "httpClient/httpc/DebugLogger.h" +#include "httpClient/httpc/ErrorLogger.h" +#include "httpClient/httpc/CERTUtil.h" +#include "httpClient/httpc/PSPRUtil.h" + +/************************************************** + * Socket / Connection module header files + **************************************************/ +#include "httpClient/httpc/Socket.h" +#include "httpClient/httpc/ServerSocket.h" +#include "httpClient/httpc/SSLSocket.h" +#include "httpClient/httpc/SSLServerSocket.h" +#include "httpClient/httpc/Connection.h" +#include "httpClient/httpc/ConnectionListener.h" +#include "httpClient/httpc/ServerConnection.h" + + +/************************************************* + * Error codes used by this module + *************************************************/ +// Socket errors +typedef enum { + SOCKET_ERROR_CREATE_SOCKET = -2001, + SOCKET_ERROR_SET_OPTION = -2002, + SOCKET_ERROR_BIND = -2003, + SOCKET_ERROR_LISTEN = -2004, + SOCKET_ERROR_CONNECTION_CLOSED = -2005, + SOCKET_ERROR_READ = -2006, + SOCKET_ERROR_WRITE = -2007, + SOCKET_ERROR_ACCEPT_THREAD = -2008, + SOCKET_ERROR_ALREADY_REGISTERED = -2009, + SOCKET_ERROR_ALREADY_LISTENING = -2010, + SOCKET_ERROR_POLL_THREAD = -2011, + SOCKET_ERROR_NO_LISTENER = -2012, + SOCKET_ERROR_POLL = -2013, + SOCKET_ERROR_POLL_TIMED_OUT = -2014, + SOCKET_ERROR_ALREADY_CONNECTED = -2015, + SOCKET_ERROR_INITIALIZATION_FAILED = -2016 +} SocketError; + +typedef enum { + SSL_ERROR_SERVER_CERT = -2016, + SSL_ERROR_SERVER_PRIVATE_KEY = -2017, + SSL_ERROR_IMPORT_FD = -2018, + SSL_ERROR_OPTION_SECURITY = -2019, + SSL_ERROR_OPTION_SERVER_HANDSHAKE = -2020, + SSL_ERROR_OPTION_REQUEST_CERTIFCATE = -2021, + SSL_ERROR_OPTION_REQUIRE_CERTIFCATE = -2022, + SSL_ERROR_CALLBACK_AUTH_CERTIFICATE = -2023, + SSL_ERROR_CALLBACK_BAD_CERT_HANDLER = -2024, + SSL_ERROR_CALLBACK_HAND_SHAKE = -2025, + SSL_ERROR_CALLBACK_PASSWORD_ARG = -2026, + SSL_ERROR_CONFIG_SECURE_SERVER = -2027, + SSL_ERROR_RESET_HAND_SHAKE = -2028, + SSL_ERROR_OPTION_ENABLE_FDX = -2029 +} SslError; + +/************************************************** + * Defines used by this module + **************************************************/ +#define SOCKET_DEFAULT_HOST_NAME "localhost" +#define SOCKET_DEFAULT_READ_TIME_OUT 1000UL // 1 sec +#define SOCKET_DEFAULT_WRITE_TIME_OUT 0xffffffffUL // infinte +#define SOCKET_DEFAULT_READ_BUFFER_SIZE 4096 // 4k +#define SOCKET_DEFAULT_WRITE_BUFFER_SIZE 4096 // 4k +#define SOCKET_DEFAULT_POLL_TIMEOUT 1000UL // 1 sec +#define SOCKET_DEFAULT_BACKLOG 50 // pending conns +#define SOCKET_DEFAULT_POOL_SIZE 100 // conn pool size + +typedef enum { + SOCKET_ERROR_SEVERE = 1, + SOCKET_ERROR_WARNING = 2, + SOCKET_ERROR_INFO = 3 +} SocketErrorLevel; + + +typedef enum { + REQUEST_CERT_NONE = 0, + REQUIRE_CERT_NONE = 1, + REQUEST_CERT_ONCE = 2, + REQUIRE_CERT_ONCE = 3, + REQUEST_CERT_ALL = 4, + REQUIRE_CERT_ALL = 5 +} RequireCert; + +#endif // _SOCKET_INC_H_ + + + + + diff --git a/pki/base/tps/src/include/httpClient/httpc/SocketLib.h b/pki/base/tps/src/include/httpClient/httpc/SocketLib.h new file mode 100644 index 000000000..5a00b2ecb --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/SocketLib.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _SOCKET_LIB_H_ +#define _SOCKET_LIB_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * SocketLib.h 1.000 06/12/2002 + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +#undef EXPORT_DECL +#ifdef _MSC_VER +#ifdef PS_SOCKET_LIB_INTERNAL + #define EXPORT_DECL __declspec( dllexport ) +#else + #define EXPORT_DECL __declspec (dllimport ) +#endif // PS_SOCKET_LIB_INTERNAL +#else + #define EXPORT_DECL +#endif // _MSC_VER + +#endif // _CONNECTION_LIB_H_ + + + diff --git a/pki/base/tps/src/include/httpClient/httpc/StringList.h b/pki/base/tps/src/include/httpClient/httpc/StringList.h new file mode 100644 index 000000000..80cd61dd6 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/StringList.h @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _STRING_LIST_H +#define _STRING_LIST_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Simple String list class using the STL List template + */ + +#include <list> +#ifdef HPUX +#include <iostream.h> +#else +#include <iostream> +#endif + +#include "httpClient/httpc/Iterator.h" + +#ifndef HPUX +using namespace std; +#endif + +typedef EXPORT_DECL list<const char *> LISTSTR; + +class EXPORT_DECL StringList { +public: + /** + * Constructor + */ + StringList(); + + /** + * Destructor + */ + ~StringList(); + + /** + * Appends a string to the end of the list + * + * @param value The string value to append + */ + void Add( const char *value ); + + /** + * Gets the string at a particular index in the list + * + * @param index Index of the string to retrieve + * @return The string at the specified index, or NULL if outside + * the range of the list + */ + const char *GetAt( int index ); + + /** + * Returns the index of a string in the list + * + * @param matchString The string to match + * @param startIndex The index to start searching from + * @return The index of the string, or -1 if not found + */ + int Find( const char *matchString, + int startIndex ); + + /** + * Returns the number of strings in the list + * + * @return The number of strings in the list + */ + int GetCount(); + + /** + * Inserts a string before the specified position + * + * @param index Position to insert the string + * @param value The string to insert + * @return The index of the string, or -1 if the requested index + * is beyond the end of the list + */ + int Insert( int index, const char *value ); + + /** + * Removes a string at the specified position + * + * @param index Position to remove the string + * @return 0 on sucess, or -1 if the requested index + * is beyond the end of the list + */ + int Remove( int index ); + + /** + * Removes all strings + */ + void RemoveAll(); + + /** + * Returns an iterator over strings in the list + * + * @return An iterator over strings in the list + */ + Iterator *GetIterator(); + + EXPORT_DECL friend ostream& operator<< ( ostream& os, StringList& list ); + +protected: + /** + * Gets the iterator for an indexed element + * + * @param index Position to get + * @return Iterator for the position (could be end()) + */ + LISTSTR::iterator GetIteratorAt( int index ); + +private: + LISTSTR m_list; +}; + +#endif // _STRING_LIST_H diff --git a/pki/base/tps/src/include/httpClient/httpc/StringUtil.h b/pki/base/tps/src/include/httpClient/httpc/StringUtil.h new file mode 100644 index 000000000..5c8955d37 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/StringUtil.h @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _STRING_UTIL_H +#define _STRING_UTIL_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * String utility functions + */ + +class EXPORT_DECL StringUtil { +private: + /** + * Constructor - can't be instantiated + */ + StringUtil() {} + + /** + * Destructor + */ + ~StringUtil() {} + +public: + /** + * Normalizes a screen name + * + * @param raw The raw screen name + * @param normalized The normalized screen name (lower case, no spaces) + */ + static void NormalizeScreenName( const char *raw, char *normalized ); + + /** + * Converts the string to lower case + * + * @param raw string to be converted + */ + static void ToLower(char* raw); +}; + +#endif // _STRING_UTIL_H diff --git a/pki/base/tps/src/include/httpClient/httpc/TaskList.h b/pki/base/tps/src/include/httpClient/httpc/TaskList.h new file mode 100644 index 000000000..779d27ead --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/TaskList.h @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __TASK_LIST_H__ +#define __TASK_LIST_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * Base class for scheduled tasks in Presence Server + */ + +class EXPORT_DECL TaskList { +public: + /** + * Constructor - creates an empty task list + * + * @param name Name of task list + */ + TaskList( const char *name ); + /** + * Destructor - Empties the task list, deleting each entry + */ + virtual ~TaskList(); + /** + * Returns true if the task list is empty + * + * @return true if the task list is empty + */ + bool IsEmpty(); + /** + * Adds a task to the list; the list is sorted by execution time + * + * @param node An entry to add + * @return The added entry + */ + ScheduledTask *Add( ScheduledTask *node ); + /** + * Removes a node from the list but does not delete it + * + * @param taskName The name of the node to remove + * @return The node with the name taskName, or NULL if not found + */ + ScheduledTask *Remove( const char *taskName ); + /** + * Executes each task for which the time is right in a separate thread; + * if the task is repeating, a new entry is created for it, otherwise + * it is removed from the list + * + * @return The number of tasks executed + */ + int ExecuteCurrent(); + /** + * Dumps the task list to the debug log + * + * @param logLevel Lowest debug level for which the log should be dumped + */ + void Dump( int logLevel ); +private: + /** + * Removes a node from the list but does not delete it; does not lock + * + * @param node The node to remove + * @return The node + */ + ScheduledTask *InternalRemove( ScheduledTask *node ); + /** + * Adds a task to the list; the list is sorted by execution time + * + * @param node An entry to add + * @return The added entry + */ + ScheduledTask *InternalAdd( ScheduledTask *node ); + + char *m_name; + ScheduledTask *m_next; + int m_interval; + PRLock *m_lock; +}; + +#endif /* __TASK_LIST_H__ */ + diff --git a/pki/base/tps/src/include/httpClient/httpc/ThreadPool.h b/pki/base/tps/src/include/httpClient/httpc/ThreadPool.h new file mode 100644 index 000000000..389d42606 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/ThreadPool.h @@ -0,0 +1,159 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef __THREAD_POOL_H +#define __THREAD_POOL_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * ThreadPool.h 1.000 06/12/2002 + * + * A worker thread pool. + * + * @author Surendra Rajam + * @version 1.000, 06/12/2002 + */ + +class EXPORT_DECL ThreadPool { + friend class WorkerThread; +public: + /** + * Constructor - creates the pool with default values + * + * @param name name of the threadpool + */ + ThreadPool(const char* name); + + /** + * Constructor + * + * @param name name of the threadpool + * @param min minimum threads in the pool + * @param max maximum threads that can be created + * @param timeout timeout for each thread + */ + ThreadPool(const char* name, int min, int max, int timeout); + + /** + * Destructor + */ + virtual ~ThreadPool(); + +public: + + /** + * Initializes the thread pool with minimum threads + */ + void Init(); + + /** + * Shutdown the thread pool + */ + void Shutdown(); + + /** + * Adds a task for future execution + * + * @param task a task to execute + */ + void AddTask(ScheduledTask* task); + + /** + * Executes the task immediately + * + * @param task a task to execute + */ + void ExecuteTask(ScheduledTask* task); + + /** + * Gets the number of active threads in the pool + * + * @return number of active threads + */ + int GetThreads(); + + /** + * Gets the number of pending tasks in the list + * + * @return number of pending tasks + */ + int GetPendingTasks(); + + /** + * Function to start a NSPR thread + */ + static void StartWorkerThread(void* arg); + +private: + /** + * Initializes constructor params + */ + void ConstructorInit(const char* name, int min, int max, int timeout); + + /** + * Creates a new thread + */ + void CreateNewThread(); + + /** + * Notify one of the threads waiting on a condition + */ + void Notify(); + +private: + char* m_name; + TaskList* m_taskList; + + int m_minThreads; + int m_maxThreads; + int m_timeout; + + int m_threads; + int m_activeThreads; + + PRBool m_threadWait; + PRLock* m_threadLock; + PRCondVar* m_threadCondVar; + + PRBool m_newThreadInitialized; + PRLock* m_newThreadLock; + PRCondVar* m_newThreadCondVar; + + bool m_keepRunning; +}; + +#endif // __THREAD_POOL_H + diff --git a/pki/base/tps/src/include/httpClient/httpc/URLUtil.h b/pki/base/tps/src/include/httpClient/httpc/URLUtil.h new file mode 100644 index 000000000..379986999 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/URLUtil.h @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _URL_UTIL_H +#define _URL_UTIL_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/** + * URL utility functions + */ + +typedef enum { + URL_TYPE_HTTP = 1, + URL_TYPE_HTTPS = 2, + URL_TYPE_LDAP = 3, + URL_TYPE_LDAPS = 4, + URL_TYPE_UNKNOWN = 5 +} UrlType; + +class EXPORT_DECL URLUtil { +private: + /** + * Constructor - can't be instantiated + */ + URLUtil() {} + + /** + * Destructor + */ + ~URLUtil() {} + +public: + /** + * Parses the URL + * + * @param url url to parse + * @param type protocol header type + * @param host hostname from the url + * @param port port number from the url + * @param path uri from the url + * @return 0 on success, negative error code otherwise + */ + static int ParseURL( const char* url, + int* type, + char** host, + int* port, + char** path ); + +private: + static int ParseURLType(const char* url, int* type, int* hlen); + static int ParseAtPort(const char* url, int* port, char** path); + static int ParseAtPath(const char* url, char** path); + static int GetPort(const char* url, int* port); + static bool IsAsciiSpace(char c); + static bool IsAsciiDigit(char c); +}; + +#endif // _URL_UTIL_H + diff --git a/pki/base/tps/src/include/httpClient/httpc/engine.h b/pki/base/tps/src/include/httpClient/httpc/engine.h new file mode 100644 index 000000000..73881ed81 --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/engine.h @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _HTTP_ENGINE_ +#define _HTTP_ENGINE_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/http.h" +#include "httpClient/httpc/response.h" +#include "httpClient/httpc/request.h" + +class __EXPORT Engine { + public: + Engine() {}; + ~Engine() {}; + + PRFileDesc *_doConnect(PRNetAddr *addr, PRBool SSLOn = PR_FALSE, + const PRInt32* cipherSuite = NULL, + PRInt32 count = 0, const char* nickname = NULL, + PRBool handshake = PR_FALSE, + /*const SecurityProtocols& secprots = SecurityProtocols() ,*/ + const char *serverName ="localhost", + PRIntervalTime iv = PR_SecondsToInterval(30)); + static PRIntervalTime globaltimeout; +}; + + +class __EXPORT HttpEngine: public Engine { + public: + HttpEngine() {}; + ~HttpEngine() {}; + + PSHttpResponse *makeRequest( PSHttpRequest &request, + const PSHttpServer& server, + int timeout = 30, PRBool expectChunked = PR_FALSE); +}; + +PRBool __EXPORT InitSecurity(char* dbpath, char* certname, char* certpassword, + char * prefix ,int verify=1); +PRBool __EXPORT EnableCipher(const char* ciphername); +void __EXPORT EnableAllSSL3Ciphers(); +__EXPORT const char * nscperror_lookup(int error); + +#endif diff --git a/pki/base/tps/src/include/httpClient/httpc/http.h b/pki/base/tps/src/include/httpClient/httpc/http.h new file mode 100644 index 000000000..0dccfddbd --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/http.h @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _HTTP_SERVER_ +#define _HTTP_SERVER_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include <stdlib.h> +#include <prnetdb.h> +#include <prio.h> +#include <time.h> +#include <plhash.h> +#include <nspr.h> +#include <plstr.h> + +#include "httpClient/httpc/PSCommonLib.h" +#include "httpClient/httpc/Cache.h" +#include "httpClient/httpc/Defines.h" +//#include "httpClient/httpc/DebugLogger.h" +//#include "httpClient/httpc/ErrorLogger.h" + +#ifdef WIN32 +#define __EXPORT __declspec(dllexport) +#else +#define __EXPORT +#endif + +class PSHttpRequest; + +class __EXPORT PSHttpServer +{ +public: + PSHttpServer(const char *addr, PRUint16 af); + ~PSHttpServer(); + + long getIp() const; + long getPort() const; + const char *getAddr() const; + void getAddr(PRNetAddr *addr) const; + void setSSL(PRBool SSLstate); + PRBool isSSL() const; + + // put a file on the server of size bytes + PRBool putFile(const char *uri, int size) const; + PRBool putFile(const char* uri, const char* localFile) const; + +private: + char *_addr; + PRNetAddr _netAddr; + PRBool SSLOn; + PRBool _putFile(PSHttpRequest& rq) const; +}; + +typedef __EXPORT enum HttpProtocol_e { HTTPNA = 0x0, + HTTP09 = 0x1, + HTTP10 = 0x2, + HTTP11 = 0x4, + HTTPBOGUS = 0x8 } HttpProtocol; + +#define NUM_PROTOS 5 // needed for arrays of tests + +__EXPORT const char *HttpProtocolToString(HttpProtocol); + +class __EXPORT HttpMessage +{ + public: + HttpMessage(long len = 0, const char* buf = NULL); + ~HttpMessage(); + + PRBool operator == (const HttpMessage& rhs); + + void addData(long len, const void* buf); + + // set data on the message + void setProtocol(HttpProtocol prot); + + // get data about the message + HttpProtocol getProtocol() const; + + + protected: + char* firstline; // first line - may be the request-line or server status + HttpProtocol proto; + long cl; +}; + + +#endif diff --git a/pki/base/tps/src/include/httpClient/httpc/request.h b/pki/base/tps/src/include/httpClient/httpc/request.h new file mode 100644 index 000000000..0399732ef --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/request.h @@ -0,0 +1,115 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef _REQUEST_H_ +#define _REQUEST_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/http.h" + +// abstract request class +class __EXPORT NetRequest +{ + public: + NetRequest(const PSHttpServer* server); + PRBool isSSL() const; + void setSSL(PRBool SSLstate); + void getAddr(PRNetAddr *addr); + const char* getAddr(); + const char* getHost(); + const PSHttpServer * getServer(); + void setServer(PSHttpServer* _server); + PRIntervalTime getTimeout() const; + const PRInt32* cipherSet; + PRInt32 cipherCount; + PRBool handshake; +// SecurityProtocols secprots; + + protected: + PRBool SSLOn; + const PSHttpServer * _server; + PRIntervalTime timeout; + +}; + +// Netscape-style request +class __EXPORT PSHttpRequest: public HttpMessage, public NetRequest +{ +public: + PSHttpRequest(const PSHttpServer* server, const char *uri, HttpProtocol proto, PRIntervalTime to); + virtual ~PSHttpRequest(); + + // connection related stuff + + // set data on the request + PRBool setMethod(const char *method); + PRBool addHeader(const char *name, const char *value); + PRBool addRandomBody(int size); + PRBool useLocalFileAsBody(const char* fileName); + PRBool setBody(int size, const char* body); + void setExpectedResponseLength(int size); + void setExpectStandardBody(); + void setExpectDynamicBody(); + void setHangupOk(); + PRBool isHangupOk(); + + // get data about the request + char *getMethod(); + //HttpProtocol getProtocol(); + const char *getHeader(const char *name); + int getExpectedResponseLength(); + PRBool getExpectStandardBody(); + PRBool getExpectDynamicBody(); + + PRBool send(PRFileDesc *sock); + void setCertNickName(const char *); + char *getCertNickName(); + +private: + char *_method; + char *_uri; + HttpProtocol _proto; + int _bodyLength; + char *_body; + char *nickName; + StringKeyCache *_headers; + int _expectedResponseLength; + PRBool _expectStandardBody; + PRBool _expectDynamicBody; + PRBool _hangupOk; + PRFileDesc* _fileFd; +}; + +#endif diff --git a/pki/base/tps/src/include/httpClient/httpc/response.h b/pki/base/tps/src/include/httpClient/httpc/response.h new file mode 100644 index 000000000..5c45d574c --- /dev/null +++ b/pki/base/tps/src/include/httpClient/httpc/response.h @@ -0,0 +1,148 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ +/** BEGIN COPYRIGHT BLOCK + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * END COPYRIGHT BLOCK **/ + +#ifndef _RESPONSE_H_ +#define _RESPONSE_H_ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "httpClient/httpc/http.h" +#include "httpClient/httpc/request.h" + +class __EXPORT RecvBuf +{ +public: + RecvBuf(const PRFileDesc *socket, int size, int timeout = 30); + virtual ~RecvBuf(); + + char getChar(); + void putBack(); + + void setChunkedMode(); + int getAllContent(); + int getTimeout(); + + char *get_content(); + int get_contentSize(); + + class EndOfFile {}; + class EndOfChunking {}; + +private: + char _getChar(); + PRBool _getBytes(int size); + + const PRFileDesc *_socket; + int _allocSize; + char *_buf; + int _curPos; + int _curSize; + + PRBool _chunkedMode; + int _currentChunkSize; + int _currentChunkBytesRead; + PRIntervalTime _timeout; + char *_content; + int _contentSize; +}; + + +class __EXPORT Response +{ + public: + Response(const PRFileDesc *sock, NetRequest *request); + + protected: + const PRFileDesc *_socket; + NetRequest *_request; +}; + + +class __EXPORT PSHttpResponse: public Response +{ + public: + PSHttpResponse( const PRFileDesc *sock, + PSHttpRequest *request ); + PSHttpResponse( const PRFileDesc *sock, + PSHttpRequest *request, + int timeout, PRBool expectChunked ); + virtual ~PSHttpResponse(); + virtual PRBool processResponse(); + + int getReturnCode(); + long getStatus(); + char *getStatusString(); + HttpProtocol getProtocol(); + char *getHeader(const char *name); + int getHeaders(char ***keys); + + PRBool checkKeepAlive(); // return true if we *expect* keepalive based on request + PRBool checkConnection(); // return true if connection is open + + long getBodyLength(); + char *getContent(); + void freeContent(); + int getContentSize(); + char *toString(); + + protected: + PSHttpRequest *_request; + int _verifyStandardBody(RecvBuf &, int, PRBool); + PRBool _handleBody(RecvBuf &buf); + void _checkResponseSanity(); + + HttpProtocol _proto; + char *_protocol; + int retcode; + char *_statusNum; + char *_statusString; + + int _keepAlive; + int _connectionClosed; + + long _bodyLength; + + PRBool _expectChunked; + PRBool _chunkedResponse; + + StringKeyCache *_headers; + + int _timeout; + char *_content; + int _contentSize; +}; + + +#endif diff --git a/pki/base/tps/src/include/main/AttributeSpec.h b/pki/base/tps/src/include/main/AttributeSpec.h new file mode 100644 index 000000000..3aa0655b5 --- /dev/null +++ b/pki/base/tps/src/include/main/AttributeSpec.h @@ -0,0 +1,68 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_ATTRIBUTESPEC_H +#define RA_ATTRIBUTESPEC_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "pk11func.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class AttributeSpec +{ + public: + AttributeSpec(); + ~AttributeSpec(); + public: + static AttributeSpec *Parse(Buffer *b, int offset); + void SetAttributeID(unsigned long v); + unsigned long GetAttributeID(); + void SetType(BYTE v); + BYTE GetType(); + void SetData(Buffer data); + Buffer GetData(); // this gets entire AttributeSpec + Buffer GetValue(); // this gets AttributeValue + public: + unsigned long m_id; + BYTE m_type; + Buffer m_data; // this contains AttributeValue +}; + +#endif /* RA_ATTRIBUTESPEC_H */ diff --git a/pki/base/tps/src/include/main/AuthenticationEntry.h b/pki/base/tps/src/include/main/AuthenticationEntry.h new file mode 100644 index 000000000..e4ec0715c --- /dev/null +++ b/pki/base/tps/src/include/main/AuthenticationEntry.h @@ -0,0 +1,64 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef AUTHENTICATIONENTRY_H +#define AUTHENTICATIONENTRY_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "authentication/Authentication.h" + +class AuthenticationEntry +{ + public: + AuthenticationEntry(); + virtual ~AuthenticationEntry(); + public: + void SetLibrary(PRLibrary* lib); + PRLibrary *GetLibrary(); + void SetId(const char *id); + char *GetId(); + void SetAuthentication(Authentication *auth); + Authentication *GetAuthentication(); + void SetType(const char *type); + char *GetType(); + + private: + PRLibrary *m_lib; + char *m_Id; + char *m_type; + Authentication *m_authentication; +}; + +#endif /* AUTHENTICATIONENTRY_H */ diff --git a/pki/base/tps/src/include/main/Base.h b/pki/base/tps/src/include/main/Base.h new file mode 100644 index 000000000..3c5260178 --- /dev/null +++ b/pki/base/tps/src/include/main/Base.h @@ -0,0 +1,63 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef BASE_H +#define BASE_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "nspr.h" + +typedef unsigned char BYTE; + +enum nsNKeyMsgEnum { + VRFY_FAILURE, + VRFY_SUCCESS, + ENCODE_DER_PUBKEY_FAILURE, + B64ENCODE_FAILURE, + VFY_BEGIN_FAILURE, + VFY_UPDATE_FAILURE, + HTTP_REQ_EXE_FAILURE, + HTTP_ERROR_RCVD, + BASE64_DECODE_FAILURE, + REQ_TO_CA_SUCCESS, + MSG_INVALID +}; + +struct ReturnStatus { + PRStatus status; + nsNKeyMsgEnum statusNum; +}; + +#endif /* BASE_H */ diff --git a/pki/base/tps/src/include/main/Buffer.h b/pki/base/tps/src/include/main/Buffer.h new file mode 100644 index 000000000..4fa7af6df --- /dev/null +++ b/pki/base/tps/src/include/main/Buffer.h @@ -0,0 +1,196 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, +// Boston, MA 02110-1301 USA +// +// Copyright (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- + +#ifndef BUFFER_H +#define BUFFER_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include <stdio.h> +#include "main/Base.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +/** + * This class represents a byte array. + */ +class Buffer { + + private: + BYTE *buf; + unsigned int len; + unsigned int res; + + public: + /** + * Creates an empty Buffer. + */ + TPS_PUBLIC Buffer() : buf(0), len(0), res(0) { } + + /** + * Creates a Buffer of length 'len', with each byte initialized to 'b'. + */ + TPS_PUBLIC Buffer(unsigned int len, BYTE b); + + /** + * Creates a Buffer of length 'len', initialized to zeroes. + */ + TPS_PUBLIC explicit Buffer(unsigned int len); + + /** + * Creates a Buffer of length 'len', initialized from 'buf'. 'buf' must + * contain at least 'len' bytes. + */ + TPS_PUBLIC Buffer(const BYTE* buf, unsigned int len); + + /** + * Copy constructor. + */ + TPS_PUBLIC Buffer(const Buffer& cpy); + + /** + * Destructor. + */ + TPS_PUBLIC ~Buffer(); + + /** + * Assignment operator. + */ + TPS_PUBLIC Buffer& operator=(const Buffer& cpy); + + /** + * Returns true if the two buffers are the same length and contain + * the same byte at each offset. + */ + TPS_PUBLIC bool operator==(const Buffer& cmp) const; + + /** + * Returns ! operator==(cmp). + */ + TPS_PUBLIC bool operator!=(const Buffer& cmp) const { return ! (*this == cmp); } + + /** + * Concatenation operator. + */ + TPS_PUBLIC Buffer operator+(const Buffer&addend) const; + + /** + * Append operators. + */ + TPS_PUBLIC Buffer& operator+=(const Buffer&addend); + TPS_PUBLIC Buffer& operator+=(BYTE b); + + /** + * Returns a pointer into the Buffer. This also enables the subscript + * operator, so you can say, for example, 'buf[4] = b' or 'b = buf[4]'. + */ + TPS_PUBLIC operator BYTE*() { return buf; } + TPS_PUBLIC operator const BYTE*() const { return buf; } + + /** + * The length of buffer. The actual amount of space allocated may be + * higher--see capacity(). + */ + TPS_PUBLIC unsigned int size() const { return len; } + + /** + * The amount of memory allocated for the buffer. This is the maximum + * size the buffer can grow before it needs to allocate more memory. + */ + TPS_PUBLIC unsigned int capacity() const { return res; } + + /** + * Sets all bytes in the buffer to 0. + */ + TPS_PUBLIC void zeroize(); + + /** + * Changes the length of the Buffer. If 'newLen' is shorter than the + * current length, the Buffer is truncated. If 'newLen' is longer, the + * new bytes are initialized to 0. If 'newLen' is the same as size(), + * this is a no-op. + */ + TPS_PUBLIC void resize(unsigned int newLen); + + /** + * Ensures that capacity() is at least 'reserve'. Allocates more memory + * if necessary. If 'reserve' is <= capacity(), this is a no-op. + * Does not affect size(). + */ + TPS_PUBLIC void reserve(unsigned int reserve); + + /** + * Returns a new Buffer that is a substring of this Buffer, starting + * from offset 'start' and continuing for 'len' bytes. This Buffer + * must have size() >= (start + len). + */ + TPS_PUBLIC Buffer substr(unsigned int start, unsigned int len) const; + + /** + * Replaces bytes i through i+n in this Buffer using the values in 'cpy'. + * This Buffer is resized if necessary. The 'cpy' argument can be a + * Buffer. + */ + TPS_PUBLIC void replace(unsigned int i, const BYTE* cpy, unsigned int n); + + /** + * returns a hex version of the buffer + */ + TPS_PUBLIC char *toHex(); + + /** + * Dumps this Buffer to the given file as formatted hex: 16 bytes per + * line, separated by spaces. + */ + TPS_PUBLIC void dump(FILE* file) const; + + /** + * returns a null-terminated string of the buf. + * should be called only by callers that are certain that buf + * is entirely representable by printable characters and wants + * a string instead. + */ + TPS_PUBLIC char *string(); + + /** + * dump()s this Buffer to stdout. + */ + TPS_PUBLIC void dump() const; + +}; + +#endif diff --git a/pki/base/tps/src/include/main/ConfigStore.h b/pki/base/tps/src/include/main/ConfigStore.h new file mode 100644 index 000000000..2d365cfbe --- /dev/null +++ b/pki/base/tps/src/include/main/ConfigStore.h @@ -0,0 +1,119 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef CONFIG_STORE_H +#define CONFIG_STORE_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "plhash.h" +#include "main/Buffer.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +#ifdef XP_WIN32 +#define TOKENDB_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TOKENDB_PUBLIC +#endif /* !XP_WIN32 */ + +class ConfigStoreRoot; + +class ConfigStore +{ + public: + ConfigStore(ConfigStoreRoot* root, const char *subStoreName); + //ConfigStore::ConfigStore(const ConfigStore &X); + + ~ConfigStore(); + static ConfigStore *Parse(const char *s, const char *separator); + static ConfigStore *CreateFromConfigFile(const char *cfg_path); + + int IsNameDefined(const char *name); + void Add(const char *name, const char *value); + const char * GetConfig(const char *name); + int Size(); + const char * GetNameAt(int pos); + ConfigStore GetSubStore(const char*name); + + // Retrieve config parameters + Buffer * GetConfigAsBuffer(const char *key); + Buffer * GetConfigAsBuffer(const char *key, const char *def); + int GetConfigAsInt(const char *key); + TPS_PUBLIC int GetConfigAsInt(const char *key, int def); + unsigned int GetConfigAsUnsignedInt(const char *key); + TPS_PUBLIC unsigned int GetConfigAsUnsignedInt(const char *key, + unsigned int def); + bool GetConfigAsBool(const char *key); + TPS_PUBLIC bool GetConfigAsBool(const char *key, bool def); + TOKENDB_PUBLIC const char *GetConfigAsString(const char *key, const char *def); + TPS_PUBLIC const char *GetConfigAsString(const char *key); + /** + * operator[] is used to look up config strings in the ConfigStore. + * For example: + * <PRE> + * const char *param = cfg["filename"]; // equivalent + * const char *param = cfg.GetConfig("filename"); // equivalent + * </PRE> + */ + const char * operator[](const char*key); + + private: + char *m_substore_name; + ConfigStoreRoot *m_root; +}; + +class ConfigStoreRoot +{ + friend class ConfigStore; + public: + ConfigStoreRoot(); + ~ConfigStoreRoot(); + void addref(); + void release(); + + private: + PLHashTable* getSet(); + PLHashTable *m_set; + int m_set_refcount; + +}; + + + +#endif /* CONFIG_STORE_H */ diff --git a/pki/base/tps/src/include/main/Login.h b/pki/base/tps/src/include/main/Login.h new file mode 100644 index 000000000..81a22870e --- /dev/null +++ b/pki/base/tps/src/include/main/Login.h @@ -0,0 +1,55 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef LOGIN_H +#define LOGIN_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" + +class Login +{ + public: + Login(char *uid, char *pwd); + ~Login(); + public: + char *GetUID(); + char *GetPassword(); + private: + char *m_uid; + char *m_pwd; +}; + +#endif /* LOGIN_H */ diff --git a/pki/base/tps/src/include/main/Memory.h b/pki/base/tps/src/include/main/Memory.h new file mode 100644 index 000000000..ca9608466 --- /dev/null +++ b/pki/base/tps/src/include/main/Memory.h @@ -0,0 +1,130 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_MEMORY_H +#define RA_MEMORY_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/MemoryMgr.h" + +#ifdef MEM_PROFILING + +#ifdef __cplusplus +extern "C" +{ +#endif + +extern void MEM_init(char *audit_file, char *dump_file); +extern void MEM_shutdown(); +extern void MEM_dump_unfree(); +extern char *MEM_strdup(const char *, const char *, const char *, const char *, int); +extern void *MEM_malloc(int, const char *, const char *, const char *, int); +extern void MEM_free(void *i, const char *, const char *, const char *, int); + +#ifdef __cplusplus +} +#endif + + +#ifdef malloc +#undef malloc +#endif + +#ifdef free +#undef free +#endif + +#ifdef strdup +#undef strdup +#endif + +#ifdef PL_strdup +#undef PL_strdup +#endif + +#ifdef PL_strfree +#undef PL_strfree +#endif + + +#define strdup(s) MEM_strdup(s,"strcpy",__FUNCTION__,__FILE__,__LINE__) +#define malloc(size) MEM_malloc(size,"malloc",__FUNCTION__,__FILE__,__LINE__) +#define free(p) MEM_free(p,"free",__FUNCTION__,__FILE__,__LINE__) +#define PR_MALLOC(size) MEM_malloc(size,"PL_MALLOC",__FUNCTION__,__FILE__,__LINE__) +#define PR_Malloc(size) MEM_malloc(size,"PR_Malloc",__FUNCTION__,__FILE__,__LINE__) +#define PR_Free(p) MEM_free(p,"free",__FUNCTION__,__FILE__,__LINE__) + +#define PL_strdup(s) MEM_strdup(s,"PL_strdup",__FUNCTION__,__FILE__,__LINE__) +#define PL_strfree(p) MEM_free(p,"PL_strfree",__FUNCTION__,__FILE__,__LINE__) + +#if 0 +extern void *operator new(size_t size, const char *func, const char *file, int line); +extern void *operator new[](size_t size, const char *func, const char *file, int line); +#endif +extern void operator delete(void* p); +extern void operator delete[](void* p); + +inline void *operator new(size_t size, const char *func, const char *file, int line) +{ + return MEM_malloc(size, "new", func, file, line); +} + +inline void *operator new[](size_t size, const char *func, const char *file, int line) +{ + return MEM_malloc(size, "new[]", func, file, line); +} + +#if 0 +inline void operator delete(void *p) +{ + MEM_free(p,"delete","", "", 0); +} + +inline void operator delete[](void *p) +{ + MEM_free(p,"delete[]","", "", 0); +} +#endif + + +#ifdef new +#undef new +#endif + +#define new new(__FUNCTION__,__FILE__,__LINE__) + +#endif + +#endif /* RA_MEMORY_H */ diff --git a/pki/base/tps/src/include/main/MemoryMgr.h b/pki/base/tps/src/include/main/MemoryMgr.h new file mode 100644 index 000000000..7e2f71dc1 --- /dev/null +++ b/pki/base/tps/src/include/main/MemoryMgr.h @@ -0,0 +1,46 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_MEMORY_MGR_H +#define RA_MEMORY_MGR_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +/* Uncomment the following to enable memory profiling */ + +/* #define MEM_PROFILING */ +#define MEM_AUDIT_FILE "/tmp/mem-audit.log" +#define MEM_DUMP_FILE "/tmp/mem-dump.log" + +#endif /* RA_MEMORY_MGR_H */ diff --git a/pki/base/tps/src/include/main/NameValueSet.h b/pki/base/tps/src/include/main/NameValueSet.h new file mode 100644 index 000000000..6c9055a59 --- /dev/null +++ b/pki/base/tps/src/include/main/NameValueSet.h @@ -0,0 +1,72 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef NAME_VALUE_SET_H +#define NAME_VALUE_SET_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "plhash.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class NameValueSet +{ + public: + TPS_PUBLIC NameValueSet(); + TPS_PUBLIC ~NameValueSet(); + public: + TPS_PUBLIC static NameValueSet *Parse(const char *s, const char *separator); + TPS_PUBLIC int IsNameDefined(const char *name); + TPS_PUBLIC void Remove(const char *name); + TPS_PUBLIC void Add(const char *name, const char *value); + TPS_PUBLIC char *GetValue(const char *name); + TPS_PUBLIC int Size(); + TPS_PUBLIC char *GetNameAt(int pos); + TPS_PUBLIC int GetValueAsInt(const char *key); + TPS_PUBLIC int GetValueAsInt(const char *key, int def); + TPS_PUBLIC int GetValueAsBool(const char *key); + TPS_PUBLIC int GetValueAsBool(const char *key, int def); + TPS_PUBLIC char *GetValueAsString(const char *key, char *def); + TPS_PUBLIC char *GetValueAsString(const char *key); + + private: + PLHashTable *m_set; +}; + +#endif /* NAME_VALUE_SET_H */ diff --git a/pki/base/tps/src/include/main/ObjectSpec.h b/pki/base/tps/src/include/main/ObjectSpec.h new file mode 100644 index 000000000..3b0bee72c --- /dev/null +++ b/pki/base/tps/src/include/main/ObjectSpec.h @@ -0,0 +1,79 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_OBJECTSPEC_H +#define RA_OBJECTSPEC_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "pk11func.h" +#include "main/Buffer.h" +#include "main/AttributeSpec.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class ObjectSpec +{ + public: + ObjectSpec(); + ~ObjectSpec(); + public: + static ObjectSpec *ParseFromTokenData(unsigned long objid, Buffer *b); + static ObjectSpec *Parse(Buffer *b, int offset, int *nread); + static void ParseAttributes(char *objectID, ObjectSpec *ObjectSpec, Buffer *b); + static void ParseCertificateAttributes(char *objectID, ObjectSpec *ObjectSpec, Buffer *b); + static void ParseKeyAttributes(char *objectID, ObjectSpec *ObjectSpec, Buffer *b); + static void ParseCertificateBlob(char *objectID, ObjectSpec *ObjectSpec, Buffer *b); + + void SetObjectID(unsigned long v); + unsigned long GetObjectID(); + void SetFixedAttributes(unsigned long v); + unsigned long GetFixedAttributes(); + int GetAttributeSpecCount(); + AttributeSpec *GetAttributeSpec(int p); + void AddAttributeSpec(AttributeSpec *p); + void RemoveAttributeSpec(int p); + Buffer GetData(); + public: + unsigned long m_objectID; + unsigned long m_fixedAttributes; +#define MAX_ATTRIBUTE_SPEC 30 + AttributeSpec *m_attributeSpec[MAX_ATTRIBUTE_SPEC]; +}; + +#endif /* RA_OBJECTSPEC_H */ diff --git a/pki/base/tps/src/include/main/PKCS11Obj.h b/pki/base/tps/src/include/main/PKCS11Obj.h new file mode 100644 index 000000000..ef3fca964 --- /dev/null +++ b/pki/base/tps/src/include/main/PKCS11Obj.h @@ -0,0 +1,80 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_PKCS11OBJ_H +#define RA_PKCS11OBJ_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "pk11func.h" +#include "main/ObjectSpec.h" +#include "main/Buffer.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class PKCS11Obj +{ + public: + PKCS11Obj(); + ~PKCS11Obj(); + public: + static PKCS11Obj *Parse(Buffer *b, int offset); + void SetFormatVersion(unsigned short v); + unsigned short GetFormatVersion(); + void SetObjectVersion(unsigned short v); + unsigned short GetObjectVersion(); + void SetCUID(Buffer CUID); + Buffer GetCUID(); + void SetTokenName(Buffer tokenName); + Buffer GetTokenName(); + Buffer GetData(); + Buffer GetCompressedData(); + int GetObjectSpecCount(); + ObjectSpec *GetObjectSpec(int p); + void AddObjectSpec(ObjectSpec *p); + void RemoveObjectSpec(int p); + public: + unsigned short m_formatVersion; + unsigned short m_objectVersion; + Buffer m_CUID; + Buffer m_tokenName; +#define MAX_OBJECT_SPEC 20 + ObjectSpec *m_objSpec[MAX_OBJECT_SPEC]; +}; + +#endif /* RA_PKCS11OBj_H */ diff --git a/pki/base/tps/src/include/main/PublishEntry.h b/pki/base/tps/src/include/main/PublishEntry.h new file mode 100644 index 000000000..05d5939a4 --- /dev/null +++ b/pki/base/tps/src/include/main/PublishEntry.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_PUBLISH_ENTRY_H +#define RA_PUBLISH_ENTRY_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "publisher/IPublisher.h" +#define MAX_PUBLISHERS 10 + +struct PublisherEntry +{ + + char *id; + IPublisher *publisher; + PRLibrary *publisher_lib; + char *factory; + + struct PublisherEntry *next; +}; + +typedef struct PublisherEntry PublisherEntry; + +#endif /* RA_PUBLISH_ENTRY_H */ + diff --git a/pki/base/tps/src/include/main/RA_Context.h b/pki/base/tps/src/include/main/RA_Context.h new file mode 100644 index 000000000..e313f45fd --- /dev/null +++ b/pki/base/tps/src/include/main/RA_Context.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_CONTEXT_H +#define RA_CONTEXT_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Context +{ + public: + TPS_PUBLIC RA_Context(); + TPS_PUBLIC virtual ~RA_Context(); + public: + virtual void LogError(const char *func, int line, const char *fmt,...); + virtual void LogInfo(const char *func, int line, const char *fmt,...); + virtual void InitializationError(const char *func, int line); +}; + +#endif /* RA_CONTEXT_H */ diff --git a/pki/base/tps/src/include/main/RA_Msg.h b/pki/base/tps/src/include/main/RA_Msg.h new file mode 100644 index 000000000..d94063b00 --- /dev/null +++ b/pki/base/tps/src/include/main/RA_Msg.h @@ -0,0 +1,79 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_MSG_H +#define RA_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include <stdio.h> + +enum RA_Op_Type { + OP_ENROLL = 1, + OP_UNBLOCK = 2, + OP_RESET_PIN = 3, + OP_RENEW = 4, + OP_FORMAT = 5 +}; + +enum RA_Msg_Type { + MSG_UNDEFINED = -1, + MSG_BEGIN_OP = 2, + MSG_LOGIN_REQUEST = 3, + MSG_LOGIN_RESPONSE = 4, + MSG_SECUREID_REQUEST = 5, + MSG_SECUREID_RESPONSE = 6, + MSG_ASQ_REQUEST = 7, + MSG_ASQ_RESPONSE = 8, + MSG_NEW_PIN_REQUEST = 11, + MSG_NEW_PIN_RESPONSE = 12, + MSG_TOKEN_PDU_REQUEST = 9, + MSG_TOKEN_PDU_RESPONSE = 10, + MSG_END_OP = 13, + MSG_STATUS_UPDATE_REQUEST = 14, + MSG_STATUS_UPDATE_RESPONSE = 15, + MSG_EXTENDED_LOGIN_REQUEST = 16, + MSG_EXTENDED_LOGIN_RESPONSE = 17 +}; + +class RA_Msg +{ + public: + RA_Msg(); + virtual ~RA_Msg(); + public: + virtual RA_Msg_Type GetType(); +}; + +#endif /* RA_MSG_H */ diff --git a/pki/base/tps/src/include/main/RA_Session.h b/pki/base/tps/src/include/main/RA_Session.h new file mode 100644 index 000000000..520a94b6a --- /dev/null +++ b/pki/base/tps/src/include/main/RA_Session.h @@ -0,0 +1,61 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_SESSION_H +#define RA_SESSION_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/RA_pblock.h" +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Session +{ + public: + TPS_PUBLIC RA_Session(); + TPS_PUBLIC virtual ~RA_Session(); + public: + virtual RA_pblock *create_pblock( char *data ); + virtual RA_Msg *ReadMsg(); + virtual char *GetRemoteIP(); + virtual void WriteMsg(RA_Msg *msg); +}; + +#endif /* RA_SESSION_H */ diff --git a/pki/base/tps/src/include/main/RA_pblock.h b/pki/base/tps/src/include/main/RA_pblock.h new file mode 100644 index 000000000..685dc321b --- /dev/null +++ b/pki/base/tps/src/include/main/RA_pblock.h @@ -0,0 +1,74 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_PBLOCK_H +#define RA_PBLOCK_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Buffer.h" + +#define MAX_NVS 50 + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +struct Buffer_nv { + char *name; + char *value_s; + Buffer *value; +}; + +class RA_pblock +{ + public: + TPS_PUBLIC RA_pblock( int tm_nargs, Buffer_nv** tm_nvs ); + TPS_PUBLIC ~RA_pblock(); + public: + Buffer_nv **GetNVs(); + TPS_PUBLIC Buffer *find_val( const char * name ); + TPS_PUBLIC char* find_val_s( const char * name ); + void free_pblock(); + TPS_PUBLIC char *get_name( int i ); + TPS_PUBLIC int get_num_of_names(); + public: + // an array of pointers to name/value pairs + Buffer_nv *m_nvs[MAX_NVS]; + int m_nargs; +}; + +#endif /* RA_PBLOCK_H */ diff --git a/pki/base/tps/src/include/main/SecureId.h b/pki/base/tps/src/include/main/SecureId.h new file mode 100644 index 000000000..fd7e6a158 --- /dev/null +++ b/pki/base/tps/src/include/main/SecureId.h @@ -0,0 +1,55 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef SECUREID_H +#define SECUREID_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" + +class SecureId +{ + public: + SecureId(char *value, char *pin); + ~SecureId(); + public: + char *GetValue(); + char *GetPIN(); /* optional pin */ + private: + char *m_value; + char *m_pin; +}; + +#endif /* RA_MSG_H */ diff --git a/pki/base/tps/src/include/main/Util.h b/pki/base/tps/src/include/main/Util.h new file mode 100644 index 000000000..bd92a50fe --- /dev/null +++ b/pki/base/tps/src/include/main/Util.h @@ -0,0 +1,98 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_UTIL_H +#define RA_UTIL_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "pk11func.h" +#include "main/Buffer.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class Util +{ + public: + TPS_PUBLIC Util(); + TPS_PUBLIC ~Util(); + public: + TPS_PUBLIC static int ascii2numeric(char ch); + TPS_PUBLIC static char *Buffer2String (Buffer &data); + TPS_PUBLIC static Buffer *Str2Buf (const char *s); + TPS_PUBLIC static char *URLEncode (Buffer &data); + TPS_PUBLIC static char *URLEncodeInHex (Buffer &data); + TPS_PUBLIC static char *URLEncode (const char *data); + TPS_PUBLIC static char *URLEncode1 (const char *data); + TPS_PUBLIC static Buffer *URLDecode(const char *data); + TPS_PUBLIC static char *SpecialURLEncode (Buffer &data); + TPS_PUBLIC static Buffer *SpecialURLDecode(const char *data); + TPS_PUBLIC static PRStatus GetRandomChallenge(Buffer &random); + TPS_PUBLIC static PRStatus CreateKeySetData( + Buffer &key_set_version, + Buffer &old_kek_key, + Buffer &new_auth_key, + Buffer &new_mac_key, + Buffer &new_kek_key, + Buffer &output); + TPS_PUBLIC static PRStatus ComputeCryptogram(PK11SymKey *key, + const Buffer &card_challenge, + const Buffer &host_challenge, + Buffer &output); + TPS_PUBLIC static PRStatus ComputeMAC(PK11SymKey *key, + Buffer &input, const Buffer &icv, + Buffer &output); + TPS_PUBLIC static PRStatus ComputeKeyCheck( + const Buffer& newKey, Buffer& output); + TPS_PUBLIC static PK11SymKey *DeriveKey(const Buffer& permKey, + const Buffer& hostChallenge, + const Buffer& cardChallenge); + TPS_PUBLIC static PRStatus EncryptData(PK11SymKey *encSessionKey, + Buffer &input, Buffer &output); + TPS_PUBLIC static PRStatus EncryptData(Buffer &kek_key, + Buffer &input, Buffer &output); + TPS_PUBLIC static PK11SymKey *DiversifyKey(PK11SymKey *master, + Buffer &data, PK11SlotInfo *slot); + TPS_PUBLIC static PRStatus DecryptData(Buffer &kek_key, + Buffer &input, Buffer &output); + TPS_PUBLIC static PRStatus DecryptData(PK11SymKey* enc_key, + Buffer &input, Buffer &output); + TPS_PUBLIC static BYTE* bool2byte(bool p); +}; + +#endif /* RA_UTIL_H */ diff --git a/pki/base/tps/src/include/modules/tps/AP_Context.h b/pki/base/tps/src/include/modules/tps/AP_Context.h new file mode 100644 index 000000000..4faca55ac --- /dev/null +++ b/pki/base/tps/src/include/modules/tps/AP_Context.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef AP_CONTEXT_H +#define AP_CONTEXT_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/RA_Context.h" + +class AP_Context : public RA_Context +{ + public: + AP_Context( server_rec *sv ); + virtual ~AP_Context(); + public: + virtual void LogError( const char *func, int line, + const char *fmt, ... ); + virtual void LogInfo( const char *func, int line, + const char *fmt, ... ); + virtual void InitializationError( const char *func, int line ); + private: + server_rec *m_sv; +}; + +#endif /* AP_CONTEXT_H */ diff --git a/pki/base/tps/src/include/modules/tps/AP_Session.h b/pki/base/tps/src/include/modules/tps/AP_Session.h new file mode 100644 index 000000000..832166a1b --- /dev/null +++ b/pki/base/tps/src/include/modules/tps/AP_Session.h @@ -0,0 +1,56 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef AP_SESSION_H +#define AP_SESSION_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/RA_Session.h" + +class AP_Session : public RA_Session +{ + public: + AP_Session( request_rec *rq ); + virtual ~AP_Session(); + public: + virtual char *GetRemoteIP(); + virtual RA_pblock *create_pblock( char *data ); + virtual RA_Msg *ReadMsg(); + virtual void WriteMsg( RA_Msg *msg ); + private: + request_rec *m_rq; +}; + +#endif /* AP_SESSION_H */ diff --git a/pki/base/tps/src/include/msg/RA_ASQ_Request_Msg.h b/pki/base/tps/src/include/msg/RA_ASQ_Request_Msg.h new file mode 100644 index 000000000..15f8bd7a4 --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_ASQ_Request_Msg.h @@ -0,0 +1,62 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_ASQ_REQUEST_MSG_H +#define RA_ASQ_REQUEST_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_ASQ_Request_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_ASQ_Request_Msg(char *question); + TPS_PUBLIC ~RA_ASQ_Request_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + public: + TPS_PUBLIC char *GetQuestion(); + private: + char *m_question; +}; + +#endif /* RA_ASQ_REQUEST_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_ASQ_Response_Msg.h b/pki/base/tps/src/include/msg/RA_ASQ_Response_Msg.h new file mode 100644 index 000000000..3614e443f --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_ASQ_Response_Msg.h @@ -0,0 +1,62 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_ASQ_RESPONSE_MSG_H +#define RA_ASQ_RESPONSE_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_ASQ_Response_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_ASQ_Response_Msg(char *answer); + TPS_PUBLIC ~RA_ASQ_Response_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + public: + TPS_PUBLIC char *GetAnswer(); + private: + char *m_answer; +}; + +#endif /* RA_ASQ_RESPONSE_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_Begin_Op_Msg.h b/pki/base/tps/src/include/msg/RA_Begin_Op_Msg.h new file mode 100644 index 000000000..48a61a659 --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_Begin_Op_Msg.h @@ -0,0 +1,64 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_BEGIN_OP_MSG_H +#define RA_BEGIN_OP_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/RA_Msg.h" +#include "main/NameValueSet.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Begin_Op_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_Begin_Op_Msg(RA_Op_Type op, NameValueSet *exts); + TPS_PUBLIC ~RA_Begin_Op_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + public: + TPS_PUBLIC RA_Op_Type GetOpType(); + TPS_PUBLIC NameValueSet *GetExtensions(); + private: + RA_Op_Type m_op; + NameValueSet *m_exts; +}; + +#endif /* RA_BEGIN_OP_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_End_Op_Msg.h b/pki/base/tps/src/include/msg/RA_End_Op_Msg.h new file mode 100644 index 000000000..fe396f05b --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_End_Op_Msg.h @@ -0,0 +1,84 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_END_OP_MSG_H +#define RA_END_OP_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + + +#define NKEY_ERROR_NO_ERROR 0 +#define NKEY_ERROR_SNAC 1 +#define NKEY_ERROR_SEC_INIT_UPDATE 2 +#define NKEY_ERROR_CREATE_CARDMGR 3 +#define NKEY_ERROR_MAC_RESET_PIN_PDU 4 +#define NKEY_ERROR_MAC_CERT_PDU 5 +#define NKEY_ERROR_MAC_LIFESTYLE_PDU 6 +#define NKEY_ERROR_MAC_ENROLL_PDU 7 +#define NKEY_ERROR_READ_OBJECT_PDU 8 +#define NKEY_ERROR_BAD_STATUS 9 +#define NKEY_ERROR_CA_RESPONSE 10 +#define NKEY_ERROR_READ_BUFFER_OVERFLOW 11 +#define NKEY_ERROR_TOKEN_RESET_PIN_FAILED 12 +#define NKEY_ERROR_CONNECTION 13 + +#define RESULT_GOOD 0 +#define RESULT_ERROR 1 + +class RA_End_Op_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_End_Op_Msg(RA_Op_Type op, int result, int msg); + TPS_PUBLIC ~RA_End_Op_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + public: + TPS_PUBLIC RA_Op_Type GetOpType(); + TPS_PUBLIC int GetResult(); + TPS_PUBLIC int GetMsg(); + private: + RA_Op_Type m_op; + int m_result; + int m_msg; +}; + +#endif /* RA_BEGIN_OP_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_Extended_Login_Request_Msg.h b/pki/base/tps/src/include/msg/RA_Extended_Login_Request_Msg.h new file mode 100644 index 000000000..fdfceedcf --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_Extended_Login_Request_Msg.h @@ -0,0 +1,73 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_EXTENDED_LOGIN_REQUEST_MSG_H +#define RA_EXTENDED_LOGIN_REQUEST_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Extended_Login_Request_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_Extended_Login_Request_Msg(int invalid_pw, + int blocked, char **parameters, int len, + char *title, char *description); + TPS_PUBLIC ~RA_Extended_Login_Request_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + public: + TPS_PUBLIC int IsInvalidPassword(); + TPS_PUBLIC int IsBlocked(); + TPS_PUBLIC int GetLen(); + TPS_PUBLIC char *GetParam(int i); + TPS_PUBLIC char *GetTitle(); + TPS_PUBLIC char *GetDescription(); + private: + char *m_title; + char *m_description; + int m_invalid_pw; + int m_blocked; + char **m_parameters; + int m_len; +}; + +#endif /* RA_EXTENDED_LOGIN_REQUEST_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_Extended_Login_Response_Msg.h b/pki/base/tps/src/include/msg/RA_Extended_Login_Response_Msg.h new file mode 100644 index 000000000..37da9feb3 --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_Extended_Login_Response_Msg.h @@ -0,0 +1,63 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_EXTENDED_LOGIN_RESPONSE_MSG_H +#define RA_EXTENDED_LOGIN_RESPONSE_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "authentication/AuthParams.h" +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Extended_Login_Response_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_Extended_Login_Response_Msg(AuthParams *param); + TPS_PUBLIC ~RA_Extended_Login_Response_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + public: + TPS_PUBLIC AuthParams *GetAuthParams(); + private: + AuthParams *m_params; +}; + +#endif /* RA_EXTENDED_LOGIN_RESPONSE_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_Login_Request_Msg.h b/pki/base/tps/src/include/msg/RA_Login_Request_Msg.h new file mode 100644 index 000000000..01a7a5acd --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_Login_Request_Msg.h @@ -0,0 +1,63 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_LOGIN_REQUEST_MSG_H +#define RA_LOGIN_REQUEST_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Login_Request_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_Login_Request_Msg(int invalid_pw, int blocked); + TPS_PUBLIC ~RA_Login_Request_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + public: + TPS_PUBLIC int IsInvalidPassword(); + TPS_PUBLIC int IsBlocked(); + private: + int m_invalid_pw; + int m_blocked; +}; + +#endif /* RA_LOGIN_REQUEST_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_Login_Response_Msg.h b/pki/base/tps/src/include/msg/RA_Login_Response_Msg.h new file mode 100644 index 000000000..dcc9e3530 --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_Login_Response_Msg.h @@ -0,0 +1,64 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_LOGIN_RESPONSE_MSG_H +#define RA_LOGIN_RESPONSE_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Login_Response_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_Login_Response_Msg(char *uid, char *password); + TPS_PUBLIC ~RA_Login_Response_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + public: + TPS_PUBLIC char *GetUID(); + TPS_PUBLIC char *GetPassword(); + private: + char *m_uid; + char *m_password; +}; + +#endif /* RA_LOGIN_RESPONSE_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_New_Pin_Request_Msg.h b/pki/base/tps/src/include/msg/RA_New_Pin_Request_Msg.h new file mode 100644 index 000000000..8ebf16259 --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_New_Pin_Request_Msg.h @@ -0,0 +1,63 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_NEW_PIN_REQUEST_MSG_H +#define RA_NEW_PIN_REQUEST_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_New_Pin_Request_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_New_Pin_Request_Msg(int min_len, int max_len); + TPS_PUBLIC ~RA_New_Pin_Request_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + public: + TPS_PUBLIC int GetMinLen(); + TPS_PUBLIC int GetMaxLen(); + private: + int m_min_len; + int m_max_len; +}; + +#endif /* RA_NEW_PIN_REQUEST_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_New_Pin_Response_Msg.h b/pki/base/tps/src/include/msg/RA_New_Pin_Response_Msg.h new file mode 100644 index 000000000..f062adcf0 --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_New_Pin_Response_Msg.h @@ -0,0 +1,62 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_NEW_PIN_RESPONSE_MSG_H +#define RA_NEW_PIN_RESPONSE_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_New_Pin_Response_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_New_Pin_Response_Msg(char *new_pin); + TPS_PUBLIC ~RA_New_Pin_Response_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + public: + TPS_PUBLIC char *GetNewPIN(); + private: + char *m_new_pin; +}; + +#endif /* RA_NEW_PIN_RESPONSE_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_SecureId_Request_Msg.h b/pki/base/tps/src/include/msg/RA_SecureId_Request_Msg.h new file mode 100644 index 000000000..132e04c22 --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_SecureId_Request_Msg.h @@ -0,0 +1,63 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_SECUREID_REQUEST_MSG_H +#define RA_SECUREID_REQUEST_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_SecureId_Request_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_SecureId_Request_Msg(int pin_required, int next_value); + TPS_PUBLIC ~RA_SecureId_Request_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + public: + TPS_PUBLIC int IsPinRequired(); + TPS_PUBLIC int IsNextValue(); + private: + int m_pin_required; + int m_next_value; +}; + +#endif /* RA_SECUREID_REQUEST_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_SecureId_Response_Msg.h b/pki/base/tps/src/include/msg/RA_SecureId_Response_Msg.h new file mode 100644 index 000000000..279e07475 --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_SecureId_Response_Msg.h @@ -0,0 +1,64 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_SECUREID_RESPONSE_MSG_H +#define RA_SECUREID_RESPONSE_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_SecureId_Response_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_SecureId_Response_Msg(char *value, char *pin); + TPS_PUBLIC ~RA_SecureId_Response_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + public: + TPS_PUBLIC char *GetValue(); + TPS_PUBLIC char *GetPIN(); + private: + char *m_value; + char *m_pin; +}; + +#endif /* RA_SECUREID_RESPONSE_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_Status_Update_Request_Msg.h b/pki/base/tps/src/include/msg/RA_Status_Update_Request_Msg.h new file mode 100644 index 000000000..bdc037c97 --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_Status_Update_Request_Msg.h @@ -0,0 +1,65 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_STATUS_UPDATE_REQUEST_MSG_H +#define RA_STATUS_UPDATE_REQUEST_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/Buffer.h" +#include "apdu/APDU.h" +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Status_Update_Request_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_Status_Update_Request_Msg(int status, const char *info); + TPS_PUBLIC ~RA_Status_Update_Request_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + TPS_PUBLIC int GetStatus(); + TPS_PUBLIC char *GetInfo(); + private: + int m_status; + char *m_info; +}; + +#endif /* RA_STATUS_UPDATE_REQUEST_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_Status_Update_Response_Msg.h b/pki/base/tps/src/include/msg/RA_Status_Update_Response_Msg.h new file mode 100644 index 000000000..c5a13eaa4 --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_Status_Update_Response_Msg.h @@ -0,0 +1,63 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_STATUS_UPDATE_RESPONSE_MSG_H +#define RA_STATUS_UPDATE_RESPONSE_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/Buffer.h" +#include "apdu/APDU.h" +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Status_Update_Response_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_Status_Update_Response_Msg(int status); + TPS_PUBLIC ~RA_Status_Update_Response_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + TPS_PUBLIC int GetStatus(); + private: + int m_status; +}; + +#endif /* RA_STATUS_UPDATE_REQUEST_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_Token_PDU_Request_Msg.h b/pki/base/tps/src/include/msg/RA_Token_PDU_Request_Msg.h new file mode 100644 index 000000000..bcbdfc7fc --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_Token_PDU_Request_Msg.h @@ -0,0 +1,63 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_TOKEN_PDU_REQUEST_MSG_H +#define RA_TOKEN_PDU_REQUEST_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Base.h" +#include "main/Buffer.h" +#include "apdu/APDU.h" +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Token_PDU_Request_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_Token_PDU_Request_Msg(APDU *apdu); + TPS_PUBLIC ~RA_Token_PDU_Request_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + TPS_PUBLIC APDU *GetAPDU(); + private: + APDU *m_apdu; +}; + +#endif /* RA_TOKEN_PDU_REQUEST_MSG_H */ diff --git a/pki/base/tps/src/include/msg/RA_Token_PDU_Response_Msg.h b/pki/base/tps/src/include/msg/RA_Token_PDU_Response_Msg.h new file mode 100644 index 000000000..e7c2d538f --- /dev/null +++ b/pki/base/tps/src/include/msg/RA_Token_PDU_Response_Msg.h @@ -0,0 +1,62 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_TOKEN_PDU_RESPONSE_MSG_H +#define RA_TOKEN_PDU_RESPONSE_MSG_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "apdu/APDU.h" +#include "apdu/APDU_Response.h" +#include "main/RA_Msg.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Token_PDU_Response_Msg : public RA_Msg +{ + public: + TPS_PUBLIC RA_Token_PDU_Response_Msg(APDU_Response *response); + TPS_PUBLIC ~RA_Token_PDU_Response_Msg(); + public: + TPS_PUBLIC RA_Msg_Type GetType(); + TPS_PUBLIC APDU_Response *GetResponse(); + private: + APDU_Response *m_response; +}; + +#endif /* RA_TOKEN_PDU_RESPONSE_MSG_H */ diff --git a/pki/base/tps/src/include/processor/RA_Enroll_Processor.h b/pki/base/tps/src/include/processor/RA_Enroll_Processor.h new file mode 100644 index 000000000..e109783a6 --- /dev/null +++ b/pki/base/tps/src/include/processor/RA_Enroll_Processor.h @@ -0,0 +1,266 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_ENROLL_PROCESSOR_H +#define RA_ENROLL_PROCESSOR_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/RA_Session.h" +#include "main/PKCS11Obj.h" +#include "processor/RA_Processor.h" +#include "cms/HttpConnection.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Enroll_Processor : public RA_Processor +{ + public: + TPS_PUBLIC RA_Enroll_Processor(); + TPS_PUBLIC ~RA_Enroll_Processor(); + public: + int ParsePublicKeyBlob(unsigned char *blob, + unsigned char *challenge, + SECKEYPublicKey *pk); + RA_Status DoEnrollment(AuthParams *login, RA_Session *session, + CERTCertificate **certificates, + char **origins, + char **ktypes, + int pkcs11obj, + PKCS11Obj * pkcs_objx, + NameValueSet *extensions, + int index, int keyTypeNum, + int start_progress, + int end_progress, + Secure_Channel *channel, Buffer *wrapped_challenge, + const char *tokenType, + const char *keyType, + Buffer *key_check, + Buffer *plaintext_challenge, + const char *cuid, + const char *msn, + const char *khex, + TokenKeyType key_type, + const char *profileId, + const char *userid, + const char *cert_id, + const char *publisher_id, + const char *cert_attr_id, + const char *pri_attr_id, + const char *pub_attr_id, + BYTE se_p1, BYTE se_p2, int keysize, const char *connid, const char *keyTypePrefix,char * applet_version); + + bool GenerateCertificate(AuthParams *login, + int keyTypeNum, + const char *keyTypeValue, + int i, + RA_Session *session, + char **origins, + char **ktypes, + char *tokenType, + PKCS11Obj *pkcs11objx, + int pkcs11obj_enable, + NameValueSet *extensions, + Secure_Channel *channel, + Buffer *wrapped_challenge, + Buffer *key_check, + Buffer *plaintext_challenge, + char *cuid, + char *msn, + const char *final_applet_version, + char *khex, + const char *userid, + RA_Status &o_status, + CERTCertificate **certificates); + + bool GenerateCertsAfterRecoveryPolicy(AuthParams *login, + RA_Session *session, + char **&origins, + char **&ktypes, + char *&tokenType, + PKCS11Obj *pkcs11objx, + int pkcs11obj_enable, + NameValueSet *extensions, + Secure_Channel *channel, + Buffer *wrapped_challenge, + Buffer *key_check, + Buffer *plaintext_challenge, + char *cuid, + char *msn, + const char *final_applet_version, + char *khex, + const char *userid, + RA_Status &o_status, + CERTCertificate **&certificates, + int &o_certNums, char **&tokenTypes); + + bool GenerateCertificates(AuthParams *login, + RA_Session *session, + char **&origins, + char **&ktypes, + char *tokenType, + PKCS11Obj *pkcs11objx, + int pkcs11obj_enable, + NameValueSet *extensions, + Secure_Channel *channel, + Buffer *wrapped_challenge, + Buffer *key_check, + Buffer *plaintext_challenge, + char *cuid, + char *msn, + const char *final_applet_version, + char *khex, + const char *userid, + RA_Status &o_status, + CERTCertificate **&certificates, + int &o_certNums, char **&tokenTypes); + + int DoPublish( + const char *cuid, + SECItem *encodedPublicKeyInfo, + Buffer *cert, + const char *publisher_id, + char *applet_version); + + bool ProcessRecovery(AuthParams *login, + char *reason, + RA_Session *session, + char **&origins, + char **&ktypes, + char *tokenType, + PKCS11Obj *pkcs11objx, + int pkcs11obj_enable, + NameValueSet *extensions, + Secure_Channel *channel, + Buffer *wrapped_challenge, + Buffer *key_check, + Buffer *plaintext_challenge, + char *cuid, + char *msn, + const char *final_applet_version, + char *khex, + const char *userid, + RA_Status &o_status, + CERTCertificate **&certificates, + char *lostTokenCUID, + int &o_certNums, char **&tokenTypes, char *origTokenType); + + bool GetCardManagerAppletInfo( + RA_Session*, + Buffer *, + RA_Status&, + char*&, + char*&, + Buffer& ); + + bool GetAppletInfo( + RA_Session *a_session, /* in */ + Buffer *a_aid , /* in */ + BYTE &o_major_version, + BYTE &o_minor_version, + BYTE &o_app_major_version, + BYTE &o_app_minor_version); + + bool FormatAppletVersionInfo( + RA_Session *a_session, + const char *a_tokenType, + char *a_cuid, + BYTE a_app_major_version, + BYTE a_app_minor_version, + RA_Status &status, // out + char * &o_appletVersion // out + ); + + bool RequestUserId( + RA_Session * a_session, + NameValueSet *extensions, + const char * a_configname, + const char * a_tokenType, + char *a_cuid, + AuthParams *& o_login, // out + const char *&o_userid, // out + RA_Status &o_status //out + ); + + + bool AuthenticateUser( + RA_Session * a_session, + const char * a_configname, + char *a_cuid, + NameValueSet *a_extensions, + const char *a_tokenType, + AuthParams *& a_login, + const char *&o_userid, + RA_Status &o_status + ); + + bool AuthenticateUserLDAP( + RA_Session *a_session, + NameValueSet *extensions, + char *a_cuid, + AuthenticationEntry *a_auth, + AuthParams *& o_login, + RA_Status &o_status); + + bool CheckAndUpgradeApplet( + RA_Session *a_session, + NameValueSet *a_extensions, + char *a_cuid, + const char *a_tokenType, + char *&o_current_applet_on_token, + BYTE &o_major_version, + BYTE &o_minor_version, + Buffer *a_aid, + RA_Status &o_status ); + + bool CheckAndUpgradeSymKeys( + RA_Session *session, + NameValueSet* extensions, + char *cuid, + const char *tokenType, + char *msn, + Buffer *a_cardmanagerAID, /* in */ + Buffer *a_appletAID, /* in */ + Secure_Channel *&channel, /* out */ + RA_Status &status /* out */ + ); + + TPS_PUBLIC RA_Status Process(RA_Session *session, NameValueSet *extensions); +}; + +#endif /* RA_ENROLL_PROCESSOR_H */ diff --git a/pki/base/tps/src/include/processor/RA_Format_Processor.h b/pki/base/tps/src/include/processor/RA_Format_Processor.h new file mode 100644 index 000000000..836c89080 --- /dev/null +++ b/pki/base/tps/src/include/processor/RA_Format_Processor.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_FORMAT_PROCESSOR_H +#define RA_FORMAT_PROCESSOR_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "processor/RA_Processor.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Format_Processor : public RA_Processor +{ + public: + TPS_PUBLIC RA_Format_Processor(); + TPS_PUBLIC ~RA_Format_Processor(); + public: + TPS_PUBLIC RA_Status Process(RA_Session *session, NameValueSet *extensions); +}; + +#endif /* RA_UPGRADE_PROCESSOR_H */ diff --git a/pki/base/tps/src/include/processor/RA_Pin_Reset_Processor.h b/pki/base/tps/src/include/processor/RA_Pin_Reset_Processor.h new file mode 100644 index 000000000..a3d511865 --- /dev/null +++ b/pki/base/tps/src/include/processor/RA_Pin_Reset_Processor.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_PIN_RESET_PROCESSOR_H +#define RA_PIN_RESET_PROCESSOR_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "processor/RA_Processor.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Pin_Reset_Processor : public RA_Processor +{ + public: + TPS_PUBLIC RA_Pin_Reset_Processor(); + TPS_PUBLIC ~RA_Pin_Reset_Processor(); + public: + TPS_PUBLIC RA_Status Process(RA_Session *session, NameValueSet *extensions); +}; + +#endif /* RA_PIN_RESET_PROCESSOR_H */ diff --git a/pki/base/tps/src/include/processor/RA_Processor.h b/pki/base/tps/src/include/processor/RA_Processor.h new file mode 100644 index 000000000..7fbe46408 --- /dev/null +++ b/pki/base/tps/src/include/processor/RA_Processor.h @@ -0,0 +1,201 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_PROCESSOR_H +#define RA_PROCESSOR_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/Login.h" +#include "main/SecureId.h" +#include "main/RA_Session.h" +#include "authentication/AuthParams.h" +#include "apdu/APDU.h" +#include "apdu/APDU_Response.h" +#include "channel/Secure_Channel.h" + +enum RA_Status { + STATUS_NO_ERROR=0, + STATUS_ERROR_SNAC=1, + STATUS_ERROR_SEC_INIT_UPDATE=2, + STATUS_ERROR_CREATE_CARDMGR=3, + STATUS_ERROR_MAC_RESET_PIN_PDU=4, + STATUS_ERROR_MAC_CERT_PDU=5, + STATUS_ERROR_MAC_LIFESTYLE_PDU=6, + STATUS_ERROR_MAC_ENROLL_PDU=7, + STATUS_ERROR_READ_OBJECT_PDU=8, + STATUS_ERROR_BAD_STATUS=9, + STATUS_ERROR_CA_RESPONSE=10, + STATUS_ERROR_READ_BUFFER_OVERFLOW=11, + STATUS_ERROR_TOKEN_RESET_PIN_FAILED=12, + STATUS_ERROR_CONNECTION=13, + STATUS_ERROR_LOGIN=14, + STATUS_ERROR_DB=15, + STATUS_ERROR_TOKEN_DISABLED=16, + STATUS_ERROR_SECURE_CHANNEL=17, + STATUS_ERROR_MISCONFIGURATION=18, + STATUS_ERROR_UPGRADE_APPLET=19, + STATUS_ERROR_KEY_CHANGE_OVER=20, + STATUS_ERROR_EXTERNAL_AUTH=21, + STATUS_ERROR_DEFAULT_TOKENTYPE_NOT_FOUND=22, + STATUS_ERROR_DEFAULT_TOKENTYPE_PARAMS_NOT_FOUND=23, + STATUS_ERROR_PUBLISH=24, + STATUS_ERROR_LDAP_CONN=25, + STATUS_ERROR_DISABLED_TOKEN=26, + STATUS_ERROR_NOT_PIN_RESETABLE=27, + STATUS_ERROR_CONN_LOST=28, + STATUS_ERROR_CREATE_TUS_TOKEN_ENTRY=29, + STATUS_ERROR_NO_SUCH_TOKEN_STATE=30, + STATUS_ERROR_NO_SUCH_LOST_REASON=31, + STATUS_ERROR_UNUSABLE_TOKEN_KEYCOMPROMISE=32, + STATUS_ERROR_INACTIVE_TOKEN_NOT_FOUND=33, + STATUS_ERROR_HAS_AT_LEAST_ONE_ACTIVE_TOKEN=34, + STATUS_ERROR_CONTACT_ADMIN=35, + STATUS_ERROR_RECOVERY_IS_PROCESSED=36, + STATUS_ERROR_RECOVERY_FAILED=37, + STATUS_ERROR_NO_OPERATION_ON_LOST_TOKEN=38, + STATUS_ERROR_KEY_ARCHIVE_OFF=39, + STATUS_ERROR_NO_TKS_CONNID=40, + STATUS_ERROR_UPDATE_TOKENDB_FAILED=41, + STATUS_ERROR_REVOKE_CERTIFICATES_FAILED=42, + STATUS_ERROR_NOT_TOKEN_OWNER=43 +}; + +class RA_Processor +{ + public: + RA_Processor(); + virtual ~RA_Processor(); + virtual RA_Status Process(RA_Session *session, NameValueSet *extensions); + char *MapPattern(NameValueSet *nv, char *pattern); + + int InitializeUpdate(RA_Session *session, + BYTE key_version, BYTE key_index, + Buffer &key_diversification_data, + Buffer &key_info_data, + Buffer &card_challenge, + Buffer &card_cryptogram, + Buffer &host_challenge); + + int CreatePin(RA_Session *session, BYTE pin_number, BYTE max_retries, char *pin); + + int IsPinPresent(RA_Session *session,BYTE pin_number); + + AuthParams *RequestLogin(RA_Session *session, int invalid_pw, int blocked); + AuthParams *RequestExtendedLogin(RA_Session *session, int invalid_pw, int blocked, char **parameters, int len, char *title, char *description); + + void StatusUpdate(RA_Session *session, NameValueSet *extensions, int status, const char *info); + void StatusUpdate(RA_Session *session, int status, const char *info); + + Buffer *GetAppletVersion(RA_Session *session); + + Secure_Channel *SetupSecureChannel(RA_Session *session, BYTE key_version, BYTE key_index, const char *connId); + Secure_Channel *SetupSecureChannel(RA_Session *session, + BYTE key_version, BYTE key_index, SecurityLevel security_level, const char *connId); + + SecureId *RequestSecureId(RA_Session *session); + + char *RequestNewPin(RA_Session *session, unsigned int min_len, unsigned int max_len); + + char *RequestASQ(RA_Session *session, char *question); + + int EncryptData(Buffer &cuid, Buffer &versionID, Buffer &in, Buffer &out, const char *connid); + + int CreateKeySetData( + Buffer &cuid, + Buffer &versionID, + Buffer &NewMasterVer, + Buffer &out, + const char *connid); + + bool GetTokenType( + const char *prefix, + int major_version, int minor_version, + const char *cuid, const char *msn, + NameValueSet *extensions, + RA_Status &o_status, + const char *&o_tokenType); + + Buffer *ListObjects(RA_Session *session, BYTE seq); + + Buffer *GetStatus(RA_Session *session, BYTE p1, BYTE p2); + + Buffer *GetData(RA_Session *session); + + int SelectApplet(RA_Session *session, BYTE p1, BYTE p2, Buffer *aid); + + int UpgradeApplet( + RA_Session *session, + char *prefix, + char *tokenType, + BYTE major_version, BYTE minor_version, + const char *new_version, + const char *applet_dir, + SecurityLevel security_level, + const char *connid, + NameValueSet *extensions, + int start_progress, int end_progress); + + int UpgradeKey(RA_Session *session, BYTE major_version, BYTE minor_version, int new_version); + + int SelectCardManager(RA_Session *session, char *prefix, char *tokenType); + + int FormatMuscleApplet( + RA_Session *session, + unsigned short memSize, + Buffer &PIN0, BYTE pin0Tries, + Buffer &unblockPIN0, BYTE unblock0Tries, + Buffer &PIN1, BYTE pin1Tries, + Buffer &unblockPIN1, BYTE unblock1Tries, + unsigned short objCreationPermissions, + unsigned short keyCreationPermissions, + unsigned short pinCreationPermissions); + + Secure_Channel *GenerateSecureChannel( + RA_Session *session, const char *connid, + Buffer &card_diversification_data, + Buffer &card_key_data, + Buffer &card_challenge, + Buffer &card_cryptogram, + Buffer &host_challenge); + AuthenticationEntry *GetAuthenticationEntry( + const char * a_prefix, + const char * a_configname, + const char * a_tokenType); + + protected: + int IsTokenDisabledByTus(Secure_Channel *channel); +}; + +#endif /* RA_PROCESSOR_H */ diff --git a/pki/base/tps/src/include/processor/RA_Renew_Processor.h b/pki/base/tps/src/include/processor/RA_Renew_Processor.h new file mode 100644 index 000000000..bb8710a74 --- /dev/null +++ b/pki/base/tps/src/include/processor/RA_Renew_Processor.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_RENEW_PROCESSOR_H +#define RA_RENEW_PROCESSOR_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "processor/RA_Processor.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Renew_Processor : public RA_Processor +{ + public: + TPS_PUBLIC RA_Renew_Processor(); + TPS_PUBLIC ~RA_Renew_Processor(); + public: + TPS_PUBLIC RA_Status Process(RA_Session *session, NameValueSet *extensions); +}; + +#endif /* RA_RENEW_PROCESSOR_H */ diff --git a/pki/base/tps/src/include/processor/RA_Unblock_Processor.h b/pki/base/tps/src/include/processor/RA_Unblock_Processor.h new file mode 100644 index 000000000..ae28ea593 --- /dev/null +++ b/pki/base/tps/src/include/processor/RA_Unblock_Processor.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef RA_UNBLOCK_PROCESSOR_H +#define RA_UNBLOCK_PROCESSOR_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "processor/RA_Processor.h" + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +class RA_Unblock_Processor : public RA_Processor +{ + public: + TPS_PUBLIC RA_Unblock_Processor(); + TPS_PUBLIC ~RA_Unblock_Processor(); + public: + TPS_PUBLIC RA_Status Process(RA_Session *session, NameValueSet *extensions); +}; + +#endif /* RA_UNBLOCK_PROCESSOR_H */ diff --git a/pki/base/tps/src/include/publisher/IConnector.h b/pki/base/tps/src/include/publisher/IConnector.h new file mode 100644 index 000000000..9a5caa70e --- /dev/null +++ b/pki/base/tps/src/include/publisher/IConnector.h @@ -0,0 +1,58 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef __ICONNECTOR_H__ +#define __ICONNECTOR_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#if !defined (I_CONNECTOR_H) +#define I_CONNECTOR_H + +#include "IPublish_Data.h" +class IConnector +{ +public: + + virtual ~IConnector() {}; + virtual int init() = 0; + virtual void shutdown() = 0; + virtual int send_msg(IPublish_Data *data) =0; + +}; + +#endif + +#endif /* __ICONNECTOR_H__ */ + diff --git a/pki/base/tps/src/include/publisher/IPublish_Data.h b/pki/base/tps/src/include/publisher/IPublish_Data.h new file mode 100644 index 000000000..50b7e3247 --- /dev/null +++ b/pki/base/tps/src/include/publisher/IPublish_Data.h @@ -0,0 +1,56 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef __IPUBLISH_DATA_H__ +#define __IPUBLISH_DATA_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#if !defined (IPUBLISH_DATA_H) +#define IPUBLISH_DATA_H + + + +class IPublish_Data +{ +public: + + virtual void Reset() = 0; + +}; + +#endif + +#endif /* __IPUBLISH_DATA_H__ */ + diff --git a/pki/base/tps/src/include/publisher/IPublisher.h b/pki/base/tps/src/include/publisher/IPublisher.h new file mode 100644 index 000000000..56a1b7357 --- /dev/null +++ b/pki/base/tps/src/include/publisher/IPublisher.h @@ -0,0 +1,74 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef __IPUBLISHER_H__ +#define __IPUBLISHER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#if !defined (IPUBLISHER_H) + +#define IPUBLISHER_H + +#include "IConnector.h" + +class IPublisher +{ + +public: + + virtual ~IPublisher() { + if( m_connector != NULL ) { + delete m_connector; + m_connector = NULL; + } + }; + virtual int init(void) = 0; + + virtual int publish(unsigned char *cuid, int cuid_len,long key_type,unsigned char * public_key,int public_key_len, + unsigned long cert_activate_date,unsigned long cert_expire_date,unsigned long applet_version,unsigned long applet_version_date)= 0; + + IConnector *getConnector() { return m_connector;} + +protected: + + IConnector * m_connector; + + +}; + +#endif + +#endif /* __IPUBLISHER_H__ */ + diff --git a/pki/base/tps/src/include/publisher/NetkeyPublisher.h b/pki/base/tps/src/include/publisher/NetkeyPublisher.h new file mode 100644 index 000000000..05cf4d191 --- /dev/null +++ b/pki/base/tps/src/include/publisher/NetkeyPublisher.h @@ -0,0 +1,74 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef __NETKEY_PUBLISHER_H__ +#define __NETKEY_PUBLISHER_H__ + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#if !defined (NETKEY_PUBLISHER_H) +#define NETKEY_PUBLISHER_H + +#include "IPublisher.h" +class IPublisher; +class NetkeyPublisher : public IPublisher +{ + +public: + + + NetkeyPublisher(); + ~NetkeyPublisher(); + + int init(void) ; + + int publish(unsigned char *cuid, int cuid_len,long key_type,unsigned char * public_key,int public_key_len, + unsigned long cert_activate_date,unsigned long cert_expire_date,unsigned long applet_version,unsigned long applet_version_date); + + + static pthread_mutex_t mutex; + + +}; + +extern "C" +{ + IPublisher *GetIPublisher(); + +}; + +#endif + +#endif /* __NETKEY_PUBLISHER_H__ */ + diff --git a/pki/base/tps/src/include/service/NK_Context.h b/pki/base/tps/src/include/service/NK_Context.h new file mode 100644 index 000000000..e5ed59992 --- /dev/null +++ b/pki/base/tps/src/include/service/NK_Context.h @@ -0,0 +1,57 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef NK_CONTEXT_H +#define NK_CONTEXT_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/RA_Context.h" + +class NK_Context : public RA_Context +{ + public: + NK_Context(pblock *pb, Session *sn, Request *rq); + virtual ~NK_Context(); + public: + virtual void LogError(const char *func, int line, const char *fmt,...); + virtual void LogInfo(const char *func, int line, const char *fmt,...); + virtual void InitializationError(const char *func, int line); + private: + pblock *m_pb; + Session *m_sn; + Request *m_rq; +}; + +#endif /* NK_CONTEXT_H */ diff --git a/pki/base/tps/src/include/service/NK_Session.h b/pki/base/tps/src/include/service/NK_Session.h new file mode 100644 index 000000000..55cd19439 --- /dev/null +++ b/pki/base/tps/src/include/service/NK_Session.h @@ -0,0 +1,58 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef NK_SESSION_H +#define NK_SESSION_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#include "main/RA_Session.h" + +class NK_Session : public RA_Session +{ + public: + NK_Session(pblock *pb, Session *sn, Request *rq); + virtual ~NK_Session(); + public: + virtual char *GetRemoteIP(); + virtual RA_pblock *create_pblock( char *data ); + virtual RA_Msg *ReadMsg(); + virtual void WriteMsg(RA_Msg *msg); + private: + pblock *m_pb; + Session *m_sn; + Request *m_rq; +}; + +#endif /* NK_SESSION_H */ diff --git a/pki/base/tps/src/include/tus/tus_db.h b/pki/base/tps/src/include/tus/tus_db.h new file mode 100644 index 000000000..092b16a51 --- /dev/null +++ b/pki/base/tps/src/include/tus/tus_db.h @@ -0,0 +1,229 @@ +/* --- BEGIN COPYRIGHT BLOCK --- + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Copyright (C) 2007 Red Hat, Inc. + * All rights reserved. + * --- END COPYRIGHT BLOCK --- + */ + +#ifndef TUS_DB_H +#define TUS_DB_H + +#ifdef HAVE_CONFIG_H +#ifndef AUTOTOOLS_CONFIG_H +#define AUTOTOOLS_CONFIG_H + +/* Eliminate warnings when using Autotools */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include <config.h> +#endif /* AUTOTOOLS_CONFIG_H */ +#endif /* HAVE_CONFIG_H */ + +#ifdef XP_WIN32 +#define TPS_PUBLIC __declspec(dllexport) +#else /* !XP_WIN32 */ +#define TPS_PUBLIC +#endif /* !XP_WIN32 */ + +#include "ldap.h" +#include "ldap_ssl.h" +#include "pk11func.h" +#include "cryptohi.h" +#include "keyhi.h" +#include "base64.h" +#include "nssb64.h" +#include "prlock.h" + +#define I_TOKEN_ID 0 +#define TOKEN_ID "cn" +#define I_TOKEN_USER 1 +#define TOKEN_USER "tokenUserID" +#define I_TOKEN_STATUS 2 +#define TOKEN_STATUS "tokenStatus" +#define I_TOKEN_APPLET 3 +#define TOKEN_APPLET "tokenAppletID" +#define I_TOKEN_KEY_INFO 4 +#define TOKEN_KEY_INFO "keyInfo" +#define I_TOKEN_MODS 5 +#define TOKEN_MODS "modified" +#define I_TOKEN_C_DATE 6 +#define TOKEN_C_DATE "dateOfCreate" +#define I_TOKEN_M_DATE 7 +#define TOKEN_M_DATE "dateOfModify" +#define I_TOKEN_RESETS 8 +#define TOKEN_RESETS "numberOfResets" +#define I_TOKEN_ENROLLMENTS 9 +#define TOKEN_ENROLLMENTS "numberOfEnrollments" +#define I_TOKEN_RENEWALS 10 +#define TOKEN_RENEWALS "numberOfRenewals" +#define I_TOKEN_RECOVERIES 11 +#define TOKEN_RECOVERIES "numberOfRecoveries" +#define I_TOKEN_POLICY 12 +#define TOKEN_POLICY "tokenPolicy" + +#define I_TOKEN_CUID 13 +#define TOKEN_CUID "tokenID" +#define I_TOKEN_OP 14 +#define TOKEN_OP "tokenOp" +#define I_TOKEN_MSG 15 +#define TOKEN_MSG "tokenMsg" +#define I_TOKEN_RESULT 16 +#define TOKEN_RESULT "tokenResult" +#define I_TOKEN_IP 17 +#define TOKEN_IP "tokenIP" +#define I_TOKEN_CERT 18 +#define TOKEN_CERT "userCertificate" +#define I_TOKEN_SUBJECT 19 +#define TOKEN_SUBJECT "tokenSubject" +#define I_TOKEN_ISSUER 20 +#define TOKEN_ISSUER "tokenIssuer" +#define I_TOKEN_ORIGIN 21 +#define TOKEN_ORIGIN "tokenOrigin" +#define I_TOKEN_SERIAL 22 +#define TOKEN_SERIAL "tokenSerial" +#define I_TOKEN_TYPE 23 +#define TOKEN_TYPE "tokenType" +#define I_TOKEN_KEY_TYPE 24 +#define TOKEN_KEY_TYPE "tokenKeyType" +#define I_TOKEN_REASON 13 +#define TOKEN_REASON "tokenReason" +#define I_TOKEN_NOT_BEFORE 26 +#define TOKEN_NOT_BEFORE "tokenNotBefore" +#define I_TOKEN_NOT_AFTER 27 +#define TOKEN_NOT_AFTER "tokenNotAfter" + +#define I_STATE_UNINITIALIZED 0 +#define STATE_UNINITIALIZED "uninitialized" +#define I_STATE_ACTIVE 1 +#define STATE_ACTIVE "active" +#define I_STATE_DISABLED 2 +#define STATE_DISABLED "disabled" + +#define MAX_RETRIES 2 + +TPS_PUBLIC void set_tus_db_port(int number); +TPS_PUBLIC void set_tus_db_host(char *name); +TPS_PUBLIC void set_tus_db_baseDN(char *dn); +TPS_PUBLIC void set_tus_db_bindDN(char *dn); +TPS_PUBLIC void set_tus_db_bindPass(char *p); + +TPS_PUBLIC int is_tus_db_initialized(); +TPS_PUBLIC int get_tus_db_config(char *name); +TPS_PUBLIC int tus_db_init(char **errorMsg); +TPS_PUBLIC int allow_token_reenroll(char *cn); +TPS_PUBLIC int is_token_pin_resetable(char *cn); +TPS_PUBLIC int is_update_pin_resetable_policy(char *cn); +TPS_PUBLIC int is_token_present(char *cn); +TPS_PUBLIC int update_token_policy (char *cn, char *policy); +TPS_PUBLIC char *get_token_policy (char *cn); +TPS_PUBLIC char *get_token_userid(char *cn); +TPS_PUBLIC void tus_db_end(); +TPS_PUBLIC int is_tus_db_entry_disabled(char *cn); +TPS_PUBLIC int add_default_tus_db_entry (const char *uid, const char *agentid, char *cn, const char *status, char *applet_version, char *key_info ); +TPS_PUBLIC int delete_tus_db_entry (char *userid, char *cn); +TPS_PUBLIC int find_tus_db_entry (char *cn, int max, LDAPMessage **result); +TPS_PUBLIC int find_tus_db_entries (const char *filter, int max, LDAPMessage **result); +TPS_PUBLIC int find_tus_token_entries (char *filter, int max, LDAPMessage **result, int order); +TPS_PUBLIC int find_tus_token_entries_no_vlv (char *filter, LDAPMessage **result, int order); +TPS_PUBLIC int tus_has_active_tokens(char *userid); +TPS_PUBLIC char *get_token_reason(LDAPMessage *e); + +TPS_PUBLIC int update_tus_db_entry (const char *agentid, + char *cn, const char *uid, char *keyInfo, + const char *status, + char *applet_version, const char *reason); +TPS_PUBLIC int update_tus_db_entry_with_mods (const char *agentid, const char *cn, LDAPMod **mods); +TPS_PUBLIC int check_and_modify_tus_db_entry (char *userid, char *cn, char *check, LDAPMod **mods); +TPS_PUBLIC int modify_tus_db_entry (char *userid, char *cn, LDAPMod **mods); +TPS_PUBLIC int add_activity (char *ip, char *id, const char *op, const char *result, const char *msg, const char *userid); +TPS_PUBLIC int find_tus_certificate_entries_by_order_no_vlv (char *filter, + LDAPMessage **result, int order); +TPS_PUBLIC int find_tus_certificate_entries_by_order (char *filter, int max, + LDAPMessage **result, int order); +TPS_PUBLIC int add_certificate (char *tokenid, char *origin, char *tokenType, char *userid, CERTCertificate *certificate, char *ktype, const char *status); +TPS_PUBLIC int add_tus_db_entry (char *cn, LDAPMod **mods); +TPS_PUBLIC int add_new_tus_db_entry (const char *userid, char *cn, const char *uid, int flag, const char *status, char *applet_version, char *key_info); +TPS_PUBLIC int find_tus_activity_entries (char *filter, int max, LDAPMessage **result); +TPS_PUBLIC int find_tus_activity_entries_no_vlv (char *filter, LDAPMessage **result, int order); +TPS_PUBLIC int get_number_of_entries (LDAPMessage *result); +TPS_PUBLIC int free_results (LDAPMessage *results); + +TPS_PUBLIC LDAPMessage *get_first_entry (LDAPMessage *result); +TPS_PUBLIC LDAPMessage *get_next_entry (LDAPMessage *entry); +TPS_PUBLIC CERTCertificate **get_certificates(LDAPMessage *entry); + +TPS_PUBLIC char **get_token_states(); +TPS_PUBLIC char **get_token_attributes(); +TPS_PUBLIC char **get_activity_attributes(); +TPS_PUBLIC char **get_attribute_values(LDAPMessage *entry, const char *attribute); +TPS_PUBLIC void free_values(char **values, int ldapValues); +TPS_PUBLIC char **get_token_users(LDAPMessage *entry); +TPS_PUBLIC char *get_token_id(LDAPMessage *entry); +TPS_PUBLIC char *get_cert_tokenType(LDAPMessage *entry); +TPS_PUBLIC char *get_token_status(LDAPMessage *entry); +TPS_PUBLIC char *get_cert_cn(LDAPMessage *entry); +TPS_PUBLIC char *get_cert_status(LDAPMessage *entry); +TPS_PUBLIC char *get_cert_type(LDAPMessage *entry); +TPS_PUBLIC char *get_cert_serial(LDAPMessage *entry); +TPS_PUBLIC char *get_cert_issuer(LDAPMessage *entry); +TPS_PUBLIC char *get_cert_attr_byname(LDAPMessage *entry, char *name); +TPS_PUBLIC char *get_applet_id(LDAPMessage *entry); +TPS_PUBLIC char *get_key_info(LDAPMessage *entry); +TPS_PUBLIC char *get_creation_date(LDAPMessage *entry); +TPS_PUBLIC char *get_modification_date(LDAPMessage *entry); +TPS_PUBLIC char *get_policy_name(); +TPS_PUBLIC char *get_reason_name(); +int find_tus_certificate_entries (char *filter, int max, LDAPMessage **result); +TPS_PUBLIC char **get_certificate_attributes(); + +TPS_PUBLIC int get_number_of_modifications(LDAPMessage *entry); +TPS_PUBLIC int get_number_of_resets(LDAPMessage *entry); +TPS_PUBLIC int get_number_of_enrollments(LDAPMessage *entry); +TPS_PUBLIC int get_number_of_renewals(LDAPMessage *entry); +TPS_PUBLIC int get_number_of_recoveries(LDAPMessage *entry); + +TPS_PUBLIC char *get_token_users_name(); +TPS_PUBLIC char *get_token_id_name(); +TPS_PUBLIC char *get_token_status_name(); +TPS_PUBLIC char *get_applet_id_name(); +TPS_PUBLIC char *get_key_info_name(); +TPS_PUBLIC char *get_creation_date_name(); +TPS_PUBLIC char *get_modification_date_name(); +TPS_PUBLIC char *get_number_of_modifications_name(); +TPS_PUBLIC char *get_number_of_resets_name(); +TPS_PUBLIC char *get_number_of_enrollments_name(); +TPS_PUBLIC char *get_number_of_renewals_name(); +TPS_PUBLIC char *get_number_of_recoveries_name(); + +TPS_PUBLIC LDAPMod **allocate_modifications(int size); +TPS_PUBLIC void free_modifications(LDAPMod **mods, int ldapValues); +TPS_PUBLIC char **allocate_values(int size, int extra); +TPS_PUBLIC char **create_modification_date_change(); +TPS_PUBLIC int base64_decode(char *src, unsigned char *dst); +TPS_PUBLIC char *tus_authenticate(char *cert); +TPS_PUBLIC int tus_authorize(const char *group, const char *userid); +TPS_PUBLIC int update_cert_status(char *cn, const char *status); +TPS_PUBLIC int update_token_status_reason(char *userid, char *cuid, + const char *tokenStatus, const char *reason); +TPS_PUBLIC int update_token_status_reason_userid(const char *userid, char *cuid, + const char *tokenStatus, const char *reason, int modifyDateOfCreate); + +#endif /* TUS_DB_H */ |