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_
20 /* standard library header */
24 /* SLP library header */
27 #include "ByteArray.h"
31 namespace smartcard_service_api
38 vector<pair<ByteArray, ByteArray> > listFilters;
41 AccessRule() : apduRule(true), nfcRule(true) {}
43 inline void setAPDUAccessRule(bool rule) { apduRule = rule; }
44 inline void setNFCAccessRule(bool rule) { nfcRule = rule; }
46 void addAPDUAccessRule(const ByteArray &apdu,
47 const ByteArray &mask);
49 inline bool isAuthorizedAccess(void) const
51 return (apduRule || (listFilters.size() > 0));
53 bool isAuthorizedAPDUAccess(const ByteArray &command) const;
54 bool isAuthorizedNFCAccess(void) const;
56 friend class AccessCondition;
64 map<ByteArray, AccessRule> mapRules;
67 AccessCondition() : permission(false) {}
69 inline void setAID(const ByteArray &aid) { this->aid = aid; }
70 inline const ByteArray getAID() const { return aid; }
71 inline void setAccessCondition(bool rule) { permission = rule; }
72 void addAccessRule(const ByteArray &hash);
74 void setAPDUAccessRule(const ByteArray &certHash, bool rule);
75 void addAPDUAccessRule(const ByteArray &certHash,
76 const ByteArray &apdu, const ByteArray &mask);
77 void addAPDUAccessRule(const ByteArray &certHash,
78 const ByteArray &rule);
80 void setNFCAccessRule(const ByteArray &certHash, bool rule);
82 bool isAuthorizedAccess(const ByteArray &certHash) const;
83 bool isAuthorizedAPDUAccess(const ByteArray &certHash,
84 const ByteArray &command) const;
85 bool isAuthorizedNFCAccess(const ByteArray &certHash) const;
87 AccessRule *getAccessRule(const ByteArray &certHash);
88 const AccessRule *getAccessRule(const ByteArray &certHash) const;
90 friend class AccessControlList;
93 } /* namespace smartcard_service_api */
94 #endif /* ACCESSCONDITION_H_ */