User: starksm
Date: 02/04/05 07:28:37
Modified: src/main/org/jboss/net/protocol/file FileURLConnection.java
Log:
Fix the getPermission method.
Revision Changes Path
1.4 +12 -36
jboss-common/src/main/org/jboss/net/protocol/file/FileURLConnection.java
Index: FileURLConnection.java
===================================================================
RCS file:
/cvsroot/jboss/jboss-common/src/main/org/jboss/net/protocol/file/FileURLConnection.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FileURLConnection.java 5 Apr 2002 07:05:33 -0000 1.3
+++ FileURLConnection.java 5 Apr 2002 15:28:36 -0000 1.4
@@ -28,7 +28,7 @@
* Provides local file access via URL semantics, correctly returning
* lastModified.
*
- * @version <tt>$Revision: 1.3 $</tt>
+ * @version <tt>$Revision: 1.4 $</tt>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
*/
public class FileURLConnection
@@ -75,41 +75,17 @@
return super.getHeaderField(name);
}
- public Permission getPermission() throws IOException {
- // this sucks... must be a better way, but screw it for now
- // if you know how this should be done, please fix it... please
- java.util.List list = new java.util.ArrayList(4);
- if (file.canRead()) list.add("read");
- if (file.canWrite()) list.add("write");
-
- SecurityManager security = System.getSecurityManager();
- if (security != null) {
- try {
- security.checkExec(file.getPath());
- list.add("execute");
- }
- catch (SecurityException ignore) {}
-
- try {
- security.checkDelete(file.getPath());
- list.add("delete");
- }
- catch (SecurityException ignore) {}
- }
- else {
- // ?? sure, whatever
- list.add("execute");
- list.add("delete");
- }
-
- StringBuffer actions = new StringBuffer();
- java.util.Iterator iter = list.iterator();
- while (iter.hasNext()) {
- actions.append(iter.next());
- if (iter.hasNext()) actions.append(",");
- }
-
- return new FilePermission(file.getPath(), actions.toString());
+ /** Return a permission for both read,write since both input
+ and output streams are supported.
+ */
+ public Permission getPermission() throws IOException
+ {
+ String path = url.getPath();
+ // See if the seperator char matches the URL '/'
+ if( File.separatorChar != '/' )
+ path = path.replace('/', File.separatorChar);
+ Permission p = new FilePermission(path, "read,write");
+ return p;
}
public long getLastModified() {
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development