2 * Copyright (c) 2014 - 2015 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 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 void OCSPService::Start() {
49 void OCSPService::Stop() {
53 GenericSocketService::ServiceDescriptionVector OCSPService::GetServiceDescription()
55 return ServiceDescriptionVector {
56 {SERVICE_SOCKET_OCSP, "http://tizen.org/privilege/internet", SOCKET_ID_OCSP}
60 bool OCSPService::ProcessOne(
61 const ConnectionID &conn,
65 LogDebug ("process One");
68 if (!info.buffer.Ready())
71 auto &buffer = info.buffer;
74 RawBufferVector chainVector;
75 buffer.Deserialize(commandId, chainVector);
77 RawBuffer response = m_logic->ocspCheck(commandId, chainVector, allowed);
78 m_serviceManager->Write(conn, response);
81 } Catch (MessageBuffer::Exception::Base) {
82 LogError("Broken protocol. Closing socket.");
83 } catch (const std::string &e) {
84 LogError("String exception(" << e << "). Closing socket");
86 LogError("Unknown exception. Closing socket.");
89 m_serviceManager->Close(conn);