2 * Copyright (c) 2015 - 2019 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 #ifndef __ODE_SERVER_H__
18 #define __ODE_SERVER_H__
26 #include <klay/file-descriptor.h>
27 #include <klay/rmi/service.h>
33 class SecureEraseServer;
34 class InternalEncryptionServer;
35 class ExternalEncryptionServer;
39 class ServerContext final: public rmi::Service {
44 bool checkPeerPrivilege(const rmi::Credentials& cred, const std::string& privilege);
46 void requestStarted();
47 void requestFinished();
49 void dbusRegisterObjects(GDBusConnection *connection);
54 std::unique_ptr<SecureEraseServer> secureErase;
55 std::unique_ptr<InternalEncryptionServer> internalEncryption;
56 std::unique_ptr<ExternalEncryptionServer> externalEncryption;
57 std::unique_ptr<LuksServer> luks;
58 std::unique_ptr<KeyServer> keys;
60 std::mutex timerMutex;
61 unsigned currentRequests;
65 class RequestLifetime {
67 explicit RequestLifetime(ServerContext& c) : ctx(&c) {
68 ctx->requestStarted();
71 RequestLifetime(RequestLifetime&& other) {
78 ctx->requestFinished();
81 RequestLifetime(const RequestLifetime&) = delete;
82 RequestLifetime& operator=(const RequestLifetime&) = delete;
90 #endif //__ODE_SERVER_H__