/** * Get the {@link CodeSigner}s for a the virtual file. * * @return the {@link CodeSigner}s for the virtual file, or {@code null} if not signed */ public CodeSigner[] getCodeSigners() { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new VirtualFilePermission(getPathName(), "read")); } final VFS.Mount mount = VFS.getMount(this); return mount.getFileSystem().getCodeSigners(mount.getMountPoint(), this); }
/** * When the file was last modified * * @return the last modified time */ public long getLastModified() { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new VirtualFilePermission(getPathName(), "read")); } final VFS.Mount mount = VFS.getMount(this); if (sm != null) { final VirtualFile target = this; return AccessController.doPrivileged(new PrivilegedAction<Long>() { @Override public Long run() { return mount.getFileSystem().getLastModified(mount.getMountPoint(), target); } }); } return mount.getFileSystem().getLastModified(mount.getMountPoint(), this); }
/** * Delete this virtual file * * @return {@code true} if file was deleted */ public boolean delete() { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new VirtualFilePermission(getPathName(), "delete")); } final VFS.Mount mount = VFS.getMount(this); if (sm != null) { final VirtualFile target = this; return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { @Override public Boolean run() { return mount.getFileSystem().delete(mount.getMountPoint(), target); } }); } return mount.getFileSystem().delete(mount.getMountPoint(), this); }
final boolean checking = WildFlySecurityManager.isChecking(); if (checking) { sm.checkPermission(new VirtualFilePermission(root.getPathName(), "read"));
/** * Determine whether the named virtual file is a directory. * * @return {@code true} if it is a directory, {@code false} otherwise */ public boolean isDirectory() { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new VirtualFilePermission(getPathName(), "read")); } final VFS.Mount mount = VFS.getMount(this); if (sm != null) { final VirtualFile target = this; return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { @Override public Boolean run() { return mount.getFileSystem().isDirectory(mount.getMountPoint(), target); } }); } return mount.getFileSystem().isDirectory(mount.getMountPoint(), this); }
/** * Get the size * * @return the size */ public long getSize() { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new VirtualFilePermission(getPathName(), "read")); } final VFS.Mount mount = VFS.getMount(this); if (sm != null) { final VirtualFile target = this; return AccessController.doPrivileged(new PrivilegedAction<Long>() { @Override public Long run() { return mount.getFileSystem().getSize(mount.getMountPoint(), target); } }); } return mount.getFileSystem().getSize(mount.getMountPoint(), this); }
/** * Tests whether the underlying implementation file still exists. * * @return true if the file exists, false otherwise. */ public boolean exists() { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new VirtualFilePermission(getPathName(), "read")); } final VFS.Mount mount = VFS.getMount(this); if (sm != null) { final VirtualFile target = this; return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { @Override public Boolean run() { return mount.getFileSystem().exists(mount.getMountPoint(), target); } }); } return mount.getFileSystem().exists(mount.getMountPoint(), this); }
/** * Determine whether the named virtual file is a plain file. * * @return {@code true} if it is a plain file, {@code false} otherwise */ public boolean isFile() { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new VirtualFilePermission(getPathName(), "read")); } final VFS.Mount mount = VFS.getMount(this); if (sm != null) { final VirtualFile target = this; return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { @Override public Boolean run() { return mount.getFileSystem().isFile(mount.getMountPoint(), target); } }); } return mount.getFileSystem().isFile(mount.getMountPoint(), this); }
final boolean checking = WildFlySecurityManager.isChecking(); if (checking) { sm.checkPermission(new VirtualFilePermission(root.getPathName(), "read"));
final boolean checking = WildFlySecurityManager.isChecking(); if (checking) { sm.checkPermission(new VirtualFilePermission(root.getPathName(), "read"));
/** * Get a physical file for this virtual file. Depending on the underlying file system type, this may simply return * an already-existing file; it may create a copy of a file; or it may reuse a preexisting copy of the file. * Furthermore, the returned file may or may not have any relationship to other files from the same or any other * virtual directory. * * @return the physical file * @throws IOException if an I/O error occurs while producing the physical file */ public File getPhysicalFile() throws IOException { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new VirtualFilePermission(getPathName(), "getfile")); } final VFS.Mount mount = VFS.getMount(this); if (sm != null) { final VirtualFile target = this; return doIoPrivileged(new PrivilegedExceptionAction<File>() { @Override public File run() throws Exception { return mount.getFileSystem().getFile(mount.getMountPoint(), target); } }); } return mount.getFileSystem().getFile(mount.getMountPoint(), this); }
/** * Access the file contents. * * @return an InputStream for the file contents. * @throws IOException for any error accessing the file system */ public InputStream openStream() throws IOException { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new VirtualFilePermission(getPathName(), "read")); } if (isDirectory()) { return new VirtualJarInputStream(this); } final VFS.Mount mount = VFS.getMount(this); if (sm != null) { final VirtualFile target = this; return doIoPrivileged(new PrivilegedExceptionAction<InputStream>() { @Override public InputStream run() throws Exception { return mount.getFileSystem().openInputStream(mount.getMountPoint(), target); } }); } return mount.getFileSystem().openInputStream(mount.getMountPoint(), this); }
private void addResourceRoot(final ModuleSpec.Builder specBuilder, final ResourceRoot resource, final List<PermissionFactory> permFactories) throws DeploymentUnitProcessingException { try { final VirtualFile root = resource.getRoot(); if (resource.getExportFilters().isEmpty()) { specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new VFSResourceLoader(resource .getRootName(), root, resource.isUsePhysicalCodeSource()))); } else { final MultiplePathFilterBuilder filterBuilder = PathFilters.multiplePathFilterBuilder(true); for (final FilterSpecification filter : resource.getExportFilters()) { filterBuilder.addFilter(filter.getPathFilter(), filter.isInclude()); } specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new VFSResourceLoader(resource .getRootName(), root, resource.isUsePhysicalCodeSource()), filterBuilder.create())); } // start with the root permFactories.add(new ImmediatePermissionFactory( new VirtualFilePermission(root.getPathName(), VirtualFilePermission.FLAG_READ))); // also include all children, recursively permFactories.add(new ImmediatePermissionFactory( new VirtualFilePermission(root.getChild("-").getPathName(), VirtualFilePermission.FLAG_READ))); } catch (IOException e) { throw ServerLogger.ROOT_LOGGER.failedToCreateVFSResourceLoader(resource.getRootName(), e); } }
private void addResourceRoot(final ModuleSpec.Builder specBuilder, final ResourceRoot resource, final List<PermissionFactory> permFactories) throws DeploymentUnitProcessingException { try { final VirtualFile root = resource.getRoot(); if (resource.getExportFilters().isEmpty()) { specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new VFSResourceLoader(resource .getRootName(), root, resource.isUsePhysicalCodeSource()))); } else { final MultiplePathFilterBuilder filterBuilder = PathFilters.multiplePathFilterBuilder(true); for (final FilterSpecification filter : resource.getExportFilters()) { filterBuilder.addFilter(filter.getPathFilter(), filter.isInclude()); } specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new VFSResourceLoader(resource .getRootName(), root, resource.isUsePhysicalCodeSource()), filterBuilder.create())); } // start with the root permFactories.add(new ImmediatePermissionFactory( new VirtualFilePermission(root.getPathName(), VirtualFilePermission.FLAG_READ))); // also include all children, recursively permFactories.add(new ImmediatePermissionFactory( new VirtualFilePermission(root.getChild("-").getPathName(), VirtualFilePermission.FLAG_READ))); } catch (IOException e) { throw ServerLogger.ROOT_LOGGER.failedToCreateVFSResourceLoader(resource.getRootName(), e); } }
private void addResourceRoot(final ModuleSpec.Builder specBuilder, final ResourceRoot resource, final List<PermissionFactory> permFactories) throws DeploymentUnitProcessingException { try { final VirtualFile root = resource.getRoot(); if (resource.getExportFilters().isEmpty()) { specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new VFSResourceLoader(resource .getRootName(), root, resource.isUsePhysicalCodeSource()))); } else { final MultiplePathFilterBuilder filterBuilder = PathFilters.multiplePathFilterBuilder(true); for (final FilterSpecification filter : resource.getExportFilters()) { filterBuilder.addFilter(filter.getPathFilter(), filter.isInclude()); } specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new VFSResourceLoader(resource .getRootName(), root, resource.isUsePhysicalCodeSource()), filterBuilder.create())); } permFactories.add(new ImmediatePermissionFactory( new VirtualFilePermission(root.getChild("-").getPathName(), VirtualFilePermission.FLAG_READ))); } catch (IOException e) { throw ServerMessages.MESSAGES.failedToCreateVFSResourceLoader(resource.getRootName(), e); } }
new VirtualFilePermission(root.getPathName(), VirtualFilePermission.FLAG_READ))); new VirtualFilePermission(root.getChild("-").getPathName(), VirtualFilePermission.FLAG_READ)));
new VirtualFilePermission(root.getPathName(), VirtualFilePermission.FLAG_READ))); new VirtualFilePermission(root.getChild("-").getPathName(), VirtualFilePermission.FLAG_READ)));