public boolean equals(final Object permission) { return permission instanceof VirtualFilePermission && equals((VirtualFilePermission) permission); }
private boolean implies(final VirtualFilePermission permission) { assert permission != null; // else the above check would have failed int remainingFlags = permission.getActionFlags(); if (remainingFlags == 0) { return true; } // snapshot final VirtualFilePermission[] permissions = this.permissions; final String theirName = permission.getName(); for (VirtualFilePermission ourPermission : permissions) { if (VirtualFilePermission.impliesPath(ourPermission.getName(), theirName)) { remainingFlags &= ~ourPermission.getActionFlags(); if (remainingFlags == 0) { return true; } } } return false; }
public boolean implies(final Permission permission) { return permission instanceof VirtualFilePermission && implies((VirtualFilePermission) permission); }
private boolean impliesUnchecked(final VirtualFilePermission permission) { final int theirFlags = permission.actionFlags; return (actionFlags & theirFlags) == theirFlags && impliesPath(getName(), permission.getName()); }
private static boolean impliesPath(String ourName, String theirName, int idx) { final int ourLen = ourName.length(); final int theirLen = theirName.length(); final int ei1 = ourIndexOf(ourName, '/', idx); final int ei2 = ourIndexOf(theirName, '/', idx); if (ei1 == idx + 1) { final char ch = ourName.charAt(idx); if (ch == '-') { // recursive wildcard... // if they are non-empty, match return theirLen > idx; // otherwise their segment is empty (no match) } else if (ch == '*') { // non-recursive wildcard... // if they are non-empty, and this is their last segment, match, unless they are '-' return theirLen > idx && ei2 == theirLen && (ei2 != ei1 || theirName.charAt(idx) != '-'); } } if (ei1 == ei2) { if (ei1 == ourLen && ei2 == theirLen) { // exact match return true; } else { // leading sequence matches, check next segment return impliesPath(ourName, theirName, ei1 + 1); } } else { return false; } }
/** * 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); }
int res = 0; for (int i = 0; i < len; i++) { if (lenIs(actions, i, len, 4) && in(actions.charAt(i), 'r', 'R') && in(actions.charAt(i + 1), 'e', 'E') && in(actions.charAt(i + 2), 'a', 'A') && in(actions.charAt(i + 3), 'd', 'D')) { res |= FLAG_READ; i += 4; } else if (lenIs(actions, i, len, 6) && in(actions.charAt(i), 'd', 'D') && in(actions.charAt(i + 1), 'e', 'E') && in(actions.charAt(i + 2), 'l', 'L') && in(actions.charAt(i + 3), 'e', 'E') && in(actions.charAt(i + 4), 't', 'T') && in(actions.charAt(i + 5), 'e', 'E')) { res |= FLAG_DELETE; i += 6; } else if (lenIs(actions, i, len, 7) && in(actions.charAt(i), 'g', 'G') && in(actions.charAt(i + 1), 'e', 'E') && in(actions.charAt(i + 2), 't', 'T') && in(actions.charAt(i + 3), 'f', 'F') && in(actions.charAt(i + 4), 'i', 'I') && in(actions.charAt(i + 5), 'l', 'L') && in(actions.charAt(i + 6), 'e', 'E')) { res |= FLAG_GET_FILE; i += 7; } else if (lenIs(actions, i, len, 1) && actions.charAt(i) == '*') {
public boolean implies(final VirtualFilePermission permission) { return permission != null && impliesUnchecked(permission); }
static boolean impliesPath(String ourName, String theirName) { if ("<<ALL FILES>>".equals(ourName)) { return true; } return impliesPath(ourName, theirName, 0); }
/** * 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); }
public int hashCode() { return getName().hashCode() * 11 + actionFlags; } }
/** * 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); }
public boolean equals(final Permission permission) { return permission instanceof VirtualFilePermission && equals((VirtualFilePermission) permission); }
/** * 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); }
final boolean checking = WildFlySecurityManager.isChecking(); if (checking) { sm.checkPermission(new VirtualFilePermission(root.getPathName(), "read"));
/** * 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"));