User: user57  
  Date: 02/04/04 23:05:36

  Modified:    src/main/org/jboss/net/protocol/file FileURLConnection.java
  Log:
   o getPermission returns a FilePermission, and we try to figure out what
     those perms may be... I have not idea if this is the correct thing todo
     or if there is a better way... if you do please enlighten me
  
  Revision  Changes    Path
  1.3       +35 -6     
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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FileURLConnection.java    5 Apr 2002 06:41:57 -0000       1.2
  +++ FileURLConnection.java    5 Apr 2002 07:05:33 -0000       1.3
  @@ -28,7 +28,7 @@
    * Provides local file access via URL semantics, correctly returning
    * lastModified.
    *
  - * @version <tt>$Revision: 1.2 $</tt>
  + * @version <tt>$Revision: 1.3 $</tt>
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
    */
   public class FileURLConnection
  @@ -75,13 +75,42 @@
         return super.getHeaderField(name);
      }
   
  -   /* FIXME (or remove me) 
      public Permission getPermission() throws IOException {
  -      // should probably return a FilePermission here... 
  -      // but I don't understand that crap, so just return the default
  -      return super.getPermission();
  +      // 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());
      }
  -   */
   
      public long getLastModified() {
         return file.lastModified();
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to