[CVS jcontainer] Renamed org.jcontainer.loom -> org.codehaus.loom
mauro-yCVjj/[email protected] Mon, 19 Apr 2004 17:20:30 -0500
| Newsgroups | gmane.comp.java.jcontainer.cvs |
|---|---|
| Message-ID | <[email protected]> |
<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>jcontainer/loom/support/xmlpolicy</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt>src/test/org/jcontainer/loom/xmlpolicy/builder/<a href="#file1"><span id="removed">MockKeyStore.java</span></a></tt></td><td></td><td align="right" id="removed">-30</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/MockKeyStore.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file2"><span id="removed">MockCertificate.java</span></a></tt></td><td></td><td align="right" id="removed">-68</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/MockCertificate.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> /<a href="#file3"><span id="removed">TestResolver.java</span></a></tt></td><td></td><td align="right" id="removed">-34</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/TestResolver.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file4"><span id="removed">TestNoInitPolicyBuilder.java</span></a></tt></td><td></td><td align="right" id="removed">-39</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/TestNoInitPolicyBuilder.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> /<a href="#file5"><span id="removed">MockKeyStoreSpi.java</span></a></tt></td><td></td><td align="right" id="removed">-123</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/MockKeyStoreSpi.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file6"><span id="removed">TestPolicyBuilder.java</span></a></tt></td><td></td><td align="right" id="removed">-39</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/TestPolicyBuilder.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> /<a href="#file7"><span id="removed">MockNoInitKeyStore.java</span></a></tt></td><td></td><td align="right" id="removed">-29</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/MockNoInitKeyStore.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file8"><span id="removed">BuilderTestCase.java</span></a></tt></td><td></td><td align="right" id="removed">-353</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/BuilderTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt>src/test/org/jcontainer/loom/xmlpolicy/verifier/test/<a href="#file9"><span id="removed">config7.xml</span></a></tt></td><td></td><td align="right" id="removed">-6</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config7.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file10"><span id="removed">config4.xml</span></a></tt></td><td></td><td align="right" id="removed">-5</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config4.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> /<a href="#file11"><span id="removed">config2.xml</span></a></tt></td><td></td><td align="right" id="removed">-9</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config2.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file12"><span id="removed">VerifierTestCase.java</span></a></tt></td><td></td><td align="right" id="removed">-186</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/VerifierTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> /<a href="#file13"><span id="removed">config1.xml</span></a></tt></td><td></td><td align="right" id="removed">-5</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config1.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file14"><span id="removed">config3.xml</span></a></tt></td><td></td><td align="right" id="removed">-6</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config3.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> /<a href="#file15"><span id="removed">config8.xml</span></a></tt></td><td></td><td align="right" id="removed">-5</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config8.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file16"><span id="removed">config9.xml</span></a></tt></td><td></td><td align="right" id="removed">-13</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config9.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> /<a href="#file17"><span id="removed">config5.xml</span></a></tt></td><td></td><td align="right" id="removed">-5</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config5.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file18"><span id="removed">config10.xml</span></a></tt></td><td></td><td align="right" id="removed">-13</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config10.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> /<a href="#file19"><span id="removed">config6.xml</span></a></tt></td><td></td><td align="right" id="removed">-6</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config6.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt>src/java/org/codehaus/loom/xmlpolicy/metadata/<a href="#file20"><span id="added">KeyStoreMetaData.java</span></a></tt></td><td align="right" id="added">+93</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/metadata/KeyStoreMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file21"><span id="added">PermissionMetaData.java</span></a></tt></td><td align="right" id="added">+131</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/metadata/PermissionMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt> /<a href="#file22"><span id="added">PolicyMetaData.java</span></a></tt></td><td align="right" id="added">+61</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/metadata/PolicyMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file23"><span id="added">GrantMetaData.java</span></a></tt></td><td align="right" id="added">+119</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/metadata/GrantMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt>src/java/org/codehaus/loom/xmlpolicy/builder/<a href="#file24"><span id="added">PolicyBuilder.java</span></a></tt></td><td align="right" id="added">+440</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/builder/PolicyBuilder.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file25"><span id="added">PolicyResolver.java</span></a></tt></td><td align="right" id="added">+44</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/builder/PolicyResolver.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt>src/test/org/codehaus/loom/xmlpolicy/reader/test/<a href="#file26"><span id="added">config3.xml</span></a></tt></td><td align="right" id="added">+2</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test/config3.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file27"><span id="added">config4.xml</span></a></tt></td><td align="right" id="added">+7</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test/config4.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt> /<a href="#file28"><span id="added">config2.xml</span></a></tt></td><td align="right" id="added">+2</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test/config2.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file29"><span id="added">ReaderTestCase.java</span></a></tt></td><td align="right" id="added">+284</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test/ReaderTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt> /<a href="#file30"><span id="added">config1.xml</span></a></tt></td><td align="right" id="added">+17</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test/config1.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file31"><span id="added">config5.xml</span></a></tt></td><td align="right" id="added">+17</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test/config5.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt>src/java/org/jcontainer/loom/xmlpolicy/metadata/<a href="#file32"><span id="removed">GrantMetaData.java</span></a></tt></td><td></td><td align="right" id="removed">-119</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/metadata/GrantMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> /<a href="#file33"><span id="removed">KeyStoreMetaData.java</span></a></tt></td><td></td><td align="right" id="removed">-93</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/metadata/KeyStoreMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file34"><span id="removed">PolicyMetaData.java</span></a></tt></td><td></td><td align="right" id="removed">-61</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/metadata/PolicyMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> /<a href="#file35"><span id="removed">PermissionMetaData.java</span></a></tt></td><td></td><td align="right" id="removed">-131</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/metadata/PermissionMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt>src/test/org/codehaus/loom/xmlpolicy/metadata/<a href="#file36"><span id="added">MetaDataTestCase.java</span></a></tt></td><td align="right" id="added">+190</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/metadata/MetaDataTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt>src/test/org/jcontainer/loom/xmlpolicy/reader/test/<a href="#file37"><span id="removed">config5.xml</span></a></tt></td><td></td><td align="right" id="removed">-17</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test/config5.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file38"><span id="removed">config2.xml</span></a></tt></td><td></td><td align="right" id="removed">-2</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test/config2.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> /<a href="#file39"><span id="removed">config1.xml</span></a></tt></td><td></td><td align="right" id="removed">-17</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test/config1.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file40"><span id="removed">config3.xml</span></a></tt></td><td></td><td align="right" id="removed">-2</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test/config3.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> /<a href="#file41"><span id="removed">ReaderTestCase.java</span></a></tt></td><td></td><td align="right" id="removed">-284</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test/ReaderTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file42"><span id="removed">config4.xml</span></a></tt></td><td></td><td align="right" id="removed">-7</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test/config4.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt>src/java/org/jcontainer/loom/xmlpolicy/builder/<a href="#file43"><span id="removed">PolicyResolver.java</span></a></tt></td><td></td><td align="right" id="removed">-44</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/builder/PolicyResolver.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file44"><span id="removed">PolicyBuilder.java</span></a></tt></td><td></td><td align="right" id="removed">-439</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/builder/PolicyBuilder.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt>src/test/org/codehaus/loom/xmlpolicy/builder/<a href="#file45"><span id="added">MockKeyStore.java</span></a></tt></td><td align="right" id="added">+30</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/MockKeyStore.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt> /<a href="#file46"><span id="added">BuilderTestCase.java</span></a></tt></td><td align="right" id="added">+355</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/BuilderTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file47"><span id="added">TestNoInitPolicyBuilder.java</span></a></tt></td><td align="right" id="added">+41</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/TestNoInitPolicyBuilder.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt> /<a href="#file48"><span id="added">MockKeyStoreSpi.java</span></a></tt></td><td align="right" id="added">+123</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/MockKeyStoreSpi.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file49"><span id="added">TestResolver.java</span></a></tt></td><td align="right" id="added">+36</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/TestResolver.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt> /<a href="#file50"><span id="added">MockCertificate.java</span></a></tt></td><td align="right" id="added">+68</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/MockCertificate.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file51"><span id="added">TestPolicyBuilder.java</span></a></tt></td><td align="right" id="added">+41</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/TestPolicyBuilder.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt> /<a href="#file52"><span id="added">MockNoInitKeyStore.java</span></a></tt></td><td align="right" id="added">+29</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/MockNoInitKeyStore.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt>src/java/org/codehaus/loom/xmlpolicy/verifier/<a href="#file53"><span id="added">Resources.properties</span></a></tt></td><td align="right" id="added">+16</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/verifier/Resources.properties?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt> /<a href="#file54"><span id="added">PolicyVerifier.java</span></a></tt></td><td align="right" id="added">+218</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/verifier/PolicyVerifier.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt>src/test/org/codehaus/loom/xmlpolicy/verifier/test/<a href="#file55"><span id="added">config7.xml</span></a></tt></td><td align="right" id="added">+6</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config7.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt> /<a href="#file56"><span id="added">config10.xml</span></a></tt></td><td align="right" id="added">+13</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config10.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file57"><span id="added">config2.xml</span></a></tt></td><td align="right" id="added">+9</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config2.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt> /<a href="#file58"><span id="added">config9.xml</span></a></tt></td><td align="right" id="added">+13</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config9.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file59"><span id="added">config6.xml</span></a></tt></td><td align="right" id="added">+6</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config6.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt> /<a href="#file60"><span id="added">config1.xml</span></a></tt></td><td align="right" id="added">+5</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config1.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file61"><span id="added">config5.xml</span></a></tt></td><td align="right" id="added">+5</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config5.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt> /<a href="#file62"><span id="added">config4.xml</span></a></tt></td><td align="right" id="added">+5</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config4.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file63"><span id="added">config3.xml</span></a></tt></td><td align="right" id="added">+6</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config3.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt> /<a href="#file64"><span id="added">config8.xml</span></a></tt></td><td align="right" id="added">+5</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config8.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file65"><span id="added">VerifierTestCase.java</span></a></tt></td><td align="right" id="added">+186</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/VerifierTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt>src/java/org/jcontainer/loom/xmlpolicy/reader/<a href="#file66"><span id="removed">policy.dtd</span></a></tt></td><td></td><td align="right" id="removed">-70</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/reader/policy.dtd?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> /<a href="#file67"><span id="removed">PolicyReader.java</span></a></tt></td><td></td><td align="right" id="removed">-201</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/reader/PolicyReader.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt><a href="#file68">project.xml</a></tt></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/project.xml?rev=1.12&content-type=text/vnd.viewcvs-markup">1.12</a> <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/project.xml.diff?r1=1.12&r2=1.13">-></a> <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/project.xml?rev=1.13&content-type=text/vnd.viewcvs-markup">1.13</a></td></tr>
<tr><td><tt>src/test/org/jcontainer/loom/xmlpolicy/runtime/<a href="#file69"><span id="removed">RuntimeTestCase.java</span></a></tt></td><td></td><td align="right" id="removed">-143</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/runtime/RuntimeTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt>src/test/org/jcontainer/loom/xmlpolicy/test/<a href="#file70"><span id="removed">AbstractPolicyTestCase.java</span></a></tt></td><td></td><td align="right" id="removed">-68</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/test/AbstractPolicyTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt>src/java/org/jcontainer/loom/xmlpolicy/runtime/<a href="#file71"><span id="removed">PolicyEntry.java</span></a></tt></td><td></td><td align="right" id="removed">-54</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/runtime/PolicyEntry.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file72"><span id="removed">DefaultPolicy.java</span></a></tt></td><td></td><td align="right" id="removed">-73</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/runtime/DefaultPolicy.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt> /<a href="#file73"><span id="removed">AbstractPolicy.java</span></a></tt></td><td></td><td align="right" id="removed">-161</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/runtime/AbstractPolicy.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt>src/test/org/jcontainer/loom/xmlpolicy/metadata/<a href="#file74"><span id="removed">MetaDataTestCase.java</span></a></tt></td><td></td><td align="right" id="removed">-186</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/metadata/MetaDataTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt>src/java/org/jcontainer/loom/xmlpolicy/verifier/<a href="#file75"><span id="removed">Resources.properties</span></a></tt></td><td></td><td align="right" id="removed">-16</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/verifier/Resources.properties?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr class="alt"><td><tt> /<a href="#file76"><span id="removed">PolicyVerifier.java</span></a></tt></td><td></td><td align="right" id="removed">-218</td><td nowrap="nowrap"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/verifier/PolicyVerifier.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a> removed</td></tr>
<tr><td><tt>src/test/org/codehaus/loom/xmlpolicy/runtime/<a href="#file77"><span id="added">RuntimeTestCase.java</span></a></tt></td><td align="right" id="added">+147</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/runtime/RuntimeTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt>src/java/org/codehaus/loom/xmlpolicy/reader/<a href="#file78"><span id="added">policy.dtd</span></a></tt></td><td align="right" id="added">+70</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/reader/policy.dtd?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file79"><span id="added">PolicyReader.java</span></a></tt></td><td align="right" id="added">+202</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/reader/PolicyReader.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt>src/java/org/codehaus/loom/xmlpolicy/runtime/<a href="#file80"><span id="added">PolicyEntry.java</span></a></tt></td><td align="right" id="added">+54</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/runtime/PolicyEntry.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt> /<a href="#file81"><span id="added">DefaultPolicy.java</span></a></tt></td><td align="right" id="added">+73</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/runtime/DefaultPolicy.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt> /<a href="#file82"><span id="added">AbstractPolicy.java</span></a></tt></td><td align="right" id="added">+161</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/runtime/AbstractPolicy.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt>src/test/org/codehaus/loom/xmlpolicy/test/<a href="#file83"><span id="added">AbstractPolicyTestCase.java</span></a></tt></td><td align="right" id="added">+69</td><td></td><td nowrap="nowrap" align="right">added <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/test/AbstractPolicyTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td></td><td align="right" id="added">+3400</td><td align="right" id="removed">-3381</td><td></td></tr>
</table>
<small id="info">41 added + 41 removed + 1 modified, total 83 files</small><br />
<pre class="comment">
Renamed org.jcontainer.loom -> org.codehaus.loom
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="removed"><big><b>MockKeyStore.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/MockKeyStore.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N MockKeyStore.java
--- MockKeyStore.java 31 Mar 2004 03:27:58 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,30 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.builder;
-
-import java.io.IOException;
-import java.security.KeyStore;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
-import java.util.HashMap;
-
-/**
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:58 $
- */
-class MockKeyStore
- extends KeyStore
-{
- MockKeyStore( final HashMap certs )
- throws IOException, NoSuchAlgorithmException, CertificateException
- {
- super( new MockKeyStoreSpi( certs ), null, null );
- load( null, null );
- }
-}
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="removed"><big><b>MockCertificate.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/MockCertificate.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N MockCertificate.java
--- MockCertificate.java 31 Mar 2004 03:27:58 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,68 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.builder;
-
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-
-/**
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:58 $
- */
-class MockCertificate
- extends Certificate
-{
- public static final MockCertificate JENNY_CERTIFICATE = new MockCertificate("jenny");
- public static final MockCertificate MISCHELLE_CERTIFICATE = new MockCertificate("mischelle");
- public static final MockCertificate GEORGE_CERTIFICATE = new MockCertificate("george");
-
- private final String m_name;
-
- public MockCertificate(final String name )
- {
- super( "name" );
- m_name = name;
- }
-
- public byte[] getEncoded()
- throws CertificateEncodingException
- {
- return new byte[ 0 ];
- }
-
- public void verify( PublicKey key )
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException
- {
- }
-
- public void verify( PublicKey key, String sigProvider )
- throws CertificateException, NoSuchAlgorithmException,
- InvalidKeyException, NoSuchProviderException,
- SignatureException
- {
- }
-
- public String toString()
- {
- return m_name;
- }
-
- public PublicKey getPublicKey()
- {
- return null;
- }
-}
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="removed"><big><b>TestResolver.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/TestResolver.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N TestResolver.java
--- TestResolver.java 31 Mar 2004 03:27:58 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,34 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.builder;
-
-import java.net.URL;
-import java.security.Policy;
-import java.util.Map;
-import org.jcontainer.loom.xmlpolicy.runtime.DefaultPolicy;
-
-/**
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:58 $
- */
-class TestResolver
- implements PolicyResolver
-{
- public URL resolveLocation( String location )
- throws Exception
- {
- return new URL( location );
- }
-
- public Policy createPolicy( Map grants )
- throws Exception
- {
- return new DefaultPolicy( grants );
- }
-}
</pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="removed"><big><b>TestNoInitPolicyBuilder.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/TestNoInitPolicyBuilder.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N TestNoInitPolicyBuilder.java
--- TestNoInitPolicyBuilder.java 31 Mar 2004 03:27:58 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,39 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.builder;
-
-import java.security.KeyStore;
-import java.net.URL;
-import java.util.HashMap;
-
-/**
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:58 $
- */
-class TestNoInitPolicyBuilder
- extends PolicyBuilder
-{
- protected KeyStore createKeyStore( String type,
- URL url )
- throws Exception
- {
- if( url.equals( new URL( "http://spice.sourceforge.net" ) ) )
- {
- final HashMap certs = new HashMap();
- certs.put( "jenny", MockCertificate.JENNY_CERTIFICATE );
- certs.put( "mischelle", MockCertificate.MISCHELLE_CERTIFICATE );
- certs.put( "george", MockCertificate.GEORGE_CERTIFICATE );
- return new MockNoInitKeyStore( certs );
- }
- else
- {
- throw new Exception( "Unable to create keystore " + url );
- }
- }
-}
</pre></div>
<hr /><a name="file5" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="removed"><big><b>MockKeyStoreSpi.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/MockKeyStoreSpi.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N MockKeyStoreSpi.java
--- MockKeyStoreSpi.java 31 Mar 2004 03:27:58 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,123 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.builder;
-
-import java.security.KeyStoreSpi;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.KeyStoreException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:58 $
- */
-class MockKeyStoreSpi
- extends KeyStoreSpi
-{
- private final HashMap m_certs;
-
- public MockKeyStoreSpi( HashMap certs )
- {
- m_certs = certs;
- }
-
- public Key engineGetKey( String alias, char[] password )
- throws NoSuchAlgorithmException, UnrecoverableKeyException
- {
- return null;
- }
-
- public Certificate[] engineGetCertificateChain( String alias )
- {
- return new Certificate[ 0 ];
- }
-
- public Certificate engineGetCertificate( String alias )
- {
- return (Certificate)m_certs.get( alias );
- }
-
- public Date engineGetCreationDate( String alias )
- {
- return null;
- }
-
- public void engineSetKeyEntry( String alias, Key key,
- char[] password,
- Certificate[] chain )
- throws KeyStoreException
- {
- }
-
- public void engineSetKeyEntry( String alias, byte[] key,
- Certificate[] chain )
- throws KeyStoreException
- {
- }
-
- public void engineSetCertificateEntry( String alias,
- Certificate cert )
- throws KeyStoreException
- {
- }
-
- public void engineDeleteEntry( String alias )
- throws KeyStoreException
- {
- }
-
- public Enumeration engineAliases()
- {
- return null;
- }
-
- public boolean engineContainsAlias( String alias )
- {
- return false;
- }
-
- public int engineSize()
- {
- return 0;
- }
-
- public boolean engineIsKeyEntry( String alias )
- {
- return false;
- }
-
- public boolean engineIsCertificateEntry( String alias )
- {
- return false;
- }
-
- public String engineGetCertificateAlias( Certificate cert )
- {
- return null;
- }
-
- public void engineStore( OutputStream stream, char[] password )
- throws IOException, NoSuchAlgorithmException, CertificateException
- {
- }
-
- public void engineLoad( InputStream stream, char[] password )
- throws IOException, NoSuchAlgorithmException, CertificateException
- {
- }
-}
</pre></div>
<hr /><a name="file6" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="removed"><big><b>TestPolicyBuilder.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/TestPolicyBuilder.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N TestPolicyBuilder.java
--- TestPolicyBuilder.java 31 Mar 2004 03:27:58 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,39 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.builder;
-
-import java.security.KeyStore;
-import java.net.URL;
-import java.util.HashMap;
-
-/**
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:58 $
- */
-class TestPolicyBuilder
- extends PolicyBuilder
-{
- protected KeyStore createKeyStore( String type,
- URL url )
- throws Exception
- {
- if( url.equals( new URL( "http://spice.sourceforge.net" ) ) )
- {
- final HashMap certs = new HashMap();
- certs.put( "jenny", MockCertificate.JENNY_CERTIFICATE );
- certs.put( "mischelle", MockCertificate.MISCHELLE_CERTIFICATE );
- certs.put( "george", MockCertificate.GEORGE_CERTIFICATE );
- return new MockKeyStore( certs );
- }
- else
- {
- throw new Exception( "Unable to create keystore " + url );
- }
- }
-}
</pre></div>
<hr /><a name="file7" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="removed"><big><b>MockNoInitKeyStore.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/MockNoInitKeyStore.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N MockNoInitKeyStore.java
--- MockNoInitKeyStore.java 31 Mar 2004 03:27:58 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.builder;
-
-import java.io.IOException;
-import java.security.KeyStore;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
-import java.util.HashMap;
-
-/**
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:58 $
- */
-class MockNoInitKeyStore
- extends KeyStore
-{
- MockNoInitKeyStore( final HashMap certs )
- throws IOException, NoSuchAlgorithmException, CertificateException
- {
- super( new MockKeyStoreSpi( certs ), null, null );
- }
-}
</pre></div>
<hr /><a name="file8" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="removed"><big><b>BuilderTestCase.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/builder/BuilderTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N BuilderTestCase.java
--- BuilderTestCase.java 31 Mar 2004 03:27:58 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,353 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.builder;
-
-import java.net.URL;
-import java.security.AllPermission;
-import java.security.CodeSource;
-import java.security.PermissionCollection;
-import java.security.Policy;
-import java.security.UnresolvedPermission;
-import java.security.cert.Certificate;
-import java.util.Enumeration;
-import java.io.FilePermission;
-import junit.framework.TestCase;
-import org.jcontainer.loom.xmlpolicy.metadata.GrantMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.KeyStoreMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.PermissionMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.PolicyMetaData;
-
-/**
- * TestCase for Builder package.
- *
- * @author Peter Donald
- */
-public class BuilderTestCase
- extends TestCase
-{
- public BuilderTestCase( final String name )
- {
- super( name );
- }
-
- public void testEmptyMetaData()
- throws Exception
- {
- final PolicyBuilder builder = new PolicyBuilder();
- final PolicyMetaData metaData =
- new PolicyMetaData( new KeyStoreMetaData[ 0 ], new GrantMetaData[ 0 ] );
- final TestResolver resolver = new TestResolver();
- try
- {
- final Policy policy = builder.buildPolicy( metaData, resolver );
- final PermissionCollection permissions =
- policy.getPermissions( new CodeSource( null, new Certificate[ 0 ] ) );
- assertEquals( "Expect no permissions for empty metaData",
- false,
- permissions.elements().hasMoreElements() );
- }
- catch( final Exception e )
- {
- fail( "Expected to be able to build Policy with empty metadata" );
- }
- }
-
- public void testNullResolverInBuildPolicy()
- throws Exception
- {
- final PolicyBuilder builder = new PolicyBuilder();
- final PolicyMetaData metaData =
- new PolicyMetaData( new KeyStoreMetaData[ 0 ], new GrantMetaData[ 0 ] );
- try
- {
- builder.buildPolicy( metaData, null );
- fail( "Expected to fail due to null pointer in buildPolicy" );
- }
- catch( final NullPointerException npe )
- {
- assertEquals( "NPE message",
- "resolver",
- npe.getMessage() );
- }
- }
-
- public void testNullMetaDataInBuildPolicy()
- throws Exception
- {
- final PolicyBuilder builder = new PolicyBuilder();
- try
- {
- builder.buildPolicy( null, new TestResolver() );
- fail( "Expected to fail due to null pointer in buildPolicy" );
- }
- catch( final NullPointerException npe )
- {
- assertEquals( "NPE message",
- "policy",
- npe.getMessage() );
- }
-
- }
-
- public void testMetaDataWithAPermission()
- throws Exception
- {
- final PolicyBuilder builder = new PolicyBuilder();
- final PermissionMetaData permission =
- new PermissionMetaData( AllPermission.class.getName(), null, null, null, null );
- final GrantMetaData grant =
- new GrantMetaData( "file:/", null, null,
- new PermissionMetaData[]{permission} );
- final PolicyMetaData metaData =
- new PolicyMetaData( new KeyStoreMetaData[ 0 ], new GrantMetaData[]{grant} );
- final TestResolver resolver = new TestResolver();
- try
- {
- final Policy policy = builder.buildPolicy( metaData, resolver );
- final CodeSource codesource =
- new CodeSource( new URL( "file:/" ), new Certificate[ 0 ] );
- final PermissionCollection permissions = policy.getPermissions( codesource );
- final Enumeration enumeration = permissions.elements();
- while( enumeration.hasMoreElements() )
- {
- final Object perm = enumeration.nextElement();
- if( perm instanceof AllPermission )
- {
- return;
- }
- }
- fail( "Expected to get permission set with ALlPermission contained" );
- }
- catch( final Exception e )
- {
- fail( "Expected to be able to build Policy with empty metadata" );
- }
- }
-
- public void testMetaDataWithAPermissionAndCerts()
- throws Exception
- {
- final PolicyBuilder builder = new TestPolicyBuilder();
- final PermissionMetaData permission =
- new PermissionMetaData( FilePermission.class.getName(), "/", "read",
- null, null );
- final GrantMetaData grant =
- new GrantMetaData( "file:/", "jenny", "default",
- new PermissionMetaData[]{permission} );
- final KeyStoreMetaData keyStore =
- new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
- final PolicyMetaData metaData =
- new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
- final TestResolver resolver = new TestResolver();
- final Policy policy = builder.buildPolicy( metaData, resolver );
- final CodeSource codesource =
- new CodeSource( new URL( "file:/" ), new Certificate[]{MockCertificate.JENNY_CERTIFICATE} );
- final PermissionCollection permissions = policy.getPermissions( codesource );
- final Enumeration enumeration = permissions.elements();
- while( enumeration.hasMoreElements() )
- {
- final Object perm = enumeration.nextElement();
- if( perm instanceof FilePermission )
- {
- return;
- }
- }
- fail( "Expected to get permission set with ALlPermission contained" );
- }
-
- public void testMetaDataWithAPermissionAndMultipleCerts()
- throws Exception
- {
- final PolicyBuilder builder = new TestPolicyBuilder();
- final PermissionMetaData permission =
- new PermissionMetaData( RuntimePermission.class.getName(), "getFactory", null,
- null, null );
- final GrantMetaData grant =
- new GrantMetaData( "file:/", "jenny,mischelle,jenny", "default",
- new PermissionMetaData[]{permission} );
- final KeyStoreMetaData keyStore =
- new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
- final PolicyMetaData metaData =
- new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
- final TestResolver resolver = new TestResolver();
- final Policy policy = builder.buildPolicy( metaData, resolver );
- final CodeSource codesource =
- new CodeSource( new URL( "file:/" ), new Certificate[]{MockCertificate.JENNY_CERTIFICATE} );
- final PermissionCollection permissions = policy.getPermissions( codesource );
- final Enumeration enumeration = permissions.elements();
- while( enumeration.hasMoreElements() )
- {
- final Object perm = enumeration.nextElement();
- if( perm instanceof RuntimePermission )
- {
- return;
- }
- }
- fail( "Expected to get permission set with ALlPermission contained" );
- }
-
- public void testMetaDataWithAPermissionAndCertsAndUnResolverPerm()
- throws Exception
- {
- final PolicyBuilder builder = new TestPolicyBuilder();
- final PermissionMetaData permission =
- new PermissionMetaData( AllPermission.class.getName(), null, null,
- "jenny", "default" );
- final GrantMetaData grant =
- new GrantMetaData( "file:/", "jenny", "default",
- new PermissionMetaData[]{permission} );
- final KeyStoreMetaData keyStore =
- new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
- final PolicyMetaData metaData =
- new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
- final TestResolver resolver = new TestResolver();
- final Policy policy = builder.buildPolicy( metaData, resolver );
- final CodeSource codesource =
- new CodeSource( new URL( "file:/" ), new Certificate[]{MockCertificate.JENNY_CERTIFICATE} );
- final PermissionCollection permissions = policy.getPermissions( codesource );
- final Enumeration enumeration = permissions.elements();
- while( enumeration.hasMoreElements() )
- {
- final Object perm = enumeration.nextElement();
- if( perm instanceof UnresolvedPermission )
- {
- return;
- }
- }
- fail( "Expected to get permission set with UnresolvedPermission contained" );
- }
-
- public void testMetaDataWithAPermissionAndCertsAndMisnamedPerm()
- throws Exception
- {
- final PolicyBuilder builder = new TestPolicyBuilder();
- final PermissionMetaData permission =
- new PermissionMetaData( AllPermission.class.getName() + "sss", null, null,
- null, null );
- final GrantMetaData grant =
- new GrantMetaData( "file:/", "jenny", "default",
- new PermissionMetaData[]{permission} );
- final KeyStoreMetaData keyStore =
- new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
- final PolicyMetaData metaData =
- new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
- final TestResolver resolver = new TestResolver();
- final Policy policy = builder.buildPolicy( metaData, resolver );
- final CodeSource codesource =
- new CodeSource( new URL( "file:/" ), new Certificate[]{MockCertificate.JENNY_CERTIFICATE} );
- final PermissionCollection permissions = policy.getPermissions( codesource );
- final Enumeration enumeration = permissions.elements();
- while( enumeration.hasMoreElements() )
- {
- final Object perm = enumeration.nextElement();
- if( perm instanceof UnresolvedPermission )
- {
- return;
- }
- }
- fail( "Expected to get permission set with UnresolvedPermission contained" );
- }
-
- public void testFailureWhenCreatingKeyStore()
- throws Exception
- {
- final PolicyBuilder builder = new TestPolicyBuilder();
- final PermissionMetaData permission =
- new PermissionMetaData( AllPermission.class.getName() + "sss", null, null,
- null, null );
- final GrantMetaData grant =
- new GrantMetaData( "file:/", "jenny", "default",
- new PermissionMetaData[]{permission} );
- final KeyStoreMetaData keyStore =
- new KeyStoreMetaData( "default", "http://spice.sourceforge.net/NoExist", "DoDgY" );
- final PolicyMetaData metaData =
- new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
- final TestResolver resolver = new TestResolver();
- try
- {
- builder.buildPolicy( metaData, resolver );
- fail( "Expected to fail when creating policy as unable to create store" );
- }
- catch( Exception e )
- {
- }
- }
-
- public void testFailureRetrievingCertForAlias()
- throws Exception
- {
- final PolicyBuilder builder = new TestNoInitPolicyBuilder();
- final PermissionMetaData permission =
- new PermissionMetaData( AllPermission.class.getName() + "sss", null, null,
- null, null );
- final GrantMetaData grant =
- new GrantMetaData( "file:/", "peter", "default",
- new PermissionMetaData[]{permission} );
- final KeyStoreMetaData keyStore =
- new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
- final PolicyMetaData metaData =
- new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
- final TestResolver resolver = new TestResolver();
- try
- {
- builder.buildPolicy( metaData, resolver );
- fail( "Expected to fail when creating policy as unable to create store" );
- }
- catch( Exception e )
- {
- }
- }
-
- public void testAliasNoExist()
- throws Exception
- {
- final PolicyBuilder builder = new TestPolicyBuilder();
- final PermissionMetaData permission =
- new PermissionMetaData( AllPermission.class.getName() + "sss", null, null,
- null, null );
- final GrantMetaData grant =
- new GrantMetaData( "file:/", "peter", "default",
- new PermissionMetaData[]{permission} );
- final KeyStoreMetaData keyStore =
- new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
- final PolicyMetaData metaData =
- new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
- final TestResolver resolver = new TestResolver();
- try
- {
- builder.buildPolicy( metaData, resolver );
- fail( "Expected to fail when creating policy as unable to load alias" );
- }
- catch( Exception e )
- {
- }
- }
-
- public void testNoKeyStore()
- throws Exception
- {
- final PolicyBuilder builder = new TestPolicyBuilder();
- final PermissionMetaData permission =
- new PermissionMetaData( AllPermission.class.getName(), null, null,
- null, null );
- final GrantMetaData grant =
- new GrantMetaData( "file:/", "peter", "default",
- new PermissionMetaData[]{permission} );
- final PolicyMetaData metaData =
- new PolicyMetaData( new KeyStoreMetaData[]{}, new GrantMetaData[]{grant} );
- final TestResolver resolver = new TestResolver();
- try
- {
- builder.buildPolicy( metaData, resolver );
- fail( "Expected to fail when creating policy as missing keystore" );
- }
- catch( Exception e )
- {
- }
- }
-}
</pre></div>
<hr /><a name="file9" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config7.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config7.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config7.xml
--- config7.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,6 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy version="1.0">
- <!-- testing bad character in center of name -->
- <keystore name="a$a"
- location="sar:/conf/keystore"
- type="JKS"/>
-</policy>
</pre></div>
<hr /><a name="file10" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config4.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config4.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config4.xml
--- config4.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,5 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy version="1.0">
- <grant code-base="sar:/SAR-INF/lib/*">
- <permission class="java.io.FilePermission" action="BadActionValue"/>
- </grant>
-</policy>
</pre></div>
<hr /><a name="file11" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config2.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config2.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config2.xml
--- config2.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,9 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy version="1.0">
- <grant code-base="myCodeBase">
- <permission class="java.io.FilePermission"
- target="${/}tmp${/}*"
- signed-by="Bob"
- key-store="nonExistingKeystore"
- action="read,write"/>
- </grant>
-</policy>
</pre></div>
<hr /><a name="file12" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>VerifierTestCase.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/VerifierTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N VerifierTestCase.java
--- VerifierTestCase.java 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,186 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.verifier.test;
-
-import org.jcontainer.loom.xmlpolicy.metadata.PolicyMetaData;
-import org.jcontainer.loom.xmlpolicy.test.AbstractPolicyTestCase;
-import org.jcontainer.loom.xmlpolicy.verifier.PolicyVerifier;
-
-/**
- * TestCase for {@link org.jcontainer.loom.xmlpolicy.reader.PolicyReader}.
- *
- * @author Peter Donald
- */
-public class VerifierTestCase
- extends AbstractPolicyTestCase
-{
- public VerifierTestCase( final String name )
- {
- super( name );
- }
-
- public void testConfig1()
- throws Exception
- {
- try
- {
- verifyResource( "config1.xml" );
- }
- catch( final Throwable t )
- {
- return;
- }
-
- fail( "Expected verify to fail as specified " +
- "bad name for keyStore" );
- }
-
- public void testConfig2()
- throws Exception
- {
- try
- {
- verifyResource( "config2.xml" );
- }
- catch( final Throwable t )
- {
- return;
- }
-
- fail( "Expected verify to fail as permission " +
- "references non existent keystore" );
- }
-
- public void testConfig3()
- throws Exception
- {
- try
- {
- verifyResource( "config3.xml" );
- }
- catch( final Throwable t )
- {
- return;
- }
-
- fail( "Expected verify to fail as grant " +
- "references non existent keystore" );
- }
-
- public void testConfig4()
- throws Exception
- {
- try
- {
- verifyResource( "config4.xml" );
- }
- catch( final Throwable t )
- {
- return;
- }
-
- fail( "Expected verify to fail as specified " +
- "action with null target" );
- }
-
- public void testConfig5()
- throws Exception
- {
- try
- {
- verifyResource( "config5.xml" );
- }
- catch( final Throwable t )
- {
- fail( "Expected to pass when not specifying keystore" );
- }
- }
-
- public void testConfig6()
- throws Exception
- {
- try
- {
- verifyResource( "config6.xml" );
- }
- catch( final Throwable t )
- {
- return;
- }
-
- fail( "Expected verify to fail as specified " +
- "empty name for keyStore" );
- }
-
- public void testConfig7()
- throws Exception
- {
- try
- {
- verifyResource( "config7.xml" );
- }
- catch( final Throwable t )
- {
- return;
- }
-
- fail( "Expected verify to fail as specified " +
- "bad character in center of name for keyStore" );
- }
-
- public void testConfig8()
- throws Exception
- {
- try
- {
- verifyResource( "config8.xml" );
- }
- catch( final Throwable t )
- {
- fail( "Expected verify to pass as specified " +
- "good name for keyStore" );
- }
- }
-
- public void testConfig9()
- throws Exception
- {
- try
- {
- verifyResource( "config9.xml" );
- }
- catch( final Throwable t )
- {
- fail( "Expected verify to pass as specified " +
- "valid reference for keyStore" );
- }
- }
-
- public void testConfig10()
- throws Exception
- {
- try
- {
- verifyResource( "config10.xml" );
- }
- catch( final Throwable t )
- {
- return;
- }
- fail( "Expected verify to fail as specified " +
- "invalid reference for keyStore" );
- }
-
- private void verifyResource( final String resource )
- throws Exception
- {
- final PolicyMetaData defs = buildFromResource( resource );
- final PolicyVerifier verifier = new PolicyVerifier();
- verifier.verifyPolicy( defs );
- }
-}
</pre></div>
<hr /><a name="file13" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config1.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config1.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config1.xml
--- config1.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,5 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy version="1.0">
- <keystore name="$myKeystore"
- location="sar:/conf/keystore"
- type="JKS"/>
-</policy>
</pre></div>
<hr /><a name="file14" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config3.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config3.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config3.xml
--- config3.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,6 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy version="1.0">
- <grant signed-by="Bob" key-store="nonExistentKeystore"
- code-base="sar:/SAR-INF/lib/*">
- <permission class="java.io.FilePermission"/>
- </grant>
-</policy>
</pre></div>
<hr /><a name="file15" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config8.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config8.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config8.xml
--- config8.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,5 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy version="1.0">
- <keystore name="a"
- location="sar:/conf/keystore"
- type="JKS"/>
-</policy>
</pre></div>
<hr /><a name="file16" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config9.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config9.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config9.xml
--- config9.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,13 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy version="1.0">
- <keystore name="aaaaa"
- location="sar:/conf/keystore"
- type="JKS"/>
- <grant code-base="myCodeBase">
- <permission class="java.io.FilePermission"
- target="${/}tmp${/}*"
- signed-by="Bob"
- key-store="aaaaa"
- action="read,write"/>
- </grant>
-
-</policy>
</pre></div>
<hr /><a name="file17" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config5.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config5.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config5.xml
--- config5.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,5 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy version="1.0">
- <grant code-base="sar:/SAR-INF/lib/*">
- <permission class="java.io.FilePermission"/>
- </grant>
-</policy>
</pre></div>
<hr /><a name="file18" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config10.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config10.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config10.xml
--- config10.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,13 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy version="1.0">
- <keystore name="a"
- location="sar:/conf/keystore"
- type="JKS"/>
- <grant code-base="myCodeBase">
- <permission class="java.io.FilePermission"
- target="${/}tmp${/}*"
- signed-by="Bob"
- key-store="a_"
- action="read,write"/>
- </grant>
-
-</policy>
</pre></div>
<hr /><a name="file19" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config6.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/verifier/test/config6.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config6.xml
--- config6.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,6 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy version="1.0">
- <!-- testing empty name -->
- <keystore name=""
- location="sar:/conf/keystore"
- type="JKS"/>
-</policy>
</pre></div>
<hr /><a name="file20" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/metadata">metadata</a><br /></span>
<div class="fileheader" id="added"><big><b>KeyStoreMetaData.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/metadata/KeyStoreMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N KeyStoreMetaData.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ KeyStoreMetaData.java 19 Apr 2004 22:20:25 -0000 1.1
@@ -0,0 +1,93 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.metadata;
+
+/**
+ * This class defines a keystore that is used when locating
+ * signers of a codebase.
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:25 $
+ */
+public class KeyStoreMetaData
+{
+ /**
+ * The name of the keystore. Used by Grants to
+ * refer to particular key stores.
+ */
+ private final String m_name;
+
+ /**
+ * The location of the keystore (usually a URL).
+ */
+ private final String m_location;
+
+ /**
+ * The type of the keystore.
+ */
+ private final String m_type;
+
+ /**
+ * Construct a keysotre.
+ *
+ * @param name the name of the key store
+ * @param location the location of keystore
+ * @param type the keystore type
+ */
+ public KeyStoreMetaData( final String name,
+ final String location,
+ final String type )
+ {
+ if( null == name )
+ {
+ throw new NullPointerException( "name" );
+ }
+ if( null == location )
+ {
+ throw new NullPointerException( "location" );
+ }
+ if( null == type )
+ {
+ throw new NullPointerException( "type" );
+ }
+
+ m_name = name;
+ m_location = location;
+ m_type = type;
+ }
+
+ /**
+ * Return the name of keystore.
+ *
+ * @return the name of keystore.
+ */
+ public String getName()
+ {
+ return m_name;
+ }
+
+ /**
+ * Return the location of the KeyStore (usually a URL).
+ *
+ * @return the location of the KeyStore (usually a URL).
+ */
+ public String getLocation()
+ {
+ return m_location;
+ }
+
+ /**
+ * Return the type of the key store (ie JKS).
+ *
+ * @return the type of the key store (ie JKS).
+ */
+ public String getType()
+ {
+ return m_type;
+ }
+}
</pre></div>
<hr /><a name="file21" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/metadata">metadata</a><br /></span>
<div class="fileheader" id="added"><big><b>PermissionMetaData.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/metadata/PermissionMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N PermissionMetaData.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PermissionMetaData.java 19 Apr 2004 22:20:25 -0000 1.1
@@ -0,0 +1,131 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.metadata;
+
+/**
+ * This class defines a keystore that is used when locating
+ * signers of a codebase.
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:25 $
+ */
+public class PermissionMetaData
+{
+ /**
+ * The class name of permission.
+ */
+ private final String m_classname;
+
+ /**
+ * The target of permission. The interpretation of this is
+ * determined by underlying permission classname.
+ */
+ private final String m_target;
+
+ /**
+ * The action(s) associated with permission.
+ * The interpretation of this field is relative to
+ * the permission and target.
+ */
+ private final String m_action;
+
+ /**
+ * The signer of the permission.
+ * (ie who signed the permission class).
+ */
+ private final String m_signedBy;
+
+ /**
+ * The keyStore to load signer from. May be null but if
+ * null then signedBy must also be null.
+ */
+ private final String m_keyStore;
+
+ /**
+ * Construct the permission meta data.
+ *
+ * @param classname the name of permission class
+ * @param target the target of permission (may be null)
+ * @param action the action of permission (may be null)
+ */
+ public PermissionMetaData( final String classname,
+ final String target,
+ final String action,
+ final String signedBy,
+ final String keyStore )
+ {
+ if( null == classname )
+ {
+ throw new NullPointerException( "classname" );
+ }
+ if( null == signedBy && null != keyStore )
+ {
+ throw new NullPointerException( "signedBy" );
+ }
+ if( null == keyStore && null != signedBy )
+ {
+ throw new NullPointerException( "keyStore" );
+ }
+
+ m_classname = classname;
+ m_target = target;
+ m_action = action;
+ m_signedBy = signedBy;
+ m_keyStore = keyStore;
+ }
+
+ /**
+ * Return the name of permission class.
+ *
+ * @return the name of permission class.
+ */
+ public String getClassname()
+ {
+ return m_classname;
+ }
+
+ /**
+ * Return the action of permission (may be null).
+ *
+ * @return the action of permission (may be null).
+ */
+ public String getTarget()
+ {
+ return m_target;
+ }
+
+ /**
+ * Return the action of permission (may be null).
+ *
+ * @return the action of permission (may be null)
+ */
+ public String getAction()
+ {
+ return m_action;
+ }
+
+ /**
+ * Return the principle name who signed the permission.
+ *
+ * @return the the principle name who signed the permission.
+ */
+ public String getSignedBy()
+ {
+ return m_signedBy;
+ }
+
+ /**
+ * Return the key store to load signer from.
+ *
+ * @return the key store to load signer from.
+ */
+ public String getKeyStore()
+ {
+ return m_keyStore;
+ }
+}
</pre></div>
<hr /><a name="file22" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/metadata">metadata</a><br /></span>
<div class="fileheader" id="added"><big><b>PolicyMetaData.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/metadata/PolicyMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N PolicyMetaData.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PolicyMetaData.java 19 Apr 2004 22:20:25 -0000 1.1
@@ -0,0 +1,61 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.metadata;
+
+/**
+ * This class defines the set of KeyStores and Grants
+ * in a policy declaration.
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:25 $
+ */
+public class PolicyMetaData
+{
+ /**
+ * The KeyStores associated with policy.
+ */
+ private final KeyStoreMetaData[] m_keyStores;
+
+ /**
+ * The grants that make up the policy.
+ */
+ private final GrantMetaData[] m_grants;
+
+ /**
+ * Create a policy with specific keystores and grants.
+ *
+ * @param keyStores the key stores
+ * @param grants the grants
+ */
+ public PolicyMetaData( final KeyStoreMetaData[] keyStores,
+ final GrantMetaData[] grants )
+ {
+ m_keyStores = keyStores;
+ m_grants = grants;
+ }
+
+ /**
+ * Return the KeyStores associated with policy.
+ *
+ * @return the KeyStores associated with policy.
+ */
+ public KeyStoreMetaData[] getKeyStores()
+ {
+ return m_keyStores;
+ }
+
+ /**
+ * Return the grants that make up policy.
+ *
+ * @return the grants that make up policy.
+ */
+ public GrantMetaData[] getGrants()
+ {
+ return m_grants;
+ }
+}
</pre></div>
<hr /><a name="file23" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/metadata">metadata</a><br /></span>
<div class="fileheader" id="added"><big><b>GrantMetaData.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/metadata/GrantMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N GrantMetaData.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ GrantMetaData.java 19 Apr 2004 22:20:25 -0000 1.1
@@ -0,0 +1,119 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.metadata;
+
+/**
+ * This class defines a keystore that is used when locating
+ * signers of a codebase.
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:25 $
+ */
+public class GrantMetaData
+{
+ /**
+ * The codebase that grant applies to.
+ */
+ private final String m_codebase;
+
+ /**
+ * The signer of codebase. May be null but if null then
+ * keyStore must also be null.
+ */
+ private final String m_signedBy;
+
+ /**
+ * The keyStore to load signer from. May be null but if
+ * null then signedBy must also be null.
+ */
+ private final String m_keyStore;
+
+ /**
+ * The set of permissions to grant codebase.
+ */
+ private final PermissionMetaData[] m_permissions;
+
+ /**
+ * Construct a grant.
+ *
+ * @param codebase the codebase grant is about
+ * @param signedBy who signed the codebase
+ * @param keyStore the name of the keystore the signer is loaded from
+ * @param permissions the set of permissions associated with grant
+ */
+ public GrantMetaData( final String codebase,
+ final String signedBy,
+ final String keyStore,
+ final PermissionMetaData[] permissions )
+ {
+ if( null == permissions )
+ {
+ throw new NullPointerException( "permissions" );
+ }
+ if( null == signedBy && null != keyStore )
+ {
+ throw new NullPointerException( "signedBy" );
+ }
+ if( null == keyStore && null != signedBy )
+ {
+ throw new NullPointerException( "keyStore" );
+ }
+ for( int i = 0; i < permissions.length; i++ )
+ {
+ if( null == permissions[ i ] )
+ {
+ throw new NullPointerException( "permissions[" + i + "]" );
+ }
+ }
+
+ m_codebase = codebase;
+ m_signedBy = signedBy;
+ m_keyStore = keyStore;
+ m_permissions = permissions;
+ }
+
+ /**
+ * Return the code base for grant.
+ *
+ * @return the code base for grant.
+ */
+ public String getCodebase()
+ {
+ return m_codebase;
+ }
+
+ /**
+ * Return the signer for grant.
+ *
+ * @return the signer for grant.
+ */
+ public String getSignedBy()
+ {
+ return m_signedBy;
+ }
+
+ /**
+ * Return the key store to load signer from.
+ *
+ * @return the key store to load signer from.
+ */
+ public String getKeyStore()
+ {
+ return m_keyStore;
+ }
+
+ /**
+ * Return the set of permissions associated with grant.
+ *
+ * @return the set of permissions associated with grant.
+ */
+ public PermissionMetaData[] getPermissions()
+ {
+ return m_permissions;
+ }
+}
</pre></div>
<hr /><a name="file24" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="added"><big><b>PolicyBuilder.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/builder/PolicyBuilder.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N PolicyBuilder.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PolicyBuilder.java 19 Apr 2004 22:20:25 -0000 1.1
@@ -0,0 +1,440 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.builder;
+
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.CodeSource;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.Permission;
+import java.security.Policy;
+import java.security.UnresolvedPermission;
+import java.security.cert.Certificate;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.PropertyPermission;
+import java.util.StringTokenizer;
+
+import org.codehaus.loom.xmlpolicy.metadata.GrantMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.KeyStoreMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.PermissionMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.PolicyMetaData;
+
+/**
+ * A Utility class that builds a Policy object from a specified
+ * PolicyMetaData.
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:25 $
+ */
+public class PolicyBuilder
+{
+ /**
+ * Build a policy for a specified meta data.
+ *
+ * @param policy the policy metadata
+ * @return the Policy object
+ * @throws Exception if unable to create Policy object
+ */
+ public Policy buildPolicy( final PolicyMetaData policy,
+ final PolicyResolver resolver )
+ throws Exception
+ {
+ if( null == policy )
+ {
+ throw new NullPointerException( "policy" );
+ }
+ if( null == resolver )
+ {
+ throw new NullPointerException( "resolver" );
+ }
+
+ final Map keyStores =
+ createKeyStores( policy.getKeyStores(), resolver );
+ final Map grants = new HashMap();
+ processGrants( policy.getGrants(), keyStores, grants, resolver );
+
+ final CodeSource codeSource = createDefaultCodeSource();
+ final Permission[] permissions = getDefaultPermissions();
+ grants.put( codeSource, permissions );
+
+ return resolver.createPolicy( grants );
+ }
+
+ /**
+ * Porcess all the grants and build up a grant map.
+ *
+ * @param metaDatas the metadata
+ * @param keyStores the configured keystores
+ * @param grants the grant map
+ * @param resolver the resolver to use to resolve locations etc
+ * @throws Exception if unable to create grant map
+ */
+ private void processGrants( final GrantMetaData[] metaDatas,
+ final Map keyStores,
+ final Map grants,
+ final PolicyResolver resolver )
+ throws Exception
+ {
+ for( int i = 0; i < metaDatas.length; i++ )
+ {
+ processGrant( metaDatas[ i ], keyStores, grants, resolver );
+ }
+ }
+
+ /**
+ * Porcess a grants and add to the grant map.
+ *
+ * @param metaData the metadata
+ * @param keyStores the configured keystores
+ * @param grants the grant map
+ * @param resolver the resolver to use to resolve locations etc
+ * @throws Exception if unable to create grant map
+ */
+ private void processGrant( final GrantMetaData metaData,
+ final Map keyStores,
+ final Map grants,
+ final PolicyResolver resolver )
+ throws Exception
+ {
+ final URL url =
+ resolver.resolveLocation( metaData.getCodebase() );
+
+ final Certificate[] signers =
+ getSigners( metaData.getSignedBy(),
+ metaData.getKeyStore(),
+ keyStores );
+ final CodeSource codeSource = new CodeSource( url, signers );
+
+ final Permission[] permissions =
+ createPermissions( metaData.getPermissions(),
+ keyStores );
+ grants.put( codeSource, permissions );
+ }
+
+ /**
+ * Create all permissions for specified metadata.
+ *
+ * @param metaDatas the metadata
+ * @param keyStores the keystores to use when loading signers
+ * @return the created permissions
+ * @throws Exception if unabel to create permissions
+ */
+ private Permission[] createPermissions( final PermissionMetaData[] metaDatas,
+ final Map keyStores )
+ throws Exception
+ {
+ final List set = new ArrayList();
+
+ for( int i = 0; i < metaDatas.length; i++ )
+ {
+ final Permission permission =
+ createPermission( metaDatas[ i ], keyStores );
+ set.add( permission );
+ }
+
+ return (Permission[])set.toArray( new Permission[ set.size() ] );
+ }
+
+ /**
+ * Create a permission for metadata.
+ *
+ * @param metaData the permission metadata
+ * @param keyStores the keystore to use (if needed)
+ * @return the created permission
+ * @throws Exception if unable to create permission
+ */
+ private Permission createPermission( final PermissionMetaData metaData,
+ final Map keyStores )
+ throws Exception
+ {
+ final String type = metaData.getClassname();
+ final String actions = metaData.getAction();
+ final String signedBy = metaData.getSignedBy();
+ final String keyStoreName = metaData.getKeyStore();
+ final String target = metaData.getTarget();
+
+ final Certificate[] signers =
+ getSigners( signedBy, keyStoreName, keyStores );
+ return createPermission( type, target, actions, signers );
+ }
+
+ /**
+ * Create a mpa of keystores from specified metadata.
+ *
+ * @param metaDatas the metadata
+ * @return the keystore map
+ * @throws Exception if unable to create all keystores
+ */
+ private Map createKeyStores( final KeyStoreMetaData[] metaDatas,
+ final PolicyResolver resolver )
+ throws Exception
+ {
+ final Map keyStores = new HashMap();
+
+ for( int i = 0; i < metaDatas.length; i++ )
+ {
+ final KeyStoreMetaData metaData = metaDatas[ i ];
+ final String name = metaData.getName();
+
+ try
+ {
+ final URL url =
+ resolver.resolveLocation( metaData.getLocation() );
+ final KeyStore keyStore =
+ createKeyStore( metaData.getType(), url );
+
+ keyStores.put( name, keyStore );
+ }
+ catch( final Exception e )
+ {
+ final String message =
+ "Error creating keystore " + name + ". Due to " + e;
+ throw new Exception( message );
+ }
+ }
+
+ return keyStores;
+ }
+
+ /**
+ * Create a permission of specified class and
+ * with specified target, action and signers.
+ *
+ * @param type the classname of Permission object
+ * @param target the target of permission
+ * @param actions the actions allowed on permission (if any)
+ * @param signers the signers (if any)
+ * @return the created Permission object
+ * @throws Exception if unable to create permission
+ */
+ private final Permission createPermission( final String type,
+ final String target,
+ final String actions,
+ final Certificate[] signers )
+ throws Exception
+ {
+ if( null != signers )
+ {
+ return new UnresolvedPermission( type, target, actions, signers );
+ }
+
+ try
+ {
+ final Class clazz = Class.forName( type );
+
+ Class paramClasses[] = null;
+ Object params[] = null;
+
+ if( null == actions && null == target )
+ {
+ paramClasses = new Class[ 0 ];
+ params = new Object[ 0 ];
+ }
+ else if( null == actions )
+ {
+ paramClasses = new Class[ 1 ];
+ paramClasses[ 0 ] = String.class;
+ params = new Object[ 1 ];
+ params[ 0 ] = target;
+ }
+ else
+ {
+ paramClasses = new Class[ 2 ];
+ paramClasses[ 0 ] = String.class;
+ paramClasses[ 1 ] = String.class;
+ params = new Object[ 2 ];
+ params[ 0 ] = target;
+ params[ 1 ] = actions;
+ }
+
+ final Constructor constructor = clazz.getConstructor( paramClasses );
+ return (Permission)constructor.newInstance( params );
+ }
+ catch( final ClassNotFoundException cnfe )
+ {
+ return new UnresolvedPermission( type, target, actions, signers );
+ }
+ }
+
+ /**
+ * Create a keystore of specified type and loading from specified url.
+ *
+ * @param type the type of key store
+ * @param url the location of key store data
+ * @return the create and configured keystore
+ * @throws Exception if unable to create or load keystore
+ */
+ protected KeyStore createKeyStore( final String type,
+ final URL url )
+ throws Exception
+ {
+ final KeyStore keyStore = KeyStore.getInstance( type );
+ final InputStream ins = url.openStream();
+ keyStore.load( ins, null );
+ return keyStore;
+ }
+
+ /**
+ * Retrieve Certificates for specified signers
+ * as loaded from keyStore.
+ *
+ * @param signedBy the signers
+ * @param keyStoreName the name of keystore
+ * @param keyStores the list of keystores to lookup
+ * @return the certificates
+ * @throws Exception if unable to get signers
+ */
+ private Certificate[] getSigners( final String signedBy,
+ final String keyStoreName,
+ final Map keyStores )
+ throws Exception
+ {
+ if( null == signedBy )
+ {
+ return null;
+ }
+ else
+ {
+ final KeyStore keyStore = getKeyStore( keyStoreName, keyStores );
+ return getCertificates( signedBy, keyStore );
+ }
+ }
+
+ /**
+ * Retrieve the set of Ceritificates for all signers.
+ *
+ * @param signedBy the comma separated list of signers
+ * @param keyStore the keystore to look for signers certificates in
+ * @return the certificate set
+ * @throws Exception if unabel to create certificates
+ */
+ private Certificate[] getCertificates( final String signedBy,
+ final KeyStore keyStore )
+ throws Exception
+ {
+ final List certificateSet = new ArrayList();
+
+ final StringTokenizer st = new StringTokenizer( signedBy, "," );
+ while( st.hasMoreTokens() )
+ {
+ final String alias = st.nextToken().trim();
+ Certificate certificate = null;
+
+ try
+ {
+ certificate = keyStore.getCertificate( alias );
+ }
+ catch( final KeyStoreException kse )
+ {
+ final String message =
+ "Unable to get certificate for alias " +
+ alias + " due to " + kse;
+ throw new Exception( message );
+ }
+
+ if( null == certificate )
+ {
+ final String message =
+ "Missing certificate for alias " + alias;
+ throw new Exception( message );
+ }
+
+ if( !certificateSet.contains( certificate ) )
+ {
+ certificateSet.add( certificate );
+ }
+ }
+
+ return (Certificate[])certificateSet.toArray( new Certificate[ certificateSet.size() ] );
+ }
+
+ /**
+ * Retrieve keystore with specified name from map.
+ * If missing throw an exception.
+ *
+ * @param keyStoreName the name of key store
+ * @param keyStores the map of stores
+ * @return the keystore
+ * @throws Exception thrown if unable to locate keystore
+ */
+ private KeyStore getKeyStore( final String keyStoreName, final Map keyStores ) throws Exception
+ {
+ final KeyStore keyStore = (KeyStore)keyStores.get( keyStoreName );
+ if( null == keyStore )
+ {
+ final String message = "Missing keystore named: " + keyStoreName;
+ throw new Exception( message );
+ }
+ else
+ {
+ return keyStore;
+ }
+ }
+
+ /**
+ * A utility method to get a default codesource
+ * that covers all files on fielsystem
+ *
+ * @return the code source
+ */
+ private CodeSource createDefaultCodeSource()
+ {
+ //Create a URL that covers whole file system.
+ final URL url;
+ try
+ {
+ url = new URL( "file:/-" );
+ }
+ catch( final MalformedURLException mue )
+ {
+ //will never happen
+ throw new IllegalStateException( mue.getMessage() );
+ }
+ final CodeSource codeSource = new CodeSource( url, null );
+ return codeSource;
+ }
+
+ /**
+ * A utility method to get all the default permissions.
+ */
+ private Permission[] getDefaultPermissions()
+ {
+ final ArrayList list = new ArrayList();
+ //these properties straight out ot ${java.home}/lib/security/java.policy
+ list.add( new PropertyPermission( "os.name", "read" ) );
+ list.add( new PropertyPermission( "os.arch", "read" ) );
+ list.add( new PropertyPermission( "os.version", "read" ) );
+ list.add( new PropertyPermission( "file.separator", "read" ) );
+ list.add( new PropertyPermission( "path.separator", "read" ) );
+ list.add( new PropertyPermission( "line.separator", "read" ) );
+
+ list.add( new PropertyPermission( "java.version", "read" ) );
+ list.add( new PropertyPermission( "java.vendor", "read" ) );
+ list.add( new PropertyPermission( "java.vendor.url", "read" ) );
+
+ list.add( new PropertyPermission( "java.class.version", "read" ) );
+ list.add( new PropertyPermission( "java.vm.version", "read" ) );
+ list.add( new PropertyPermission( "java.vm.vendor", "read" ) );
+ list.add( new PropertyPermission( "java.vm.name", "read" ) );
+
+ list.add( new PropertyPermission( "java.specification.version", "read" ) );
+ list.add( new PropertyPermission( "java.specification.vendor", "read" ) );
+ list.add( new PropertyPermission( "java.specification.name", "read" ) );
+ list.add( new PropertyPermission( "java.vm.specification.version", "read" ) );
+ list.add( new PropertyPermission( "java.vm.specification.vendor", "read" ) );
+ list.add( new PropertyPermission( "java.vm.specification.name", "read" ) );
+
+ return (Permission[])list.toArray( new Permission[ list.size() ] );
+ }
+}
</pre></div>
<hr /><a name="file25" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="added"><big><b>PolicyResolver.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/builder/PolicyResolver.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N PolicyResolver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PolicyResolver.java 19 Apr 2004 22:20:25 -0000 1.1
@@ -0,0 +1,44 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.builder;
+
+import java.net.URL;
+import java.security.Policy;
+import java.util.Map;
+
+/**
+ * This is the interface via which elements of Policy are resolved.
+ * For example it is possible for the Policy file to use abstract URLs
+ * such as "sar:/SAR-INF/lib/" which need to be mapped to a concrete
+ * URL. It is also necessary for the target values of permissions
+ * to be "resolved" using a pseuedo expression language.
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:25 $
+ */
+public interface PolicyResolver
+{
+ /**
+ * Resolve a location to a URL.
+ *
+ * @param location the location
+ * @return the URL
+ * @throws Exception if unable to resolve URL
+ */
+ URL resolveLocation( String location )
+ throws Exception;
+
+ /**
+ * Create a Policy object from a grant map.
+ *
+ * @param grants the grants map
+ * @return the Policy object
+ */
+ Policy createPolicy( Map grants )
+ throws Exception;
+}
</pre></div>
<hr /><a name="file26" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader">reader</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config3.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test/config3.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config3.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config3.xml 19 Apr 2004 22:20:25 -0000 1.1
@@ -0,0 +1,2 @@
</small></pre><pre class="diff" id="added">+<policy version="3.2">
+</policy>
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file27" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader">reader</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config4.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test/config4.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config4.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config4.xml 19 Apr 2004 22:20:25 -0000 1.1
@@ -0,0 +1,7 @@
</small></pre><pre class="diff" id="added">+<policy version="1.0">
+
+ <!-- a grant with no codebase -->
+ <grant>
+ <permission class="java.io.FilePermission"/>
+ </grant>
+</policy>
</pre></div>
<hr /><a name="file28" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader">reader</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config2.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test/config2.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config2.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config2.xml 19 Apr 2004 22:20:25 -0000 1.1
@@ -0,0 +1,2 @@
</small></pre><pre class="diff" id="added">+<policy>
+</policy>
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file29" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader">reader</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>ReaderTestCase.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test/ReaderTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N ReaderTestCase.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ReaderTestCase.java 19 Apr 2004 22:20:25 -0000 1.1
@@ -0,0 +1,284 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.reader.test;
+
+import org.codehaus.loom.xmlpolicy.metadata.GrantMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.KeyStoreMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.PermissionMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.PolicyMetaData;
+import org.codehaus.loom.xmlpolicy.test.AbstractPolicyTestCase;
+
+/**
+ * TestCase for {@link org.codehaus.loom.xmlpolicy.reader.PolicyReader}.
+ *
+ * @author Peter Donald
+ */
+public class ReaderTestCase
+ extends AbstractPolicyTestCase
+{
+ public ReaderTestCase( final String name )
+ {
+ super( name );
+ }
+
+ public void testConfig1()
+ throws Exception
+ {
+ final PolicyMetaData policy = buildFromResource( "config1.xml" );
+
+ assertEquals( "Policy KeyStore Count",
+ 1,
+ policy.getKeyStores().length );
+
+ final KeyStoreMetaData keyStore = policy.getKeyStores()[ 0 ];
+ assertEquals( "KeyStore Name",
+ "myKeystore",
+ keyStore.getName() );
+ assertEquals( "KeyStore Location",
+ "sar:/conf/keystore",
+ keyStore.getLocation() );
+ assertEquals( "KeyStore Type",
+ "JKS",
+ keyStore.getType() );
+
+ assertEquals( "Policy Grant Count",
+ 2,
+ policy.getGrants().length );
+
+ final GrantMetaData grant1 = policy.getGrants()[ 0 ];
+ final GrantMetaData grant2 = policy.getGrants()[ 1 ];
+
+ assertEquals( "grant1.getCodebase()",
+ "myCodeBase",
+ grant1.getCodebase() );
+ assertEquals( "grant1.getKeyStore()",
+ null,
+ grant1.getKeyStore() );
+ assertEquals( "grant1.getSignedBy()",
+ null,
+ grant1.getSignedBy() );
+
+ assertEquals( "grant1.getPermissions().length",
+ 1,
+ grant1.getPermissions().length );
+
+ final PermissionMetaData permission1 = grant1.getPermissions()[ 0 ];
+ assertEquals( "permission1.getClassname()",
+ "java.io.FilePermission",
+ permission1.getClassname() );
+ assertEquals( "permission1.getAction()",
+ "read,write",
+ permission1.getAction() );
+ assertEquals( "permission1.getTarget()",
+ "${/}tmp${/}*",
+ permission1.getTarget() );
+ assertEquals( "permission1.getKeyStore()",
+ "myKeystore",
+ permission1.getKeyStore() );
+ assertEquals( "permission1.getSignedBy()",
+ "Bob",
+ permission1.getSignedBy() );
+
+ assertEquals( "grant2.getCodebase()",
+ "sar:/SAR-INF/lib/*",
+ grant2.getCodebase() );
+ assertEquals( "grant2.getKeyStore()",
+ "myKeystore",
+ grant2.getKeyStore() );
+ assertEquals( "grant2.getSignedBy()",
+ "Bob",
+ grant2.getSignedBy() );
+
+ assertEquals( "grant2.getPermissions().length",
+ 1,
+ grant2.getPermissions().length );
+
+ final PermissionMetaData permission2 = grant2.getPermissions()[ 0 ];
+ assertEquals( "permission2.getClassname()",
+ "java.io.FilePermission",
+ permission2.getClassname() );
+ assertEquals( "permission2.getAction()",
+ null,
+ permission2.getAction() );
+ assertEquals( "permission2.getTarget()",
+ null,
+ permission2.getTarget() );
+ assertEquals( "permission2.getKeyStore()",
+ null,
+ permission2.getKeyStore() );
+ assertEquals( "permission2.getSignedBy()",
+ null,
+ permission2.getSignedBy() );
+ }
+
+ public void testConfig2()
+ throws Exception
+ {
+ try
+ {
+ buildFromResource( "config2.xml" );
+ }
+ catch( final Throwable t )
+ {
+ return;
+ }
+ fail( "Should have failed as loaded a " +
+ "configuration with no version" );
+ }
+
+ public void testConfig3()
+ throws Exception
+ {
+ try
+ {
+ buildFromResource( "config3.xml" );
+ }
+ catch( final Throwable t )
+ {
+ return;
+ }
+ fail( "Should have failed as loaded a " +
+ "configuration with bad version set" );
+ }
+
+ public void testConfig4()
+ throws Exception
+ {
+ final PolicyMetaData policy = buildFromResource( "config4.xml" );
+ assertEquals( "Policy KeyStore Count",
+ 0,
+ policy.getKeyStores().length );
+
+ assertEquals( "Policy Grant Count",
+ 1,
+ policy.getGrants().length );
+
+ final GrantMetaData grant1 = policy.getGrants()[ 0 ];
+
+ assertEquals( "grant1.getCodebase()",
+ null,
+ grant1.getCodebase() );
+ assertEquals( "grant1.getKeyStore()",
+ null,
+ grant1.getKeyStore() );
+ assertEquals( "grant1.getSignedBy()",
+ null,
+ grant1.getSignedBy() );
+
+ assertEquals( "grant1.getPermissions().length",
+ 1,
+ grant1.getPermissions().length );
+
+ final PermissionMetaData permission1 = grant1.getPermissions()[ 0 ];
+ assertEquals( "permission1.getClassname()",
+ "java.io.FilePermission",
+ permission1.getClassname() );
+ assertEquals( "permission1.getAction()",
+ null,
+ permission1.getAction() );
+ assertEquals( "permission1.getTarget()",
+ null,
+ permission1.getTarget() );
+ assertEquals( "permission1.getKeyStore()",
+ null,
+ permission1.getKeyStore() );
+ assertEquals( "permission1.getSignedBy()",
+ null,
+ permission1.getSignedBy() );
+ }
+
+ public void testConfig5()
+ throws Exception
+ {
+ final PolicyMetaData policy = buildFromResource( "config5.xml" );
+
+ assertEquals( "Policy KeyStore Count",
+ 1,
+ policy.getKeyStores().length );
+
+ final KeyStoreMetaData keyStore = policy.getKeyStores()[ 0 ];
+ assertEquals( "KeyStore Name",
+ "default",
+ keyStore.getName() );
+ assertEquals( "KeyStore Location",
+ "sar:/conf/keystore",
+ keyStore.getLocation() );
+ assertEquals( "KeyStore Type",
+ "JKS",
+ keyStore.getType() );
+
+ assertEquals( "Policy Grant Count",
+ 2,
+ policy.getGrants().length );
+
+ final GrantMetaData grant1 = policy.getGrants()[ 0 ];
+ final GrantMetaData grant2 = policy.getGrants()[ 1 ];
+
+ assertEquals( "grant1.getCodebase()",
+ "myCodeBase",
+ grant1.getCodebase() );
+ assertEquals( "grant1.getKeyStore()",
+ null,
+ grant1.getKeyStore() );
+ assertEquals( "grant1.getSignedBy()",
+ null,
+ grant1.getSignedBy() );
+
+ assertEquals( "grant1.getPermissions().length",
+ 1,
+ grant1.getPermissions().length );
+
+ final PermissionMetaData permission1 = grant1.getPermissions()[ 0 ];
+ assertEquals( "permission1.getClassname()",
+ "java.io.FilePermission",
+ permission1.getClassname() );
+ assertEquals( "permission1.getAction()",
+ "read,write",
+ permission1.getAction() );
+ assertEquals( "permission1.getTarget()",
+ "${/}tmp${/}*",
+ permission1.getTarget() );
+ assertEquals( "permission1.getKeyStore()",
+ "default",
+ permission1.getKeyStore() );
+ assertEquals( "permission1.getSignedBy()",
+ "Bob",
+ permission1.getSignedBy() );
+
+ assertEquals( "grant2.getCodebase()",
+ "sar:/SAR-INF/lib/*",
+ grant2.getCodebase() );
+ assertEquals( "grant2.getKeyStore()",
+ "default",
+ grant2.getKeyStore() );
+ assertEquals( "grant2.getSignedBy()",
+ "Bob",
+ grant2.getSignedBy() );
+
+ assertEquals( "grant2.getPermissions().length",
+ 1,
+ grant2.getPermissions().length );
+
+ final PermissionMetaData permission2 = grant2.getPermissions()[ 0 ];
+ assertEquals( "permission2.getClassname()",
+ "java.io.FilePermission",
+ permission2.getClassname() );
+ assertEquals( "permission2.getAction()",
+ null,
+ permission2.getAction() );
+ assertEquals( "permission2.getTarget()",
+ null,
+ permission2.getTarget() );
+ assertEquals( "permission2.getKeyStore()",
+ null,
+ permission2.getKeyStore() );
+ assertEquals( "permission2.getSignedBy()",
+ null,
+ permission2.getSignedBy() );
+ }
+}
</pre></div>
<hr /><a name="file30" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader">reader</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config1.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test/config1.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config1.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config1.xml 19 Apr 2004 22:20:25 -0000 1.1
@@ -0,0 +1,17 @@
</small></pre><pre class="diff" id="added">+<policy version="1.0">
+ <keystore name="myKeystore"
+ location="sar:/conf/keystore"
+ type="JKS"/>
+
+ <grant code-base="myCodeBase">
+ <permission class="java.io.FilePermission"
+ target="${/}tmp${/}*"
+ signed-by="Bob"
+ key-store="myKeystore"
+ action="read,write"/>
+ </grant>
+
+ <grant signed-by="Bob" key-store="myKeystore" code-base="sar:/SAR-INF/lib/*">
+ <permission class="java.io.FilePermission"/>
+ </grant>
+</policy>
</pre></div>
<hr /><a name="file31" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader">reader</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config5.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/reader/test/config5.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config5.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config5.xml 19 Apr 2004 22:20:25 -0000 1.1
@@ -0,0 +1,17 @@
</small></pre><pre class="diff" id="added">+<policy version="1.0">
+
+ <keystore name="default"
+ location="sar:/conf/keystore"
+ type="JKS"/>
+
+ <grant code-base="myCodeBase">
+ <permission class="java.io.FilePermission"
+ target="${/}tmp${/}*"
+ signed-by="Bob"
+ action="read,write"/>
+ </grant>
+
+ <grant signed-by="Bob" code-base="sar:/SAR-INF/lib/*">
+ <permission class="java.io.FilePermission"/>
+ </grant>
+</policy>
</pre></div>
<hr /><a name="file32" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/metadata">metadata</a><br /></span>
<div class="fileheader" id="removed"><big><b>GrantMetaData.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/metadata/GrantMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N GrantMetaData.java
--- GrantMetaData.java 31 Mar 2004 03:27:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,119 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.metadata;
-
-/**
- * This class defines a keystore that is used when locating
- * signers of a codebase.
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:57 $
- */
-public class GrantMetaData
-{
- /**
- * The codebase that grant applies to.
- */
- private final String m_codebase;
-
- /**
- * The signer of codebase. May be null but if null then
- * keyStore must also be null.
- */
- private final String m_signedBy;
-
- /**
- * The keyStore to load signer from. May be null but if
- * null then signedBy must also be null.
- */
- private final String m_keyStore;
-
- /**
- * The set of permissions to grant codebase.
- */
- private final PermissionMetaData[] m_permissions;
-
- /**
- * Construct a grant.
- *
- * @param codebase the codebase grant is about
- * @param signedBy who signed the codebase
- * @param keyStore the name of the keystore the signer is loaded from
- * @param permissions the set of permissions associated with grant
- */
- public GrantMetaData( final String codebase,
- final String signedBy,
- final String keyStore,
- final PermissionMetaData[] permissions )
- {
- if( null == permissions )
- {
- throw new NullPointerException( "permissions" );
- }
- if( null == signedBy && null != keyStore )
- {
- throw new NullPointerException( "signedBy" );
- }
- if( null == keyStore && null != signedBy )
- {
- throw new NullPointerException( "keyStore" );
- }
- for( int i = 0; i < permissions.length; i++ )
- {
- if( null == permissions[ i ] )
- {
- throw new NullPointerException( "permissions[" + i + "]" );
- }
- }
-
- m_codebase = codebase;
- m_signedBy = signedBy;
- m_keyStore = keyStore;
- m_permissions = permissions;
- }
-
- /**
- * Return the code base for grant.
- *
- * @return the code base for grant.
- */
- public String getCodebase()
- {
- return m_codebase;
- }
-
- /**
- * Return the signer for grant.
- *
- * @return the signer for grant.
- */
- public String getSignedBy()
- {
- return m_signedBy;
- }
-
- /**
- * Return the key store to load signer from.
- *
- * @return the key store to load signer from.
- */
- public String getKeyStore()
- {
- return m_keyStore;
- }
-
- /**
- * Return the set of permissions associated with grant.
- *
- * @return the set of permissions associated with grant.
- */
- public PermissionMetaData[] getPermissions()
- {
- return m_permissions;
- }
-}
</pre></div>
<hr /><a name="file33" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/metadata">metadata</a><br /></span>
<div class="fileheader" id="removed"><big><b>KeyStoreMetaData.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/metadata/KeyStoreMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N KeyStoreMetaData.java
--- KeyStoreMetaData.java 31 Mar 2004 03:27:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,93 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.metadata;
-
-/**
- * This class defines a keystore that is used when locating
- * signers of a codebase.
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:57 $
- */
-public class KeyStoreMetaData
-{
- /**
- * The name of the keystore. Used by Grants to
- * refer to particular key stores.
- */
- private final String m_name;
-
- /**
- * The location of the keystore (usually a URL).
- */
- private final String m_location;
-
- /**
- * The type of the keystore.
- */
- private final String m_type;
-
- /**
- * Construct a keysotre.
- *
- * @param name the name of the key store
- * @param location the location of keystore
- * @param type the keystore type
- */
- public KeyStoreMetaData( final String name,
- final String location,
- final String type )
- {
- if( null == name )
- {
- throw new NullPointerException( "name" );
- }
- if( null == location )
- {
- throw new NullPointerException( "location" );
- }
- if( null == type )
- {
- throw new NullPointerException( "type" );
- }
-
- m_name = name;
- m_location = location;
- m_type = type;
- }
-
- /**
- * Return the name of keystore.
- *
- * @return the name of keystore.
- */
- public String getName()
- {
- return m_name;
- }
-
- /**
- * Return the location of the KeyStore (usually a URL).
- *
- * @return the location of the KeyStore (usually a URL).
- */
- public String getLocation()
- {
- return m_location;
- }
-
- /**
- * Return the type of the key store (ie JKS).
- *
- * @return the type of the key store (ie JKS).
- */
- public String getType()
- {
- return m_type;
- }
-}
</pre></div>
<hr /><a name="file34" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/metadata">metadata</a><br /></span>
<div class="fileheader" id="removed"><big><b>PolicyMetaData.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/metadata/PolicyMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N PolicyMetaData.java
--- PolicyMetaData.java 31 Mar 2004 03:27:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,61 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.metadata;
-
-/**
- * This class defines the set of KeyStores and Grants
- * in a policy declaration.
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:57 $
- */
-public class PolicyMetaData
-{
- /**
- * The KeyStores associated with policy.
- */
- private final KeyStoreMetaData[] m_keyStores;
-
- /**
- * The grants that make up the policy.
- */
- private final GrantMetaData[] m_grants;
-
- /**
- * Create a policy with specific keystores and grants.
- *
- * @param keyStores the key stores
- * @param grants the grants
- */
- public PolicyMetaData( final KeyStoreMetaData[] keyStores,
- final GrantMetaData[] grants )
- {
- m_keyStores = keyStores;
- m_grants = grants;
- }
-
- /**
- * Return the KeyStores associated with policy.
- *
- * @return the KeyStores associated with policy.
- */
- public KeyStoreMetaData[] getKeyStores()
- {
- return m_keyStores;
- }
-
- /**
- * Return the grants that make up policy.
- *
- * @return the grants that make up policy.
- */
- public GrantMetaData[] getGrants()
- {
- return m_grants;
- }
-}
</pre></div>
<hr /><a name="file35" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/metadata">metadata</a><br /></span>
<div class="fileheader" id="removed"><big><b>PermissionMetaData.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/metadata/PermissionMetaData.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N PermissionMetaData.java
--- PermissionMetaData.java 31 Mar 2004 03:27:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,131 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.metadata;
-
-/**
- * This class defines a keystore that is used when locating
- * signers of a codebase.
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:57 $
- */
-public class PermissionMetaData
-{
- /**
- * The class name of permission.
- */
- private final String m_classname;
-
- /**
- * The target of permission. The interpretation of this is
- * determined by underlying permission classname.
- */
- private final String m_target;
-
- /**
- * The action(s) associated with permission.
- * The interpretation of this field is relative to
- * the permission and target.
- */
- private final String m_action;
-
- /**
- * The signer of the permission.
- * (ie who signed the permission class).
- */
- private final String m_signedBy;
-
- /**
- * The keyStore to load signer from. May be null but if
- * null then signedBy must also be null.
- */
- private final String m_keyStore;
-
- /**
- * Construct the permission meta data.
- *
- * @param classname the name of permission class
- * @param target the target of permission (may be null)
- * @param action the action of permission (may be null)
- */
- public PermissionMetaData( final String classname,
- final String target,
- final String action,
- final String signedBy,
- final String keyStore )
- {
- if( null == classname )
- {
- throw new NullPointerException( "classname" );
- }
- if( null == signedBy && null != keyStore )
- {
- throw new NullPointerException( "signedBy" );
- }
- if( null == keyStore && null != signedBy )
- {
- throw new NullPointerException( "keyStore" );
- }
-
- m_classname = classname;
- m_target = target;
- m_action = action;
- m_signedBy = signedBy;
- m_keyStore = keyStore;
- }
-
- /**
- * Return the name of permission class.
- *
- * @return the name of permission class.
- */
- public String getClassname()
- {
- return m_classname;
- }
-
- /**
- * Return the action of permission (may be null).
- *
- * @return the action of permission (may be null).
- */
- public String getTarget()
- {
- return m_target;
- }
-
- /**
- * Return the action of permission (may be null).
- *
- * @return the action of permission (may be null)
- */
- public String getAction()
- {
- return m_action;
- }
-
- /**
- * Return the principle name who signed the permission.
- *
- * @return the the principle name who signed the permission.
- */
- public String getSignedBy()
- {
- return m_signedBy;
- }
-
- /**
- * Return the key store to load signer from.
- *
- * @return the key store to load signer from.
- */
- public String getKeyStore()
- {
- return m_keyStore;
- }
-}
</pre></div>
<hr /><a name="file36" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/metadata">metadata</a><br /></span>
<div class="fileheader" id="added"><big><b>MetaDataTestCase.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/metadata/MetaDataTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N MetaDataTestCase.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MetaDataTestCase.java 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,190 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.metadata;
+
+import org.codehaus.loom.xmlpolicy.metadata.GrantMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.KeyStoreMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.PermissionMetaData;
+
+import junit.framework.TestCase;
+
+/**
+ * TestCase for {@link org.codehaus.loom.xmlpolicy.reader.PolicyReader}.
+ *
+ * @author Peter Donald
+ */
+public class MetaDataTestCase
+ extends TestCase
+{
+ public MetaDataTestCase( final String name )
+ {
+ super( name );
+ }
+
+ public void testNullClassNameInPermissionCtor()
+ throws Exception
+ {
+ try
+ {
+ new PermissionMetaData( null, null, null, null, null );
+ fail( "Expected to fail due to null pointer in ctor" );
+ }
+ catch( final NullPointerException npe )
+ {
+ assertEquals( "NPE message",
+ "classname",
+ npe.getMessage() );
+ }
+ }
+
+ public void testNullPermissionsInGrantCtor()
+ throws Exception
+ {
+ try
+ {
+ new GrantMetaData( null, null, null, null );
+ fail( "Expected to fail due to null pointer in ctor" );
+ }
+ catch( final NullPointerException npe )
+ {
+ assertEquals( "NPE message",
+ "permissions",
+ npe.getMessage() );
+ }
+ }
+
+ public void testNullPermissionsElementInGrantCtor()
+ throws Exception
+ {
+ try
+ {
+ new GrantMetaData( null, null, null, new PermissionMetaData[]{null} );
+ fail( "Expected to fail due to null pointer in ctor" );
+ }
+ catch( final NullPointerException npe )
+ {
+ assertEquals( "NPE message",
+ "permissions[0]",
+ npe.getMessage() );
+ }
+ }
+
+
+ public void testNullSignedByNonNullKeyStoreInGrantCtor()
+ throws Exception
+ {
+ try
+ {
+ new GrantMetaData( null, null, "default", new PermissionMetaData[0] );
+ fail( "Expected to fail due to null pointer in ctor" );
+ }
+ catch( final NullPointerException npe )
+ {
+ assertEquals( "NPE message",
+ "signedBy",
+ npe.getMessage() );
+ }
+ }
+
+ public void testNullKeyStoreNonNullSignedByInGrantCtor()
+ throws Exception
+ {
+ try
+ {
+ new GrantMetaData( null, "default", null, new PermissionMetaData[ 0 ] );
+ fail( "Expected to fail due to null pointer in ctor" );
+ }
+ catch( final NullPointerException npe )
+ {
+ assertEquals( "NPE message",
+ "keyStore",
+ npe.getMessage() );
+ }
+ }
+
+ public void testNullNameInKeyStoreCtor()
+ throws Exception
+ {
+ try
+ {
+ new KeyStoreMetaData( null, "", "" );
+ fail( "Expected to fail due to null pointer in ctor" );
+ }
+ catch( final NullPointerException npe )
+ {
+ assertEquals( "NPE message",
+ "name",
+ npe.getMessage() );
+ }
+ }
+
+ public void testNullLocationInKeyStoreCtor()
+ throws Exception
+ {
+ try
+ {
+ new KeyStoreMetaData( "", null, "" );
+ fail( "Expected to fail due to null pointer in ctor" );
+ }
+ catch( final NullPointerException npe )
+ {
+ assertEquals( "NPE message",
+ "location",
+ npe.getMessage() );
+ }
+ }
+
+ public void testNullTypeInKeyStoreCtor()
+ throws Exception
+ {
+ try
+ {
+ new KeyStoreMetaData( "", "", null );
+ fail( "Expected to fail due to null pointer in ctor" );
+ }
+ catch( final NullPointerException npe )
+ {
+ assertEquals( "NPE message",
+ "type",
+ npe.getMessage() );
+ }
+ }
+
+ public void testNullKeyStoreNonNullSignedByInPermissionCtor()
+ throws Exception
+ {
+ try
+ {
+ new PermissionMetaData( "", "", "", "", null );
+ fail( "Expected to fail due to null pointer in ctor" );
+ }
+ catch( final NullPointerException npe )
+ {
+ assertEquals( "NPE message",
+ "keyStore",
+ npe.getMessage() );
+ }
+ }
+
+ public void testNullSignedByNonNullKeyStoreInPermissionCtor()
+ throws Exception
+ {
+ try
+ {
+ new PermissionMetaData( "", "","", null, "default" );
+ fail( "Expected to fail due to null pointer in ctor" );
+ }
+ catch( final NullPointerException npe )
+ {
+ assertEquals( "NPE message",
+ "signedBy",
+ npe.getMessage() );
+ }
+ }
+
+}
</pre></div>
<hr /><a name="file37" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader">reader</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config5.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test/config5.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config5.xml
--- config5.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,17 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy version="1.0">
-
- <keystore name="default"
- location="sar:/conf/keystore"
- type="JKS"/>
-
- <grant code-base="myCodeBase">
- <permission class="java.io.FilePermission"
- target="${/}tmp${/}*"
- signed-by="Bob"
- action="read,write"/>
- </grant>
-
- <grant signed-by="Bob" code-base="sar:/SAR-INF/lib/*">
- <permission class="java.io.FilePermission"/>
- </grant>
-</policy>
</pre></div>
<hr /><a name="file38" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader">reader</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config2.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test/config2.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config2.xml
--- config2.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,2 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy>
-</policy>
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file39" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader">reader</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config1.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test/config1.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config1.xml
--- config1.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,17 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy version="1.0">
- <keystore name="myKeystore"
- location="sar:/conf/keystore"
- type="JKS"/>
-
- <grant code-base="myCodeBase">
- <permission class="java.io.FilePermission"
- target="${/}tmp${/}*"
- signed-by="Bob"
- key-store="myKeystore"
- action="read,write"/>
- </grant>
-
- <grant signed-by="Bob" key-store="myKeystore" code-base="sar:/SAR-INF/lib/*">
- <permission class="java.io.FilePermission"/>
- </grant>
-</policy>
</pre></div>
<hr /><a name="file40" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader">reader</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config3.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test/config3.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config3.xml
--- config3.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,2 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy version="3.2">
-</policy>
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file41" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader">reader</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>ReaderTestCase.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test/ReaderTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N ReaderTestCase.java
--- ReaderTestCase.java 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,284 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.reader.test;
-
-import org.jcontainer.loom.xmlpolicy.metadata.GrantMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.KeyStoreMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.PermissionMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.PolicyMetaData;
-import org.jcontainer.loom.xmlpolicy.test.AbstractPolicyTestCase;
-
-/**
- * TestCase for {@link org.jcontainer.loom.xmlpolicy.reader.PolicyReader}.
- *
- * @author Peter Donald
- */
-public class ReaderTestCase
- extends AbstractPolicyTestCase
-{
- public ReaderTestCase( final String name )
- {
- super( name );
- }
-
- public void testConfig1()
- throws Exception
- {
- final PolicyMetaData policy = buildFromResource( "config1.xml" );
-
- assertEquals( "Policy KeyStore Count",
- 1,
- policy.getKeyStores().length );
-
- final KeyStoreMetaData keyStore = policy.getKeyStores()[ 0 ];
- assertEquals( "KeyStore Name",
- "myKeystore",
- keyStore.getName() );
- assertEquals( "KeyStore Location",
- "sar:/conf/keystore",
- keyStore.getLocation() );
- assertEquals( "KeyStore Type",
- "JKS",
- keyStore.getType() );
-
- assertEquals( "Policy Grant Count",
- 2,
- policy.getGrants().length );
-
- final GrantMetaData grant1 = policy.getGrants()[ 0 ];
- final GrantMetaData grant2 = policy.getGrants()[ 1 ];
-
- assertEquals( "grant1.getCodebase()",
- "myCodeBase",
- grant1.getCodebase() );
- assertEquals( "grant1.getKeyStore()",
- null,
- grant1.getKeyStore() );
- assertEquals( "grant1.getSignedBy()",
- null,
- grant1.getSignedBy() );
-
- assertEquals( "grant1.getPermissions().length",
- 1,
- grant1.getPermissions().length );
-
- final PermissionMetaData permission1 = grant1.getPermissions()[ 0 ];
- assertEquals( "permission1.getClassname()",
- "java.io.FilePermission",
- permission1.getClassname() );
- assertEquals( "permission1.getAction()",
- "read,write",
- permission1.getAction() );
- assertEquals( "permission1.getTarget()",
- "${/}tmp${/}*",
- permission1.getTarget() );
- assertEquals( "permission1.getKeyStore()",
- "myKeystore",
- permission1.getKeyStore() );
- assertEquals( "permission1.getSignedBy()",
- "Bob",
- permission1.getSignedBy() );
-
- assertEquals( "grant2.getCodebase()",
- "sar:/SAR-INF/lib/*",
- grant2.getCodebase() );
- assertEquals( "grant2.getKeyStore()",
- "myKeystore",
- grant2.getKeyStore() );
- assertEquals( "grant2.getSignedBy()",
- "Bob",
- grant2.getSignedBy() );
-
- assertEquals( "grant2.getPermissions().length",
- 1,
- grant2.getPermissions().length );
-
- final PermissionMetaData permission2 = grant2.getPermissions()[ 0 ];
- assertEquals( "permission2.getClassname()",
- "java.io.FilePermission",
- permission2.getClassname() );
- assertEquals( "permission2.getAction()",
- null,
- permission2.getAction() );
- assertEquals( "permission2.getTarget()",
- null,
- permission2.getTarget() );
- assertEquals( "permission2.getKeyStore()",
- null,
- permission2.getKeyStore() );
- assertEquals( "permission2.getSignedBy()",
- null,
- permission2.getSignedBy() );
- }
-
- public void testConfig2()
- throws Exception
- {
- try
- {
- buildFromResource( "config2.xml" );
- }
- catch( final Throwable t )
- {
- return;
- }
- fail( "Should have failed as loaded a " +
- "configuration with no version" );
- }
-
- public void testConfig3()
- throws Exception
- {
- try
- {
- buildFromResource( "config3.xml" );
- }
- catch( final Throwable t )
- {
- return;
- }
- fail( "Should have failed as loaded a " +
- "configuration with bad version set" );
- }
-
- public void testConfig4()
- throws Exception
- {
- final PolicyMetaData policy = buildFromResource( "config4.xml" );
- assertEquals( "Policy KeyStore Count",
- 0,
- policy.getKeyStores().length );
-
- assertEquals( "Policy Grant Count",
- 1,
- policy.getGrants().length );
-
- final GrantMetaData grant1 = policy.getGrants()[ 0 ];
-
- assertEquals( "grant1.getCodebase()",
- null,
- grant1.getCodebase() );
- assertEquals( "grant1.getKeyStore()",
- null,
- grant1.getKeyStore() );
- assertEquals( "grant1.getSignedBy()",
- null,
- grant1.getSignedBy() );
-
- assertEquals( "grant1.getPermissions().length",
- 1,
- grant1.getPermissions().length );
-
- final PermissionMetaData permission1 = grant1.getPermissions()[ 0 ];
- assertEquals( "permission1.getClassname()",
- "java.io.FilePermission",
- permission1.getClassname() );
- assertEquals( "permission1.getAction()",
- null,
- permission1.getAction() );
- assertEquals( "permission1.getTarget()",
- null,
- permission1.getTarget() );
- assertEquals( "permission1.getKeyStore()",
- null,
- permission1.getKeyStore() );
- assertEquals( "permission1.getSignedBy()",
- null,
- permission1.getSignedBy() );
- }
-
- public void testConfig5()
- throws Exception
- {
- final PolicyMetaData policy = buildFromResource( "config5.xml" );
-
- assertEquals( "Policy KeyStore Count",
- 1,
- policy.getKeyStores().length );
-
- final KeyStoreMetaData keyStore = policy.getKeyStores()[ 0 ];
- assertEquals( "KeyStore Name",
- "default",
- keyStore.getName() );
- assertEquals( "KeyStore Location",
- "sar:/conf/keystore",
- keyStore.getLocation() );
- assertEquals( "KeyStore Type",
- "JKS",
- keyStore.getType() );
-
- assertEquals( "Policy Grant Count",
- 2,
- policy.getGrants().length );
-
- final GrantMetaData grant1 = policy.getGrants()[ 0 ];
- final GrantMetaData grant2 = policy.getGrants()[ 1 ];
-
- assertEquals( "grant1.getCodebase()",
- "myCodeBase",
- grant1.getCodebase() );
- assertEquals( "grant1.getKeyStore()",
- null,
- grant1.getKeyStore() );
- assertEquals( "grant1.getSignedBy()",
- null,
- grant1.getSignedBy() );
-
- assertEquals( "grant1.getPermissions().length",
- 1,
- grant1.getPermissions().length );
-
- final PermissionMetaData permission1 = grant1.getPermissions()[ 0 ];
- assertEquals( "permission1.getClassname()",
- "java.io.FilePermission",
- permission1.getClassname() );
- assertEquals( "permission1.getAction()",
- "read,write",
- permission1.getAction() );
- assertEquals( "permission1.getTarget()",
- "${/}tmp${/}*",
- permission1.getTarget() );
- assertEquals( "permission1.getKeyStore()",
- "default",
- permission1.getKeyStore() );
- assertEquals( "permission1.getSignedBy()",
- "Bob",
- permission1.getSignedBy() );
-
- assertEquals( "grant2.getCodebase()",
- "sar:/SAR-INF/lib/*",
- grant2.getCodebase() );
- assertEquals( "grant2.getKeyStore()",
- "default",
- grant2.getKeyStore() );
- assertEquals( "grant2.getSignedBy()",
- "Bob",
- grant2.getSignedBy() );
-
- assertEquals( "grant2.getPermissions().length",
- 1,
- grant2.getPermissions().length );
-
- final PermissionMetaData permission2 = grant2.getPermissions()[ 0 ];
- assertEquals( "permission2.getClassname()",
- "java.io.FilePermission",
- permission2.getClassname() );
- assertEquals( "permission2.getAction()",
- null,
- permission2.getAction() );
- assertEquals( "permission2.getTarget()",
- null,
- permission2.getTarget() );
- assertEquals( "permission2.getKeyStore()",
- null,
- permission2.getKeyStore() );
- assertEquals( "permission2.getSignedBy()",
- null,
- permission2.getSignedBy() );
- }
-}
</pre></div>
<hr /><a name="file42" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader">reader</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>config4.xml</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/reader/test/config4.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config4.xml
--- config4.xml 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,7 +0,0 @@
</small></pre><pre class="diff" id="removed">-<policy version="1.0">
-
- <!-- a grant with no codebase -->
- <grant>
- <permission class="java.io.FilePermission"/>
- </grant>
-</policy>
</pre></div>
<hr /><a name="file43" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="removed"><big><b>PolicyResolver.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/builder/PolicyResolver.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N PolicyResolver.java
--- PolicyResolver.java 31 Mar 2004 03:27:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,44 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.builder;
-
-import java.net.URL;
-import java.security.Policy;
-import java.util.Map;
-
-/**
- * This is the interface via which elements of Policy are resolved.
- * For example it is possible for the Policy file to use abstract URLs
- * such as "sar:/SAR-INF/lib/" which need to be mapped to a concrete
- * URL. It is also necessary for the target values of permissions
- * to be "resolved" using a pseuedo expression language.
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:57 $
- */
-public interface PolicyResolver
-{
- /**
- * Resolve a location to a URL.
- *
- * @param location the location
- * @return the URL
- * @throws Exception if unable to resolve URL
- */
- URL resolveLocation( String location )
- throws Exception;
-
- /**
- * Create a Policy object from a grant map.
- *
- * @param grants the grants map
- * @return the Policy object
- */
- Policy createPolicy( Map grants )
- throws Exception;
-}
</pre></div>
<hr /><a name="file44" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="removed"><big><b>PolicyBuilder.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/builder/PolicyBuilder.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N PolicyBuilder.java
--- PolicyBuilder.java 31 Mar 2004 03:27:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,439 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.builder;
-
-import java.io.InputStream;
-import java.lang.reflect.Constructor;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.CodeSource;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.Permission;
-import java.security.Policy;
-import java.security.UnresolvedPermission;
-import java.security.cert.Certificate;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.PropertyPermission;
-import java.util.StringTokenizer;
-import org.jcontainer.loom.xmlpolicy.metadata.GrantMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.KeyStoreMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.PermissionMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.PolicyMetaData;
-
-/**
- * A Utility class that builds a Policy object from a specified
- * PolicyMetaData.
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:57 $
- */
-public class PolicyBuilder
-{
- /**
- * Build a policy for a specified meta data.
- *
- * @param policy the policy metadata
- * @return the Policy object
- * @throws Exception if unable to create Policy object
- */
- public Policy buildPolicy( final PolicyMetaData policy,
- final PolicyResolver resolver )
- throws Exception
- {
- if( null == policy )
- {
- throw new NullPointerException( "policy" );
- }
- if( null == resolver )
- {
- throw new NullPointerException( "resolver" );
- }
-
- final Map keyStores =
- createKeyStores( policy.getKeyStores(), resolver );
- final Map grants = new HashMap();
- processGrants( policy.getGrants(), keyStores, grants, resolver );
-
- final CodeSource codeSource = createDefaultCodeSource();
- final Permission[] permissions = getDefaultPermissions();
- grants.put( codeSource, permissions );
-
- return resolver.createPolicy( grants );
- }
-
- /**
- * Porcess all the grants and build up a grant map.
- *
- * @param metaDatas the metadata
- * @param keyStores the configured keystores
- * @param grants the grant map
- * @param resolver the resolver to use to resolve locations etc
- * @throws Exception if unable to create grant map
- */
- private void processGrants( final GrantMetaData[] metaDatas,
- final Map keyStores,
- final Map grants,
- final PolicyResolver resolver )
- throws Exception
- {
- for( int i = 0; i < metaDatas.length; i++ )
- {
- processGrant( metaDatas[ i ], keyStores, grants, resolver );
- }
- }
-
- /**
- * Porcess a grants and add to the grant map.
- *
- * @param metaData the metadata
- * @param keyStores the configured keystores
- * @param grants the grant map
- * @param resolver the resolver to use to resolve locations etc
- * @throws Exception if unable to create grant map
- */
- private void processGrant( final GrantMetaData metaData,
- final Map keyStores,
- final Map grants,
- final PolicyResolver resolver )
- throws Exception
- {
- final URL url =
- resolver.resolveLocation( metaData.getCodebase() );
-
- final Certificate[] signers =
- getSigners( metaData.getSignedBy(),
- metaData.getKeyStore(),
- keyStores );
- final CodeSource codeSource = new CodeSource( url, signers );
-
- final Permission[] permissions =
- createPermissions( metaData.getPermissions(),
- keyStores );
- grants.put( codeSource, permissions );
- }
-
- /**
- * Create all permissions for specified metadata.
- *
- * @param metaDatas the metadata
- * @param keyStores the keystores to use when loading signers
- * @return the created permissions
- * @throws Exception if unabel to create permissions
- */
- private Permission[] createPermissions( final PermissionMetaData[] metaDatas,
- final Map keyStores )
- throws Exception
- {
- final List set = new ArrayList();
-
- for( int i = 0; i < metaDatas.length; i++ )
- {
- final Permission permission =
- createPermission( metaDatas[ i ], keyStores );
- set.add( permission );
- }
-
- return (Permission[])set.toArray( new Permission[ set.size() ] );
- }
-
- /**
- * Create a permission for metadata.
- *
- * @param metaData the permission metadata
- * @param keyStores the keystore to use (if needed)
- * @return the created permission
- * @throws Exception if unable to create permission
- */
- private Permission createPermission( final PermissionMetaData metaData,
- final Map keyStores )
- throws Exception
- {
- final String type = metaData.getClassname();
- final String actions = metaData.getAction();
- final String signedBy = metaData.getSignedBy();
- final String keyStoreName = metaData.getKeyStore();
- final String target = metaData.getTarget();
-
- final Certificate[] signers =
- getSigners( signedBy, keyStoreName, keyStores );
- return createPermission( type, target, actions, signers );
- }
-
- /**
- * Create a mpa of keystores from specified metadata.
- *
- * @param metaDatas the metadata
- * @return the keystore map
- * @throws Exception if unable to create all keystores
- */
- private Map createKeyStores( final KeyStoreMetaData[] metaDatas,
- final PolicyResolver resolver )
- throws Exception
- {
- final Map keyStores = new HashMap();
-
- for( int i = 0; i < metaDatas.length; i++ )
- {
- final KeyStoreMetaData metaData = metaDatas[ i ];
- final String name = metaData.getName();
-
- try
- {
- final URL url =
- resolver.resolveLocation( metaData.getLocation() );
- final KeyStore keyStore =
- createKeyStore( metaData.getType(), url );
-
- keyStores.put( name, keyStore );
- }
- catch( final Exception e )
- {
- final String message =
- "Error creating keystore " + name + ". Due to " + e;
- throw new Exception( message );
- }
- }
-
- return keyStores;
- }
-
- /**
- * Create a permission of specified class and
- * with specified target, action and signers.
- *
- * @param type the classname of Permission object
- * @param target the target of permission
- * @param actions the actions allowed on permission (if any)
- * @param signers the signers (if any)
- * @return the created Permission object
- * @throws Exception if unable to create permission
- */
- private final Permission createPermission( final String type,
- final String target,
- final String actions,
- final Certificate[] signers )
- throws Exception
- {
- if( null != signers )
- {
- return new UnresolvedPermission( type, target, actions, signers );
- }
-
- try
- {
- final Class clazz = Class.forName( type );
-
- Class paramClasses[] = null;
- Object params[] = null;
-
- if( null == actions && null == target )
- {
- paramClasses = new Class[ 0 ];
- params = new Object[ 0 ];
- }
- else if( null == actions )
- {
- paramClasses = new Class[ 1 ];
- paramClasses[ 0 ] = String.class;
- params = new Object[ 1 ];
- params[ 0 ] = target;
- }
- else
- {
- paramClasses = new Class[ 2 ];
- paramClasses[ 0 ] = String.class;
- paramClasses[ 1 ] = String.class;
- params = new Object[ 2 ];
- params[ 0 ] = target;
- params[ 1 ] = actions;
- }
-
- final Constructor constructor = clazz.getConstructor( paramClasses );
- return (Permission)constructor.newInstance( params );
- }
- catch( final ClassNotFoundException cnfe )
- {
- return new UnresolvedPermission( type, target, actions, signers );
- }
- }
-
- /**
- * Create a keystore of specified type and loading from specified url.
- *
- * @param type the type of key store
- * @param url the location of key store data
- * @return the create and configured keystore
- * @throws Exception if unable to create or load keystore
- */
- protected KeyStore createKeyStore( final String type,
- final URL url )
- throws Exception
- {
- final KeyStore keyStore = KeyStore.getInstance( type );
- final InputStream ins = url.openStream();
- keyStore.load( ins, null );
- return keyStore;
- }
-
- /**
- * Retrieve Certificates for specified signers
- * as loaded from keyStore.
- *
- * @param signedBy the signers
- * @param keyStoreName the name of keystore
- * @param keyStores the list of keystores to lookup
- * @return the certificates
- * @throws Exception if unable to get signers
- */
- private Certificate[] getSigners( final String signedBy,
- final String keyStoreName,
- final Map keyStores )
- throws Exception
- {
- if( null == signedBy )
- {
- return null;
- }
- else
- {
- final KeyStore keyStore = getKeyStore( keyStoreName, keyStores );
- return getCertificates( signedBy, keyStore );
- }
- }
-
- /**
- * Retrieve the set of Ceritificates for all signers.
- *
- * @param signedBy the comma separated list of signers
- * @param keyStore the keystore to look for signers certificates in
- * @return the certificate set
- * @throws Exception if unabel to create certificates
- */
- private Certificate[] getCertificates( final String signedBy,
- final KeyStore keyStore )
- throws Exception
- {
- final List certificateSet = new ArrayList();
-
- final StringTokenizer st = new StringTokenizer( signedBy, "," );
- while( st.hasMoreTokens() )
- {
- final String alias = st.nextToken().trim();
- Certificate certificate = null;
-
- try
- {
- certificate = keyStore.getCertificate( alias );
- }
- catch( final KeyStoreException kse )
- {
- final String message =
- "Unable to get certificate for alias " +
- alias + " due to " + kse;
- throw new Exception( message );
- }
-
- if( null == certificate )
- {
- final String message =
- "Missing certificate for alias " + alias;
- throw new Exception( message );
- }
-
- if( !certificateSet.contains( certificate ) )
- {
- certificateSet.add( certificate );
- }
- }
-
- return (Certificate[])certificateSet.toArray( new Certificate[ certificateSet.size() ] );
- }
-
- /**
- * Retrieve keystore with specified name from map.
- * If missing throw an exception.
- *
- * @param keyStoreName the name of key store
- * @param keyStores the map of stores
- * @return the keystore
- * @throws Exception thrown if unable to locate keystore
- */
- private KeyStore getKeyStore( final String keyStoreName, final Map keyStores ) throws Exception
- {
- final KeyStore keyStore = (KeyStore)keyStores.get( keyStoreName );
- if( null == keyStore )
- {
- final String message = "Missing keystore named: " + keyStoreName;
- throw new Exception( message );
- }
- else
- {
- return keyStore;
- }
- }
-
- /**
- * A utility method to get a default codesource
- * that covers all files on fielsystem
- *
- * @return the code source
- */
- private CodeSource createDefaultCodeSource()
- {
- //Create a URL that covers whole file system.
- final URL url;
- try
- {
- url = new URL( "file:/-" );
- }
- catch( final MalformedURLException mue )
- {
- //will never happen
- throw new IllegalStateException( mue.getMessage() );
- }
- final CodeSource codeSource = new CodeSource( url, null );
- return codeSource;
- }
-
- /**
- * A utility method to get all the default permissions.
- */
- private Permission[] getDefaultPermissions()
- {
- final ArrayList list = new ArrayList();
- //these properties straight out ot ${java.home}/lib/security/java.policy
- list.add( new PropertyPermission( "os.name", "read" ) );
- list.add( new PropertyPermission( "os.arch", "read" ) );
- list.add( new PropertyPermission( "os.version", "read" ) );
- list.add( new PropertyPermission( "file.separator", "read" ) );
- list.add( new PropertyPermission( "path.separator", "read" ) );
- list.add( new PropertyPermission( "line.separator", "read" ) );
-
- list.add( new PropertyPermission( "java.version", "read" ) );
- list.add( new PropertyPermission( "java.vendor", "read" ) );
- list.add( new PropertyPermission( "java.vendor.url", "read" ) );
-
- list.add( new PropertyPermission( "java.class.version", "read" ) );
- list.add( new PropertyPermission( "java.vm.version", "read" ) );
- list.add( new PropertyPermission( "java.vm.vendor", "read" ) );
- list.add( new PropertyPermission( "java.vm.name", "read" ) );
-
- list.add( new PropertyPermission( "java.specification.version", "read" ) );
- list.add( new PropertyPermission( "java.specification.vendor", "read" ) );
- list.add( new PropertyPermission( "java.specification.name", "read" ) );
- list.add( new PropertyPermission( "java.vm.specification.version", "read" ) );
- list.add( new PropertyPermission( "java.vm.specification.vendor", "read" ) );
- list.add( new PropertyPermission( "java.vm.specification.name", "read" ) );
-
- return (Permission[])list.toArray( new Permission[ list.size() ] );
- }
-}
</pre></div>
<hr /><a name="file45" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="added"><big><b>MockKeyStore.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/MockKeyStore.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N MockKeyStore.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MockKeyStore.java 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,30 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.builder;
+
+import java.io.IOException;
+import java.security.KeyStore;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.util.HashMap;
+
+/**
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:26 $
+ */
+class MockKeyStore
+ extends KeyStore
+{
+ MockKeyStore( final HashMap certs )
+ throws IOException, NoSuchAlgorithmException, CertificateException
+ {
+ super( new MockKeyStoreSpi( certs ), null, null );
+ load( null, null );
+ }
+}
</pre></div>
<hr /><a name="file46" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="added"><big><b>BuilderTestCase.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/BuilderTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N BuilderTestCase.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ BuilderTestCase.java 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,355 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.builder;
+
+import java.net.URL;
+import java.security.AllPermission;
+import java.security.CodeSource;
+import java.security.PermissionCollection;
+import java.security.Policy;
+import java.security.UnresolvedPermission;
+import java.security.cert.Certificate;
+import java.util.Enumeration;
+import java.io.FilePermission;
+import junit.framework.TestCase;
+
+import org.codehaus.loom.xmlpolicy.builder.PolicyBuilder;
+import org.codehaus.loom.xmlpolicy.metadata.GrantMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.KeyStoreMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.PermissionMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.PolicyMetaData;
+
+/**
+ * TestCase for Builder package.
+ *
+ * @author Peter Donald
+ */
+public class BuilderTestCase
+ extends TestCase
+{
+ public BuilderTestCase( final String name )
+ {
+ super( name );
+ }
+
+ public void testEmptyMetaData()
+ throws Exception
+ {
+ final PolicyBuilder builder = new PolicyBuilder();
+ final PolicyMetaData metaData =
+ new PolicyMetaData( new KeyStoreMetaData[ 0 ], new GrantMetaData[ 0 ] );
+ final TestResolver resolver = new TestResolver();
+ try
+ {
+ final Policy policy = builder.buildPolicy( metaData, resolver );
+ final PermissionCollection permissions =
+ policy.getPermissions( new CodeSource( null, new Certificate[ 0 ] ) );
+ assertEquals( "Expect no permissions for empty metaData",
+ false,
+ permissions.elements().hasMoreElements() );
+ }
+ catch( final Exception e )
+ {
+ fail( "Expected to be able to build Policy with empty metadata" );
+ }
+ }
+
+ public void testNullResolverInBuildPolicy()
+ throws Exception
+ {
+ final PolicyBuilder builder = new PolicyBuilder();
+ final PolicyMetaData metaData =
+ new PolicyMetaData( new KeyStoreMetaData[ 0 ], new GrantMetaData[ 0 ] );
+ try
+ {
+ builder.buildPolicy( metaData, null );
+ fail( "Expected to fail due to null pointer in buildPolicy" );
+ }
+ catch( final NullPointerException npe )
+ {
+ assertEquals( "NPE message",
+ "resolver",
+ npe.getMessage() );
+ }
+ }
+
+ public void testNullMetaDataInBuildPolicy()
+ throws Exception
+ {
+ final PolicyBuilder builder = new PolicyBuilder();
+ try
+ {
+ builder.buildPolicy( null, new TestResolver() );
+ fail( "Expected to fail due to null pointer in buildPolicy" );
+ }
+ catch( final NullPointerException npe )
+ {
+ assertEquals( "NPE message",
+ "policy",
+ npe.getMessage() );
+ }
+
+ }
+
+ public void testMetaDataWithAPermission()
+ throws Exception
+ {
+ final PolicyBuilder builder = new PolicyBuilder();
+ final PermissionMetaData permission =
+ new PermissionMetaData( AllPermission.class.getName(), null, null, null, null );
+ final GrantMetaData grant =
+ new GrantMetaData( "file:/", null, null,
+ new PermissionMetaData[]{permission} );
+ final PolicyMetaData metaData =
+ new PolicyMetaData( new KeyStoreMetaData[ 0 ], new GrantMetaData[]{grant} );
+ final TestResolver resolver = new TestResolver();
+ try
+ {
+ final Policy policy = builder.buildPolicy( metaData, resolver );
+ final CodeSource codesource =
+ new CodeSource( new URL( "file:/" ), new Certificate[ 0 ] );
+ final PermissionCollection permissions = policy.getPermissions( codesource );
+ final Enumeration enumeration = permissions.elements();
+ while( enumeration.hasMoreElements() )
+ {
+ final Object perm = enumeration.nextElement();
+ if( perm instanceof AllPermission )
+ {
+ return;
+ }
+ }
+ fail( "Expected to get permission set with ALlPermission contained" );
+ }
+ catch( final Exception e )
+ {
+ fail( "Expected to be able to build Policy with empty metadata" );
+ }
+ }
+
+ public void testMetaDataWithAPermissionAndCerts()
+ throws Exception
+ {
+ final PolicyBuilder builder = new TestPolicyBuilder();
+ final PermissionMetaData permission =
+ new PermissionMetaData( FilePermission.class.getName(), "/", "read",
+ null, null );
+ final GrantMetaData grant =
+ new GrantMetaData( "file:/", "jenny", "default",
+ new PermissionMetaData[]{permission} );
+ final KeyStoreMetaData keyStore =
+ new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
+ final PolicyMetaData metaData =
+ new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
+ final TestResolver resolver = new TestResolver();
+ final Policy policy = builder.buildPolicy( metaData, resolver );
+ final CodeSource codesource =
+ new CodeSource( new URL( "file:/" ), new Certificate[]{MockCertificate.JENNY_CERTIFICATE} );
+ final PermissionCollection permissions = policy.getPermissions( codesource );
+ final Enumeration enumeration = permissions.elements();
+ while( enumeration.hasMoreElements() )
+ {
+ final Object perm = enumeration.nextElement();
+ if( perm instanceof FilePermission )
+ {
+ return;
+ }
+ }
+ fail( "Expected to get permission set with ALlPermission contained" );
+ }
+
+ public void testMetaDataWithAPermissionAndMultipleCerts()
+ throws Exception
+ {
+ final PolicyBuilder builder = new TestPolicyBuilder();
+ final PermissionMetaData permission =
+ new PermissionMetaData( RuntimePermission.class.getName(), "getFactory", null,
+ null, null );
+ final GrantMetaData grant =
+ new GrantMetaData( "file:/", "jenny,mischelle,jenny", "default",
+ new PermissionMetaData[]{permission} );
+ final KeyStoreMetaData keyStore =
+ new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
+ final PolicyMetaData metaData =
+ new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
+ final TestResolver resolver = new TestResolver();
+ final Policy policy = builder.buildPolicy( metaData, resolver );
+ final CodeSource codesource =
+ new CodeSource( new URL( "file:/" ), new Certificate[]{MockCertificate.JENNY_CERTIFICATE} );
+ final PermissionCollection permissions = policy.getPermissions( codesource );
+ final Enumeration enumeration = permissions.elements();
+ while( enumeration.hasMoreElements() )
+ {
+ final Object perm = enumeration.nextElement();
+ if( perm instanceof RuntimePermission )
+ {
+ return;
+ }
+ }
+ fail( "Expected to get permission set with ALlPermission contained" );
+ }
+
+ public void testMetaDataWithAPermissionAndCertsAndUnResolverPerm()
+ throws Exception
+ {
+ final PolicyBuilder builder = new TestPolicyBuilder();
+ final PermissionMetaData permission =
+ new PermissionMetaData( AllPermission.class.getName(), null, null,
+ "jenny", "default" );
+ final GrantMetaData grant =
+ new GrantMetaData( "file:/", "jenny", "default",
+ new PermissionMetaData[]{permission} );
+ final KeyStoreMetaData keyStore =
+ new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
+ final PolicyMetaData metaData =
+ new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
+ final TestResolver resolver = new TestResolver();
+ final Policy policy = builder.buildPolicy( metaData, resolver );
+ final CodeSource codesource =
+ new CodeSource( new URL( "file:/" ), new Certificate[]{MockCertificate.JENNY_CERTIFICATE} );
+ final PermissionCollection permissions = policy.getPermissions( codesource );
+ final Enumeration enumeration = permissions.elements();
+ while( enumeration.hasMoreElements() )
+ {
+ final Object perm = enumeration.nextElement();
+ if( perm instanceof UnresolvedPermission )
+ {
+ return;
+ }
+ }
+ fail( "Expected to get permission set with UnresolvedPermission contained" );
+ }
+
+ public void testMetaDataWithAPermissionAndCertsAndMisnamedPerm()
+ throws Exception
+ {
+ final PolicyBuilder builder = new TestPolicyBuilder();
+ final PermissionMetaData permission =
+ new PermissionMetaData( AllPermission.class.getName() + "sss", null, null,
+ null, null );
+ final GrantMetaData grant =
+ new GrantMetaData( "file:/", "jenny", "default",
+ new PermissionMetaData[]{permission} );
+ final KeyStoreMetaData keyStore =
+ new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
+ final PolicyMetaData metaData =
+ new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
+ final TestResolver resolver = new TestResolver();
+ final Policy policy = builder.buildPolicy( metaData, resolver );
+ final CodeSource codesource =
+ new CodeSource( new URL( "file:/" ), new Certificate[]{MockCertificate.JENNY_CERTIFICATE} );
+ final PermissionCollection permissions = policy.getPermissions( codesource );
+ final Enumeration enumeration = permissions.elements();
+ while( enumeration.hasMoreElements() )
+ {
+ final Object perm = enumeration.nextElement();
+ if( perm instanceof UnresolvedPermission )
+ {
+ return;
+ }
+ }
+ fail( "Expected to get permission set with UnresolvedPermission contained" );
+ }
+
+ public void testFailureWhenCreatingKeyStore()
+ throws Exception
+ {
+ final PolicyBuilder builder = new TestPolicyBuilder();
+ final PermissionMetaData permission =
+ new PermissionMetaData( AllPermission.class.getName() + "sss", null, null,
+ null, null );
+ final GrantMetaData grant =
+ new GrantMetaData( "file:/", "jenny", "default",
+ new PermissionMetaData[]{permission} );
+ final KeyStoreMetaData keyStore =
+ new KeyStoreMetaData( "default", "http://spice.sourceforge.net/NoExist", "DoDgY" );
+ final PolicyMetaData metaData =
+ new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
+ final TestResolver resolver = new TestResolver();
+ try
+ {
+ builder.buildPolicy( metaData, resolver );
+ fail( "Expected to fail when creating policy as unable to create store" );
+ }
+ catch( Exception e )
+ {
+ }
+ }
+
+ public void testFailureRetrievingCertForAlias()
+ throws Exception
+ {
+ final PolicyBuilder builder = new TestNoInitPolicyBuilder();
+ final PermissionMetaData permission =
+ new PermissionMetaData( AllPermission.class.getName() + "sss", null, null,
+ null, null );
+ final GrantMetaData grant =
+ new GrantMetaData( "file:/", "peter", "default",
+ new PermissionMetaData[]{permission} );
+ final KeyStoreMetaData keyStore =
+ new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
+ final PolicyMetaData metaData =
+ new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
+ final TestResolver resolver = new TestResolver();
+ try
+ {
+ builder.buildPolicy( metaData, resolver );
+ fail( "Expected to fail when creating policy as unable to create store" );
+ }
+ catch( Exception e )
+ {
+ }
+ }
+
+ public void testAliasNoExist()
+ throws Exception
+ {
+ final PolicyBuilder builder = new TestPolicyBuilder();
+ final PermissionMetaData permission =
+ new PermissionMetaData( AllPermission.class.getName() + "sss", null, null,
+ null, null );
+ final GrantMetaData grant =
+ new GrantMetaData( "file:/", "peter", "default",
+ new PermissionMetaData[]{permission} );
+ final KeyStoreMetaData keyStore =
+ new KeyStoreMetaData( "default", "http://spice.sourceforge.net", "DoDgY" );
+ final PolicyMetaData metaData =
+ new PolicyMetaData( new KeyStoreMetaData[]{keyStore}, new GrantMetaData[]{grant} );
+ final TestResolver resolver = new TestResolver();
+ try
+ {
+ builder.buildPolicy( metaData, resolver );
+ fail( "Expected to fail when creating policy as unable to load alias" );
+ }
+ catch( Exception e )
+ {
+ }
+ }
+
+ public void testNoKeyStore()
+ throws Exception
+ {
+ final PolicyBuilder builder = new TestPolicyBuilder();
+ final PermissionMetaData permission =
+ new PermissionMetaData( AllPermission.class.getName(), null, null,
+ null, null );
+ final GrantMetaData grant =
+ new GrantMetaData( "file:/", "peter", "default",
+ new PermissionMetaData[]{permission} );
+ final PolicyMetaData metaData =
+ new PolicyMetaData( new KeyStoreMetaData[]{}, new GrantMetaData[]{grant} );
+ final TestResolver resolver = new TestResolver();
+ try
+ {
+ builder.buildPolicy( metaData, resolver );
+ fail( "Expected to fail when creating policy as missing keystore" );
+ }
+ catch( Exception e )
+ {
+ }
+ }
+}
</pre></div>
<hr /><a name="file47" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="added"><big><b>TestNoInitPolicyBuilder.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/TestNoInitPolicyBuilder.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N TestNoInitPolicyBuilder.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TestNoInitPolicyBuilder.java 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,41 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.builder;
+
+import java.security.KeyStore;
+import java.net.URL;
+import java.util.HashMap;
+
+import org.codehaus.loom.xmlpolicy.builder.PolicyBuilder;
+
+/**
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:26 $
+ */
+class TestNoInitPolicyBuilder
+ extends PolicyBuilder
+{
+ protected KeyStore createKeyStore( String type,
+ URL url )
+ throws Exception
+ {
+ if( url.equals( new URL( "http://spice.sourceforge.net" ) ) )
+ {
+ final HashMap certs = new HashMap();
+ certs.put( "jenny", MockCertificate.JENNY_CERTIFICATE );
+ certs.put( "mischelle", MockCertificate.MISCHELLE_CERTIFICATE );
+ certs.put( "george", MockCertificate.GEORGE_CERTIFICATE );
+ return new MockNoInitKeyStore( certs );
+ }
+ else
+ {
+ throw new Exception( "Unable to create keystore " + url );
+ }
+ }
+}
</pre></div>
<hr /><a name="file48" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="added"><big><b>MockKeyStoreSpi.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/MockKeyStoreSpi.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N MockKeyStoreSpi.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MockKeyStoreSpi.java 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,123 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.builder;
+
+import java.security.KeyStoreSpi;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.KeyStoreException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:26 $
+ */
+class MockKeyStoreSpi
+ extends KeyStoreSpi
+{
+ private final HashMap m_certs;
+
+ public MockKeyStoreSpi( HashMap certs )
+ {
+ m_certs = certs;
+ }
+
+ public Key engineGetKey( String alias, char[] password )
+ throws NoSuchAlgorithmException, UnrecoverableKeyException
+ {
+ return null;
+ }
+
+ public Certificate[] engineGetCertificateChain( String alias )
+ {
+ return new Certificate[ 0 ];
+ }
+
+ public Certificate engineGetCertificate( String alias )
+ {
+ return (Certificate)m_certs.get( alias );
+ }
+
+ public Date engineGetCreationDate( String alias )
+ {
+ return null;
+ }
+
+ public void engineSetKeyEntry( String alias, Key key,
+ char[] password,
+ Certificate[] chain )
+ throws KeyStoreException
+ {
+ }
+
+ public void engineSetKeyEntry( String alias, byte[] key,
+ Certificate[] chain )
+ throws KeyStoreException
+ {
+ }
+
+ public void engineSetCertificateEntry( String alias,
+ Certificate cert )
+ throws KeyStoreException
+ {
+ }
+
+ public void engineDeleteEntry( String alias )
+ throws KeyStoreException
+ {
+ }
+
+ public Enumeration engineAliases()
+ {
+ return null;
+ }
+
+ public boolean engineContainsAlias( String alias )
+ {
+ return false;
+ }
+
+ public int engineSize()
+ {
+ return 0;
+ }
+
+ public boolean engineIsKeyEntry( String alias )
+ {
+ return false;
+ }
+
+ public boolean engineIsCertificateEntry( String alias )
+ {
+ return false;
+ }
+
+ public String engineGetCertificateAlias( Certificate cert )
+ {
+ return null;
+ }
+
+ public void engineStore( OutputStream stream, char[] password )
+ throws IOException, NoSuchAlgorithmException, CertificateException
+ {
+ }
+
+ public void engineLoad( InputStream stream, char[] password )
+ throws IOException, NoSuchAlgorithmException, CertificateException
+ {
+ }
+}
</pre></div>
<hr /><a name="file49" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="added"><big><b>TestResolver.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/TestResolver.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N TestResolver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TestResolver.java 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,36 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.builder;
+
+import java.net.URL;
+import java.security.Policy;
+import java.util.Map;
+
+import org.codehaus.loom.xmlpolicy.builder.PolicyResolver;
+import org.codehaus.loom.xmlpolicy.runtime.DefaultPolicy;
+
+/**
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:26 $
+ */
+class TestResolver
+ implements PolicyResolver
+{
+ public URL resolveLocation( String location )
+ throws Exception
+ {
+ return new URL( location );
+ }
+
+ public Policy createPolicy( Map grants )
+ throws Exception
+ {
+ return new DefaultPolicy( grants );
+ }
+}
</pre></div>
<hr /><a name="file50" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="added"><big><b>MockCertificate.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/MockCertificate.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N MockCertificate.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MockCertificate.java 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,68 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.builder;
+
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.PublicKey;
+import java.security.SignatureException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
+
+/**
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:26 $
+ */
+class MockCertificate
+ extends Certificate
+{
+ public static final MockCertificate JENNY_CERTIFICATE = new MockCertificate("jenny");
+ public static final MockCertificate MISCHELLE_CERTIFICATE = new MockCertificate("mischelle");
+ public static final MockCertificate GEORGE_CERTIFICATE = new MockCertificate("george");
+
+ private final String m_name;
+
+ public MockCertificate(final String name )
+ {
+ super( "name" );
+ m_name = name;
+ }
+
+ public byte[] getEncoded()
+ throws CertificateEncodingException
+ {
+ return new byte[ 0 ];
+ }
+
+ public void verify( PublicKey key )
+ throws CertificateException, NoSuchAlgorithmException,
+ InvalidKeyException, NoSuchProviderException,
+ SignatureException
+ {
+ }
+
+ public void verify( PublicKey key, String sigProvider )
+ throws CertificateException, NoSuchAlgorithmException,
+ InvalidKeyException, NoSuchProviderException,
+ SignatureException
+ {
+ }
+
+ public String toString()
+ {
+ return m_name;
+ }
+
+ public PublicKey getPublicKey()
+ {
+ return null;
+ }
+}
</pre></div>
<hr /><a name="file51" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="added"><big><b>TestPolicyBuilder.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/TestPolicyBuilder.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N TestPolicyBuilder.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TestPolicyBuilder.java 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,41 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.builder;
+
+import java.security.KeyStore;
+import java.net.URL;
+import java.util.HashMap;
+
+import org.codehaus.loom.xmlpolicy.builder.PolicyBuilder;
+
+/**
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:26 $
+ */
+class TestPolicyBuilder
+ extends PolicyBuilder
+{
+ protected KeyStore createKeyStore( String type,
+ URL url )
+ throws Exception
+ {
+ if( url.equals( new URL( "http://spice.sourceforge.net" ) ) )
+ {
+ final HashMap certs = new HashMap();
+ certs.put( "jenny", MockCertificate.JENNY_CERTIFICATE );
+ certs.put( "mischelle", MockCertificate.MISCHELLE_CERTIFICATE );
+ certs.put( "george", MockCertificate.GEORGE_CERTIFICATE );
+ return new MockKeyStore( certs );
+ }
+ else
+ {
+ throw new Exception( "Unable to create keystore " + url );
+ }
+ }
+}
</pre></div>
<hr /><a name="file52" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder">builder</a><br /></span>
<div class="fileheader" id="added"><big><b>MockNoInitKeyStore.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/builder/MockNoInitKeyStore.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N MockNoInitKeyStore.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ MockNoInitKeyStore.java 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,29 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.builder;
+
+import java.io.IOException;
+import java.security.KeyStore;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.util.HashMap;
+
+/**
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:26 $
+ */
+class MockNoInitKeyStore
+ extends KeyStore
+{
+ MockNoInitKeyStore( final HashMap certs )
+ throws IOException, NoSuchAlgorithmException, CertificateException
+ {
+ super( new MockKeyStoreSpi( certs ), null, null );
+ }
+}
</pre></div>
<hr /><a name="file53" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/verifier">verifier</a><br /></span>
<div class="fileheader" id="added"><big><b>Resources.properties</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/verifier/Resources.properties?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N Resources.properties
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Resources.properties 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,16 @@
</small></pre><pre class="diff" id="added">+valid-names.notice=Verifying that all key-stores have valid names.
+valid-signedBy.notice=Verifying that all signed-by attributes are accompanied by a key-store attribute.
+valid-keyStoreReferences.notice=Verify that any keystore names used by grant or permission reference actual keystores
+valid-actions.notice=Verify that if target is null then actions is null.
+
+grant-missing-keystore.error=Grant for codebase "{0}" has a signed-by attribute but no key-store attribute.
+grant-extra-keystore.error=Grant for codebase "{0}" defined a key-store attribute without defining a signed-by attribute.
+permission-missing-keystore.error=Permission loaded from codebase "{0}" of type "{1}" has a signed-by attribute but no key-store attribute.
+permission-extra-keystore.error=Permission loaded from codebase "{0}" of type "{1}" defined a key-store attribute without defining a signed-by attribute.
+
+bad-keystore-reference.error=Referenced non-existent keystore {0}.
+
+empty-name.error=Keystore name is empty.
+name-invalid-start.error=Keystore name "{0}" starts with an invalid character.
+name-invalid-char.error=Keystore name "{0}" contains an invalid character "{1}".
+permission-missing-action.error=Permission on codebase "{0}" of type "{1}" defines a target without an action.
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file54" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/verifier">verifier</a><br /></span>
<div class="fileheader" id="added"><big><b>PolicyVerifier.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/verifier/PolicyVerifier.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N PolicyVerifier.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PolicyVerifier.java 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,218 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.verifier;
+
+import org.codehaus.loom.xmlpolicy.metadata.GrantMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.KeyStoreMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.PermissionMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.PolicyMetaData;
+import org.codehaus.spice.salt.i18n.Resources;
+import org.codehaus.spice.salt.i18n.ResourceManager;
+
+/**
+ * Verify Policy set is valid. Validity is defined as
+ * <ul>
+ * <li>All KeyStore names should be defined starting with
+ * letters or '_' and then continuing with Alpha-Numeric
+ * characters, '-', '.' or '_'.</li>
+ * <li>If signedBy is specified then keystore is specified
+ * for both grants and permissions.</li>
+ * <li>That any keystore names used by grant or permission
+ * reference actual keystores.</li>
+ * <li>If target is null then actions is null.</li>
+ * </ul>
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:26 $
+ */
+public class PolicyVerifier
+{
+ private final static Resources REZ =
+ ResourceManager.getPackageResources( PolicyVerifier.class );
+
+ public void verifyPolicy( final PolicyMetaData policy )
+ throws Exception
+ {
+ String message = null;
+
+ message = REZ.getString( "valid-names.notice" );
+ info( message );
+ verifyNames( policy );
+
+ message = REZ.getString( "valid-keyStoreReferences.notice" );
+ info( message );
+ verifyKeyStoreReferences( policy );
+
+ message = REZ.getString( "valid-actions.notice" );
+ info( message );
+ verifyActions( policy );
+ }
+
+ /**
+ * Log an informational message.
+ * Sub-classes should overide this.
+ *
+ * @param message the message
+ */
+ protected void info( final String message )
+ {
+ //noop
+ }
+
+ /**
+ * Verify that all the keystores have valid names.
+ *
+ * @throws Exception if validity check fails
+ */
+ private void verifyNames( final PolicyMetaData policy )
+ throws Exception
+ {
+ final KeyStoreMetaData[] keyStores = policy.getKeyStores();
+ for( int i = 0; i < keyStores.length; i++ )
+ {
+ final String name = keyStores[ i ].getName();
+ verifyName( name );
+ }
+ }
+
+ /**
+ * Verify that each reference to a keystore is valid.
+ *
+ * @throws Exception if validity check fails
+ */
+ private void verifyKeyStoreReferences( final PolicyMetaData policy )
+ throws Exception
+ {
+ final GrantMetaData[] grants = policy.getGrants();
+ for( int i = 0; i < grants.length; i++ )
+ {
+ verifyKeyStore( policy, grants[ i ] );
+ }
+ }
+
+ /**
+ * Verify that each reference to a keystore is valid.
+ *
+ * @throws Exception if validity check fails
+ */
+ private void verifyKeyStore( final PolicyMetaData policy,
+ final GrantMetaData grant )
+ throws Exception
+ {
+ verifyKeyStoreReference( policy, grant.getKeyStore() );
+ final PermissionMetaData[] permissions = grant.getPermissions();
+ for( int j = 0; j < permissions.length; j++ )
+ {
+ final PermissionMetaData permission = permissions[ j ];
+ verifyKeyStoreReference( policy, permission.getKeyStore() );
+ }
+ }
+
+ /**
+ * Verify that each reference to a keystore is valid.
+ *
+ * @throws Exception if validity check fails
+ */
+ private void verifyKeyStoreReference( final PolicyMetaData policy,
+ final String keyStoreName )
+ throws Exception
+ {
+ //Ignore keystores that are not specified
+ if( null == keyStoreName )
+ {
+ return;
+ }
+ final KeyStoreMetaData[] keyStores = policy.getKeyStores();
+ for( int i = 0; i < keyStores.length; i++ )
+ {
+ final KeyStoreMetaData keyStore = keyStores[ i ];
+ if( keyStore.getName().equals( keyStoreName ) )
+ {
+ return;
+ }
+ }
+
+ final String message =
+ REZ.format( "bad-keystore-reference.error",
+ keyStoreName );
+ throw new Exception( message );
+ }
+
+ /**
+ * Verify that all the classloaders have valid names.
+ *
+ * @throws Exception if validity check fails
+ */
+ private void verifyName( final String name )
+ throws Exception
+ {
+ final int size = name.length();
+ if( 0 == size )
+ {
+ final String message =
+ REZ.format( "empty-name.error",
+ name );
+ throw new Exception( message );
+ }
+ final char ch = name.charAt( 0 );
+ if( !Character.isLetter( ch ) &&
+ '_' != ch )
+ {
+ final String message =
+ REZ.format( "name-invalid-start.error",
+ name );
+ throw new Exception( message );
+ }
+
+ for( int i = 1; i < size; i++ )
+ {
+ final char c = name.charAt( i );
+ if( !Character.isLetterOrDigit( c ) &&
+ '_' != c &&
+ '-' != c &&
+ '.' != c )
+ {
+ final String message =
+ REZ.format( "name-invalid-char.error",
+ name,
+ String.valueOf( c ) );
+ throw new Exception( message );
+ }
+ }
+ }
+
+ /**
+ * Verify that an action is null if a target is null.
+ *
+ * @throws Exception if validity check fails
+ */
+ private void verifyActions( final PolicyMetaData policy )
+ throws Exception
+ {
+ final GrantMetaData[] grants = policy.getGrants();
+ for( int i = 0; i < grants.length; i++ )
+ {
+ final GrantMetaData grant = grants[ i ];
+ final PermissionMetaData[] permissions = grant.getPermissions();
+ for( int j = 0; j < permissions.length; j++ )
+ {
+ final PermissionMetaData permission = permissions[ j ];
+ final String target = permission.getTarget();
+ final String action = permission.getAction();
+ if( null == target && null != action )
+ {
+ final String message =
+ REZ.format( "permission-missing-action.error",
+ grant.getCodebase(),
+ permission.getClassname() );
+ throw new Exception( message );
+ }
+ }
+ }
+ }
+}
</pre></div>
<hr /><a name="file55" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config7.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config7.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config7.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config7.xml 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,6 @@
</small></pre><pre class="diff" id="added">+<policy version="1.0">
+ <!-- testing bad character in center of name -->
+ <keystore name="a$a"
+ location="sar:/conf/keystore"
+ type="JKS"/>
+</policy>
</pre></div>
<hr /><a name="file56" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config10.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config10.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config10.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config10.xml 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,13 @@
</small></pre><pre class="diff" id="added">+<policy version="1.0">
+ <keystore name="a"
+ location="sar:/conf/keystore"
+ type="JKS"/>
+ <grant code-base="myCodeBase">
+ <permission class="java.io.FilePermission"
+ target="${/}tmp${/}*"
+ signed-by="Bob"
+ key-store="a_"
+ action="read,write"/>
+ </grant>
+
+</policy>
</pre></div>
<hr /><a name="file57" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config2.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config2.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config2.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config2.xml 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,9 @@
</small></pre><pre class="diff" id="added">+<policy version="1.0">
+ <grant code-base="myCodeBase">
+ <permission class="java.io.FilePermission"
+ target="${/}tmp${/}*"
+ signed-by="Bob"
+ key-store="nonExistingKeystore"
+ action="read,write"/>
+ </grant>
+</policy>
</pre></div>
<hr /><a name="file58" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config9.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config9.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config9.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config9.xml 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,13 @@
</small></pre><pre class="diff" id="added">+<policy version="1.0">
+ <keystore name="aaaaa"
+ location="sar:/conf/keystore"
+ type="JKS"/>
+ <grant code-base="myCodeBase">
+ <permission class="java.io.FilePermission"
+ target="${/}tmp${/}*"
+ signed-by="Bob"
+ key-store="aaaaa"
+ action="read,write"/>
+ </grant>
+
+</policy>
</pre></div>
<hr /><a name="file59" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config6.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config6.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config6.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config6.xml 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,6 @@
</small></pre><pre class="diff" id="added">+<policy version="1.0">
+ <!-- testing empty name -->
+ <keystore name=""
+ location="sar:/conf/keystore"
+ type="JKS"/>
+</policy>
</pre></div>
<hr /><a name="file60" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config1.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config1.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config1.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config1.xml 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,5 @@
</small></pre><pre class="diff" id="added">+<policy version="1.0">
+ <keystore name="$myKeystore"
+ location="sar:/conf/keystore"
+ type="JKS"/>
+</policy>
</pre></div>
<hr /><a name="file61" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config5.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config5.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config5.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config5.xml 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,5 @@
</small></pre><pre class="diff" id="added">+<policy version="1.0">
+ <grant code-base="sar:/SAR-INF/lib/*">
+ <permission class="java.io.FilePermission"/>
+ </grant>
+</policy>
</pre></div>
<hr /><a name="file62" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config4.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config4.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config4.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config4.xml 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,5 @@
</small></pre><pre class="diff" id="added">+<policy version="1.0">
+ <grant code-base="sar:/SAR-INF/lib/*">
+ <permission class="java.io.FilePermission" action="BadActionValue"/>
+ </grant>
+</policy>
</pre></div>
<hr /><a name="file63" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config3.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config3.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config3.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config3.xml 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,6 @@
</small></pre><pre class="diff" id="added">+<policy version="1.0">
+ <grant signed-by="Bob" key-store="nonExistentKeystore"
+ code-base="sar:/SAR-INF/lib/*">
+ <permission class="java.io.FilePermission"/>
+ </grant>
+</policy>
</pre></div>
<hr /><a name="file64" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>config8.xml</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/config8.xml?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N config8.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config8.xml 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,5 @@
</small></pre><pre class="diff" id="added">+<policy version="1.0">
+ <keystore name="a"
+ location="sar:/conf/keystore"
+ type="JKS"/>
+</policy>
</pre></div>
<hr /><a name="file65" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier">verifier</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>VerifierTestCase.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/verifier/test/VerifierTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N VerifierTestCase.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ VerifierTestCase.java 19 Apr 2004 22:20:26 -0000 1.1
@@ -0,0 +1,186 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.verifier.test;
+
+import org.codehaus.loom.xmlpolicy.metadata.PolicyMetaData;
+import org.codehaus.loom.xmlpolicy.test.AbstractPolicyTestCase;
+import org.codehaus.loom.xmlpolicy.verifier.PolicyVerifier;
+
+/**
+ * TestCase for {@link org.codehaus.loom.xmlpolicy.reader.PolicyReader}.
+ *
+ * @author Peter Donald
+ */
+public class VerifierTestCase
+ extends AbstractPolicyTestCase
+{
+ public VerifierTestCase( final String name )
+ {
+ super( name );
+ }
+
+ public void testConfig1()
+ throws Exception
+ {
+ try
+ {
+ verifyResource( "config1.xml" );
+ }
+ catch( final Throwable t )
+ {
+ return;
+ }
+
+ fail( "Expected verify to fail as specified " +
+ "bad name for keyStore" );
+ }
+
+ public void testConfig2()
+ throws Exception
+ {
+ try
+ {
+ verifyResource( "config2.xml" );
+ }
+ catch( final Throwable t )
+ {
+ return;
+ }
+
+ fail( "Expected verify to fail as permission " +
+ "references non existent keystore" );
+ }
+
+ public void testConfig3()
+ throws Exception
+ {
+ try
+ {
+ verifyResource( "config3.xml" );
+ }
+ catch( final Throwable t )
+ {
+ return;
+ }
+
+ fail( "Expected verify to fail as grant " +
+ "references non existent keystore" );
+ }
+
+ public void testConfig4()
+ throws Exception
+ {
+ try
+ {
+ verifyResource( "config4.xml" );
+ }
+ catch( final Throwable t )
+ {
+ return;
+ }
+
+ fail( "Expected verify to fail as specified " +
+ "action with null target" );
+ }
+
+ public void testConfig5()
+ throws Exception
+ {
+ try
+ {
+ verifyResource( "config5.xml" );
+ }
+ catch( final Throwable t )
+ {
+ fail( "Expected to pass when not specifying keystore" );
+ }
+ }
+
+ public void testConfig6()
+ throws Exception
+ {
+ try
+ {
+ verifyResource( "config6.xml" );
+ }
+ catch( final Throwable t )
+ {
+ return;
+ }
+
+ fail( "Expected verify to fail as specified " +
+ "empty name for keyStore" );
+ }
+
+ public void testConfig7()
+ throws Exception
+ {
+ try
+ {
+ verifyResource( "config7.xml" );
+ }
+ catch( final Throwable t )
+ {
+ return;
+ }
+
+ fail( "Expected verify to fail as specified " +
+ "bad character in center of name for keyStore" );
+ }
+
+ public void testConfig8()
+ throws Exception
+ {
+ try
+ {
+ verifyResource( "config8.xml" );
+ }
+ catch( final Throwable t )
+ {
+ fail( "Expected verify to pass as specified " +
+ "good name for keyStore" );
+ }
+ }
+
+ public void testConfig9()
+ throws Exception
+ {
+ try
+ {
+ verifyResource( "config9.xml" );
+ }
+ catch( final Throwable t )
+ {
+ fail( "Expected verify to pass as specified " +
+ "valid reference for keyStore" );
+ }
+ }
+
+ public void testConfig10()
+ throws Exception
+ {
+ try
+ {
+ verifyResource( "config10.xml" );
+ }
+ catch( final Throwable t )
+ {
+ return;
+ }
+ fail( "Expected verify to fail as specified " +
+ "invalid reference for keyStore" );
+ }
+
+ private void verifyResource( final String resource )
+ throws Exception
+ {
+ final PolicyMetaData defs = buildFromResource( resource );
+ final PolicyVerifier verifier = new PolicyVerifier();
+ verifier.verifyPolicy( defs );
+ }
+}
</pre></div>
<hr /><a name="file66" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/reader">reader</a><br /></span>
<div class="fileheader" id="removed"><big><b>policy.dtd</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/reader/policy.dtd?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N policy.dtd
--- policy.dtd 31 Mar 2004 03:27:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,70 +0,0 @@
</small></pre><pre class="diff" id="removed">-<!--
-
- This is the DTD defining the Policy 1.0
- descriptor (XML) file format/syntax.
-
- Author: Peter Donald
-
- This descriptor is used to define information in a java.policy
- except in a XML file format.
-
- Copyright (C) The Spice Group. All rights reserved.
-
- This software is published under the terms of the Spice
- Software License version 1.1, a copy of which has been included
- with this distribution in the LICENSE.txt file.
-
--->
-
-<!--
-The policy is the document root and contians the other elements:
--->
-<!ELEMENT policy (keystore*,grant*)>
- <!ATTLIST policy
- version CDATA #REQUIRED
- xmlns CDATA #FIXED "http://spice.sourceforge.net/xmlpolicy/policy_1_0.dtd" >
-
-<!--
-The keystore element describes a particular keystore. It defines:
-
-Attributes:
-name the name of keystore. Must be a string
- containing alphanumeric characters, '.', '-', '_' and
- starting with a letter or a '_'.
-location the location of the keystore
-type the keystore type
--->
-<!ELEMENT policy EMPTY>
- <!ATTLIST policy
- name CDATA #REQUIRED
- location CDATA #REQUIRED
- type CDATA #REQUIRED >
-
-<!--
-The grant defines a set of permisisons allowed for
-a particular codebase. It defines:
-
-Attributes:
-name the code-base URL
-signed-by who needs to have signed code at codebase for grant to apply (optional)
-key-store where to load signature from (optional)
-
-Elements:
-permission the permissions to grant
--->
-<!ELEMENT grant (permission*)>
- <!ATTLIST grant
- code-base CDATA #IMPLIED
- signed-by CDATA #IMPLIED
- key-store CDATA #IMPLIED >
-
-<!--
-The permission element defines a permission for a codebase.
--->
-<!ELEMENT permission EMPTY>
- <!ATTLIST permission
- class CDATA #REQUIRED
- target CDATA #IMPLIED
- action CDATA #IMPLIED
- signed-by CDATA #IMPLIED
- key-store CDATA #IMPLIED >
</pre></div>
<hr /><a name="file67" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/reader">reader</a><br /></span>
<div class="fileheader" id="removed"><big><b>PolicyReader.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/reader/PolicyReader.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N PolicyReader.java
--- PolicyReader.java 31 Mar 2004 03:27:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,201 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.reader;
-
-import java.util.ArrayList;
-import org.jcontainer.loom.xmlpolicy.metadata.GrantMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.KeyStoreMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.PermissionMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.PolicyMetaData;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-/**
- * This class builds a {@link PolicyMetaData} object from
- * specified XML document.
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:57 $
- */
-public class PolicyReader
-{
- /**
- * Build ClassLoader MetaData from a DOM tree.
- *
- * @param element the root element
- * @return the meta data
- * @throws Exception if malformed DOM
- */
- public PolicyMetaData readPolicy( final Element element )
- throws Exception
- {
- final String version = element.getAttribute( "version" );
- if( !"1.0".equals( version ) )
- {
- final String message = "Bad version:" + version;
- throw new Exception( message );
- }
-
- final NodeList keyStoreConfigs = element.getElementsByTagName( "keystore" );
- final KeyStoreMetaData[] keyStores = buildKeyStores( keyStoreConfigs );
-
- final NodeList grantConfigs =
- element.getElementsByTagName( "grant" );
- final GrantMetaData[] grants = buildGrants( grantConfigs );
-
- return new PolicyMetaData( keyStores, grants );
- }
-
- /**
- * Build an array of GrantMetaDatas from node list.
- *
- * @param elements the nodes to process
- * @return the GrantMetaData
- */
- private GrantMetaData[] buildGrants( final NodeList elements )
- throws Exception
- {
- final ArrayList grants = new ArrayList();
- final int length = elements.getLength();
-
- for( int i = 0; i < length; i++ )
- {
- final Element element = (Element)elements.item( i );
- final GrantMetaData grant = buildGrant( element );
- grants.add( grant );
- }
-
- return (GrantMetaData[])grants.toArray( new GrantMetaData[ grants.size() ] );
- }
-
- /**
- * Build a GrantMetaData from an element.
- *
- * @param element the nodes to process
- * @return the GrantMetaData
- */
- private GrantMetaData buildGrant( final Element element )
- throws Exception
- {
- final String codeBase = getAttribute( element, "code-base" );
- final String signedBy = getAttribute( element, "signed-by" );
- String keyStore = getAttribute( element, "key-store" );
- if( null != signedBy && null == keyStore )
- {
- keyStore = "default";
- }
- final NodeList permissionElements =
- element.getElementsByTagName( "permission" );
- final PermissionMetaData[] permissions = buildPermissions( permissionElements );
- return new GrantMetaData( codeBase, signedBy, keyStore, permissions );
- }
-
- /**
- * Build an array of PermissionMetaDatas from node list.
- *
- * @param elements the nodes to process
- * @return the PermissionMetaDatas
- */
- private PermissionMetaData[] buildPermissions( final NodeList elements )
- throws Exception
- {
- final ArrayList grants = new ArrayList();
- final int length = elements.getLength();
-
- for( int i = 0; i < length; i++ )
- {
- final Element element = (Element)elements.item( i );
- final PermissionMetaData permission = buildPermission( element );
- grants.add( permission );
- }
-
- return (PermissionMetaData[])grants.toArray( new PermissionMetaData[ grants.size() ] );
- }
-
- /**
- * Build a PermissionMetaData from an element.
- *
- * @param element the node to process
- * @return the PermissionMetaData
- */
- private PermissionMetaData buildPermission( final Element element )
- throws Exception
- {
- final String classname = getAttribute( element, "class" );
- final String target = getAttribute( element, "target" );
- final String action = getAttribute( element, "action" );
- final String signedBy = getAttribute( element, "signed-by" );
- String keyStore = getAttribute( element, "key-store" );
- if( null != signedBy && null == keyStore )
- {
- keyStore = "default";
- }
- return new PermissionMetaData( classname, target, action,
- signedBy, keyStore );
- }
-
- /**
- * Build an array of KeyStore meta datas from node list.
- *
- * @param elements the nodes to process
- * @return the keyStores
- */
- private KeyStoreMetaData[] buildKeyStores( final NodeList elements )
- throws Exception
- {
- final ArrayList keyStores = new ArrayList();
- final int length = elements.getLength();
-
- for( int i = 0; i < length; i++ )
- {
- final Element element = (Element)elements.item( i );
- final KeyStoreMetaData keyStore = buildKeyStore( element );
- keyStores.add( keyStore );
- }
-
- return (KeyStoreMetaData[])keyStores.toArray( new KeyStoreMetaData[ keyStores.size() ] );
- }
-
- /**
- * Build a KeyStoreMetaData from an element.
- *
- * @param element the nodes to process
- * @return the keyStore
- */
- private KeyStoreMetaData buildKeyStore( final Element element )
- throws Exception
- {
- final String name = element.getAttribute( "name" );
- final String location = getAttribute( element, "location" );
- final String type = getAttribute( element, "type" );
- return new KeyStoreMetaData( name, location, type );
- }
-
- /**
- * Utility method to get value of attribute. If attribute
- * has a empty/null value or does not appear in XML then return
- * null, elese return value.
- *
- * @param element the element
- * @param name the attribute name
- * @return the cleaned attribute value
- */
- private String getAttribute( final Element element,
- final String name )
- {
- final String value = element.getAttribute( name );
- if( "".equals( value ) )
- {
- return null;
- }
- else
- {
- return value;
- }
- }
-}
</pre></div>
<hr /><a name="file68" /><div class="file">
<span class="pathname"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a><br /></span>
<div class="fileheader"><big><b>project.xml</b></big> <small id="info"><a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/project.xml?rev=1.12&content-type=text/vnd.viewcvs-markup">1.12</a> <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/project.xml.diff?r1=1.12&r2=1.13">-></a> <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/project.xml?rev=1.13&content-type=text/vnd.viewcvs-markup">1.13</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.12 -r1.13
--- project.xml 31 Mar 2004 02:43:55 -0000 1.12
+++ project.xml 19 Apr 2004 22:20:27 -0000 1.13
@@ -4,7 +4,7 @@
</small></pre><pre class="diff" id="context"> <name>XMLPolicy</name>
<id>loom-xmlpolicy</id>
<inceptionYear>2002</inceptionYear>
</pre><pre class="diff" id="removed">- <package>org.<span id="removedchars">jcontainer</span>.loom.xmlpolicy</package>
</pre><pre class="diff" id="added">+ <package>org.<span id="addedchars">codehaus</span>.loom.xmlpolicy</package>
</pre><pre class="diff" id="context">
<shortDescription>Toolkit to construct Policy object from an XML descriptor.</shortDescription>
</pre></div>
<hr /><a name="file69" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/runtime">runtime</a><br /></span>
<div class="fileheader" id="removed"><big><b>RuntimeTestCase.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/runtime/RuntimeTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N RuntimeTestCase.java
--- RuntimeTestCase.java 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,143 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.runtime;
-
-import java.net.URL;
-import java.security.CodeSource;
-import java.security.Permissions;
-import java.security.AllPermission;
-import java.security.Policy;
-import java.security.PermissionCollection;
-import java.security.Permission;
-import java.security.cert.Certificate;
-import java.util.HashMap;
-import java.util.Enumeration;
-import junit.framework.TestCase;
-
-/**
- * TestCase for Runtime package.
- *
- * @author Peter Donald
- */
-public class RuntimeTestCase
- extends TestCase
-{
- public RuntimeTestCase( final String name )
- {
- super( name );
- }
-
- public void testNullCodeSourceInEntryCtor()
- throws Exception
- {
- try
- {
- new PolicyEntry( null, new Permissions() );
- fail( "Expected to fail due to null pointer in ctor" );
- }
- catch( final NullPointerException npe )
- {
- assertEquals( "NPE message",
- "codeSource",
- npe.getMessage() );
- }
- }
-
- public void testNullPermissionsInEntryCtor()
- throws Exception
- {
- try
- {
- new PolicyEntry( new CodeSource( new URL( "http://spice.sourveforge.net" ),
- new Certificate[ 0 ] ),
- null );
- fail( "Expected to fail due to null pointer in ctor" );
- }
- catch( final NullPointerException npe )
- {
- assertEquals( "NPE message",
- "permissions",
- npe.getMessage() );
- }
- }
-
- public void testEntryCtor()
- throws Exception
- {
- final URL url = new URL( "http://spice.sourveforge.net" );
- final CodeSource codeSource = new CodeSource( url, new Certificate[ 0 ] );
- final Permissions permissions = new Permissions();
- try
- {
- final PolicyEntry entry = new PolicyEntry( codeSource, permissions );
- assertEquals( "Entry.getCodeSource", codeSource, entry.getCodeSource() );
- assertEquals( "Entry.getPermissions", permissions, entry.getPermissions() );
- }
- catch( final Throwable t )
- {
- fail( "Expected ctor not to except" );
- }
- }
-
- public void testPolicyAccessPermission()
- throws Exception
- {
- final URL url = new URL( "file:/-" );
- final CodeSource codeSource = new CodeSource( url, new Certificate[ 0 ] );
- final AllPermission allPermission = new AllPermission();
- final HashMap grants = new HashMap();
- grants.put( codeSource, new Permission[]{allPermission} );
-
- final Policy policy = new DefaultPolicy( grants );
- policy.refresh();
- final PermissionCollection resultPermissions = policy.getPermissions( codeSource );
- final Enumeration enumeration = resultPermissions.elements();
- while( enumeration.hasMoreElements() )
- {
- final Permission permission = (Permission)enumeration.nextElement();
- assertEquals( "Permissions for codeSource" + codeSource,
- allPermission,
- permission );
- return;
- }
- fail( "Expected to find AllPermission in set" );
- }
-
- public void testPolicyAccessPermissionNotCovered()
- throws Exception
- {
- final URL url = new URL( "http://spice.sourceforge.net/-" );
- final CodeSource codeSource = new CodeSource( url, new Certificate[ 0 ] );
- final AllPermission allPermission = new AllPermission();
- final HashMap grants = new HashMap();
- grants.put( codeSource, new Permission[]{allPermission} );
-
- final Policy policy = new DefaultPolicy( grants );
- policy.refresh();
- final PermissionCollection resultPermissions = policy.getPermissions( new CodeSource( null, new Certificate[ 0 ] ) );
- final Enumeration enumeration = resultPermissions.elements();
- assertEquals( "Permissions for codeSource" + codeSource,
- false, enumeration.hasMoreElements() );
- }
-
- public void testPolicyAccessPermissionForNonSpecifiedCodeBase()
- throws Exception
- {
- final Policy policy = new DefaultPolicy();
- policy.refresh();
-
- final URL url = new URL( "http://spice.sourceforge.net/-" );
- final CodeSource codeSource = new CodeSource( url, new Certificate[ 0 ] );
- final PermissionCollection permissions = policy.getPermissions( codeSource );
- assertEquals( "Expect no permissions for http://...", false, permissions.elements().hasMoreElements() );
-
- final CodeSource otherCodeSource = new CodeSource( null, new Certificate[ 0 ] );
- final PermissionCollection otherPermissions = policy.getPermissions( otherCodeSource );
- assertEquals( "Expect no permissions for null location", false, otherPermissions.elements().hasMoreElements() );
- }
-}
</pre></div>
<hr /><a name="file70" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/test">test</a><br /></span>
<div class="fileheader" id="removed"><big><b>AbstractPolicyTestCase.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/test/AbstractPolicyTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N AbstractPolicyTestCase.java
--- AbstractPolicyTestCase.java 31 Mar 2004 03:27:59 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,68 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.test;
-
-import java.io.InputStream;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import junit.framework.TestCase;
-import org.jcontainer.loom.xmlpolicy.metadata.PolicyMetaData;
-import org.jcontainer.loom.xmlpolicy.reader.PolicyReader;
-import org.w3c.dom.Document;
-
-/**
- * An abstract testcase to test policys.
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:59 $
- */
-public class AbstractPolicyTestCase
- extends TestCase
-{
- protected PolicyMetaData buildFromStream( final InputStream stream )
- throws Exception
- {
- try
- {
- final PolicyReader builder = new PolicyReader();
- final Document config = load( stream );
- return builder.readPolicy( config.getDocumentElement() );
- }
- catch( final Exception e )
- {
- fail( "Error building Policy: " + e );
- return null;
- }
- }
-
- protected Document load( final InputStream stream )
- throws Exception
- {
- final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- //factory.setValidating(true);
- //factory.setNamespaceAware(true);
- final DocumentBuilder builder = factory.newDocumentBuilder();
- return builder.parse( stream );
- }
-
- protected PolicyMetaData buildFromResource( final String resource )
- throws Exception
- {
- final InputStream stream = getClass().getResourceAsStream( resource );
- if( null == stream )
- {
- fail( "Missing resource " + resource );
- }
- return buildFromStream( stream );
- }
-
- public AbstractPolicyTestCase( String name )
- {
- super( name );
- }
-}
</pre></div>
<hr /><a name="file71" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/runtime">runtime</a><br /></span>
<div class="fileheader" id="removed"><big><b>PolicyEntry.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/runtime/PolicyEntry.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N PolicyEntry.java
--- PolicyEntry.java 31 Mar 2004 03:27:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,54 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.runtime;
-
-import java.security.CodeSource;
-import java.security.Permissions;
-
-/**
- * Internal Policy Entry holder class.
- * Holds information about an entry in policy file.
- */
-final class PolicyEntry
-{
- /**
- * The code source that entry is about.
- */
- private final CodeSource m_codeSource;
-
- /**
- * the set of permissions for code source.
- */
- private final Permissions m_permissions;
-
- public PolicyEntry( final CodeSource codeSource,
- final Permissions permissions )
- {
- if( null == codeSource )
- {
- throw new NullPointerException( "codeSource" );
- }
- if( null == permissions )
- {
- throw new NullPointerException( "permissions" );
- }
-
- m_codeSource = codeSource;
- m_permissions = permissions;
- }
-
- public CodeSource getCodeSource()
- {
- return m_codeSource;
- }
-
- public Permissions getPermissions()
- {
- return m_permissions;
- }
-}
</pre></div>
<hr /><a name="file72" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/runtime">runtime</a><br /></span>
<div class="fileheader" id="removed"><big><b>DefaultPolicy.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/runtime/DefaultPolicy.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N DefaultPolicy.java
--- DefaultPolicy.java 31 Mar 2004 03:27:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,73 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.runtime;
-
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.Permissions;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * A policy implementation that accepts policys details from a map.
- * The map is between a codebase and a array of permissions.
- * Note that it was a deliberate decision to limit the time at which you can
- * specify policy data for security reasons.
- *
- * @author Peter Donald
- */
-public class DefaultPolicy
- extends AbstractPolicy
-{
- /**
- * Create a Policy that applies specified grants.
- * Each entry in map maps a CodeSource to an array
- * of Permissions.
- *
- * @param grants the grant map
- * @throws Exception if unable to construct Policy
- */
- public DefaultPolicy( final Map grants )
- throws Exception
- {
- processGrants( grants );
- }
-
- /**
- * Create a policy with zero entrys.
- * Sub-classes usually use this constructor then
- * invoke processGrants separately.
- */
- public DefaultPolicy()
- {
- }
-
- /**
- * Process map of grants and configure Policy appropriately.
- *
- * @param grants the grants map
- * @throws Exception if unable to perform configuration
- */
- protected final void processGrants( final Map grants )
- throws Exception
- {
- final Iterator iterator = grants.keySet().iterator();
- while( iterator.hasNext() )
- {
- final CodeSource codeSource = (CodeSource)iterator.next();
- final Permission[] permissions = (Permission[])grants.get( codeSource );
- final Permissions permissionSet = createPermissionSetFor( codeSource );
-
- for( int i = 0; i < permissions.length; i++ )
- {
- final Permission permission = permissions[ i ];
- permissionSet.add( permission );
- }
- }
- }
-}
</pre></div>
<hr /><a name="file73" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/runtime">runtime</a><br /></span>
<div class="fileheader" id="removed"><big><b>AbstractPolicy.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/runtime/AbstractPolicy.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N AbstractPolicy.java
--- AbstractPolicy.java 31 Mar 2004 03:27:57 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,161 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.runtime;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-import java.security.Policy;
-import java.security.cert.Certificate;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import org.codehaus.spice.salt.io.FileUtil;
-
-/**
- * Abstract Policy class that makes it easy to add permission
- * sets to policy.
- *
- * @author Peter Donald
- */
-public abstract class AbstractPolicy
- extends Policy
-{
- /**
- * List of PolicyEntry objects described by AbstractPolicy.
- */
- private final ArrayList m_entries = new ArrayList();
-
- /**
- * Overide so we can have a per-application security policy with
- * no side-effects to other applications.
- *
- * @param codeSource the CodeSource to get permissions for
- * @return the PermissionCollection
- */
- public PermissionCollection getPermissions( final CodeSource codeSource )
- {
- final CodeSource target = normalize( codeSource );
-
- final Permissions permissions = new Permissions();
- final int size = m_entries.size();
-
- for( int i = 0; i < size; i++ )
- {
- final PolicyEntry entry = (PolicyEntry)m_entries.get( i );
- if( entry.getCodeSource().implies( target ) )
- {
- copyPermissions( permissions, entry.getPermissions() );
- }
- }
-
- return permissions;
- }
-
- /**
- * Refresh policy. Ignored in this implementation.
- */
- public void refresh()
- {
- }
-
- /**
- * Create a set of permissions for a particular codesource.
- * These are read-write permissions and can be written till until the
- * time in which they are applied to code.
- *
- * @param codeSource the code source
- * @return the permission set
- */
- protected Permissions createPermissionSetFor( final CodeSource codeSource )
- {
- final CodeSource target = normalize( codeSource );
- final PolicyEntry entry =
- new PolicyEntry( target, new Permissions() );
- m_entries.add( entry );
- return entry.getPermissions();
- }
-
- /**
- * Normalizing CodeSource involves removing relative addressing
- * (like .. and .) for file urls.
- *
- * @param codeSource the codeSource to be normalized
- * @return the normalized codeSource
- */
- private CodeSource normalize( final CodeSource codeSource )
- {
- final URL initialLocation = codeSource.getLocation();
-
- // This is a bit of a h ack. I don't know why CodeSource should behave like this
- // Fear not, this only seems to be a problem for home grown classloaders.
- // - Paul Hammant, Nov 2000
- if( null == initialLocation )
- {
- return codeSource;
- }
-
- String location = null;
-
- if( !initialLocation.getProtocol().equalsIgnoreCase( "file" ) )
- {
- location = initialLocation.getFile();
- location = FileUtil.normalize( location );
- }
- else
- {
- final File file = new File( initialLocation.getFile() );
- location = file.getAbsoluteFile().toString().replace( File.separatorChar, '/' );
- location = FileUtil.normalize( location );
- }
-
- URL finalLocation = null;
- try
- {
- finalLocation = new URL( initialLocation.getProtocol(),
- initialLocation.getHost(),
- initialLocation.getPort(),
- location );
- }
- catch( final MalformedURLException mue )
- {
- error( "Error building codeBase", mue );
- }
-
- final Certificate[] certificates = codeSource.getCertificates();
- return new CodeSource( finalLocation, certificates );
- }
-
- /**
- * Utility method to cpoy permissions from specified source to specified destination.
- *
- * @param destination the destination of permissions
- * @param source the source of permissions
- */
- private void copyPermissions( final Permissions destination,
- final Permissions source )
- {
- final Enumeration enum = source.elements();
- while( enum.hasMoreElements() )
- {
- destination.add( (Permission)enum.nextElement() );
- }
- }
-
- /**
- * Error occured in policy. Subclasses should overide.
- */
- protected void error( final String message,
- final Throwable throwable )
- {
- System.err.println( message );
- }
-}
</pre></div>
<hr /><a name="file74" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/metadata">metadata</a><br /></span>
<div class="fileheader" id="removed"><big><b>MetaDataTestCase.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/jcontainer/loom/xmlpolicy/metadata/MetaDataTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N MetaDataTestCase.java
--- MetaDataTestCase.java 31 Mar 2004 03:27:58 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,186 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.metadata;
-
-import junit.framework.TestCase;
-
-/**
- * TestCase for {@link org.jcontainer.loom.xmlpolicy.reader.PolicyReader}.
- *
- * @author Peter Donald
- */
-public class MetaDataTestCase
- extends TestCase
-{
- public MetaDataTestCase( final String name )
- {
- super( name );
- }
-
- public void testNullClassNameInPermissionCtor()
- throws Exception
- {
- try
- {
- new PermissionMetaData( null, null, null, null, null );
- fail( "Expected to fail due to null pointer in ctor" );
- }
- catch( final NullPointerException npe )
- {
- assertEquals( "NPE message",
- "classname",
- npe.getMessage() );
- }
- }
-
- public void testNullPermissionsInGrantCtor()
- throws Exception
- {
- try
- {
- new GrantMetaData( null, null, null, null );
- fail( "Expected to fail due to null pointer in ctor" );
- }
- catch( final NullPointerException npe )
- {
- assertEquals( "NPE message",
- "permissions",
- npe.getMessage() );
- }
- }
-
- public void testNullPermissionsElementInGrantCtor()
- throws Exception
- {
- try
- {
- new GrantMetaData( null, null, null, new PermissionMetaData[]{null} );
- fail( "Expected to fail due to null pointer in ctor" );
- }
- catch( final NullPointerException npe )
- {
- assertEquals( "NPE message",
- "permissions[0]",
- npe.getMessage() );
- }
- }
-
-
- public void testNullSignedByNonNullKeyStoreInGrantCtor()
- throws Exception
- {
- try
- {
- new GrantMetaData( null, null, "default", new PermissionMetaData[0] );
- fail( "Expected to fail due to null pointer in ctor" );
- }
- catch( final NullPointerException npe )
- {
- assertEquals( "NPE message",
- "signedBy",
- npe.getMessage() );
- }
- }
-
- public void testNullKeyStoreNonNullSignedByInGrantCtor()
- throws Exception
- {
- try
- {
- new GrantMetaData( null, "default", null, new PermissionMetaData[ 0 ] );
- fail( "Expected to fail due to null pointer in ctor" );
- }
- catch( final NullPointerException npe )
- {
- assertEquals( "NPE message",
- "keyStore",
- npe.getMessage() );
- }
- }
-
- public void testNullNameInKeyStoreCtor()
- throws Exception
- {
- try
- {
- new KeyStoreMetaData( null, "", "" );
- fail( "Expected to fail due to null pointer in ctor" );
- }
- catch( final NullPointerException npe )
- {
- assertEquals( "NPE message",
- "name",
- npe.getMessage() );
- }
- }
-
- public void testNullLocationInKeyStoreCtor()
- throws Exception
- {
- try
- {
- new KeyStoreMetaData( "", null, "" );
- fail( "Expected to fail due to null pointer in ctor" );
- }
- catch( final NullPointerException npe )
- {
- assertEquals( "NPE message",
- "location",
- npe.getMessage() );
- }
- }
-
- public void testNullTypeInKeyStoreCtor()
- throws Exception
- {
- try
- {
- new KeyStoreMetaData( "", "", null );
- fail( "Expected to fail due to null pointer in ctor" );
- }
- catch( final NullPointerException npe )
- {
- assertEquals( "NPE message",
- "type",
- npe.getMessage() );
- }
- }
-
- public void testNullKeyStoreNonNullSignedByInPermissionCtor()
- throws Exception
- {
- try
- {
- new PermissionMetaData( "", "", "", "", null );
- fail( "Expected to fail due to null pointer in ctor" );
- }
- catch( final NullPointerException npe )
- {
- assertEquals( "NPE message",
- "keyStore",
- npe.getMessage() );
- }
- }
-
- public void testNullSignedByNonNullKeyStoreInPermissionCtor()
- throws Exception
- {
- try
- {
- new PermissionMetaData( "", "","", null, "default" );
- fail( "Expected to fail due to null pointer in ctor" );
- }
- catch( final NullPointerException npe )
- {
- assertEquals( "NPE message",
- "signedBy",
- npe.getMessage() );
- }
- }
-
-}
</pre></div>
<hr /><a name="file75" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/verifier">verifier</a><br /></span>
<div class="fileheader" id="removed"><big><b>Resources.properties</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/verifier/Resources.properties?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N Resources.properties
--- Resources.properties 31 Mar 2004 03:27:58 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,16 +0,0 @@
</small></pre><pre class="diff" id="removed">-valid-names.notice=Verifying that all key-stores have valid names.
-valid-signedBy.notice=Verifying that all signed-by attributes are accompanied by a key-store attribute.
-valid-keyStoreReferences.notice=Verify that any keystore names used by grant or permission reference actual keystores
-valid-actions.notice=Verify that if target is null then actions is null.
-
-grant-missing-keystore.error=Grant for codebase "{0}" has a signed-by attribute but no key-store attribute.
-grant-extra-keystore.error=Grant for codebase "{0}" defined a key-store attribute without defining a signed-by attribute.
-permission-missing-keystore.error=Permission loaded from codebase "{0}" of type "{1}" has a signed-by attribute but no key-store attribute.
-permission-extra-keystore.error=Permission loaded from codebase "{0}" of type "{1}" defined a key-store attribute without defining a signed-by attribute.
-
-bad-keystore-reference.error=Referenced non-existent keystore {0}.
-
-empty-name.error=Keystore name is empty.
-name-invalid-start.error=Keystore name "{0}" starts with an invalid character.
-name-invalid-char.error=Keystore name "{0}" contains an invalid character "{1}".
-permission-missing-action.error=Permission on codebase "{0}" of type "{1}" defines a target without an action.
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file76" /><div class="file">
<span class="pathname" id="removed"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/l
oom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy">xmlpolicy</a>/<a href="http!
://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/verifier">verifier</a><br /></span>
<div class="fileheader" id="removed"><big><b>PolicyVerifier.java</b></big> <small id="info">removed after <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/jcontainer/loom/xmlpolicy/verifier/PolicyVerifier.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N PolicyVerifier.java
--- PolicyVerifier.java 31 Mar 2004 03:27:58 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,218 +0,0 @@
</small></pre><pre class="diff" id="removed">-/*
- * Copyright (C) The Spice Group. All rights reserved.
- *
- * This software is published under the terms of the Spice
- * Software License version 1.1, a copy of which has been included
- * with this distribution in the LICENSE.txt file.
- */
-package org.jcontainer.loom.xmlpolicy.verifier;
-
-import org.jcontainer.loom.xmlpolicy.metadata.GrantMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.KeyStoreMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.PermissionMetaData;
-import org.jcontainer.loom.xmlpolicy.metadata.PolicyMetaData;
-import org.codehaus.spice.salt.i18n.Resources;
-import org.codehaus.spice.salt.i18n.ResourceManager;
-
-/**
- * Verify Policy set is valid. Validity is defined as
- * <ul>
- * <li>All KeyStore names should be defined starting with
- * letters or '_' and then continuing with Alpha-Numeric
- * characters, '-', '.' or '_'.</li>
- * <li>If signedBy is specified then keystore is specified
- * for both grants and permissions.</li>
- * <li>That any keystore names used by grant or permission
- * reference actual keystores.</li>
- * <li>If target is null then actions is null.</li>
- * </ul>
- *
- * @author Peter Donald
- * @version $Revision: 1.1 $ $Date: 2004/03/31 03:27:58 $
- */
-public class PolicyVerifier
-{
- private final static Resources REZ =
- ResourceManager.getPackageResources( PolicyVerifier.class );
-
- public void verifyPolicy( final PolicyMetaData policy )
- throws Exception
- {
- String message = null;
-
- message = REZ.getString( "valid-names.notice" );
- info( message );
- verifyNames( policy );
-
- message = REZ.getString( "valid-keyStoreReferences.notice" );
- info( message );
- verifyKeyStoreReferences( policy );
-
- message = REZ.getString( "valid-actions.notice" );
- info( message );
- verifyActions( policy );
- }
-
- /**
- * Log an informational message.
- * Sub-classes should overide this.
- *
- * @param message the message
- */
- protected void info( final String message )
- {
- //noop
- }
-
- /**
- * Verify that all the keystores have valid names.
- *
- * @throws Exception if validity check fails
- */
- private void verifyNames( final PolicyMetaData policy )
- throws Exception
- {
- final KeyStoreMetaData[] keyStores = policy.getKeyStores();
- for( int i = 0; i < keyStores.length; i++ )
- {
- final String name = keyStores[ i ].getName();
- verifyName( name );
- }
- }
-
- /**
- * Verify that each reference to a keystore is valid.
- *
- * @throws Exception if validity check fails
- */
- private void verifyKeyStoreReferences( final PolicyMetaData policy )
- throws Exception
- {
- final GrantMetaData[] grants = policy.getGrants();
- for( int i = 0; i < grants.length; i++ )
- {
- verifyKeyStore( policy, grants[ i ] );
- }
- }
-
- /**
- * Verify that each reference to a keystore is valid.
- *
- * @throws Exception if validity check fails
- */
- private void verifyKeyStore( final PolicyMetaData policy,
- final GrantMetaData grant )
- throws Exception
- {
- verifyKeyStoreReference( policy, grant.getKeyStore() );
- final PermissionMetaData[] permissions = grant.getPermissions();
- for( int j = 0; j < permissions.length; j++ )
- {
- final PermissionMetaData permission = permissions[ j ];
- verifyKeyStoreReference( policy, permission.getKeyStore() );
- }
- }
-
- /**
- * Verify that each reference to a keystore is valid.
- *
- * @throws Exception if validity check fails
- */
- private void verifyKeyStoreReference( final PolicyMetaData policy,
- final String keyStoreName )
- throws Exception
- {
- //Ignore keystores that are not specified
- if( null == keyStoreName )
- {
- return;
- }
- final KeyStoreMetaData[] keyStores = policy.getKeyStores();
- for( int i = 0; i < keyStores.length; i++ )
- {
- final KeyStoreMetaData keyStore = keyStores[ i ];
- if( keyStore.getName().equals( keyStoreName ) )
- {
- return;
- }
- }
-
- final String message =
- REZ.format( "bad-keystore-reference.error",
- keyStoreName );
- throw new Exception( message );
- }
-
- /**
- * Verify that all the classloaders have valid names.
- *
- * @throws Exception if validity check fails
- */
- private void verifyName( final String name )
- throws Exception
- {
- final int size = name.length();
- if( 0 == size )
- {
- final String message =
- REZ.format( "empty-name.error",
- name );
- throw new Exception( message );
- }
- final char ch = name.charAt( 0 );
- if( !Character.isLetter( ch ) &&
- '_' != ch )
- {
- final String message =
- REZ.format( "name-invalid-start.error",
- name );
- throw new Exception( message );
- }
-
- for( int i = 1; i < size; i++ )
- {
- final char c = name.charAt( i );
- if( !Character.isLetterOrDigit( c ) &&
- '_' != c &&
- '-' != c &&
- '.' != c )
- {
- final String message =
- REZ.format( "name-invalid-char.error",
- name,
- String.valueOf( c ) );
- throw new Exception( message );
- }
- }
- }
-
- /**
- * Verify that an action is null if a target is null.
- *
- * @throws Exception if validity check fails
- */
- private void verifyActions( final PolicyMetaData policy )
- throws Exception
- {
- final GrantMetaData[] grants = policy.getGrants();
- for( int i = 0; i < grants.length; i++ )
- {
- final GrantMetaData grant = grants[ i ];
- final PermissionMetaData[] permissions = grant.getPermissions();
- for( int j = 0; j < permissions.length; j++ )
- {
- final PermissionMetaData permission = permissions[ j ];
- final String target = permission.getTarget();
- final String action = permission.getAction();
- if( null == target && null != action )
- {
- final String message =
- REZ.format( "permission-missing-action.error",
- grant.getCodebase(),
- permission.getClassname() );
- throw new Exception( message );
- }
- }
- }
- }
-}
</pre></div>
<hr /><a name="file77" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/runtime">runtime</a><br /></span>
<div class="fileheader" id="added"><big><b>RuntimeTestCase.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/runtime/RuntimeTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N RuntimeTestCase.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ RuntimeTestCase.java 19 Apr 2004 22:20:27 -0000 1.1
@@ -0,0 +1,147 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.runtime;
+
+import java.net.URL;
+import java.security.CodeSource;
+import java.security.Permissions;
+import java.security.AllPermission;
+import java.security.Policy;
+import java.security.PermissionCollection;
+import java.security.Permission;
+import java.security.cert.Certificate;
+import java.util.HashMap;
+import java.util.Enumeration;
+
+import org.codehaus.loom.xmlpolicy.runtime.DefaultPolicy;
+import org.codehaus.loom.xmlpolicy.runtime.PolicyEntry;
+
+import junit.framework.TestCase;
+
+/**
+ * TestCase for Runtime package.
+ *
+ * @author Peter Donald
+ */
+public class RuntimeTestCase
+ extends TestCase
+{
+ public RuntimeTestCase( final String name )
+ {
+ super( name );
+ }
+
+ public void testNullCodeSourceInEntryCtor()
+ throws Exception
+ {
+ try
+ {
+ new PolicyEntry( null, new Permissions() );
+ fail( "Expected to fail due to null pointer in ctor" );
+ }
+ catch( final NullPointerException npe )
+ {
+ assertEquals( "NPE message",
+ "codeSource",
+ npe.getMessage() );
+ }
+ }
+
+ public void testNullPermissionsInEntryCtor()
+ throws Exception
+ {
+ try
+ {
+ new PolicyEntry( new CodeSource( new URL( "http://spice.sourveforge.net" ),
+ new Certificate[ 0 ] ),
+ null );
+ fail( "Expected to fail due to null pointer in ctor" );
+ }
+ catch( final NullPointerException npe )
+ {
+ assertEquals( "NPE message",
+ "permissions",
+ npe.getMessage() );
+ }
+ }
+
+ public void testEntryCtor()
+ throws Exception
+ {
+ final URL url = new URL( "http://spice.sourveforge.net" );
+ final CodeSource codeSource = new CodeSource( url, new Certificate[ 0 ] );
+ final Permissions permissions = new Permissions();
+ try
+ {
+ final PolicyEntry entry = new PolicyEntry( codeSource, permissions );
+ assertEquals( "Entry.getCodeSource", codeSource, entry.getCodeSource() );
+ assertEquals( "Entry.getPermissions", permissions, entry.getPermissions() );
+ }
+ catch( final Throwable t )
+ {
+ fail( "Expected ctor not to except" );
+ }
+ }
+
+ public void testPolicyAccessPermission()
+ throws Exception
+ {
+ final URL url = new URL( "file:/-" );
+ final CodeSource codeSource = new CodeSource( url, new Certificate[ 0 ] );
+ final AllPermission allPermission = new AllPermission();
+ final HashMap grants = new HashMap();
+ grants.put( codeSource, new Permission[]{allPermission} );
+
+ final Policy policy = new DefaultPolicy( grants );
+ policy.refresh();
+ final PermissionCollection resultPermissions = policy.getPermissions( codeSource );
+ final Enumeration enumeration = resultPermissions.elements();
+ while( enumeration.hasMoreElements() )
+ {
+ final Permission permission = (Permission)enumeration.nextElement();
+ assertEquals( "Permissions for codeSource" + codeSource,
+ allPermission,
+ permission );
+ return;
+ }
+ fail( "Expected to find AllPermission in set" );
+ }
+
+ public void testPolicyAccessPermissionNotCovered()
+ throws Exception
+ {
+ final URL url = new URL( "http://spice.sourceforge.net/-" );
+ final CodeSource codeSource = new CodeSource( url, new Certificate[ 0 ] );
+ final AllPermission allPermission = new AllPermission();
+ final HashMap grants = new HashMap();
+ grants.put( codeSource, new Permission[]{allPermission} );
+
+ final Policy policy = new DefaultPolicy( grants );
+ policy.refresh();
+ final PermissionCollection resultPermissions = policy.getPermissions( new CodeSource( null, new Certificate[ 0 ] ) );
+ final Enumeration enumeration = resultPermissions.elements();
+ assertEquals( "Permissions for codeSource" + codeSource,
+ false, enumeration.hasMoreElements() );
+ }
+
+ public void testPolicyAccessPermissionForNonSpecifiedCodeBase()
+ throws Exception
+ {
+ final Policy policy = new DefaultPolicy();
+ policy.refresh();
+
+ final URL url = new URL( "http://spice.sourceforge.net/-" );
+ final CodeSource codeSource = new CodeSource( url, new Certificate[ 0 ] );
+ final PermissionCollection permissions = policy.getPermissions( codeSource );
+ assertEquals( "Expect no permissions for http://...", false, permissions.elements().hasMoreElements() );
+
+ final CodeSource otherCodeSource = new CodeSource( null, new Certificate[ 0 ] );
+ final PermissionCollection otherPermissions = policy.getPermissions( otherCodeSource );
+ assertEquals( "Expect no permissions for null location", false, otherPermissions.elements().hasMoreElements() );
+ }
+}
</pre></div>
<hr /><a name="file78" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/reader">reader</a><br /></span>
<div class="fileheader" id="added"><big><b>policy.dtd</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/reader/policy.dtd?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N policy.dtd
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ policy.dtd 19 Apr 2004 22:20:27 -0000 1.1
@@ -0,0 +1,70 @@
</small></pre><pre class="diff" id="added">+<!--
+
+ This is the DTD defining the Policy 1.0
+ descriptor (XML) file format/syntax.
+
+ Author: Peter Donald
+
+ This descriptor is used to define information in a java.policy
+ except in a XML file format.
+
+ Copyright (C) The Spice Group. All rights reserved.
+
+ This software is published under the terms of the Spice
+ Software License version 1.1, a copy of which has been included
+ with this distribution in the LICENSE.txt file.
+
+-->
+
+<!--
+The policy is the document root and contians the other elements:
+-->
+<!ELEMENT policy (keystore*,grant*)>
+ <!ATTLIST policy
+ version CDATA #REQUIRED
+ xmlns CDATA #FIXED "http://spice.sourceforge.net/xmlpolicy/policy_1_0.dtd" >
+
+<!--
+The keystore element describes a particular keystore. It defines:
+
+Attributes:
+name the name of keystore. Must be a string
+ containing alphanumeric characters, '.', '-', '_' and
+ starting with a letter or a '_'.
+location the location of the keystore
+type the keystore type
+-->
+<!ELEMENT policy EMPTY>
+ <!ATTLIST policy
+ name CDATA #REQUIRED
+ location CDATA #REQUIRED
+ type CDATA #REQUIRED >
+
+<!--
+The grant defines a set of permisisons allowed for
+a particular codebase. It defines:
+
+Attributes:
+name the code-base URL
+signed-by who needs to have signed code at codebase for grant to apply (optional)
+key-store where to load signature from (optional)
+
+Elements:
+permission the permissions to grant
+-->
+<!ELEMENT grant (permission*)>
+ <!ATTLIST grant
+ code-base CDATA #IMPLIED
+ signed-by CDATA #IMPLIED
+ key-store CDATA #IMPLIED >
+
+<!--
+The permission element defines a permission for a codebase.
+-->
+<!ELEMENT permission EMPTY>
+ <!ATTLIST permission
+ class CDATA #REQUIRED
+ target CDATA #IMPLIED
+ action CDATA #IMPLIED
+ signed-by CDATA #IMPLIED
+ key-store CDATA #IMPLIED >
</pre></div>
<hr /><a name="file79" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/reader">reader</a><br /></span>
<div class="fileheader" id="added"><big><b>PolicyReader.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/reader/PolicyReader.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N PolicyReader.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PolicyReader.java 19 Apr 2004 22:20:27 -0000 1.1
@@ -0,0 +1,202 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.reader;
+
+import java.util.ArrayList;
+
+import org.codehaus.loom.xmlpolicy.metadata.GrantMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.KeyStoreMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.PermissionMetaData;
+import org.codehaus.loom.xmlpolicy.metadata.PolicyMetaData;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * This class builds a {@link PolicyMetaData} object from
+ * specified XML document.
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:27 $
+ */
+public class PolicyReader
+{
+ /**
+ * Build ClassLoader MetaData from a DOM tree.
+ *
+ * @param element the root element
+ * @return the meta data
+ * @throws Exception if malformed DOM
+ */
+ public PolicyMetaData readPolicy( final Element element )
+ throws Exception
+ {
+ final String version = element.getAttribute( "version" );
+ if( !"1.0".equals( version ) )
+ {
+ final String message = "Bad version:" + version;
+ throw new Exception( message );
+ }
+
+ final NodeList keyStoreConfigs = element.getElementsByTagName( "keystore" );
+ final KeyStoreMetaData[] keyStores = buildKeyStores( keyStoreConfigs );
+
+ final NodeList grantConfigs =
+ element.getElementsByTagName( "grant" );
+ final GrantMetaData[] grants = buildGrants( grantConfigs );
+
+ return new PolicyMetaData( keyStores, grants );
+ }
+
+ /**
+ * Build an array of GrantMetaDatas from node list.
+ *
+ * @param elements the nodes to process
+ * @return the GrantMetaData
+ */
+ private GrantMetaData[] buildGrants( final NodeList elements )
+ throws Exception
+ {
+ final ArrayList grants = new ArrayList();
+ final int length = elements.getLength();
+
+ for( int i = 0; i < length; i++ )
+ {
+ final Element element = (Element)elements.item( i );
+ final GrantMetaData grant = buildGrant( element );
+ grants.add( grant );
+ }
+
+ return (GrantMetaData[])grants.toArray( new GrantMetaData[ grants.size() ] );
+ }
+
+ /**
+ * Build a GrantMetaData from an element.
+ *
+ * @param element the nodes to process
+ * @return the GrantMetaData
+ */
+ private GrantMetaData buildGrant( final Element element )
+ throws Exception
+ {
+ final String codeBase = getAttribute( element, "code-base" );
+ final String signedBy = getAttribute( element, "signed-by" );
+ String keyStore = getAttribute( element, "key-store" );
+ if( null != signedBy && null == keyStore )
+ {
+ keyStore = "default";
+ }
+ final NodeList permissionElements =
+ element.getElementsByTagName( "permission" );
+ final PermissionMetaData[] permissions = buildPermissions( permissionElements );
+ return new GrantMetaData( codeBase, signedBy, keyStore, permissions );
+ }
+
+ /**
+ * Build an array of PermissionMetaDatas from node list.
+ *
+ * @param elements the nodes to process
+ * @return the PermissionMetaDatas
+ */
+ private PermissionMetaData[] buildPermissions( final NodeList elements )
+ throws Exception
+ {
+ final ArrayList grants = new ArrayList();
+ final int length = elements.getLength();
+
+ for( int i = 0; i < length; i++ )
+ {
+ final Element element = (Element)elements.item( i );
+ final PermissionMetaData permission = buildPermission( element );
+ grants.add( permission );
+ }
+
+ return (PermissionMetaData[])grants.toArray( new PermissionMetaData[ grants.size() ] );
+ }
+
+ /**
+ * Build a PermissionMetaData from an element.
+ *
+ * @param element the node to process
+ * @return the PermissionMetaData
+ */
+ private PermissionMetaData buildPermission( final Element element )
+ throws Exception
+ {
+ final String classname = getAttribute( element, "class" );
+ final String target = getAttribute( element, "target" );
+ final String action = getAttribute( element, "action" );
+ final String signedBy = getAttribute( element, "signed-by" );
+ String keyStore = getAttribute( element, "key-store" );
+ if( null != signedBy && null == keyStore )
+ {
+ keyStore = "default";
+ }
+ return new PermissionMetaData( classname, target, action,
+ signedBy, keyStore );
+ }
+
+ /**
+ * Build an array of KeyStore meta datas from node list.
+ *
+ * @param elements the nodes to process
+ * @return the keyStores
+ */
+ private KeyStoreMetaData[] buildKeyStores( final NodeList elements )
+ throws Exception
+ {
+ final ArrayList keyStores = new ArrayList();
+ final int length = elements.getLength();
+
+ for( int i = 0; i < length; i++ )
+ {
+ final Element element = (Element)elements.item( i );
+ final KeyStoreMetaData keyStore = buildKeyStore( element );
+ keyStores.add( keyStore );
+ }
+
+ return (KeyStoreMetaData[])keyStores.toArray( new KeyStoreMetaData[ keyStores.size() ] );
+ }
+
+ /**
+ * Build a KeyStoreMetaData from an element.
+ *
+ * @param element the nodes to process
+ * @return the keyStore
+ */
+ private KeyStoreMetaData buildKeyStore( final Element element )
+ throws Exception
+ {
+ final String name = element.getAttribute( "name" );
+ final String location = getAttribute( element, "location" );
+ final String type = getAttribute( element, "type" );
+ return new KeyStoreMetaData( name, location, type );
+ }
+
+ /**
+ * Utility method to get value of attribute. If attribute
+ * has a empty/null value or does not appear in XML then return
+ * null, elese return value.
+ *
+ * @param element the element
+ * @param name the attribute name
+ * @return the cleaned attribute value
+ */
+ private String getAttribute( final Element element,
+ final String name )
+ {
+ final String value = element.getAttribute( name );
+ if( "".equals( value ) )
+ {
+ return null;
+ }
+ else
+ {
+ return value;
+ }
+ }
+}
</pre></div>
<hr /><a name="file80" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/runtime">runtime</a><br /></span>
<div class="fileheader" id="added"><big><b>PolicyEntry.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/runtime/PolicyEntry.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N PolicyEntry.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PolicyEntry.java 19 Apr 2004 22:20:27 -0000 1.1
@@ -0,0 +1,54 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.runtime;
+
+import java.security.CodeSource;
+import java.security.Permissions;
+
+/**
+ * Internal Policy Entry holder class.
+ * Holds information about an entry in policy file.
+ */
+final class PolicyEntry
+{
+ /**
+ * The code source that entry is about.
+ */
+ private final CodeSource m_codeSource;
+
+ /**
+ * the set of permissions for code source.
+ */
+ private final Permissions m_permissions;
+
+ public PolicyEntry( final CodeSource codeSource,
+ final Permissions permissions )
+ {
+ if( null == codeSource )
+ {
+ throw new NullPointerException( "codeSource" );
+ }
+ if( null == permissions )
+ {
+ throw new NullPointerException( "permissions" );
+ }
+
+ m_codeSource = codeSource;
+ m_permissions = permissions;
+ }
+
+ public CodeSource getCodeSource()
+ {
+ return m_codeSource;
+ }
+
+ public Permissions getPermissions()
+ {
+ return m_permissions;
+ }
+}
</pre></div>
<hr /><a name="file81" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/runtime">runtime</a><br /></span>
<div class="fileheader" id="added"><big><b>DefaultPolicy.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/runtime/DefaultPolicy.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N DefaultPolicy.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DefaultPolicy.java 19 Apr 2004 22:20:27 -0000 1.1
@@ -0,0 +1,73 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.runtime;
+
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.Permissions;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * A policy implementation that accepts policys details from a map.
+ * The map is between a codebase and a array of permissions.
+ * Note that it was a deliberate decision to limit the time at which you can
+ * specify policy data for security reasons.
+ *
+ * @author Peter Donald
+ */
+public class DefaultPolicy
+ extends AbstractPolicy
+{
+ /**
+ * Create a Policy that applies specified grants.
+ * Each entry in map maps a CodeSource to an array
+ * of Permissions.
+ *
+ * @param grants the grant map
+ * @throws Exception if unable to construct Policy
+ */
+ public DefaultPolicy( final Map grants )
+ throws Exception
+ {
+ processGrants( grants );
+ }
+
+ /**
+ * Create a policy with zero entrys.
+ * Sub-classes usually use this constructor then
+ * invoke processGrants separately.
+ */
+ public DefaultPolicy()
+ {
+ }
+
+ /**
+ * Process map of grants and configure Policy appropriately.
+ *
+ * @param grants the grants map
+ * @throws Exception if unable to perform configuration
+ */
+ protected final void processGrants( final Map grants )
+ throws Exception
+ {
+ final Iterator iterator = grants.keySet().iterator();
+ while( iterator.hasNext() )
+ {
+ final CodeSource codeSource = (CodeSource)iterator.next();
+ final Permission[] permissions = (Permission[])grants.get( codeSource );
+ final Permissions permissionSet = createPermissionSetFor( codeSource );
+
+ for( int i = 0; i < permissions.length; i++ )
+ {
+ final Permission permission = permissions[ i ];
+ permissionSet.add( permission );
+ }
+ }
+ }
+}
</pre></div>
<hr /><a name="file82" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java">java</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/runtime">runtime</a><br /></span>
<div class="fileheader" id="added"><big><b>AbstractPolicy.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/java/org/codehaus/loom/xmlpolicy/runtime/AbstractPolicy.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N AbstractPolicy.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AbstractPolicy.java 19 Apr 2004 22:20:27 -0000 1.1
@@ -0,0 +1,161 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.runtime;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.cert.Certificate;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import org.codehaus.spice.salt.io.FileUtil;
+
+/**
+ * Abstract Policy class that makes it easy to add permission
+ * sets to policy.
+ *
+ * @author Peter Donald
+ */
+public abstract class AbstractPolicy
+ extends Policy
+{
+ /**
+ * List of PolicyEntry objects described by AbstractPolicy.
+ */
+ private final ArrayList m_entries = new ArrayList();
+
+ /**
+ * Overide so we can have a per-application security policy with
+ * no side-effects to other applications.
+ *
+ * @param codeSource the CodeSource to get permissions for
+ * @return the PermissionCollection
+ */
+ public PermissionCollection getPermissions( final CodeSource codeSource )
+ {
+ final CodeSource target = normalize( codeSource );
+
+ final Permissions permissions = new Permissions();
+ final int size = m_entries.size();
+
+ for( int i = 0; i < size; i++ )
+ {
+ final PolicyEntry entry = (PolicyEntry)m_entries.get( i );
+ if( entry.getCodeSource().implies( target ) )
+ {
+ copyPermissions( permissions, entry.getPermissions() );
+ }
+ }
+
+ return permissions;
+ }
+
+ /**
+ * Refresh policy. Ignored in this implementation.
+ */
+ public void refresh()
+ {
+ }
+
+ /**
+ * Create a set of permissions for a particular codesource.
+ * These are read-write permissions and can be written till until the
+ * time in which they are applied to code.
+ *
+ * @param codeSource the code source
+ * @return the permission set
+ */
+ protected Permissions createPermissionSetFor( final CodeSource codeSource )
+ {
+ final CodeSource target = normalize( codeSource );
+ final PolicyEntry entry =
+ new PolicyEntry( target, new Permissions() );
+ m_entries.add( entry );
+ return entry.getPermissions();
+ }
+
+ /**
+ * Normalizing CodeSource involves removing relative addressing
+ * (like .. and .) for file urls.
+ *
+ * @param codeSource the codeSource to be normalized
+ * @return the normalized codeSource
+ */
+ private CodeSource normalize( final CodeSource codeSource )
+ {
+ final URL initialLocation = codeSource.getLocation();
+
+ // This is a bit of a h ack. I don't know why CodeSource should behave like this
+ // Fear not, this only seems to be a problem for home grown classloaders.
+ // - Paul Hammant, Nov 2000
+ if( null == initialLocation )
+ {
+ return codeSource;
+ }
+
+ String location = null;
+
+ if( !initialLocation.getProtocol().equalsIgnoreCase( "file" ) )
+ {
+ location = initialLocation.getFile();
+ location = FileUtil.normalize( location );
+ }
+ else
+ {
+ final File file = new File( initialLocation.getFile() );
+ location = file.getAbsoluteFile().toString().replace( File.separatorChar, '/' );
+ location = FileUtil.normalize( location );
+ }
+
+ URL finalLocation = null;
+ try
+ {
+ finalLocation = new URL( initialLocation.getProtocol(),
+ initialLocation.getHost(),
+ initialLocation.getPort(),
+ location );
+ }
+ catch( final MalformedURLException mue )
+ {
+ error( "Error building codeBase", mue );
+ }
+
+ final Certificate[] certificates = codeSource.getCertificates();
+ return new CodeSource( finalLocation, certificates );
+ }
+
+ /**
+ * Utility method to cpoy permissions from specified source to specified destination.
+ *
+ * @param destination the destination of permissions
+ * @param source the source of permissions
+ */
+ private void copyPermissions( final Permissions destination,
+ final Permissions source )
+ {
+ final Enumeration enum = source.elements();
+ while( enum.hasMoreElements() )
+ {
+ destination.add( (Permission)enum.nextElement() );
+ }
+ }
+
+ /**
+ * Error occured in policy. Subclasses should overide.
+ */
+ protected void error( final String message,
+ final Throwable throwable )
+ {
+ System.err.println( message );
+ }
+}
</pre></div>
<hr /><a name="file83" /><div class="file">
<span class="pathname" id="added"><a href="http://xstream.cvs.codehaus.org/jcontainer">jcontainer</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support">support</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy">xmlpolicy</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src">src</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test">test</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org">org</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus">codehaus</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom">loom</a>/<a href="http://xstream.cvs.codehaus.org/jcontainer/loom/supp
ort/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy">xmlpolicy</a>/<a href="http://xstream!
.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/test">test</a><br /></span>
<div class="fileheader" id="added"><big><b>AbstractPolicyTestCase.java</b></big> <small id="info">added at <a href="http://xstream.cvs.codehaus.org/jcontainer/loom/support/xmlpolicy/src/test/org/codehaus/loom/xmlpolicy/test/AbstractPolicyTestCase.java?rev=1.1&content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N AbstractPolicyTestCase.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AbstractPolicyTestCase.java 19 Apr 2004 22:20:27 -0000 1.1
@@ -0,0 +1,69 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.loom.xmlpolicy.test;
+
+import java.io.InputStream;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import junit.framework.TestCase;
+
+import org.codehaus.loom.xmlpolicy.metadata.PolicyMetaData;
+import org.codehaus.loom.xmlpolicy.reader.PolicyReader;
+import org.w3c.dom.Document;
+
+/**
+ * An abstract testcase to test policys.
+ *
+ * @author Peter Donald
+ * @version $Revision: 1.1 $ $Date: 2004/04/19 22:20:27 $
+ */
+public class AbstractPolicyTestCase
+ extends TestCase
+{
+ protected PolicyMetaData buildFromStream( final InputStream stream )
+ throws Exception
+ {
+ try
+ {
+ final PolicyReader builder = new PolicyReader();
+ final Document config = load( stream );
+ return builder.readPolicy( config.getDocumentElement() );
+ }
+ catch( final Exception e )
+ {
+ fail( "Error building Policy: " + e );
+ return null;
+ }
+ }
+
+ protected Document load( final InputStream stream )
+ throws Exception
+ {
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ //factory.setValidating(true);
+ //factory.setNamespaceAware(true);
+ final DocumentBuilder builder = factory.newDocumentBuilder();
+ return builder.parse( stream );
+ }
+
+ protected PolicyMetaData buildFromResource( final String resource )
+ throws Exception
+ {
+ final InputStream stream = getClass().getResourceAsStream( resource );
+ if( null == stream )
+ {
+ fail( "Missing resource " + resource );
+ }
+ return buildFromStream( stream );
+ }
+
+ public AbstractPolicyTestCase( String name )
+ {
+ super( name );
+ }
+}
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -> email">CVSspam</a> 0.2.8</small></center>
</body></html>