2 * Copyright (c) 2014 Samsung Electronics Co.
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 ocsp-service.cpp
18 * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
20 * @brief OCSP service implementation.
23 #include <protocols.h>
25 #include <dpl/serialization.h>
26 #include <dpl/log/log.h>
28 #include <ocsp-service.h>
29 #include <ocsp-logic.h>
32 const CKM::InterfaceID SOCKET_ID_OCSP = 0;
33 } // namespace anonymous
37 OCSPService::OCSPService()
38 : m_logic(new OCSPLogic())
41 OCSPService::~OCSPService() {
45 GenericSocketService::ServiceDescriptionVector OCSPService::GetServiceDescription()
47 return ServiceDescriptionVector {
48 {SERVICE_SOCKET_OCSP, "key-manager::api-ocsp", SOCKET_ID_OCSP}
52 bool OCSPService::ProcessOne(
53 const ConnectionID &conn,
56 LogDebug ("process One");
59 if (!info.buffer.Ready())
62 auto &buffer = info.buffer;
65 RawBufferVector chainVector;
66 buffer.Deserialize(commandId, chainVector);
68 RawBuffer response = m_logic->ocspCheck(commandId, chainVector);
69 m_serviceManager->Write(conn, response);
72 } Catch (MessageBuffer::Exception::Base) {
73 LogError("Broken protocol. Closing socket.");
74 } catch (const std::string &e) {
75 LogError("String exception(" << e << "). Closing socket");
77 LogError("Unknown exception. Closing socket.");
80 m_serviceManager->Close(conn);