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 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
package issrg.pba.rbac; |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
import issrg.pba.rbac.policies.*; |
51 |
|
import java.security.Principal; |
52 |
|
import issrg.utils.repository.AttributeRepository; |
53 |
|
import issrg.pba.PolicyParser; |
54 |
|
import issrg.pba.Subject; |
55 |
|
import issrg.pba.Target; |
56 |
|
import issrg.pba.Action; |
57 |
|
import issrg.pba.PbaException; |
58 |
|
import issrg.pba.CredentialsService; |
59 |
|
import issrg.pba.repository.AuthzTokenRepository; |
60 |
|
|
61 |
|
import issrg.pba.rbac.URLHandler; |
62 |
|
|
63 |
|
import issrg.SAWS.*; |
64 |
|
import issrg.pba.rbac.SAWSLogLevelConstant; |
65 |
|
|
66 |
|
import org.apache.log4j.*; |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
@author |
74 |
|
|
|
|
| 88.4% |
Uncovered Elements: 8 (69) |
Complexity: 13 |
Complexity Density: 0.6 |
|
75 |
|
public abstract class PolicyFinder { |
76 |
|
|
77 |
|
|
78 |
|
protected AuthzTokenRepository Repository=null; |
79 |
|
private Logger logger = Logger.getLogger(PolicyFinder.class); |
80 |
|
|
81 |
|
protected SignatureVerifier sv=null; |
82 |
|
|
83 |
|
|
84 |
|
protected PolicyParser parsedPolicy; |
85 |
|
|
86 |
|
|
87 |
|
protected issrg.pba.AuthzTokenParser tokenParser; |
88 |
|
|
89 |
|
|
90 |
|
protected issrg.pba.rbac.policies.AllocationPolicy allocationPolicy; |
91 |
|
|
92 |
|
|
93 |
|
protected issrg.pba.rbac.policies.AccessPolicy accessPolicy; |
94 |
|
|
95 |
|
protected issrg.pba.rbac.policies.MSoDPolicySet msodPolicySet; |
96 |
|
protected SAWSServer sawsServer = null; |
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
protected int satLevel=0; |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
101 |
25
|
public int getSATLevel(){... |
102 |
25
|
return satLevel; |
103 |
|
} |
104 |
|
protected String soa=null; |
105 |
|
|
106 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
107 |
25
|
public SAWSServer getSAWSServer()... |
108 |
|
{ |
109 |
25
|
return sawsServer; |
110 |
|
} |
111 |
|
|
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
4
|
public String getSOA()... |
114 |
|
{ |
115 |
4
|
return soa; |
116 |
|
} |
117 |
|
|
118 |
|
protected String filepath=null; |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
119 |
4
|
public String getfilepath(){... |
120 |
4
|
return filepath; |
121 |
|
} |
122 |
|
|
123 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
124 |
0
|
public void SAWSCloseLog(){... |
125 |
0
|
if(getSAWSServer()!=null) |
126 |
0
|
getSAWSServer().closeLog(); |
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
protected String policyOID; |
133 |
|
|
134 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
20
|
static {... |
136 |
20
|
issrg.pba.rbac.xmlpolicy.XMLPolicyParser.registerDefaultNodes(); |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
142 |
52
|
public PolicyParser getParsedPolicy(){... |
143 |
52
|
return parsedPolicy; |
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
150 |
1549
|
public AllocationPolicy getAllocationPolicy(){... |
151 |
1549
|
return allocationPolicy; |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
157 |
1359
|
public AccessPolicy getAccessPolicy(){... |
158 |
1359
|
logger.debug("return access control policy"); |
159 |
1359
|
return accessPolicy; |
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
165 |
0
|
public MSoDPolicySet getMSoDPolicy(){... |
166 |
0
|
return msodPolicySet; |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
172 |
1548
|
public AuthzTokenRepository getRepository(){... |
173 |
1548
|
return Repository; |
174 |
|
} |
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
179 |
22
|
public SignatureVerifier getSV(){... |
180 |
22
|
return sv; |
181 |
|
} |
182 |
|
|
183 |
|
|
184 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
185 |
1552
|
public String getPolicyOID(){... |
186 |
1552
|
return policyOID; |
187 |
|
} |
188 |
|
|
189 |
|
private static final String DOCTYPE = "<!DOCTYPE"; |
190 |
|
private static final String SYSTEM = "SYSTEM"; |
191 |
|
private static final String DOCTYPE_C = ">"; |
192 |
|
private static final String COMMENT_O = "<!--"; |
193 |
|
private static final String COMMENT_C = "-->"; |
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
@param |
206 |
|
@return |
207 |
|
|
|
|
| 97.4% |
Uncovered Elements: 1 (38) |
Complexity: 12 |
Complexity Density: 0.43 |
|
208 |
24
|
public static String removeSystemTag(String xml){... |
209 |
24
|
int doctypeIdx=0; |
210 |
24
|
int commentIdx=0; |
211 |
|
|
212 |
24
|
while (true){ |
213 |
42
|
doctypeIdx=xml.indexOf(DOCTYPE, doctypeIdx); |
214 |
42
|
if (doctypeIdx==-1) break; |
215 |
|
|
216 |
18
|
while (true){ |
217 |
37
|
commentIdx=xml.indexOf(COMMENT_O, commentIdx); |
218 |
37
|
int e=xml.length(); |
219 |
|
|
220 |
37
|
if (commentIdx>=0){ |
221 |
36
|
e=xml.indexOf(COMMENT_C, commentIdx+COMMENT_O.length()); |
222 |
|
}else{ |
223 |
1
|
commentIdx=e; |
224 |
|
} |
225 |
|
|
226 |
37
|
if (doctypeIdx<e){ |
227 |
18
|
break; |
228 |
|
} |
229 |
|
|
230 |
19
|
commentIdx=e+COMMENT_C.length(); |
231 |
|
} |
232 |
|
|
233 |
18
|
if (doctypeIdx<commentIdx){ |
234 |
18
|
int e=xml.indexOf(DOCTYPE_C, doctypeIdx); |
235 |
18
|
int s=xml.indexOf(SYSTEM, doctypeIdx); |
236 |
|
|
237 |
18
|
if (e>=0 && s>=0 && s<e && xml.charAt(s-1)<=' ' |
238 |
|
&& xml.charAt(s+SYSTEM.length())<=' '){ |
239 |
|
|
240 |
1
|
char [] chr=new char[xml.length()]; |
241 |
1
|
StringBuffer sb = new StringBuffer(xml); |
242 |
1
|
sb.getChars(0, chr.length, chr, 0); |
243 |
|
|
244 |
1
|
sb=new StringBuffer(new String(chr, 0, s)); |
245 |
1
|
sb.append(new String(chr, e, chr.length-e)); |
246 |
|
|
247 |
1
|
xml=sb.toString(); |
248 |
|
|
249 |
|
} |
250 |
18
|
commentIdx=doctypeIdx; |
251 |
18
|
doctypeIdx++; |
252 |
|
} |
253 |
|
} |
254 |
|
|
255 |
24
|
return xml; |
256 |
|
} |
257 |
|
} |