You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2012/07/17 12:03:58 UTC
svn commit: r1362433 - in /river/jtsk/trunk:
qa/src/com/sun/jini/test/impl/start/aggregatepolicyprovider/
src/org/apache/river/api/security/ src/org/apache/river/impl/net/
test/src/org/apache/river/api/security/ test/src/org/apache/river/impl/net/
Author: peter_firmstone
Date: Tue Jul 17 10:03:57 2012
New Revision: 1362433
URL: http://svn.apache.org/viewvc?rev=1362433&view=rev
Log:
Fixing URI / URL issues on windows. Found cause of failing test SubPoliciesTest, pseudo URL file strings have /C: prepended on windows platforms.
Made fields final in UriString as suggested by Dan Rollo - thanks.
Added:
river/jtsk/trunk/test/src/org/apache/river/api/security/URIGrantTest.java
river/jtsk/trunk/test/src/org/apache/river/impl/net/
river/jtsk/trunk/test/src/org/apache/river/impl/net/UriStringTest.java
- copied, changed from r1361696, river/jtsk/trunk/test/src/org/apache/river/api/security/UriStringTest.java
Removed:
river/jtsk/trunk/test/src/org/apache/river/api/security/UriStringTest.java
Modified:
river/jtsk/trunk/qa/src/com/sun/jini/test/impl/start/aggregatepolicyprovider/SubPoliciesTest.0.policy
river/jtsk/trunk/qa/src/com/sun/jini/test/impl/start/aggregatepolicyprovider/SubPoliciesTest.1.policy
river/jtsk/trunk/src/org/apache/river/api/security/URIGrant.java
river/jtsk/trunk/src/org/apache/river/impl/net/UriString.java
Modified: river/jtsk/trunk/qa/src/com/sun/jini/test/impl/start/aggregatepolicyprovider/SubPoliciesTest.0.policy
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/qa/src/com/sun/jini/test/impl/start/aggregatepolicyprovider/SubPoliciesTest.0.policy?rev=1362433&r1=1362432&r2=1362433&view=diff
==============================================================================
--- river/jtsk/trunk/qa/src/com/sun/jini/test/impl/start/aggregatepolicyprovider/SubPoliciesTest.0.policy (original)
+++ river/jtsk/trunk/qa/src/com/sun/jini/test/impl/start/aggregatepolicyprovider/SubPoliciesTest.0.policy Tue Jul 17 10:03:57 2012
@@ -66,3 +66,19 @@ grant codeBase "file:/foo/-" {
grant codeBase "file:/bar.jar" {
permission java.lang.RuntimePermission "D0";
};
+
+/* For Microsoft Platform URI grants, URL prepends /C: while URI doesn't
+ * this is only required for pseudo URI strings.
+ */
+
+grant codeBase "file:/C:/foo/*" {
+ permission java.lang.RuntimePermission "B0";
+};
+
+grant codeBase "file:/C:/foo/-" {
+ permission java.lang.RuntimePermission "C0";
+};
+
+grant codeBase "file:/C:/bar.jar" {
+ permission java.lang.RuntimePermission "D0";
+};
\ No newline at end of file
Modified: river/jtsk/trunk/qa/src/com/sun/jini/test/impl/start/aggregatepolicyprovider/SubPoliciesTest.1.policy
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/qa/src/com/sun/jini/test/impl/start/aggregatepolicyprovider/SubPoliciesTest.1.policy?rev=1362433&r1=1362432&r2=1362433&view=diff
==============================================================================
--- river/jtsk/trunk/qa/src/com/sun/jini/test/impl/start/aggregatepolicyprovider/SubPoliciesTest.1.policy (original)
+++ river/jtsk/trunk/qa/src/com/sun/jini/test/impl/start/aggregatepolicyprovider/SubPoliciesTest.1.policy Tue Jul 17 10:03:57 2012
@@ -6,14 +6,30 @@ grant {
permission java.lang.RuntimePermission "A1";
};
-grant codeBase "file:/foo/*" {
+grant codeBase "file:///foo/*" {
permission java.lang.RuntimePermission "B1";
};
-grant codeBase "file:/foo/-" {
+grant codeBase "file:///foo/-" {
permission java.lang.RuntimePermission "C1";
};
-grant codeBase "file:/bar.jar" {
+grant codeBase "file:///bar.jar" {
permission java.lang.RuntimePermission "D1";
};
+
+/* For Microsoft Platform URI grants, URL prepends /C: while URI doesn't
+ * this is only required for pseudo URI strings.
+ */
+
+grant codeBase "file:///C:/foo/*" {
+ permission java.lang.RuntimePermission "B1";
+};
+
+grant codeBase "file:///C:/foo/-" {
+ permission java.lang.RuntimePermission "C1";
+};
+
+grant codeBase "file:///C:/bar.jar" {
+ permission java.lang.RuntimePermission "D1";
+};
\ No newline at end of file
Modified: river/jtsk/trunk/src/org/apache/river/api/security/URIGrant.java
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/org/apache/river/api/security/URIGrant.java?rev=1362433&r1=1362432&r2=1362433&view=diff
==============================================================================
--- river/jtsk/trunk/src/org/apache/river/api/security/URIGrant.java (original)
+++ river/jtsk/trunk/src/org/apache/river/api/security/URIGrant.java Tue Jul 17 10:03:57 2012
@@ -199,7 +199,7 @@ class URIGrant extends CertificateGrant
* @return {@code true} if the argument code source is implied by this
* {@code CodeSource}, otherwise {@code false}.
*/
- private final boolean implies(URI grant, URI implied) {
+ final boolean implies(URI grant, URI implied) { // package private for junit
//
// Here, javadoc:N refers to the appropriate item in the API spec for
// the CodeSource.implies()
Modified: river/jtsk/trunk/src/org/apache/river/impl/net/UriString.java
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/org/apache/river/impl/net/UriString.java?rev=1362433&r1=1362432&r2=1362433&view=diff
==============================================================================
--- river/jtsk/trunk/src/org/apache/river/impl/net/UriString.java (original)
+++ river/jtsk/trunk/src/org/apache/river/impl/net/UriString.java Tue Jul 17 10:03:57 2012
@@ -37,35 +37,35 @@ public class UriString {
// Allowed
private static final char [] lowalpha = "abcdefghijklmnopqrstuvwxyz".toCharArray();
private static final char [] upalpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
- private static char [] numeric = "0123456789".toCharArray();
- private static char [] reserved = {';','/','?',':','@','&','=','+','$',','};
- private static char [] mark = "-_.!~*'()".toCharArray();
- private static char escape = '%';
- private static char fragment = '#';
+ private static final char [] numeric = "0123456789".toCharArray();
+ private static final char [] reserved = {';','/','?',':','@','&','=','+','$',','};
+ private static final char [] mark = "-_.!~*'()".toCharArray();
+ private static final char escape = '%';
+ private static final char fragment = '#';
// Excluded
- private static Character [] control = {
+ private static final Character [] control = {
'\u0000','\u0001','\u0002','\u0003','\u0004','\u0005','\u0006','\u0007',
'\u0008','\u0009','\n', '\u000B','\u000C','\r', '\u000E','\u000F',
'\u0010','\u0011','\u0012','\u0013','\u0014','\u0015','\u0016','\u0017',
'\u0018','\u0019','\u001A','\u001B','\u001C','\u001D','\u001E','\u001F',
'\u007F'
};
- private static String [] contEsc = {
+ private static final String [] contEsc = {
"%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07",
"%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F",
"%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17",
"%18", "%19", "%1A", "%1B", "%1C", "%1D", "%1E", "%1F",
"%7F"
};
- private static Character space = '\u0020';
- private static String spaceEsc = "%20";
+ private static final Character space = '\u0020';
+ private static final String spaceEsc = "%20";
// Excluded because they are often used as delimiters around URI
- private static Character [] delims = {'<','>','"'};
- private static String [] delimEsc = {"%3C", "%3E", "%22"};
+ private static final Character [] delims = {'<','>','"'};
+ private static final String [] delimEsc = {"%3C", "%3E", "%22"};
// Excluded because gateways and other transport agents are known
// to sometimes modify such characters, or they are used as delimiters.
- private static Character [] unwise = {'{','}','|','\\','^','[',']','`'};
- private static String [] unwiseEsc = {"%7B", "%7D", "%7C", "%5C",
+ private static final Character [] unwise = {'{','}','|','\\','^','[',']','`'};
+ private static final String [] unwiseEsc = {"%7B", "%7D", "%7C", "%5C",
"%53", "%5B", "%5D", "%60"};
Added: river/jtsk/trunk/test/src/org/apache/river/api/security/URIGrantTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/test/src/org/apache/river/api/security/URIGrantTest.java?rev=1362433&view=auto
==============================================================================
--- river/jtsk/trunk/test/src/org/apache/river/api/security/URIGrantTest.java (added)
+++ river/jtsk/trunk/test/src/org/apache/river/api/security/URIGrantTest.java Tue Jul 17 10:03:57 2012
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.api.security;
+
+import java.net.MalformedURLException;
+import java.security.CodeSource;
+import java.net.URL;
+import java.security.ProtectionDomain;
+import java.net.URISyntaxException;
+import java.security.cert.Certificate;
+import java.security.Permission;
+import java.security.Principal;
+import java.net.URI;
+import junit.framework.Assert;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author peter
+ */
+public class URIGrantTest {
+ URIGrant instance;
+ ProtectionDomain pd;
+ public URIGrantTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws URISyntaxException, MalformedURLException {
+ URI [] u = new URI[2];
+ u[0] = new URI("file:///foo/*");
+ u[1] = new URI("file:///C:/foo/*");
+ instance = new URIGrant(u, new Certificate[0], new Principal[0], new Permission[0]);
+ pd = new ProtectionDomain( new CodeSource(new URL("file:/foo/bar"), (Certificate []) null), null);
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ @Test
+ public void testImplies() throws URISyntaxException {
+ System.out.println("Test implies");
+ URI grant = new URI("file:///foo/*");
+ URI otherGrant = new URI("file:/foo/*");
+ URI implied = new URI("file:/foo/bar");
+ URI alsoImplied = new URI("file:///foo/bar");
+ Assert.assertTrue(instance.implies(grant, implied));
+ Assert.assertTrue(instance.implies(grant,alsoImplied));
+ Assert.assertTrue(instance.implies(otherGrant, implied));
+ Assert.assertTrue(instance.implies(otherGrant, alsoImplied));
+ }
+
+ @Test
+ public void testImpliesPD() throws URISyntaxException {
+ System.out.println("Test implies ProtectionDomain");
+ Assert.assertTrue(instance.implies(pd));
+ }
+}
Copied: river/jtsk/trunk/test/src/org/apache/river/impl/net/UriStringTest.java (from r1361696, river/jtsk/trunk/test/src/org/apache/river/api/security/UriStringTest.java)
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/test/src/org/apache/river/impl/net/UriStringTest.java?p2=river/jtsk/trunk/test/src/org/apache/river/impl/net/UriStringTest.java&p1=river/jtsk/trunk/test/src/org/apache/river/api/security/UriStringTest.java&r1=1361696&r2=1362433&rev=1362433&view=diff
==============================================================================
--- river/jtsk/trunk/test/src/org/apache/river/api/security/UriStringTest.java (original)
+++ river/jtsk/trunk/test/src/org/apache/river/impl/net/UriStringTest.java Tue Jul 17 10:03:57 2012
@@ -2,7 +2,7 @@
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
-package org.apache.river.api.security;
+package org.apache.river.impl.net;
import org.junit.After;
import org.junit.AfterClass;