|
1 |
/**
|
|
2 |
* '$RCSfile$'
|
|
3 |
* Copyright: 2004 Regents of the University of California and the
|
|
4 |
* National Center for Ecological Analysis and Synthesis
|
|
5 |
* Purpose: To test the Access Controls in metacat by JUnit
|
|
6 |
*
|
|
7 |
* '$Author: daigle $'
|
|
8 |
* '$Date: 2009-08-14 14:26:08 -0700 (Fri, 14 Aug 2009) $'
|
|
9 |
* '$Revision: 5027 $'
|
|
10 |
*
|
|
11 |
* This program is free software; you can redistribute it and/or modify
|
|
12 |
* it under the terms of the GNU General Public License as published by
|
|
13 |
* the Free Software Foundation; either version 2 of the License, or
|
|
14 |
* (at your option) any later version.
|
|
15 |
*
|
|
16 |
* This program is distributed in the hope that it will be useful,
|
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19 |
* GNU General Public License for more details.
|
|
20 |
*
|
|
21 |
* You should have received a copy of the GNU General Public License
|
|
22 |
* along with this program; if not, write to the Free Software
|
|
23 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
24 |
*/
|
|
25 |
|
|
26 |
package edu.ucsb.nceas.metacattest;
|
|
27 |
|
|
28 |
import java.io.IOException;
|
|
29 |
import java.io.StringReader;
|
|
30 |
import java.util.Vector;
|
|
31 |
|
|
32 |
import junit.framework.Test;
|
|
33 |
import junit.framework.TestSuite;
|
|
34 |
|
|
35 |
import edu.ucsb.nceas.MCTestCase;
|
|
36 |
import edu.ucsb.nceas.metacat.DocInfoHandler;
|
|
37 |
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlException;
|
|
38 |
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlInterface;
|
|
39 |
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlList;
|
|
40 |
import edu.ucsb.nceas.metacat.accesscontrol.XMLAccessDAO;
|
|
41 |
import edu.ucsb.nceas.metacat.client.InsufficientKarmaException;
|
|
42 |
import edu.ucsb.nceas.metacat.client.MetacatAuthException;
|
|
43 |
import edu.ucsb.nceas.metacat.client.MetacatException;
|
|
44 |
import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException;
|
|
45 |
import edu.ucsb.nceas.metacat.properties.PropertyService;
|
|
46 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
|
|
47 |
|
|
48 |
import org.xml.sax.ContentHandler;
|
|
49 |
import org.xml.sax.ErrorHandler;
|
|
50 |
import org.xml.sax.InputSource;
|
|
51 |
import org.xml.sax.SAXException;
|
|
52 |
import org.xml.sax.XMLReader;
|
|
53 |
import org.xml.sax.helpers.XMLReaderFactory;
|
|
54 |
|
|
55 |
|
|
56 |
/**
|
|
57 |
* A JUnit test for testing Access Control API in Metacat. Note that this is different
|
|
58 |
* than the Access Control test. That test is more concerned with making sure different
|
|
59 |
* combinations of access rules act appropriately. This test is more concerned with the
|
|
60 |
* funtioning of the API itself.
|
|
61 |
*/
|
|
62 |
public class AccessAPITest extends MCTestCase {
|
|
63 |
|
|
64 |
private String testdatadir = "test/clienttestfiles/";
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Constructor to build the test
|
|
68 |
*
|
|
69 |
* @param name
|
|
70 |
* the name of the test method
|
|
71 |
*/
|
|
72 |
public AccessAPITest(String name) {
|
|
73 |
super(name);
|
|
74 |
}
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Establish a testing framework by initializing appropriate objects
|
|
78 |
*/
|
|
79 |
public void setUp() throws Exception {
|
|
80 |
metacatConnectionNeeded = true;
|
|
81 |
super.setUp();
|
|
82 |
}
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Release any objects after tests are complete
|
|
86 |
*/
|
|
87 |
public void tearDown() {
|
|
88 |
}
|
|
89 |
|
|
90 |
/**
|
|
91 |
* Create a suite of tests to be run together
|
|
92 |
*/
|
|
93 |
public static Test suite() {
|
|
94 |
TestSuite suite = new TestSuite();
|
|
95 |
suite.addTest(new AccessAPITest("initialize"));
|
|
96 |
// Test basic functions
|
|
97 |
suite.addTest(new AccessAPITest("testSetSingleAccess"));
|
|
98 |
suite.addTest(new AccessAPITest("testSetBlockAccess"));
|
|
99 |
|
|
100 |
return suite;
|
|
101 |
}
|
|
102 |
|
|
103 |
/**
|
|
104 |
* Run an initial test that always passes to check that the test harness is
|
|
105 |
* working.
|
|
106 |
*/
|
|
107 |
public void initialize() {
|
|
108 |
assertTrue(1 == 1);
|
|
109 |
}
|
|
110 |
|
|
111 |
/**
|
|
112 |
* Test adding a single access record.
|
|
113 |
*/
|
|
114 |
public void testSetSingleAccess() {
|
|
115 |
String principal = null;
|
|
116 |
Vector<XMLAccessDAO> accessDAOList = null;
|
|
117 |
Vector<XMLAccessDAO> realAccessDAOList = null;
|
|
118 |
XMLAccessDAO accessDAO = null;
|
|
119 |
String accessXML = null;
|
|
120 |
|
|
121 |
try {
|
|
122 |
debug("AccessAPITest.testSetSingleAccess Running");
|
|
123 |
|
|
124 |
m.login(username, password);
|
|
125 |
|
|
126 |
// insert a document for us to test with
|
|
127 |
String docId = generateDocumentId() + ".1";
|
|
128 |
String testDoc = getTestDocFromFile(testdatadir + "accessBlockTestFile1.xml");
|
|
129 |
// debug("test doc: " + testDoc);
|
|
130 |
insertDocumentId(docId, testDoc, SUCCESS, false);
|
|
131 |
|
|
132 |
// test inserting a single access record with allowFirst permission order and allow read
|
|
133 |
// access. We expect this to succeed.
|
|
134 |
debug("AccessAPITest.testSetSingleAccess - Test 1, add user allowFirst allow read access");
|
|
135 |
principal = "uid=test30,o=NCEAS,dc=ecoinformatics,dc=org";
|
|
136 |
setSingleAccess(docId, principal,
|
|
137 |
Integer.toString(AccessControlInterface.READ),
|
|
138 |
AccessControlInterface.ALLOW,
|
|
139 |
AccessControlInterface.ALLOWFIRST,
|
|
140 |
true);
|
|
141 |
accessDAOList = new Vector<XMLAccessDAO>();
|
|
142 |
accessDAO = new XMLAccessDAO();
|
|
143 |
accessDAO.setDocId(docId);
|
|
144 |
accessDAO.setPrincipalName(principal);
|
|
145 |
accessDAO.setPermission(new Long(AccessControlInterface.READ));
|
|
146 |
accessDAO.setPermType(AccessControlInterface.ALLOW);
|
|
147 |
accessDAO.setPermOrder(AccessControlInterface.ALLOWFIRST);
|
|
148 |
accessDAOList.add(accessDAO);
|
|
149 |
|
|
150 |
accessXML = m.getAccessControl(docId);
|
|
151 |
realAccessDAOList = getAccessDAOList(docId, accessXML);
|
|
152 |
compareAccessDAOs(realAccessDAOList, accessDAOList, false);
|
|
153 |
|
|
154 |
// test inserting a single access record with denyFirst permission order and allow read
|
|
155 |
// access. We expect this to fail since a single doc cannot have multiple permission orders.
|
|
156 |
debug("AccessAPITest.testSetSingleAccess - Test 2, add user denyFirst allow read/write access");
|
|
157 |
principal = "uid=test31,o=NCEAS,dc=ecoinformatics,dc=org";
|
|
158 |
setSingleAccess(docId, principal,
|
|
159 |
Integer.toString(AccessControlInterface.READ | AccessControlInterface.WRITE),
|
|
160 |
AccessControlInterface.ALLOW,
|
|
161 |
AccessControlInterface.DENYFIRST,
|
|
162 |
false);
|
|
163 |
|
|
164 |
|
|
165 |
} catch (AccessControlException ace) {
|
|
166 |
fail("AccessAPITest.testSetSingleAccess - Access Control error: " + ace.getMessage());
|
|
167 |
} catch (IOException ioe) {
|
|
168 |
fail("AccessAPITest.testSetSingleAccess - I/O error: " + ioe.getMessage());
|
|
169 |
} catch (MetacatAuthException mae) {
|
|
170 |
fail("AccessAPITest.testSetSingleAccess - Metacat authentication error: " + mae.getMessage());
|
|
171 |
} catch (MetacatException me) {
|
|
172 |
fail("AccessAPITest.testSetSingleAccess - Metacat error: " + me.getMessage());
|
|
173 |
} catch (InsufficientKarmaException ike) {
|
|
174 |
fail("AccessAPITest.testSetSingleAccess - Insufficient karma error: " + ike.getMessage());
|
|
175 |
} catch (MetacatInaccessibleException mie) {
|
|
176 |
fail("AccessAPITest.testSetSingleAccess - Metacat Inaccessible Error: " + mie.getMessage());
|
|
177 |
}
|
|
178 |
}
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Test setting a block of access for a document
|
|
182 |
*/
|
|
183 |
public void testSetBlockAccess() {
|
|
184 |
String accessBlockXML = null;
|
|
185 |
String accessXML = null;
|
|
186 |
Vector<XMLAccessDAO> realAccessDAOList = null;
|
|
187 |
Vector<XMLAccessDAO> accessBlockDAOList = null;
|
|
188 |
|
|
189 |
try {
|
|
190 |
debug("AccessAPITest.testSetBlockAccess - Running");
|
|
191 |
|
|
192 |
m.login(username, password);
|
|
193 |
|
|
194 |
String docId = generateDocumentId() + ".1";
|
|
195 |
String testDoc = getTestDocFromFile(testdatadir + "accessBlockTestFile1.xml");
|
|
196 |
// debug("test doc: " + testDoc);
|
|
197 |
insertDocumentId(docId, testDoc, SUCCESS, false);
|
|
198 |
|
|
199 |
debug("AccessAPITest.testSetBlockAccess - Test 1 using accessBlock1.xml");
|
|
200 |
accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock1.xml");
|
|
201 |
setBlockAccess(docId, accessBlockXML, true);
|
|
202 |
accessXML = m.getAccessControl(docId);
|
|
203 |
realAccessDAOList = getAccessDAOList(docId, accessXML);
|
|
204 |
accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
|
|
205 |
debugAccessDAOList(accessBlockDAOList);
|
|
206 |
compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
|
|
207 |
|
|
208 |
debug("AccessAPITest.testSetBlockAccess - Test 2 using accessBlock2.xml");
|
|
209 |
accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock2.xml");
|
|
210 |
setBlockAccess(docId, accessBlockXML, true);
|
|
211 |
accessXML = m.getAccessControl(docId);
|
|
212 |
realAccessDAOList = getAccessDAOList(docId, accessXML);
|
|
213 |
accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
|
|
214 |
debugAccessDAOList(accessBlockDAOList);
|
|
215 |
compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
|
|
216 |
|
|
217 |
debug("AccessAPITest.testSetBlockAccess - Test 3 using accessBlock3.xml");
|
|
218 |
accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock3.xml");
|
|
219 |
setBlockAccess(docId, accessBlockXML, true);
|
|
220 |
accessXML = m.getAccessControl(docId);
|
|
221 |
realAccessDAOList = getAccessDAOList(docId, accessXML);
|
|
222 |
accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
|
|
223 |
debugAccessDAOList(accessBlockDAOList);
|
|
224 |
compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
|
|
225 |
|
|
226 |
debug("AccessAPITest.testSetBlockAccess - Test 4 using accessBlock4.xml");
|
|
227 |
accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock4.xml");
|
|
228 |
setBlockAccess(docId, accessBlockXML, true);
|
|
229 |
accessXML = m.getAccessControl(docId);
|
|
230 |
realAccessDAOList = getAccessDAOList(docId, accessXML);
|
|
231 |
accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
|
|
232 |
debugAccessDAOList(accessBlockDAOList);
|
|
233 |
compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
|
|
234 |
|
|
235 |
debug("AccessAPITest.testSetBlockAccess - Test 5 using accessBlock5.xml");
|
|
236 |
accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock5.xml");
|
|
237 |
setBlockAccess(docId, accessBlockXML, true);
|
|
238 |
accessXML = m.getAccessControl(docId);
|
|
239 |
realAccessDAOList = getAccessDAOList(docId, accessXML);
|
|
240 |
accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
|
|
241 |
debugAccessDAOList(accessBlockDAOList);
|
|
242 |
compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
|
|
243 |
|
|
244 |
debug("AccessAPITest.testSetBlockAccess - Test 6 using accessBlock6.xml");
|
|
245 |
accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock6.xml");
|
|
246 |
setBlockAccess(docId, accessBlockXML, true);
|
|
247 |
accessXML = m.getAccessControl(docId);
|
|
248 |
realAccessDAOList = getAccessDAOList(docId, accessXML);
|
|
249 |
accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
|
|
250 |
debugAccessDAOList(accessBlockDAOList);
|
|
251 |
compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
|
|
252 |
|
|
253 |
debug("AccessAPITest.testSetBlockAccess - Test 7 using accessBlock7.xml");
|
|
254 |
accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock7.xml");
|
|
255 |
setBlockAccess(docId, accessBlockXML, true);
|
|
256 |
accessXML = m.getAccessControl(docId);
|
|
257 |
realAccessDAOList = getAccessDAOList(docId, accessXML);
|
|
258 |
accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
|
|
259 |
debugAccessDAOList(accessBlockDAOList);
|
|
260 |
compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
|
|
261 |
|
|
262 |
debug("AccessAPITest.testSetBlockAccess - Test 8 using accessBlock8.xml");
|
|
263 |
accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock8.xml");
|
|
264 |
setBlockAccess(docId, accessBlockXML, true);
|
|
265 |
accessXML = m.getAccessControl(docId);
|
|
266 |
realAccessDAOList = getAccessDAOList(docId, accessXML);
|
|
267 |
accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
|
|
268 |
debugAccessDAOList(accessBlockDAOList);
|
|
269 |
compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
|
|
270 |
|
|
271 |
debug("AccessAPITest.testSetBlockAccess - Test 9 using accessBlock9.xml");
|
|
272 |
accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock9.xml");
|
|
273 |
setBlockAccess(docId, accessBlockXML, true);
|
|
274 |
accessXML = m.getAccessControl(docId);
|
|
275 |
realAccessDAOList = getAccessDAOList(docId, accessXML);
|
|
276 |
accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
|
|
277 |
debugAccessDAOList(accessBlockDAOList);
|
|
278 |
compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
|
|
279 |
|
|
280 |
} catch (AccessControlException ace) {
|
|
281 |
fail("AccessAPITest.testSetBlockAccess - Access Control error: " + ace.getMessage());
|
|
282 |
} catch (IOException ioe) {
|
|
283 |
fail("AccessAPITest.testSetBlockAccess - I/O error: " + ioe.getMessage());
|
|
284 |
} catch (MetacatAuthException mae) {
|
|
285 |
fail("AccessAPITest.testSetBlockAccess - Metacat authentication error: " + mae.getMessage());
|
|
286 |
} catch (MetacatException me) {
|
|
287 |
fail("AccessAPITest.testSetBlockAccess - Metacat error: " + me.getMessage());
|
|
288 |
} catch (InsufficientKarmaException ike) {
|
|
289 |
fail("AccessAPITest.testSetBlockAccess - Metacat error: " + ike.getMessage());
|
|
290 |
} catch (MetacatInaccessibleException mie) {
|
|
291 |
fail("AccessAPITest.testSetBlockAccess - Metacat Inaccessible Error: " + mie.getMessage());
|
|
292 |
}
|
|
293 |
}
|
|
294 |
|
|
295 |
/**
|
|
296 |
* Update a document in metacat. The expected result is passed as result
|
|
297 |
*/
|
|
298 |
private String setSingleAccess(String docId, String principal, String permission,
|
|
299 |
String permType, String permOrder, boolean successExpected) {
|
|
300 |
debug("AccessAPITest.setSingleAccess - docid: " + docId + ", prinicpal: " +
|
|
301 |
principal + ", permission: " + permission + ", permType: " + permType +
|
|
302 |
", permOrder: " + permOrder + ", errorExpected: " + successExpected);
|
|
303 |
String response = null;
|
|
304 |
try {
|
|
305 |
response = m.setAccess(docId, principal, permission, permType, permOrder);
|
|
306 |
|
|
307 |
debug("AccessAPITest.setSingleAccess - response: " + response);
|
|
308 |
|
|
309 |
if (successExpected) {
|
|
310 |
assertTrue(response, (response.indexOf("<success>") != -1));
|
|
311 |
} else {
|
|
312 |
assertTrue(response, (response.indexOf("<success>") == -1));
|
|
313 |
}
|
|
314 |
} catch (MetacatInaccessibleException mie) {
|
|
315 |
fail("AccessAPITest.setSingleAccess - Metacat inaccessible: " + mie.getMessage());
|
|
316 |
} catch (InsufficientKarmaException ike) {
|
|
317 |
|
|
318 |
} catch (MetacatException me) {
|
|
319 |
if (successExpected) {
|
|
320 |
fail("AccessAPITest.setSingleAccess - Metacat error: " + me.getMessage());
|
|
321 |
} else {
|
|
322 |
debug("AccessAPITest.setSingleAccess - Expected Metacat error: " + me.getMessage());
|
|
323 |
}
|
|
324 |
} catch (Exception e) {
|
|
325 |
fail("AccessAPITest.setSingleAccess - General error: " + e.getMessage());
|
|
326 |
}
|
|
327 |
|
|
328 |
return response;
|
|
329 |
}
|
|
330 |
|
|
331 |
/**
|
|
332 |
* Update a document in metacat. The expected result is passed as result
|
|
333 |
*/
|
|
334 |
private String setBlockAccess(String docId, String accessBlockXML, boolean successExpected) {
|
|
335 |
debug("AccessAPITest.setBlockAccess - docid: " + docId + ", accessBlockXML: " +
|
|
336 |
accessBlockXML + ", errorExpected: " + successExpected);
|
|
337 |
String response = null;
|
|
338 |
try {
|
|
339 |
response = m.setAccess(docId, accessBlockXML);
|
|
340 |
|
|
341 |
debug("AccessAPITest.setBlockAccess - response: " + response);
|
|
342 |
|
|
343 |
if (successExpected) {
|
|
344 |
assertTrue(response, (response.indexOf("<success>") != -1));
|
|
345 |
} else {
|
|
346 |
assertTrue(response, (response.indexOf("<success>") == -1));
|
|
347 |
}
|
|
348 |
} catch (MetacatInaccessibleException mie) {
|
|
349 |
fail("AccessAPITest.setBlockAccess - Metacat inaccessible: " + mie.getMessage());
|
|
350 |
} catch (InsufficientKarmaException ike) {
|
|
351 |
|
|
352 |
} catch (MetacatException me) {
|
|
353 |
if (successExpected) {
|
|
354 |
fail("AccessAPITest.setBlockAccess - Metacat error: " + me.getMessage());
|
|
355 |
} else {
|
|
356 |
debug("AccessAPITest.setBlockAccess - Expected Metacat error: " + me.getMessage());
|
|
357 |
}
|
|
358 |
} catch (Exception e) {
|
|
359 |
fail("AccessAPITest.setBlockAccess - General error: " + e.getMessage());
|
|
360 |
}
|
|
361 |
|
|
362 |
return response;
|
|
363 |
}
|
|
364 |
|
|
365 |
private void compareAccessDAOs(Vector<XMLAccessDAO> mainAccessDAOList,
|
|
366 |
Vector<XMLAccessDAO> subAccessDAOList, boolean exactMatch) {
|
|
367 |
|
|
368 |
|
|
369 |
//debug("test access DAO: ");
|
|
370 |
//debugAccessDAOList(subAccessDAOList);
|
|
371 |
//debug("\naccess DAOs from database: ");
|
|
372 |
//debugAccessDAOList(mainAccessDAOList);
|
|
373 |
|
|
374 |
if (exactMatch) {
|
|
375 |
if (mainAccessDAOList.size() != subAccessDAOList.size()) {
|
|
376 |
fail("AccessAPITest.compareAccessDAOs - access DAO list sizes do not match. " +
|
|
377 |
"Primary DAO list size: " + mainAccessDAOList.size() +
|
|
378 |
", secondary DAO list size: " + subAccessDAOList.size());
|
|
379 |
}
|
|
380 |
}
|
|
381 |
|
|
382 |
for (XMLAccessDAO subAccessDAO : subAccessDAOList) {
|
|
383 |
boolean matchFound = false;
|
|
384 |
for (XMLAccessDAO mainAccessDAO : mainAccessDAOList) {
|
|
385 |
if (subAccessDAO.getDocId().equals(mainAccessDAO.getDocId()) &&
|
|
386 |
subAccessDAO.getPermOrder().equals(mainAccessDAO.getPermOrder()) &&
|
|
387 |
subAccessDAO.getPermType().equals(mainAccessDAO.getPermType()) &&
|
|
388 |
subAccessDAO.getPrincipalName().equals(mainAccessDAO.getPrincipalName()) &&
|
|
389 |
subAccessDAO.getPermission().equals(mainAccessDAO.getPermission())) {
|
|
390 |
matchFound = true;
|
|
391 |
break;
|
|
392 |
}
|
|
393 |
}
|
|
394 |
|
|
395 |
if (!matchFound) {
|
|
396 |
fail("AccessAPITest.compareAccessDAOs - secondary access DAO does not exist in " +
|
|
397 |
"primary DAO list");
|
|
398 |
}
|
|
399 |
}
|
|
400 |
}
|
|
401 |
|
|
402 |
private Vector<XMLAccessDAO> getAccessDAOList(String docId, String accessXML)
|
|
403 |
throws AccessControlException {
|
|
404 |
|
|
405 |
Vector<XMLAccessDAO> accessControlList = null;
|
|
406 |
XMLReader parser = null;
|
|
407 |
DocInfoHandler docInfoHandler = new DocInfoHandler(docId);
|
|
408 |
ContentHandler chandler = docInfoHandler;
|
|
409 |
|
|
410 |
try {
|
|
411 |
// Get an instance of the parser
|
|
412 |
String parserName = PropertyService.getProperty("xml.saxparser");
|
|
413 |
parser = XMLReaderFactory.createXMLReader(parserName);
|
|
414 |
|
|
415 |
// Turn off validation
|
|
416 |
parser.setFeature("http://xml.org/sax/features/validation", false);
|
|
417 |
parser.setContentHandler((ContentHandler)chandler);
|
|
418 |
parser.setErrorHandler((ErrorHandler)chandler);
|
|
419 |
|
|
420 |
parser.parse(new InputSource(new StringReader(accessXML)));
|
|
421 |
|
|
422 |
accessControlList = docInfoHandler.getAccessControlList();
|
|
423 |
} catch (PropertyNotFoundException pnfe) {
|
|
424 |
throw new AccessControlException("AccessAPITest.getAccessDAOList - " +
|
|
425 |
"property error: " + pnfe.getMessage());
|
|
426 |
} catch (IOException ioe) {
|
|
427 |
throw new AccessControlException("AccessAPITest.getAccessDAOList - " +
|
|
428 |
"I/O error: " + ioe.getMessage());
|
|
429 |
} catch (SAXException se) {
|
|
430 |
throw new AccessControlException("AccessAPITest.getAccessDAOList - " +
|
|
431 |
"SAX error: " + se.getMessage());
|
|
432 |
}
|
|
433 |
|
|
434 |
return accessControlList;
|
|
435 |
}
|
|
436 |
|
|
437 |
private void debugAccessDAOList(Vector<XMLAccessDAO> accessDAOList) {
|
|
438 |
for (XMLAccessDAO xmlAccessDAO : accessDAOList) {
|
|
439 |
debug("Doc ID: " + xmlAccessDAO.getDocId());
|
|
440 |
debug("Perm Order: " + xmlAccessDAO.getPermOrder());
|
|
441 |
debug("Perm Type: " + xmlAccessDAO.getPermType());
|
|
442 |
debug("Principal " + xmlAccessDAO.getPrincipalName());
|
|
443 |
String permissionStr =
|
|
444 |
AccessControlList.txtValue(xmlAccessDAO.getPermission().intValue());
|
|
445 |
debug("Permission " + permissionStr);
|
|
446 |
}
|
|
447 |
}
|
|
448 |
}
|
0 |
449 |
|
Add access api test and supporting files