Project

General

Profile

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
 * A JUnit test for testing Access Control API in Metacat.  Note that this is different
57
 * than the Access Control test.  That test is more concerned with making sure different
58
 * combinations of access rules act appropriately.  This test is more concerned with the
59
 * funtioning of the API itself.
60
 */
61
public class AccessAPITest extends MCTestCase {
62

    
63
	/**
64
	 * Constructor to build the test
65
	 * 
66
	 * @param name
67
	 *            the name of the test method
68
	 */
69
	public AccessAPITest(String name) {
70
		super(name);
71
	}
72

    
73
	/**
74
	 * Establish a testing framework by initializing appropriate objects
75
	 */
76
	public void setUp() throws Exception {
77
		metacatConnectionNeeded = true;
78
		super.setUp();
79
	}
80

    
81
	/**
82
	 * Release any objects after tests are complete
83
	 */
84
	public void tearDown() {
85
	}
86

    
87
	/**
88
	 * Create a suite of tests to be run together
89
	 */
90
	public static Test suite() {
91
		TestSuite suite = new TestSuite();
92
		suite.addTest(new AccessAPITest("initialize"));
93
		// Test basic functions
94
		suite.addTest(new AccessAPITest("testSetSingleAccess"));
95
		suite.addTest(new AccessAPITest("testSetBlockAccess"));
96

    
97
		return suite;
98
	}
99

    
100
	/**
101
	 * Run an initial test that always passes to check that the test harness is
102
	 * working.
103
	 */
104
	public void initialize() {
105
		assertTrue(1 == 1);
106
	}
107

    
108
	/**
109
	 * Test adding access records for single principals.
110
	 */
111
	public void testSetSingleAccess() {
112
		String principal = null;
113
		Vector<XMLAccessDAO> accessDAOList = null;
114
		Vector<XMLAccessDAO> realAccessDAOList = null;
115
		XMLAccessDAO accessDAO = null;
116
		String accessXML = null;
117
	
118
		try {
119
			debug("AccessAPITest.testSetSingleAccess Running");
120
			
121
			m.login(username, password);
122

    
123
			// insert a document for us to test with
124
			String docId = generateDocumentId() + ".1";
125
			String testDoc = getTestDocFromFile(testdatadir + "accessBlockTestFile1.xml");
126
			// debug("test doc: " + testDoc);
127
			insertDocumentId(docId, testDoc, SUCCESS, false);
128
					
129
			// test inserting a single access record with allowFirst permission order and allow read 
130
			// access.  We expect this to succeed.
131
			debug("AccessAPITest.testSetSingleAccess - Test 1, add user allowFirst allow read access");
132
			principal = "uid=test30,o=NCEAS,dc=ecoinformatics,dc=org";
133
			setSingleAccess(docId, principal, 
134
					"READ", 
135
					AccessControlInterface.ALLOW, 
136
					AccessControlInterface.ALLOWFIRST,
137
					true);
138
			accessDAOList = new Vector<XMLAccessDAO>();
139
			accessDAO = new XMLAccessDAO();
140
			accessDAO.setDocId(docId);
141
			accessDAO.setPrincipalName(principal);
142
			accessDAO.setPermission(new Long(AccessControlInterface.READ));
143
			accessDAO.setPermType(AccessControlInterface.ALLOW);
144
			accessDAO.setPermOrder(AccessControlInterface.ALLOWFIRST);
145
			accessDAOList.add(accessDAO);
146
			
147
			// get the access control for this doc id from metacat and make sure this
148
			// access record is in that list.
149
			accessXML = m.getAccessControl(docId);
150
			realAccessDAOList = getAccessDAOList(docId, accessXML);	
151
			compareAccessDAOs(realAccessDAOList, accessDAOList, false);	
152
			
153
			// test inserting a single access record with denyFirst permission order and allow read 
154
			// access.  We expect this to fail since a single doc cannot have multiple permission orders.
155
			debug("AccessAPITest.testSetSingleAccess - Test 2, add user denyFirst allow read/write access");
156
			principal = "uid=test31,o=NCEAS,dc=ecoinformatics,dc=org";
157
			setSingleAccess(docId, principal, 
158
					Integer.toString(AccessControlInterface.READ | AccessControlInterface.WRITE), 
159
					AccessControlInterface.ALLOW, 
160
					AccessControlInterface.DENYFIRST,
161
					false);
162

    
163

    
164
		} catch (AccessControlException ace) {
165
			fail("AccessAPITest.testSetSingleAccess - Access Control error: " + ace.getMessage());
166
		} catch (IOException ioe) {
167
			fail("AccessAPITest.testSetSingleAccess - I/O error: " + ioe.getMessage());
168
		} catch (MetacatAuthException mae) {
169
			fail("AccessAPITest.testSetSingleAccess - Metacat authentication error: " + mae.getMessage()); 
170
		} catch (MetacatException me) {
171
			fail("AccessAPITest.testSetSingleAccess - Metacat error: " + me.getMessage()); 
172
		} catch (InsufficientKarmaException ike) {
173
			fail("AccessAPITest.testSetSingleAccess - Insufficient karma error: " + ike.getMessage()); 
174
		} catch (MetacatInaccessibleException mie) {
175
			fail("AccessAPITest.testSetSingleAccess - Metacat Inaccessible Error: " + mie.getMessage());
176
		} 
177
	}
178
	
179
	/**
180
	 * Test setting a block of access for a document.  Each call should replace the access for that
181
	 * 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
			// log in
193
			m.login(username, password);
194

    
195
			// insert a document for us to test with
196
			String docId = generateDocumentId() + ".1";
197
			String testDoc = getTestDocFromFile(testdatadir + "accessBlockTestFile1.xml");
198
			// debug("test doc: " + testDoc);
199
			insertDocumentId(docId, testDoc, SUCCESS, false);
200
			
201
			// replace access for doc using the access section in accessBlock1.xml, 
202
			// then test that the access was updated and that is the only access
203
			// for the doc
204
			debug("AccessAPITest.testSetBlockAccess - Test 1 using accessBlock1.xml");			
205
			accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock1.xml");
206
			setBlockAccess(docId, accessBlockXML, true);
207
			accessXML = m.getAccessControl(docId);
208
			realAccessDAOList = getAccessDAOList(docId, accessXML);
209
			accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
210
			debugAccessDAOList(accessBlockDAOList);
211
			compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
212

    
213
			// replace access for doc using the access section in accessBlock2.xml, 
214
			// then test that the access was updated and that is the only access
215
			// for the doc
216
			debug("AccessAPITest.testSetBlockAccess - Test 2 using accessBlock2.xml");			
217
			accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock2.xml");
218
			setBlockAccess(docId, accessBlockXML, true);
219
			accessXML = m.getAccessControl(docId);
220
			realAccessDAOList = getAccessDAOList(docId, accessXML);
221
			accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
222
			debugAccessDAOList(accessBlockDAOList);
223
			compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
224

    
225
			// replace access for doc using the access section in accessBlock3.xml, 
226
			// then test that the access was updated and that is the only access
227
			// for the doc
228
			debug("AccessAPITest.testSetBlockAccess - Test 3 using accessBlock3.xml");			
229
			accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock3.xml");
230
			setBlockAccess(docId, accessBlockXML, true);
231
			accessXML = m.getAccessControl(docId);
232
			realAccessDAOList = getAccessDAOList(docId, accessXML);
233
			accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
234
			debugAccessDAOList(accessBlockDAOList);
235
			compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
236
			
237
			// replace access for doc using the access section in accessBlock4.xml, 
238
			// then test that the access was updated and that is the only access
239
			// for the doc
240
			debug("AccessAPITest.testSetBlockAccess - Test 4 using accessBlock4.xml");			
241
			accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock4.xml");
242
			setBlockAccess(docId, accessBlockXML, true);
243
			accessXML = m.getAccessControl(docId);
244
			realAccessDAOList = getAccessDAOList(docId, accessXML);
245
			accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
246
			debugAccessDAOList(accessBlockDAOList);
247
			compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
248
			
249
			// replace access for doc using the access section in accessBlock5.xml, 
250
			// then test that the access was updated and that is the only access
251
			// for the doc
252
			debug("AccessAPITest.testSetBlockAccess - Test 5 using accessBlock5.xml");			
253
			accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock5.xml");
254
			setBlockAccess(docId, accessBlockXML, true);
255
			accessXML = m.getAccessControl(docId);
256
			realAccessDAOList = getAccessDAOList(docId, accessXML);
257
			accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
258
			debugAccessDAOList(accessBlockDAOList);
259
			compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
260
			
261
			// replace access for doc using the access section in accessBlock6.xml, 
262
			// then test that the access was updated and that is the only access
263
			// for the doc
264
			debug("AccessAPITest.testSetBlockAccess - Test 6 using accessBlock6.xml");			
265
			accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock6.xml");
266
			setBlockAccess(docId, accessBlockXML, true);
267
			accessXML = m.getAccessControl(docId);
268
			realAccessDAOList = getAccessDAOList(docId, accessXML);
269
			accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
270
			debugAccessDAOList(accessBlockDAOList);
271
			compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
272
			
273
			// replace access for doc using the access section in accessBlock7.xml, 
274
			// then test that the access was updated and that is the only access
275
			// for the doc
276
			debug("AccessAPITest.testSetBlockAccess - Test 7 using accessBlock7.xml");			
277
			accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock7.xml");
278
			setBlockAccess(docId, accessBlockXML, true);
279
			accessXML = m.getAccessControl(docId);
280
			realAccessDAOList = getAccessDAOList(docId, accessXML);
281
			accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
282
			debugAccessDAOList(accessBlockDAOList);
283
			compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
284
			
285
			// replace access for doc using the access section in accessBlock8.xml, 
286
			// then test that the access was updated and that is the only access
287
			// for the doc
288
			debug("AccessAPITest.testSetBlockAccess - Test 8 using accessBlock8.xml");			
289
			accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock8.xml");
290
			setBlockAccess(docId, accessBlockXML, true);
291
			accessXML = m.getAccessControl(docId);
292
			realAccessDAOList = getAccessDAOList(docId, accessXML);
293
			accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
294
			debugAccessDAOList(accessBlockDAOList);
295
			compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
296
			
297
			// replace access for doc using the access section in accessBlock9.xml, 
298
			// then test that the access was updated and that is the only access
299
			// for the doc
300
			debug("AccessAPITest.testSetBlockAccess - Test 9 using accessBlock9.xml");			
301
			accessBlockXML = getTestDocFromFile(testdatadir + "accessBlock9.xml");
302
			setBlockAccess(docId, accessBlockXML, true);
303
			accessXML = m.getAccessControl(docId);
304
			realAccessDAOList = getAccessDAOList(docId, accessXML);
305
			accessBlockDAOList = getAccessDAOList(docId, accessBlockXML);
306
			debugAccessDAOList(accessBlockDAOList);
307
			compareAccessDAOs(realAccessDAOList, accessBlockDAOList, true);
308
			
309
		} catch (AccessControlException ace) {
310
			fail("AccessAPITest.testSetBlockAccess - Access Control error: " + ace.getMessage());
311
		} catch (IOException ioe) {
312
			fail("AccessAPITest.testSetBlockAccess - I/O error: " + ioe.getMessage());
313
		} catch (MetacatAuthException mae) {
314
			fail("AccessAPITest.testSetBlockAccess - Metacat authentication error: " + mae.getMessage()); 
315
		} catch (MetacatException me) {
316
			fail("AccessAPITest.testSetBlockAccess - Metacat error: " + me.getMessage()); 
317
		} catch (InsufficientKarmaException ike) {
318
			fail("AccessAPITest.testSetBlockAccess - Metacat error: " + ike.getMessage()); 
319
		} catch (MetacatInaccessibleException mie) {
320
			fail("AccessAPITest.testSetBlockAccess - Metacat Inaccessible Error: " + mie.getMessage());
321
		}
322
	}
323

    
324
	/**
325
	 * Insert a single row of access for a document.
326
	 * 
327
	 * @param docId
328
	 *            the id of the document to update
329
	 * @param principal
330
	 *            the principal credentails
331
	 * @param permission
332
	 *            the permission
333
	 * @param permType
334
	 *            the permission type
335
	 * @param permOrder
336
	 *            the permission order
337
	 * @param successExpected
338
	 *            if true, we expect the insert to succeed, otherwise, we expect
339
	 *            it to fail
340
	 * @return the metacat response xml
341
	 */
342
	private String setSingleAccess(String docId, String principal, String permission, 
343
			String permType, String permOrder, boolean successExpected) {
344
		debug("AccessAPITest.setSingleAccess - docid: " + docId + ", prinicpal: " + 
345
				principal + ", permission: " + permission + ", permType: " + permType + 
346
				", permOrder: " + permOrder + ", errorExpected: " + successExpected);
347
		String response = null;
348
		try {
349
			// set the access using metacat client
350
			response = m.setAccess(docId, principal, permission, permType, permOrder); 
351

    
352
			debug("AccessAPITest.setSingleAccess - response: " + response);
353
			
354
			if (successExpected) {
355
				assertTrue(response, (response.indexOf("<success>") != -1));
356
			} else {
357
				assertTrue(response, (response.indexOf("<success>") == -1));
358
			}			
359
		} catch (MetacatInaccessibleException mie) {
360
			fail("AccessAPITest.setSingleAccess - Metacat inaccessible: " + mie.getMessage());
361
		} catch (InsufficientKarmaException ike) {
362

    
363
		} catch (MetacatException me) {
364
			if (successExpected) {
365
				fail("AccessAPITest.setSingleAccess - Metacat error: " + me.getMessage());
366
			} else {
367
				debug("AccessAPITest.setSingleAccess - Expected Metacat error: " + me.getMessage());
368
			}
369
		} catch (Exception e) {
370
			fail("AccessAPITest.setSingleAccess - General error: " + e.getMessage());
371
		}
372

    
373
		return response;
374
	}
375
	
376
	/**
377
	 * Replace a block of access
378
	 * 
379
	 * @param docId
380
	 *            the id of the doc we want to update
381
	 * @param accessBlockXML
382
	 *            the access xml section
383
	 * @param successExpected
384
	 *            if true, we expect the insert to succeed, otherwise, we expect
385
	 *            it to fail
386
	 * @return the metacat response xml
387
	 */
388
	private String setBlockAccess(String docId, String accessBlockXML, boolean successExpected) {
389
		debug("AccessAPITest.setBlockAccess - docid: " + docId + ", accessBlockXML: " + 
390
				accessBlockXML + ", errorExpected: " + successExpected);
391
		String response = null;
392
		try {
393
			// set the access using metacat client
394
			response = m.setAccess(docId, accessBlockXML); 
395

    
396
			debug("AccessAPITest.setBlockAccess - response: " + response);
397
			
398
			if (successExpected) {
399
				assertTrue(response, (response.indexOf("<success>") != -1));
400
			} else {
401
				assertTrue(response, (response.indexOf("<success>") == -1));
402
			}			
403
		} catch (MetacatInaccessibleException mie) {
404
			fail("AccessAPITest.setBlockAccess - Metacat inaccessible: " + mie.getMessage());
405
		} catch (InsufficientKarmaException ike) {
406

    
407
		} catch (MetacatException me) {
408
			if (successExpected) {
409
				fail("AccessAPITest.setBlockAccess - Metacat error: " + me.getMessage());
410
			} else {
411
				debug("AccessAPITest.setBlockAccess - Expected Metacat error: " + me.getMessage());
412
			}
413
		} catch (Exception e) {
414
			fail("AccessAPITest.setBlockAccess - General error: " + e.getMessage());
415
		}
416

    
417
		return response;
418
	}
419
	
420
	/**
421
	 * Compare two lists of XML Access DAO objects. The first list is the master
422
	 * list and the second is the sub list. All elements of the sub list must be
423
	 * in the master list or a failed assertion is generated. If the exactMatch
424
	 * parameter is true, the master and sub lists must be the same, otherwise,
425
	 * the sub list can be a subset of the master list.
426
	 * 
427
	 * @param mainAccessDAOList
428
	 *            The main list of DAOs
429
	 * @param subAccessDAOList
430
	 *            The sub list of DAOs
431
	 * @param exactMatch
432
	 *            if true, the master and sub lists must be exactly the same,
433
	 *            otherwise, the sublist must only be a subset of the master
434
	 */
435
	private void compareAccessDAOs(Vector<XMLAccessDAO> mainAccessDAOList, 
436
			Vector<XMLAccessDAO> subAccessDAOList, boolean exactMatch) {
437
		
438
		
439
		//debug("test access DAO: ");
440
		//debugAccessDAOList(subAccessDAOList);
441
		//debug("\naccess DAOs from database: ");
442
		//debugAccessDAOList(mainAccessDAOList);
443
		
444
		// if exactMatch is true, both lists must be the same size.  The next section will
445
		// make sure elements match.
446
		if (exactMatch) {
447
			if (mainAccessDAOList.size() != subAccessDAOList.size()) {
448
				fail("AccessAPITest.compareAccessDAOs - access DAO list sizes do not match.  " + 
449
						"Primary DAO list size: " + mainAccessDAOList.size() + 
450
						", secondary DAO list size: " + subAccessDAOList.size());
451
			}
452
		}
453
		
454
		
455
		// iterate through the sub list and make sure all its elements are in the master list
456
		for (XMLAccessDAO subAccessDAO : subAccessDAOList) {
457
			boolean matchFound = false;
458
			for (XMLAccessDAO mainAccessDAO : mainAccessDAOList) {		
459
			    /*System.out.println("subAccessDAO.docid: '" + subAccessDAO.getDocId() + "'");
460
			    System.out.println("mainAccessDAO.docid: '" + mainAccessDAO.getDocId() + "'");
461
			    
462
			    System.out.println("subAccessDAO.permOrder: '" + subAccessDAO.getPermOrder() + "'");
463
                System.out.println("mainAccessDAO.permOrder: '" + mainAccessDAO.getPermOrder() + "'");
464
                
465
                System.out.println("subAccessDAO.permtype: '" + subAccessDAO.getPermType() + "'");
466
                System.out.println("mainAccessDAO.docid: '" + mainAccessDAO.getPermType() + "'");
467
                
468
                System.out.println("subAccessDAO.princname: '" + subAccessDAO.getPrincipalName() + "'");
469
                System.out.println("mainAccessDAO.princname: '" + mainAccessDAO.getPrincipalName() + "'");
470
                
471
                System.out.println("subAccessDAO.perm: '" + subAccessDAO.getPermission() + "'");
472
                System.out.println("mainAccessDAO.perm: '" + mainAccessDAO.getPermission() + "'");*/
473
				if (subAccessDAO.getDocId().equals(mainAccessDAO.getDocId()) &&
474
						subAccessDAO.getPermOrder().equals(mainAccessDAO.getPermOrder()) &&
475
						subAccessDAO.getPermType().equals(mainAccessDAO.getPermType()) &&
476
						subAccessDAO.getPrincipalName().equals(mainAccessDAO.getPrincipalName()) &&
477
						subAccessDAO.getPermission().equals(mainAccessDAO.getPermission())) {
478
					matchFound = true;
479
					break;
480
				}			
481
			}
482
			
483
			if (!matchFound) {
484
				fail("AccessAPITest.compareAccessDAOs - secondary access DAO does not exist in " + 
485
						"primary DAO list");
486
			}
487
		}
488
	}
489
	
490
	/**
491
	 * Get a vector of access DAO objects from an EML 2.1.0-like access section
492
	 * of xml
493
	 * 
494
	 * @param docId
495
	 *            the doc id that we are getting access for. this makes it
496
	 *            easier to create a DocInfoHandler object.
497
	 * @param accessXML
498
	 *            the access xml we want to parse.
499
	 * @return a list of XML access DAO objects.
500
	 */
501
	private Vector<XMLAccessDAO> getAccessDAOList(String docId, String accessXML) 
502
			throws AccessControlException {
503
		
504
		Vector<XMLAccessDAO> accessControlList = null;
505
		XMLReader parser = null;
506
		DocInfoHandler docInfoHandler = new DocInfoHandler(docId); 
507
		ContentHandler chandler = docInfoHandler;
508

    
509
		try {
510
			// Get an instance of the parser.  the DocInfoHandler will handle 
511
			// the extraction of access info.
512
			String parserName = PropertyService.getProperty("xml.saxparser");
513
			parser = XMLReaderFactory.createXMLReader(parserName);
514
	
515
			// Turn off validation
516
			parser.setFeature("http://xml.org/sax/features/validation", false);
517
			parser.setContentHandler((ContentHandler)chandler);
518
			parser.setErrorHandler((ErrorHandler)chandler);
519
	
520
			parser.parse(new InputSource(new StringReader(accessXML)));
521
				
522
			accessControlList = docInfoHandler.getAccessControlList();
523
		} catch (PropertyNotFoundException pnfe) {
524
			throw new AccessControlException("AccessAPITest.getAccessDAOList - " + 
525
					"property error: " + pnfe.getMessage());
526
		} catch (IOException ioe) {
527
			throw new AccessControlException("AccessAPITest.getAccessDAOList - " + 
528
					"I/O error: " + ioe.getMessage());
529
		} catch (SAXException se) {
530
			throw new AccessControlException("AccessAPITest.getAccessDAOList - " + 
531
					"SAX error: " + se.getMessage());
532
		}
533
        
534
        return accessControlList;
535
	}
536
	
537
	/**
538
	 * Print out the contents of an access DAO list
539
	 * @param accessDAOList
540
	 */
541
	private void debugAccessDAOList(Vector<XMLAccessDAO> accessDAOList) {
542
		for (XMLAccessDAO xmlAccessDAO : accessDAOList) {
543
			debug("Doc ID:      " + xmlAccessDAO.getDocId());
544
			debug("Perm Order:  " + xmlAccessDAO.getPermOrder());
545
			debug("Perm Type:   " + xmlAccessDAO.getPermType());
546
			debug("Principal    " + xmlAccessDAO.getPrincipalName());
547
			String permissionStr = 
548
				AccessControlList.txtValue(xmlAccessDAO.getPermission().intValue());
549
			debug("Permission   " + permissionStr);
550
		}
551
	}
552
}
(1-1/24)