• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 #ifndef _RIGHT_H
17 #define _RIGHT_H
18 
19 #include <Drm2CommonTypes.h>
20 #include <uvector.h>
21 #include <ustring.h>
22 #include <rights/Constraint.h>
23 #include <rights/OperationPermission.h>
24 using namespace ustl;
25 
26 class Right {
27 public:
28     /**
29      * Constructor for Right.
30      */
31     Right();
32 
33     /**
34      * Destructor for Right.
35      */
36     ~Right();
37 
38     /**
39      * Add the asset id related with right into asset name list.
40      * @param id the id of the asset.
41      */
42     void addAssetID(const string& id);
43 
44     /**
45      * Add a operation permission into right's operation permission list.
46      * @param op a pointer of operation permission.
47      */
48     void addOperationPermission(OperationPermission* op);
49 
50     /**
51      * Get the constraint related with operation type.
52      * @param type the specific operation type.
53      * @return NULL if not found otherwise the constraint pointer.
54      */
55     Constraint* getConstraint(OperationPermission::OPERATION type);
56 
57     /**
58      * Test whether the right has specific operation type or not.
59      * @param type the specific type.
60      * @return true/false to indicate the result.
61      */
62     bool checkPermission(OperationPermission::OPERATION type);
63 
64 public:
65     vector<string> mAssetNameList;
66 
67 PRIVATE:
68     vector<OperationPermission*> mOpList;
69 
70 PRIVATE:
71 
72     /**
73      * Disable the assignment between rights.
74      */
75     Right& operator=(const Right& right);
76 
77     /**
78      * Disable copy constructor.
79      */
80     Right(const Right& right);
81    };
82 
83 #endif
84