Java 日看一类(20)之IO包中的FilePermission类与FilePermissionCollection类

《AI大模型评测与智能测试》 第三篇“实践蓝图”(第6-7章)着眼于测试领域AI应用,重点介绍了RAG、AI Agent开发及构建端到端智能测试系统的方法。本书聚焦AI时代的“质量”核心,以“AI赋能测试”(AI For Testing)与“AI模型评测”(Testing For AI)为双轮驱动。内容不仅深入剖析如何科学度量AI大模型的内在质量,还系统讲解如何利用AI赋能传统软件测试,帮助读者贯通从模型原理、评测到应用开发的全链路知识。 阅读详情

该类继承自Permission类,并完成了Serializable接口

引入了如下包:

import java.security.*;
import java.util.Enumeration;
import java.util.List;
import java.util.ArrayList;
import java.util.Vector;
import java.util.Collections;
import sun.security.util.SecurityConstants;



该类的类头注释如下:

/**
 * This class represents access to a file or directory.  A FilePermission consists
 * of a pathname and a set of actions valid for that pathname.
 * <P>
 * Pathname is the pathname of the file or directory granted the specified
 * actions. A pathname that ends in "/*" (where "/" is
 * the file separator character, <code>File.separatorChar</code>) indicates
 * all the files and directories contained in that directory. A pathname
 * that ends with "/-" indicates (recursively) all files
 * and subdirectories contained in that directory. A pathname consisting of
 * the special token "&lt;&lt;ALL FILES&gt;&gt;" matches <b>any</b> file.
 * <P>
 * Note: A pathname consisting of a single "*" indicates all the files
 * in the current directory, while a pathname consisting of a single "-"
 * indicates all the files in the current directory and
 * (recursively) all files and subdirectories contained in the current
 * directory.
 * <P>
 * The actions to be granted are passed to the constructor in a string containing
 * a list of one or more comma-separated keywords. The possible keywords are
 * "read", "write", "execute", "delete", and "readlink". Their meaning is
 * defined as follows:
 *
 * <DL>
 *    <DT> read <DD> read permission
 *    <DT> write <DD> write permission
 *    <DT> execute
 *    <DD> execute permission. Allows <code>Runtime.exec</code> to
 *         be called. Corresponds to <code>SecurityManager.checkExec</code>.
 *    <DT> delete
 *    <DD> delete permission. Allows <code>File.delete</code> to
 *         be called. Corresponds to <code>SecurityManager.checkDelete</code>.
 *    <DT> readlink
 *    <DD> read link permission. Allows the target of a
 *         <a href="../nio/file/package-summary.html#links">symbolic link</a>
 *         to be read by invoking the {@link java.nio.file.Files#readSymbolicLink
 *         readSymbolicLink } method.
 * </DL>
 * <P>
 * The actions string is converted to lowercase before processing.
 * <P>
 * Be careful when granting FilePermissions. Think about the implications
 * of granting read and especially write access to various files and
 * directories. The "&lt;&lt;ALL FILES&gt;&gt;" permission with write action is
 * especially dangerous. This grants permission to write to the entire
 * file system. One thing this effectively allows is replacement of the
 * system binary, including the JVM runtime environment.
 *
 * <p>Please note: Code can always read a file from the same
 * directory it's in (or a subdirectory of that directory); it does not
 * need explicit permission to do so.
 *
 * @see java.security.Permission
 * @see java.security.Permissions
 * @see java.security.PermissionCollection
 *
 *
 * @author Marianne Mueller
 * @author Roland Schemers
 * @since 1.2
 *
 * @serial exclude
 */

大意如下:

这个类表示对文件和目录的访问

FilePermission包括了一个路径名和一系列对该路径的有效操作

路径名是被授予指定操作的文件的路径名

一个路径名以‘/’(该文件系统的路径分隔符为‘/’)结尾时,表示该路径下的所有文件和目录

