merge the formfield patch from ooo-build
[ooovba.git] / xmlsecurity / source / xmlsec / errorcallback.cxx
blob516a3951ee39ebf0c5b0d978f3b11fe7e1c15364
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: errorcallback.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmlsecurity.hxx"
35 * Implementation of the I/O interfaces based on stream and URI binding
37 #include "errorcallback.hxx"
39 #include <sal/types.h>
40 //For reasons that escape me, this is what xmlsec does when size_t is not 4
41 #if SAL_TYPES_SIZEOFPOINTER != 4
42 # define XMLSEC_NO_SIZE_T
43 #endif
44 #include "xmlsec/xmlsec.h"
45 #include "xmlsec/errors.h"
47 using namespace ::com::sun::star::xml::crypto;
49 // ::com::sun::star::uno::Reference< XXMLSecurityTemplate > g_xErrorRecorder;
50 // bool g_bErrorRecorded;
52 // SecurityOperationStatus getOperationStatus(int reason)
53 // {
54 // switch (reason)
55 // {
56 // case XMLSEC_ERRORS_R_XMLSEC_FAILED:
57 // return SecurityOperationStatus_ENGINE_FAILED;
58 // case XMLSEC_ERRORS_R_MALLOC_FAILED:
59 // return SecurityOperationStatus_MALLOC_FAILED;
60 // case XMLSEC_ERRORS_R_STRDUP_FAILED:
61 // return SecurityOperationStatus_STRDUP_FAILED;
62 // case XMLSEC_ERRORS_R_CRYPTO_FAILED:
63 // return SecurityOperationStatus_CRYPTO_FAILED;
64 // case XMLSEC_ERRORS_R_XML_FAILED:
65 // return SecurityOperationStatus_XML_FAILED;
66 // case XMLSEC_ERRORS_R_XSLT_FAILED:
67 // return SecurityOperationStatus_XSLT_FAILED;
68 // case XMLSEC_ERRORS_R_IO_FAILED:
69 // return SecurityOperationStatus_IO_FAILED;
70 // case XMLSEC_ERRORS_R_DISABLED:
71 // return SecurityOperationStatus_DISABLED;
72 // case XMLSEC_ERRORS_R_NOT_IMPLEMENTED:
73 // return SecurityOperationStatus_NOT_IMPLEMENTED;
74 // case XMLSEC_ERRORS_R_INVALID_SIZE:
75 // return SecurityOperationStatus_INVALID_SIZE;
76 // case XMLSEC_ERRORS_R_INVALID_DATA:
77 // return SecurityOperationStatus_INVALID_DATA;
78 // case XMLSEC_ERRORS_R_INVALID_RESULT:
79 // return SecurityOperationStatus_INVALID_RESULT;
80 // case XMLSEC_ERRORS_R_INVALID_TYPE:
81 // return SecurityOperationStatus_INVALID_TYPE;
82 // case XMLSEC_ERRORS_R_INVALID_OPERATION:
83 // return SecurityOperationStatus_INVALID_OPERATION;
84 // case XMLSEC_ERRORS_R_INVALID_STATUS:
85 // return SecurityOperationStatus_INVALID_STATUS;
86 // case XMLSEC_ERRORS_R_INVALID_FORMAT:
87 // return SecurityOperationStatus_INVALID_FORMAT;
88 // case XMLSEC_ERRORS_R_DATA_NOT_MATCH:
89 // return SecurityOperationStatus_DATA_NOT_MATCH;
90 // case XMLSEC_ERRORS_R_INVALID_NODE:
91 // return SecurityOperationStatus_INVALID_NODE;
92 // case XMLSEC_ERRORS_R_INVALID_NODE_CONTENT:
93 // return SecurityOperationStatus_INVALID_NODE_CONTENT;
94 // case XMLSEC_ERRORS_R_INVALID_NODE_ATTRIBUTE:
95 // return SecurityOperationStatus_INVALID_NODE_ATTRIBUTE;
96 // case XMLSEC_ERRORS_R_MISSING_NODE_ATTRIBUTE:
97 // return SecurityOperationStatus_MISSING_NODE_ATTRIBUTE;
98 // case XMLSEC_ERRORS_R_NODE_ALREADY_PRESENT:
99 // return SecurityOperationStatus_NODE_ALREADY_PRESENT;
100 // case XMLSEC_ERRORS_R_UNEXPECTED_NODE:
101 // return SecurityOperationStatus_UNEXPECTED_NODE;
102 // case XMLSEC_ERRORS_R_NODE_NOT_FOUND:
103 // return SecurityOperationStatus_NODE_NOT_FOUND;
104 // case XMLSEC_ERRORS_R_INVALID_TRANSFORM:
105 // return SecurityOperationStatus_INVALID_TRANSFORM;
106 // case XMLSEC_ERRORS_R_INVALID_TRANSFORM_KEY:
107 // return SecurityOperationStatus_INVALID_TRANSFORM_KEY;
108 // case XMLSEC_ERRORS_R_INVALID_URI_TYPE:
109 // return SecurityOperationStatus_INVALID_URI_TYPE;
110 // case XMLSEC_ERRORS_R_TRANSFORM_SAME_DOCUMENT_REQUIRED:
111 // return SecurityOperationStatus_TRANSFORM_SAME_DOCUMENT_REQUIRED;
112 // case XMLSEC_ERRORS_R_TRANSFORM_DISABLED:
113 // return SecurityOperationStatus_TRANSFORM_DISABLED;
114 // case XMLSEC_ERRORS_R_INVALID_KEY_DATA:
115 // return SecurityOperationStatus_INVALID_KEY_DATA;
116 // case XMLSEC_ERRORS_R_KEY_DATA_NOT_FOUND:
117 // return SecurityOperationStatus_KEY_DATA_NOT_FOUND;
118 // case XMLSEC_ERRORS_R_KEY_DATA_ALREADY_EXIST:
119 // return SecurityOperationStatus_KEY_DATA_ALREADY_EXIST;
120 // case XMLSEC_ERRORS_R_INVALID_KEY_DATA_SIZE:
121 // return SecurityOperationStatus_INVALID_KEY_DATA_SIZE;
122 // case XMLSEC_ERRORS_R_KEY_NOT_FOUND:
123 // return SecurityOperationStatus_KEY_NOT_FOUND;
124 // case XMLSEC_ERRORS_R_KEYDATA_DISABLED:
125 // return SecurityOperationStatus_KEYDATA_DISABLED;
126 // case XMLSEC_ERRORS_R_MAX_RETRIEVALS_LEVEL:
127 // return SecurityOperationStatus_MAX_RETRIEVALS_LEVEL;
128 // case XMLSEC_ERRORS_R_MAX_RETRIEVAL_TYPE_MISMATCH:
129 // return SecurityOperationStatus_MAX_RETRIEVAL_TYPE_MISMATCH;
130 // case XMLSEC_ERRORS_R_MAX_ENCKEY_LEVEL:
131 // return SecurityOperationStatus_MAX_ENCKEY_LEVEL;
132 // case XMLSEC_ERRORS_R_CERT_VERIFY_FAILED:
133 // return SecurityOperationStatus_CERT_VERIFY_FAILED;
134 // case XMLSEC_ERRORS_R_CERT_NOT_FOUND:
135 // return SecurityOperationStatus_CERT_NOT_FOUND;
136 // case XMLSEC_ERRORS_R_CERT_REVOKED:
137 // return SecurityOperationStatus_CERT_REVOKED;
138 // case XMLSEC_ERRORS_R_CERT_ISSUER_FAILED:
139 // return SecurityOperationStatus_CERT_ISSUER_FAILED;
140 // case XMLSEC_ERRORS_R_CERT_NOT_YET_VALID:
141 // return SecurityOperationStatus_CERT_NOT_YET_VALID;
142 // case XMLSEC_ERRORS_R_CERT_HAS_EXPIRED:
143 // return SecurityOperationStatus_CERT_HAS_EXPIRED;
144 // case XMLSEC_ERRORS_R_DSIG_NO_REFERENCES:
145 // return SecurityOperationStatus_DSIG_NO_REFERENCES;
146 // case XMLSEC_ERRORS_R_DSIG_INVALID_REFERENCE:
147 // return SecurityOperationStatus_DSIG_INVALID_REFERENCE;
148 // case XMLSEC_ERRORS_R_ASSERTION:
149 // return SecurityOperationStatus_ASSERTION;
150 // default:
151 // return SecurityOperationStatus_RUNTIMEERROR_FAILED;
152 // }
153 // }
156 extern "C"
157 void errorCallback(const char * /*file*/,
158 int /*line*/,
159 const char * /*func*/,
160 const char * /*errorObject*/,
161 const char * /*errorSubject*/,
162 int /*reason*/,
163 const char * /*msg*/)
165 #if OSL_DEBUG_LEVEL > 1
166 // const char * afunc = func ? func : "";
167 // const char * errObj = errorObject ? errorObject : "";
168 // const char * errSub = errorSubject ? errorSubject : "";
169 // const char * amsg = msg ? msg : "";
170 // fprintf(stdout, "xmlsec error: %s, %s, %s, %i %s \n", afunc, errObj, errSub, reason, amsg);
171 #endif
172 //ToDo write log message
173 // if (g_xErrorRecorder.is() && !g_bErrorRecorded)
174 // {
175 // g_xErrorRecorder->setStatus(getOperationStatus(reason));
177 // if ( reason != XMLSEC_ERRORS_R_ASSERTION && reason!=XMLSEC_ERRORS_R_XMLSEC_FAILED)
178 // {
179 // g_bErrorRecorded = true;
180 // }
181 // }
184 // void setErrorRecorder(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSecurityTemplate >& xTemplate)
185 // {
186 // g_xErrorRecorder = xTemplate;
187 // g_xErrorRecorder->setStatus(SecurityOperationStatus_OPERATION_SUCCEEDED);
188 // g_bErrorRecorded = false;
189 // xmlSecErrorsSetCallback(errorCallback);
190 // }
192 //void setErrorRecorder(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSignatureTemplate >& xTemplate)
194 void setErrorRecorder()
196 // ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSecurityTemplate >
197 // xSecurityTemplate(xTemplate, ::com::sun::star::uno::UNO_QUERY);
198 // setErrorRecorder( xSecurityTemplate );
199 xmlSecErrorsSetCallback(errorCallback);
202 // void setErrorRecorder(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLEncryptionTemplate >& xTemplate)
203 // {
204 // ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XXMLSecurityTemplate >
205 // xSecurityTemplate(xTemplate, ::com::sun::star::uno::UNO_QUERY);
206 // setErrorRecorder( xSecurityTemplate );
207 // }
209 void clearErrorRecorder()
211 xmlSecErrorsSetCallback(NULL);
212 // g_xErrorRecorder = NULL;