2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file XmlSecAdapter.h
18 * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
22 #ifndef _XMLSECADAPTER_H_
23 #define _XMLSECADAPTER_H_
25 #include <xmlsec/keysmngr.h>
27 #include <dpl/exception.h>
28 #include <dpl/noncopyable.h>
29 #include <dpl/singleton.h>
31 #include "Certificate.h"
32 #include "ValidatorCommon.h"
34 namespace ValidationCore {
35 class XmlSec : public DPL::Noncopyable
41 /* You _must_ set one of the value: certificatePath or certificate. */
44 allowBrokenChain(false),
45 errorBrokenChain(false)
50 * Absolute path to signature file.
52 std::string signatureFile;
54 * Direcotory with signed data.
55 * If you leave it empty xmlsec will use directory extracted
58 std::string workingDirectory;
60 * Path to trusted certificate.
62 std::string certificatePath;
64 * Trusted certificate. In most cases it should be Root CA certificate.
66 CertificatePtr certificatePtr;
69 * 0 - uses current time.
71 time_t validationTime;
74 * If true, signature validation will not be interrupted by chain error.
75 * If true and chain is broken then the value errorBrokenChain will be
78 bool allowBrokenChain;
81 * This will be set if chain is incomplete or broken.
83 bool errorBrokenChain;
86 * Reference checked by xmlsec
88 ReferenceSet referenceSet;
94 ERROR_INVALID_SIGNATURE
100 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
101 DECLARE_EXCEPTION_TYPE(Base, InternalError)
105 * Context - input/output param.
107 Result validate(XmlSecContext *context);
112 void deinitialize(void);
114 void loadDERCertificateMemory(XmlSecContext *context,
115 xmlSecKeysMngrPtr mngr);
116 void loadPEMCertificateFile(XmlSecContext *context,
117 xmlSecKeysMngrPtr mngr);
118 Result validateFile(XmlSecContext *context,
119 xmlSecKeysMngrPtr mngr);
123 static std::string s_prefixPath;
124 static int fileMatchCallback(const char *filename);
125 static void* fileOpenCallback(const char *filename);
126 static int fileReadCallback(void *context,
129 static int fileCloseCallback(void *context);
130 static void fileExtractPrefix(XmlSecContext *context);
133 typedef DPL::Singleton<XmlSec> XmlSecSingleton;
134 } // namespace ValidationCore
135 #endif // _XMLSECVERIFICATOR_H_