2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
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 ACCESSCONDITION_H_
18 #define ACCESSCONDITION_H_
23 #include "ByteArray.h"
27 namespace smartcard_service_api
34 vector<pair<ByteArray, ByteArray> > listFilters;
37 AccessRule() : apduRule(true), nfcRule(true) {}
39 inline void setAPDUAccessRule(bool rule) { apduRule = rule; }
40 inline void setNFCAccessRule(bool rule) { nfcRule = rule; }
42 void addAPDUAccessRule(const ByteArray &apdu,
43 const ByteArray &mask);
45 inline bool isAuthorizedAccess(void) const
47 return (apduRule || (listFilters.size() > 0));
49 bool isAuthorizedAPDUAccess(const ByteArray &command) const;
50 bool isAuthorizedNFCAccess(void) const;
52 friend class AccessCondition;
60 map<ByteArray, AccessRule> mapRules;
63 AccessCondition() : permission(false) {}
65 inline void setAID(const ByteArray &aid) { this->aid = aid; }
66 inline const ByteArray getAID() const { return aid; }
67 inline void setAccessCondition(bool rule) { permission = rule; }
68 void addAccessRule(const ByteArray &hash);
70 void setAPDUAccessRule(const ByteArray &certHash, bool rule);
71 void addAPDUAccessRule(const ByteArray &certHash,
72 const ByteArray &apdu, const ByteArray &mask);
73 void addAPDUAccessRule(const ByteArray &certHash,
74 const ByteArray &rule);
76 void setNFCAccessRule(const ByteArray &certHash, bool rule);
78 bool isAuthorizedAccess(const ByteArray &certHash) const;
79 bool isAuthorizedAPDUAccess(const ByteArray &certHash,
80 const ByteArray &command) const;
81 bool isAuthorizedNFCAccess(const ByteArray &certHash) const;
83 AccessRule *getAccessRule(const ByteArray &certHash);
84 const AccessRule *getAccessRule(const ByteArray &certHash) const;
86 friend class AccessControlList;
89 } /* namespace smartcard_service_api */
90 #endif /* ACCESSCONDITION_H_ */