一个路径名以‘/-’为路径结尾时,递归的表示该路径下的所有文件和子目录(就是说子目录下的目录和文件也被包含

可以用特殊字段‘<<ALL FILES>>’作为路径名来匹配所有的文件和目录


注:

由单个‘*’组成的路径表示当前路径下的所有文件及目录,由单个‘-’组成的路径递归表示当前路径下的所有文件及目录


将需要授予操作的关键字以字符串形式传递给构造函数

该字符串包含一个或多个关键字,用逗号相隔

可能使用的关键字有:‘read’,‘write’,‘execute’,‘delete’,‘readlink’

关键字对应操作如下:

read:读权限

write:写权限

execute:执行权限,允许调用Runtime.exec,符合SecurityManager.CheckExec的要求

delete:删除权限,允许调用File.delete,符合SecurityManager.CheckDelete的要求

readlink:读取链接权限,允许通过调用Java.nio.file.Files中的readSymbolicLink方法来读取链接对象


操作字符串在操作前被转化为小写


请小心的授权FilePermission,对各种目录和文件进行读和写权限授予时(尤其是写权限)请三思而后行

对<<All Files>>授予写权限是特别危险的

这个将会授予其对整个文件系统的修改权限

事实上他甚至允许了对系统二进制文件进行替换(包括java虚拟机的运行环境


该类总是有对其目录下文件(包含子目录的读取权限)的读权限(不包含写权限),不需要显式授权



该类含有如下的成员变量:

执行操作

private final static int EXECUTE = 0x1;

写入操作

private final static int WRITE   = 0x2;

读取操作

private final static int READ    = 0x4;

删除操作

private final static int DELETE  = 0x8;

读取链接操作

private final static int READLINK    = 0x10;

全部操作

private final static int ALL     = READ|WRITE|EXECUTE|DELETE|READLINK;

无操作

private final static int NONE    = 0x0;

当前操作(就是操作的int值

private transient int mask;

标记路径是否包含目录

private transient boolean directory;

标记是否递归

private transient boolean recursive;

权限字符串

private String actions;

规范化后的路径

private transient String cpath;

特殊字符-(递归

private static final char RECURSIVE_CHAR = '-';

特殊字符*(不递归

private static final char WILD_CHAR = '*';

串行序列号

private static final long serialVersionUID = 7930732926638008763L;




该类含有如下的方法:

初始化该类的功能(非构造函数

private void init(int mask) {
    if ((mask & ALL) != mask)//不是规定操作关键字之一
            throw new IllegalArgumentException("invalid actions mask");

    if (mask == NONE)//未授予任何操作
            throw new IllegalArgumentException("invalid actions mask");

    if ((cpath = getName()) == null)//路径名为空
            throw new NullPointerException("name can't be null");

    this.mask = mask;//当前操作置入

    if (cpath.equals("<<ALL FILES>>")) {//若路径为全文件系统
        directory = true;//判定为目录
        recursive = true;//判定可递归
        cpath = "";//路径为空
        return;
    }

    // store only the canonical cpath if possible
    cpath = AccessController.doPrivileged(new PrivilegedAction<String>() {//权限检查解除,创建String类的特权操作
        public String run() {//实现run函数
            try {
                String path = cpath;
                if (cpath.endsWith("*")) {//如果路径由*结尾
                    // call getCanonicalPath with a path with wildcard character
                    // replaced to avoid calling it with paths that are
                    // intended to match all entries in a directory
                    path = path.substring(0, path.length()-1) + "-";//提取*之前的路径并在之后加上-
                    path = new File(path).getCanonicalPath();//获得上一步提取后的标准化路径
                    return path.substring(0, path.length()-1) + "*";//提取获得标准路径‘-’前的的路径并在最后加上*
                } else {
                    return new File(path).getCanonicalPath();//直接获得标准路径
                }
            } catch (IOException ioe) {
                return cpath;
            }
        }
    });

    int len = cpath.length();
    char last = ((len > 0) ? cpath.charAt(len - 1) : 0);//获得标准路径的最后一个字符(如果路径为空则也为空

    if (last == RECURSIVE_CHAR &&
        cpath.charAt(len - 2) == File.separatorChar) {//最后一个字符为-且倒数第二个字符为系统默认路径分隔符
        directory = true;//属性为目录
        recursive = true;//允许递归
        cpath = cpath.substring(0, --len);//路径中除去-
    } else if (last == WILD_CHAR &&
        cpath.charAt(len - 2) == File.separatorChar) {//最后一个字符为*
        directory = true;//判定为目录
        //recursive = false;
        cpath = cpath.substring(0, --len);
    } else {//都不是就什么都不用管
        // overkill since they are initialized to false, but
        // commented out here to remind us...
        //directory = false;
        //recursive = false;
    }

    // XXX: at this point the path should be absolute. die if it isn't?
}

构造函数(传入未被标准化的抽象路径,传入操作权限字符串

public FilePermission(String path, String actions) {
    super(path);//调用Permission的构造函数
    init(getMask(actions));//将操作权限字符串转化为整形并传入初始化函数
}

构造函数(仅本包中的类可以访问,传入的是转化好的整形操作权限

FilePermission(String path, int mask) {
    super(path);
    init(mask);
}

检查当前FilePermission对象的是否含有指定的隐藏权限(说明了该类实质就是权限标记和与权限标记相关的一系列操作

public boolean implies(Permission p) {
    if (!(p instanceof FilePermission))//检测p是否为FilePermission对象
        return false;

    FilePermission that = (FilePermission) p;

    // we get the effective mask. i.e., the "and" of this and that.
    // They must be equal to that.mask for implies to return true.

    return ((this.mask & that.mask) == that.mask) && impliesIgnoreMask(that);//若当前的FilePermission对象含有的权限拥有传入对象的所有权限甚至还多则为真
}

表示是否可忽略权限(传入路径为当前路径子集则可以忽略对传入路径权限的声明

boolean impliesIgnoreMask(FilePermission that) {
    if (this.directory) {//如果权限对应的是目录
        if (this.recursive) {//如果当前目录可递归
            // make sure that.path is longer then path so
            // something like /foo/- does not imply /foo
            if (that.directory) {//传入的权限对应也为目录
                return (that.cpath.length() >= this.cpath.length()) &&
                        that.cpath.startsWith(this.cpath);//判定传入的FilePermission是否为当前对象的子路径
            }  else {//若为文件,判定是否为当前路径下的文件
                return ((that.cpath.length() > this.cpath.length()) &&
                    that.cpath.startsWith(this.cpath));
            }
        } else {//不可递归
            if (that.directory) {//传入的为目录
                // if the permission passed in is a directory
                // specification, make sure that a non-recursive
                // permission (i.e., this object) can't imply a recursive
                // permission.
                if (that.recursive)//如果传入的对象可递归则返回False
                    return false;
                else
                    return (this.cpath.equals(that.cpath));//不可递归则判定两路径是否相等(因为均不可递归,不能为子目录
            } else {//传入的为文件
                int last = that.cpath.lastIndexOf(File.separatorChar);//获得最后一个路径分隔符的位置
                if (last == -1)//不存在路径分隔符
                    return false;
                else {
                    // this.cpath.equals(that.cpath.substring(0, last+1));
                    // Use regionMatches to avoid creating new string
                    return (this.cpath.length() == (last + 1)) &&//当前目录为该文件所在目录(最后一位是*)
                        this.cpath.regionMatches(0, that.cpath, 0, last+1);
                }
            }
        }
    } else if (that.directory) {//如果当前路径并非目录且传入的为目录
        // if this is NOT recursive/wildcarded,
        // do not let it imply a recursive/wildcarded permission
        return false;
    } else {//均为文件
        return (this.cpath.equals(that.cpath));
    }
}
对象判等(传入对象与当前对象判等
public boolean equals(Object obj) {
    if (obj == this)
        return true;

    if (! (obj instanceof FilePermission))
        return false;

    FilePermission that = (FilePermission) obj;

    return (this.mask == that.mask) &&
        this.cpath.equals(that.cpath) &&
        (this.directory == that.directory) &&
        (this.recursive == that.recursive);
}
返回该类的hash值
public int hashCode() {
    return 0;
}
将传入的字符串对应权限用int值替换
private static int getMask(String actions) {
    int mask = NONE;//权限赋空

    // Null action valid?
    if (actions == null) {//不存在权限操作
        return mask;
    }

    // Use object identity comparison against known-interned strings for
    // performance benefit (these values are used heavily within the JDK).
    if (actions == SecurityConstants.FILE_READ_ACTION) {//引入的sun包,这一段主要是单个权限赋予的判定(这些其实都是声明的字符串变量,理解为define即可
        return READ;
    } else if (actions == SecurityConstants.FILE_WRITE_ACTION) {
        return WRITE;
    } else if (actions == SecurityConstants.FILE_EXECUTE_ACTION) {
        return EXECUTE;
    } else if (actions == SecurityConstants.FILE_DELETE_ACTION) {
        return DELETE;
    } else if (actions == SecurityConstants.FILE_READLINK_ACTION) {
        return READLINK;
    }

    char[] a = actions.toCharArray();//获得字符数组

    int i = a.length - 1;
    if (i < 0)
        return mask;

    while (i != -1) {//多权限检查
        char c;

        // skip whitespace
        while ((i!=-1) && ((c = a[i]) == ' ' ||
                           c == '\r' ||
                           c == '\n' ||
                           c == '\f' ||
                           c == '\t'))//跳过空格、换行、输入、新行符、结束符等,从末尾开始loop,比较少见
            i--;

        // check for the known strings
        int matchlen;//匹配长度

        if (i >= 3 && (a[i-3] == 'r' || a[i-3] == 'R') &&
                      (a[i-2] == 'e' || a[i-2] == 'E') &&
                      (a[i-1] == 'a' || a[i-1] == 'A') &&
                      (a[i] == 'd' || a[i] == 'D'))
        {
            matchlen = 4;
            mask |= READ;//按位或

        } else if (i >= 4 && (a[i-4] == 'w' || a[i-4] == 'W') &&
                             (a[i-3] == 'r' || a[i-3] == 'R') &&
                             (a[i-2] == 'i' || a[i-2] == 'I') &&
                             (a[i-1] == 't' || a[i-1] == 'T') &&
                             (a[i] == 'e' || a[i] == 'E'))
        {
            matchlen = 5;
            mask |= WRITE;

        } else if (i >= 6 && (a[i-6] == 'e' || a[i-6] == 'E') &&
                             (a[i-5] == 'x' || a[i-5] == 'X') &&
                             (a[i-4] == 'e' || a[i-4] == 'E') &&
                             (a[i-3] == 'c' || a[i-3] == 'C') &&
                             (a[i-2] == 'u' || a[i-2] == 'U') &&
                             (a[i-1] == 't' || a[i-1] == 'T') &&
                             (a[i] == 'e' || a[i] == 'E'))
        {
            matchlen = 7;
            mask |= EXECUTE;

        } else if (i >= 5 && (a[i-5] == 'd' || a[i-5] == 'D') &&
                             (a[i-4] == 'e' || a[i-4] == 'E') &&
                             (a[i-3] == 'l' || a[i-3] == 'L') &&
                             (a[i-2] == 'e' || a[i-2] == 'E') &&
                             (a[i-1] == 't' || a[i-1] == 'T') &&
                             (a[i] == 'e' || a[i] == 'E'))
        {
            matchlen = 6;
            mask |= DELETE;

        } else if (i >= 7 && (a[i-7] == 'r' || a[i-7] == 'R') &&
                             (a[i-6] == 'e' || a[i-6] == 'E') &&
                             (a[i-5] == 'a' || a[i-5] == 'A') &&
                             (a[i-4] == 'd' || a[i-4] == 'D') &&
                             (a[i-3] == 'l' || a[i-3] == 'L') &&
                             (a[i-2] == 'i' || a[i-2] == 'I') &&
                             (a[i-1] == 'n' || a[i-1] == 'N') &&
                             (a[i] == 'k' || a[i] == 'K'))
        {
            matchlen = 8;
            mask |= READLINK;

        } else {//错误权限
            // parse error
            throw new IllegalArgumentException(
                    "invalid permission: " + actions);
        }

        // make sure we didn't just match the tail of a word
        // like "ackbarfaccept".  Also, skip to the comma.
        boolean seencomma = false;//前一个字符是否为‘,’
        while (i >= matchlen && !seencomma) {
            switch(a[i-matchlen]) {//确认刚匹配完的字符前一个为‘,’
            case ',':
                seencomma = true;
                break;
            case ' ': case '\r': case '\n':
            case '\f': case '\t':
                break;//直接回到第一步进行跳过
            default:
                throw new IllegalArgumentException(
                        "invalid permission: " + actions);
            }
            i--;
        }

        // point i at the location of the comma minus one (or -1).
        i -= matchlen;
    }

    return mask;//返回权限
}
获得mask值(权限值)
int getMask() {
    return mask;
}
获得权限名称(mask转回string)
private static String getActions(int mask) {
    StringBuilder sb = new StringBuilder();
    boolean comma = false;//在输入时是否需要逗号分隔,即在判定这个权限前判定的权限其是否拥有

    if ((mask & READ) == READ) {//按位与,判定是否输出read
        comma = true;
        sb.append("read");
    }

    if ((mask & WRITE) == WRITE) {
        if (comma) sb.append(',');//先加入‘,’分隔
        else comma = true;
        sb.append("write");
    }

    if ((mask & EXECUTE) == EXECUTE) {
        if (comma) sb.append(',');
        else comma = true;
        sb.append("execute");
    }

    if ((mask & DELETE) == DELETE) {
        if (comma) sb.append(',');
        else comma = true;
        sb.append("delete");
    }

    if ((mask & READLINK) == READLINK) {
        if (comma) sb.append(',');
        else comma = true;
        sb.append("readlink");
    }

    return sb.toString();
}

获得权限

public String getActions() {
    if (actions == null)
        actions = getActions(this.mask);

    return actions;
}

返回用于储存FilePermission的FilePermissionCollection对象

public PermissionCollection newPermissionCollection() {
    return new FilePermissionCollection();
}

把当前类的状态输出到流中储存(序列化

private void writeObject(ObjectOutputStream s)
    throws IOException
{
    // Write out the actions. The superclass takes care of the name
    // call getActions to make sure actions field is initialized
    if (actions == null)//其实只输出action,就两个非静态变量,一个还是不进序列化的(笑),所以action不能为空
        getActions();
    s.defaultWriteObject();
}

从流中读取类状态(但是权限对应的路径没有了,不是很懂这样序列化还有啥用,可能只能通过对象名来判断所属路径了(笑)

private void readObject(ObjectInputStream s)
     throws IOException, ClassNotFoundException
{
    // Read in the actions, then restore everything else by calling init.
    s.defaultReadObject();
    init(getMask(actions));
}




该类用于给文件授予权限,使用时务必小心




该类文件中还少见的写了第二个类,FilePermissionCollection,由于这个类无法外部访问,所以就放到这里一起讲了

该类继承自PermissionCollection,实现了序列化接口

引入的包同上




类头注释如下

/**
 * A FilePermissionCollection stores a set of FilePermission permissions.
 * FilePermission objects
 * must be stored in a manner that allows them to be inserted in any
 * order, but enable the implies function to evaluate the implies
 * method.
 * For example, if you have two FilePermissions:
 * <OL>
 * <LI> "/tmp/-", "read"
 * <LI> "/tmp/scratch/foo", "write"
 * </OL>
 * And you are calling the implies function with the FilePermission:
 * "/tmp/scratch/foo", "read,write", then the implies function must
 * take into account both the /tmp/- and /tmp/scratch/foo
 * permissions, so the effective permission is "read,write".
 *
 * @see java.security.Permission
 * @see java.security.Permissions
 * @see java.security.PermissionCollection
 *
 *
 * @author Marianne Mueller
 * @author Roland Schemers
 *
 * @serial include
 *
 */

大意如下:

FilePermissionCollection储存了一系列FilePermission的权限

FilePermission对象必须用同一个方法储存,这样才能允许被插入一个队列

但这也使得隐藏权限的检查较为麻烦

例如,有两个FilePermission:

 "/tmp/-", "read"
"/tmp/scratch/foo", "write"
你调用权限检查函数,写入一个FilePermission
"/tmp/scratch/foo", "read,write",

接下来权限检查函数必须考虑到这两条路径的权限,所以最终有效的权限是read、write



该类含有如下成员变量:

储存FilePermission的链表

private transient List<Permission> perms;

序列化ID:

private static final long serialVersionUID = 2202956749081564585L;

文件权限对象的序列化链表

private static final ObjectStreamField[] serialPersistentFields = {
    new ObjectStreamField("permissions", Vector.class),
};


该类含有如下方法:

构造函数(初始化储存空间

public FilePermissionCollection() {
    perms = new ArrayList<>();
}

将要储存的FilePermission加入储存链表

public void add(Permission permission) {
    if (! (permission instanceof FilePermission))//判定对象种类
        throw new IllegalArgumentException("invalid permission: "+
                                           permission);
    if (isReadOnly())//如果是只读属性
        throw new SecurityException(//安全异常
            "attempt to add a Permission to a readonly PermissionCollection");

    synchronized (this) {//线程锁写入
        perms.add(permission);
    }
}

检测是否含有隐藏的指定权限

public boolean implies(Permission permission) {//传入的是需要检测的属性
    if (! (permission instanceof FilePermission))//检测所属类
        return false;

    FilePermission fp = (FilePermission) permission;

    int desired = fp.getMask();//获得需检测权限标志
    int effective = 0;//当前有效权限
    int needed = desired;//需要匹配的权限

    synchronized (this) {
        int len = perms.size();
        for (int i = 0; i < len; i++) {
            FilePermission x = (FilePermission) perms.get(i);
            if (((needed & x.getMask()) != 0) && x.impliesIgnoreMask(fp)) {//传入权限与当前需要检测权限有交集,且传入路径为当前路径的子路径
                effective |=  x.getMask();//获得当前权限
                if ((effective & desired) == desired)//当前权限与传入权限相同则表示含有指定权限
                    return true;
                needed = (desired ^ effective);//异或位运算(表示当前需要的进行匹配的权限,如果不了解这里为什么要用异或的话可以自己把16进制化成二进制异或看看
            }
        }
    }
    return false;
}
返回容器中所有Permission对象的枚举
public Enumeration<Permission> elements() {
    // Convert Iterator into Enumeration
    synchronized (this) {
        return Collections.enumeration(perms);
    }
}

序列化

private void writeObject(ObjectOutputStream out) throws IOException {
    // Don't call out.defaultWriteObject()

    // Write out Vector
    Vector<Permission> permissions = new Vector<>(perms.size());//创建缓冲
    synchronized (this) {
        permissions.addAll(perms);//拷贝写入
    }

    ObjectOutputStream.PutField pfields = out.putFields();
    pfields.put("permissions", permissions);//将当前拷贝出的缓冲写入链表
    out.writeFields();//序列化写出
}

读入 反序列化

private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    // Don't call defaultReadObject()

    // Read in serialized fields
    ObjectInputStream.GetField gfields = in.readFields();//缓冲区

    // Get the one we want
    @SuppressWarnings("unchecked")
    Vector<Permission> permissions = (Vector<Permission>)gfields.get("permissions", null);//读取链表
    perms = new ArrayList<>(permissions.size());
    perms.addAll(permissions);//拷贝出链表内容
}



该类仅被FilePermission使用,读懂该类有利于理解FilePermission的工作原理


RK3588+YT9215快速拓展以太网口 YT9215支持7个端口的非阻塞数据传输,确保高效的数据流处理;在开发过程中,最重要的一点就是YT9215与RK3588的GMAC连接和配置部分,下面是gmac1对应dtsi文件的修改,包括注释掉rgmii_phy1对应的mdio1,以及gmac1对应的phy-handle部分,同时将gmac1修改成1000Mbps全双工模式。这就是最简单,最快速的RK3588拓展网口的方法了,如果需要用到交换芯片的其他功能,那就不可以直接使用原厂提供的bin,而是需要对YT9215进行另外的驱动开发。 阅读详情

相关推荐

IAR调试CC1310的错误:Fatal error:Failed to connect to the XDS emlulator (Error -241 @ 0x0:)

从simplelink_cc13x0_sdk_2_10_00_36导入collector工程后,rebuild后进行debug,出现了如图错误:Fatal error:Failed to connect to the XDS emlulator (connect ICEPick)...(Error -241 @ 0x0)A router subpath could not be accessed....

qq_40417648的博客 6228

FilePermission详解

此类表示对文件和目录的访问。FilePermission 由路径名和对该路径名有效的操作集合组成。 路径名是授予指定操作的文件或目录的路径名。以 "/*"(其中 "/" 是文件分隔符字符,即 File.separatorChar)结尾的路径名指示包含在该目录中的所有文件和目录。以 "/-" 结尾的路径名(递归地)指示包含在该目录中的所有文件和子目录。由特殊标记 ">" 组成的路径名可匹配任何文件

liaojiande12的专栏 1631

固定时间收敛的控制器设计(基础知识)

针对控制系统的有限时间收敛和固定时间收敛给出一些常用定理。

qq_40241332的博客 1万+

filepermission java_Java FilePermission

Java FilePermission1 什么是Java FilePermissionJava FilePermission类包含与目录或文件相关的权限。所有权限都与路径相关。路径可以有两种类型:D:\\IO\\-:表示该权限与所有子目录和文件都递归关联。D:\\IO\\*:表示该权限与该目录中的所有目录和文件(子目录除外)相关联。2Java FilePermission的语法public fi...

weixin_36146690的博客 498

模拟ic入门——设计一个单极运放(一)单级运算放大器设计基础

主要介绍了单级运放的基本理论和使用场景

qq_64956710的博客 3750

深度学习环境搭建以及DeepLabCut安装过程

文章目录 一、查询电脑硬件 安装GeForce驱动程序 二、环境搭建与软件安装 1.安装CUDA运算平台软件 2.安装cuDNN支持包 3.配置环境变量 三、 DeepLabCut环境配置 1.安装Anaconda 2.创建容器环境 3.激活容器环境 4.安装TensorFlow 5.验证TensorFlow是否安装成功 6...

m0_51136557的博客 3159

(每日持续更新)jdk api之FilePermission基础、应用、实战

主要用于表示对文件系统资源的权限。它允许或拒绝对指定文件或目录执行的特定操作。类继承了Permission返回与此权限对象关联的操作字符串。检查指定的权限是否是此权限的子集。

a89879193的专栏 1231

Mathtype公式下标深度调整技巧:解决固定行距下的显示不全问题

本文针对在Word等文档中设置固定行距时,Mathtype公式下标显示不全的问题,提供了专业解决方案。核心在于调整Mathtype软件内部的“下标深度”参数,通过修改单个公式或批量格式化全文,使公式完美适配固定行距,确保下标清晰完整,且不影响文档整体排版。

pepsi的博客 1503

java.io.file.sync_java.io.FilePermission

public final class FilePermission此类表示对文件和目录的访问。FilePermission 由路径名和对该路径名有效的操作集合组成。路径名是授予指定操作的文件或目录的路径名。以 "/*"(其中 "/" 是文件分隔符字符,即 File.separatorChar)结尾的路径名指示包含在该目录中的所有文件和目录。以 "/-" 结尾的路径名(递归地)指示包含在该目录中的所...

weixin_36378683的博客 383

高效爬取懂车帝车型数据:从静态解析到动态反爬实战

本文详细解析了如何高效爬取懂车帝车型数据,从静态HTML解析到动态接口反爬的完整实战路径。文章重点介绍了使用浏览器开发者工具定位数据、应对CSS混淆与参数加密等反爬策略,并提供了整合静态与动态抓取逻辑的Python代码示例,帮助开发者稳健地获取结构化车型信息。

wind6的博客 937

YOLOv8【第十一章:视频追踪与流处理篇·第3节】匈牙利算法(Hungarian Algorithm)与 KM 算法匹配机制详解!

🏆 本文收录于 《YOLOv8实战:从入门到深度优化》 专栏。该专栏系统复现并梳理全网各类 YOLOv8 改进与实战案例(当前已覆盖分类 / 检测 / 分割 / 追踪 / 关键点 / OBB 检测等方向),坚持持续更新 + 深度解析,质量分长期稳定在 97 分以上,可视为当前市面上 覆盖较全、更新较快、实战导向极强 的 YOLO 改进系列内容之一。

**My Coding Family** 450

filepermission java_访问被拒绝(“ java.io.FilePermission”“执行”...

我是初学者.这是我写的第一个小程序我想用小程序运行exe应用程序package appletexample;import java.io.*;import java.awt.*;import java.applet.Applet;public class Welcome extends Applet {public void init() {String execommand = "C:\\win...

weixin_34898320的博客 1764

simulink的Sine Wave 模块详解

模块是 Simulink 中的一个信号源模块,用于生成正弦波信号。该模块可以根据设定的幅值、频率、相位和偏移量,在仿真过程中产生周期性的正弦波形。模块都能提供强有力的支持。通过深入了解其参数的影响及结合 MATLAB 脚本的应用,读者可以更加有效地利用这一模块进行仿真和研究。此外,通过实际应用场景的扩展以及常见问题解答部分的帮助,能够更好地掌握。模块是一个非常实用的工具,适用于需要生成正弦波信号的各种场景。模块的参数,可以进一步增强学习体验。模块参数的影响,下面我们将详细探讨每个参数如何影响仿真结果。

xiaoheshang_123的博客 1052

Elasticsearch 执行语句时报错java.io.FilePermission

"reason": "access denied (\"java.io.FilePermission\" \"F:\\Elasticsearch\\elasticsearch-5.6.8%20-%2001\\plugins\\ik-analyzer\\config\\IKAnalyzer.cfg.xml\" \"read\")"

龙源IT 的博客 1829

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Java FilePermission暗含()方法与示例

FilePermission类implies()方法 (FilePermission Class implies() method) implies() method is available in java.io package. implies()方法在java.io包中可用。 implies() method is used to check whether this FilePermis...

cumudi0723的博客 228

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

如何在Java中设置文件的权限?

如何在Java中设置文件的权限?

weixin_45428910的博客 2095

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

java file 权限_Java文件权限(设置)

Java File类包含检查应用程序用户的文件权限的方法。它们还有一些方法可以为用户和其他所有人设置文件权限。Java文件权限下面是一个使用File类权限方法的简单java程序。它将首先检查用户的文件权限,之后,更改应用程序用户的文件权限,然后更改所有其他用户的文件权限。import java.io.File;public class JavaFilePermissions {public sta...

weixin_35895431的博客 3158

Java 拒绝访问本地文件_java - java.security.AccessControlException:拒绝访问(java.io.FilePermission文件读取) - 堆栈内存溢出...

下面的代码提示输入框中的文件名和位置。 当我输入file://C:/test/abc.tiff然后我得到了java.security.AccessControlException: access denied (java.io.FilePermission \\c\test\abc.tiff read)代码片段CMBDocument document = evt.getDocument();St...

weixin_34036667的博客 892

java权限设置权限_Java设置文件权限

Java设置文件权限package com.kkoolerter;import java.io.File;import java.io.FileOutputStream;import java.io.FilePermission;import java.io.OutputStream;public class FilePermissionTest {/*** @param args*/public...

weixin_31832223的博客 1391

filepermission java_Java FilePermission equals()方法与示例

FilePermission类equals()方法equals()方法在java.io包中可用。equals()方法用于检查此FilePermission和给定对象在路径名和操作方面是否相等。equals()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。在检查两个对象的相等性时,equals()方法不会引发异常。语法:publicbooleanequ...

weixin_30894765的博客 187

解决es的hanlp插件报java.io.FilePermission“ “data/dictionary/CoreNatureDictionary.tr.txt“ “read“错误

解决es的hanlp插件报java.io.FilePermission" “data/dictionary/CoreNatureDictionary.tr.txt” "read"错误 在更新elasticsearch并更新对应的分词插件之后出现了以下的错误: java.io.FilePermission" "data/dictionary/CoreNatureDictionary.tr.txt" "read" 但是我在win10的权限都是完全控制的,所以对这个很奇怪 在网上说了很多要修改java8的j

佐勒之博 3257

Java源码详解:深入Java安全之FilePermission解析——从权限模型实现机制、通配符逻辑、历史变迁及其在现代Java中的定位到JDK 25的演进与终结

摘要(148字) Java安全体系的标志性组件FilePermission在JDK 25中被正式废弃,宣告了Security Manager时代的终结。作为Java沙箱安全的核心实现,它曾通过路径模式匹配和位掩码机制(如READ=0x4)实现细粒度的文件访问控制。其源码展现了三大设计精髓:1) 用位运算高效处理权限组合;2) 双模式兼容新旧路径规范;3) 通配符语义实现递归目录控制。尽管现代Java转向容器化隔离方案,但该类的实现仍是一部权限系统的经典教材,尤其体现在implies()的蕴含逻辑与FileP

yangzhihua的专栏 162

Application run failed - access denied (“java.io.FilePermission“ “...\IKAnalyzer.cfg.xml“ “read“)

报错案例 2021-07-02 11:35:14.927 ERROR 23348 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'esProductController': Unsatis

weixin_45220702的博客 330

access denied (“java.io.FilePermission“ “/cert/elastic-certificates.p12“ “read“)

我在配置跨集群数据同步时候。A集群需要从B集群同步数据,但是B集群是带有安全认证的。所以需要把B集群的证书放在A集群。 为了偷懒,我把elastic-certificates.p12 证书,放在了config目录的外边。然后就报了下边的错。一开始我以为没有读权限,所以就使用chmod 777elastic-certificates.p12 但是已经不能使用。 后台把文件挪到了config目录下,然后又修改elasticsearch.yml里边的配置路径,使用了elastic-certific...

Angus 2647

‘access denied (“java.io.FilePermission“...... “IKAnalyzer.cfg.xml“ “read“(elasticsearch很容易踩到的坑)

希望看到我上篇安装的文章的人务必先看到这篇文章,不然就会踩到这个坑。刚开始碰到这个问题就立马去更改文件夹权限,然后发现完全不起作用,直到看到网上有人说是文件夹路径中存在空格才明白,然后就把elasticsearch-7.8.1这个文件夹移到用户下就解决问题了。版权声明:本文为优快云博主「Trisyp」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。原文链接:https://blog.youkuaiyun.com/Trisyp/article/details/108026488。

m0_70556273的博客 1018

Java安全——策略文件说明

java安全策略文件说明

多头注意力探索Now 2748
上一篇: Java 日看一类(19)之IO包中的FileOutputStream类
下一篇: Java 日看一类(21)之IO包中的FileReader类
wyf95278
博客等级 码龄10年 38粉丝 71原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值