jaxp/src/java.xml/share/classes/javax/xml/validation/SecuritySupport.java
changeset 31287 d6581a7c221f
parent 31284 e9b8469adb9a
child 31288 204ed502eb8a
equal deleted inserted replaced
31286:4c6b605ceb9f 31287:d6581a7c221f
    93         } catch (PrivilegedActionException e) {
    93         } catch (PrivilegedActionException e) {
    94             throw (IOException)e.getException();
    94             throw (IOException)e.getException();
    95         }
    95         }
    96     }
    96     }
    97 
    97 
    98     URL getResourceAsURL(final ClassLoader cl,
    98     // Used for debugging purposes
    99                                            final String name)
    99     String getClassSource(Class<?> cls) {
   100     {
   100         return AccessController.doPrivileged(new PrivilegedAction<String>() {
   101         return (URL)
   101             public String run() {
   102             AccessController.doPrivileged(new PrivilegedAction() {
   102                CodeSource cs = cls.getProtectionDomain().getCodeSource();
   103                 public Object run() {
   103                if (cs != null) {
   104                     URL url;
   104                     return cs.getLocation().toString();
   105                     if (cl == null) {
   105                } else {
   106                         url = Object.class.getResource(name);
   106                    return "(no code source)";
   107                     } else {
   107                }
   108                         url = cl.getResource(name);
   108             }
   109                     }
   109         });
   110                     return url;
       
   111                 }
       
   112             });
       
   113     }
       
   114 
       
   115     Enumeration getResources(final ClassLoader cl,
       
   116                                            final String name) throws IOException
       
   117     {
       
   118         try{
       
   119         return (Enumeration)
       
   120             AccessController.doPrivileged(new PrivilegedExceptionAction() {
       
   121                 public Object run() throws IOException{
       
   122                     Enumeration enumeration;
       
   123                     if (cl == null) {
       
   124                         enumeration = ClassLoader.getSystemResources(name);
       
   125                     } else {
       
   126                         enumeration = cl.getResources(name);
       
   127                     }
       
   128                     return enumeration;
       
   129                 }
       
   130             });
       
   131         }catch(PrivilegedActionException e){
       
   132             throw (IOException)e.getException();
       
   133         }
       
   134     }
   110     }
   135 
   111 
   136     boolean doesFileExist(final File f) {
   112     boolean doesFileExist(final File f) {
   137     return ((Boolean)
   113         return ((Boolean)
   138             AccessController.doPrivileged(new PrivilegedAction() {
   114             AccessController.doPrivileged(new PrivilegedAction() {
   139                 public Object run() {
   115                 public Object run() {
   140                     return new Boolean(f.exists());
   116                     return new Boolean(f.exists());
   141                 }
   117                 }
   142             })).booleanValue();
   118             })).booleanValue();