Search in sources :

Example 1 with FileSystem

use of sun.management.FileSystem in project jdk8u_jdk by JetBrains.

the class ConnectorBootstrap method checkRestrictedFile.

private static void checkRestrictedFile(String restrictedFileName) {
    if (restrictedFileName == null || restrictedFileName.length() == 0) {
        throw new AgentConfigurationError(FILE_NOT_SET);
    }
    File file = new File(restrictedFileName);
    if (!file.exists()) {
        throw new AgentConfigurationError(FILE_NOT_FOUND, restrictedFileName);
    }
    if (!file.canRead()) {
        throw new AgentConfigurationError(FILE_NOT_READABLE, restrictedFileName);
    }
    FileSystem fs = FileSystem.open();
    try {
        if (fs.supportsFileSecurity(file)) {
            if (!fs.isAccessUserOnly(file)) {
                final String msg = Agent.getText("jmxremote.ConnectorBootstrap.file.readonly", restrictedFileName);
                log.config("startRemoteConnectorServer", msg);
                throw new AgentConfigurationError(FILE_ACCESS_NOT_RESTRICTED, restrictedFileName);
            }
        }
    } catch (IOException e) {
        throw new AgentConfigurationError(FILE_READ_FAILED, e, restrictedFileName);
    }
}
Also used : AgentConfigurationError(sun.management.AgentConfigurationError) FileSystem(sun.management.FileSystem) IOException(java.io.IOException) File(java.io.File)

Example 2 with FileSystem

use of sun.management.FileSystem in project jdk8u_jdk by JetBrains.

the class ConnectorBootstrap method checkPasswordFile.

private static void checkPasswordFile(String passwordFileName) {
    if (passwordFileName == null || passwordFileName.length() == 0) {
        throw new AgentConfigurationError(PASSWORD_FILE_NOT_SET);
    }
    File file = new File(passwordFileName);
    if (!file.exists()) {
        throw new AgentConfigurationError(PASSWORD_FILE_NOT_FOUND, passwordFileName);
    }
    if (!file.canRead()) {
        throw new AgentConfigurationError(PASSWORD_FILE_NOT_READABLE, passwordFileName);
    }
    FileSystem fs = FileSystem.open();
    try {
        if (fs.supportsFileSecurity(file)) {
            if (!fs.isAccessUserOnly(file)) {
                final String msg = Agent.getText("jmxremote.ConnectorBootstrap.password.readonly", passwordFileName);
                log.config("startRemoteConnectorServer", msg);
                throw new AgentConfigurationError(PASSWORD_FILE_ACCESS_NOT_RESTRICTED, passwordFileName);
            }
        }
    } catch (IOException e) {
        throw new AgentConfigurationError(PASSWORD_FILE_READ_FAILED, e, passwordFileName);
    }
}
Also used : AgentConfigurationError(sun.management.AgentConfigurationError) FileSystem(sun.management.FileSystem) IOException(java.io.IOException) File(java.io.File)

Example 3 with FileSystem

use of sun.management.FileSystem in project jdk8u_jdk by JetBrains.

the class AdaptorBootstrap method checkAclFile.

private static void checkAclFile(String aclFileName) {
    if (aclFileName == null || aclFileName.length() == 0) {
        throw new AgentConfigurationError(SNMP_ACL_FILE_NOT_SET);
    }
    final File file = new File(aclFileName);
    if (!file.exists()) {
        throw new AgentConfigurationError(SNMP_ACL_FILE_NOT_FOUND, aclFileName);
    }
    if (!file.canRead()) {
        throw new AgentConfigurationError(SNMP_ACL_FILE_NOT_READABLE, aclFileName);
    }
    FileSystem fs = FileSystem.open();
    try {
        if (fs.supportsFileSecurity(file)) {
            if (!fs.isAccessUserOnly(file)) {
                throw new AgentConfigurationError(SNMP_ACL_FILE_ACCESS_NOT_RESTRICTED, aclFileName);
            }
        }
    } catch (IOException e) {
        throw new AgentConfigurationError(SNMP_ACL_FILE_READ_FAILED, aclFileName);
    }
}
Also used : AgentConfigurationError(sun.management.AgentConfigurationError) FileSystem(sun.management.FileSystem) IOException(java.io.IOException) File(java.io.File)

Aggregations

File (java.io.File)3 IOException (java.io.IOException)3 AgentConfigurationError (sun.management.AgentConfigurationError)3 FileSystem (sun.management.FileSystem)3