1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
package issrg.pba.rbac; |
33 |
|
|
34 |
|
import issrg.pba.Credentials; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@author |
41 |
|
@author |
42 |
|
@author |
43 |
|
@version |
44 |
|
|
45 |
|
|
|
|
| 15.1% |
Uncovered Elements: 45 (53) |
Complexity: 10 |
Complexity Density: 0.69 |
|
46 |
|
public class RoleBasedCredentials extends SubsetCredentials implements Role { |
47 |
|
protected String roleType; |
48 |
|
private Object roleValue; |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
@param |
54 |
|
@param |
55 |
|
|
56 |
|
@return |
57 |
|
|
58 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
0
|
public static RoleBasedCredentials newCredentials(String roleType, String roleValue) {... |
60 |
0
|
return new RoleBasedCredentials(roleType, roleValue); |
61 |
|
} |
62 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
63 |
2919
|
protected RoleBasedCredentials(){}... |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
@param |
69 |
|
|
70 |
|
@param |
71 |
|
|
72 |
|
@throws |
73 |
|
|
74 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
75 |
0
|
public RoleBasedCredentials(String roleType, Object roleValue) {... |
76 |
0
|
if (roleType==null){ |
77 |
0
|
throw new IllegalArgumentException("roleType cannot be null"); |
78 |
|
} |
79 |
0
|
this.roleType=roleType; |
80 |
0
|
this.roleValue=roleValue; |
81 |
|
} |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
@return |
87 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
88 |
816
|
public String getRoleType(){... |
89 |
816
|
return roleType; |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
@return |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
97 |
0
|
public Object getRoleValue(){... |
98 |
0
|
return roleValue; |
99 |
|
} |
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
@return |
105 |
|
|
106 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
107 |
0
|
public Object clone(){... |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
0
|
return new RoleBasedCredentials(roleType, roleValue); |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
@param |
122 |
|
|
123 |
|
@return |
124 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
125 |
0
|
public boolean contains(Credentials c){... |
126 |
0
|
if (!(c instanceof RoleBasedCredentials)){ |
127 |
0
|
return super.contains(c); |
128 |
|
} |
129 |
0
|
RoleBasedCredentials rbc = (RoleBasedCredentials)c; |
130 |
|
|
131 |
0
|
return roleType.intern()==rbc.getRoleType().intern() && |
132 |
|
(roleValue==null || roleValue.equals(rbc.getRoleValue())); |
133 |
|
} |
134 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.5 |
|
135 |
7425
|
public String toString(){... |
136 |
7425
|
Object roleValue = getRoleValue(); |
137 |
|
|
138 |
7425
|
return "role "+roleType+": "+(roleValue==null?"null":roleValue.toString()); |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
@param |
149 |
|
@param |
150 |
|
|
151 |
|
|
152 |
|
@return |
153 |
|
|
154 |
|
|
155 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 8 |
Complexity Density: 0.67 |
|
156 |
0
|
public static java.util.Vector getRoleValues(Credentials creds, String type){... |
157 |
0
|
java.util.Vector result = new java.util.Vector(); |
158 |
|
|
159 |
0
|
if (creds!=null){ |
160 |
|
|
161 |
0
|
if (creds instanceof issrg.pba.rbac.SetOfSubsetsCredentials){ |
162 |
0
|
java.util.Vector v = ((issrg.pba.rbac.SetOfSubsetsCredentials)creds).getValue(); |
163 |
|
|
164 |
0
|
for (int i=v.size(); i-->0;){ |
165 |
0
|
result.addAll(getRoleValues((Credentials)(v.get(i)), type)); |
166 |
|
} |
167 |
|
}else{ |
168 |
0
|
if (creds instanceof RoleBasedCredentials){ |
169 |
0
|
if (type==null || type.equals(((RoleBasedCredentials)creds).getRoleType())){ |
170 |
0
|
result.add(((RoleBasedCredentials)creds).getRoleValue()); |
171 |
|
} |
172 |
0
|
}else if (creds instanceof ExpirableCredentials){ |
173 |
0
|
result.addAll(getRoleValues(((ExpirableCredentials)creds).expirable, type)); |
174 |
|
} |
175 |
|
} |
176 |
|
} |
177 |
|
|
178 |
0
|
return result; |
179 |
|
} |
180 |
|
} |