Search in sources :

Example 1 with PermissionsDeploymentDescriptorFile

use of com.sun.enterprise.deployment.io.PermissionsDeploymentDescriptorFile in project Payara by payara.

the class XMLPermissionsHandler method configureAppDeclaredPermissions.

private void configureAppDeclaredPermissions(File base) throws XMLStreamException, FileNotFoundException {
    File permissionsXml = new File(base.getAbsolutePath(), PermissionXMLParser.PERMISSIONS_XML);
    if (permissionsXml.exists()) {
        FileInputStream fi = null;
        try {
            // this one uses the Node approach
            PermissionsDeploymentDescriptorFile pddf = new PermissionsDeploymentDescriptorFile();
            if (serviceLocator != null) {
                dasConfig = serviceLocator.getService(DasConfig.class);
                if (dasConfig != null) {
                    String xmlValidationLevel = dasConfig.getDeployXmlValidation();
                    if (xmlValidationLevel.equals("none"))
                        pddf.setXMLValidation(false);
                    else
                        pddf.setXMLValidation(true);
                    pddf.setXMLValidationLevel(xmlValidationLevel);
                }
            }
            fi = new FileInputStream(permissionsXml);
            PermissionsDescriptor pd = (PermissionsDescriptor) pddf.read(fi);
            declaredPermXml = pd.getDeclaredPermissions();
        } catch (SAXParseException e) {
            throw new SecurityException(e);
        } catch (IOException e) {
            throw new SecurityException(e);
        } finally {
            if (fi != null) {
                try {
                    fi.close();
                } catch (IOException e) {
                }
            }
        }
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("App declared permission = " + declaredPermXml);
        }
    }
}
Also used : PermissionsDescriptor(com.sun.enterprise.deployment.PermissionsDescriptor) PermissionsDeploymentDescriptorFile(com.sun.enterprise.deployment.io.PermissionsDeploymentDescriptorFile) SAXParseException(org.xml.sax.SAXParseException) DasConfig(com.sun.enterprise.config.serverbeans.DasConfig) IOException(java.io.IOException) PermissionsDeploymentDescriptorFile(com.sun.enterprise.deployment.io.PermissionsDeploymentDescriptorFile) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 2 with PermissionsDeploymentDescriptorFile

use of com.sun.enterprise.deployment.io.PermissionsDeploymentDescriptorFile in project Payara by payara.

the class PermissionsXMLLoader method getPermissionsDeploymentDescriptorFile.

private PermissionsDeploymentDescriptorFile getPermissionsDeploymentDescriptorFile() {
    PermissionsDeploymentDescriptorFile descriptorFile = new PermissionsDeploymentDescriptorFile();
    if (serviceLocator == null) {
        return descriptorFile;
    }
    dasConfig = serviceLocator.getService(DasConfig.class);
    if (dasConfig == null) {
        return descriptorFile;
    }
    String xmlValidationLevel = dasConfig.getDeployXmlValidation();
    if (xmlValidationLevel.equals("none")) {
        descriptorFile.setXMLValidation(false);
    } else {
        descriptorFile.setXMLValidation(true);
    }
    descriptorFile.setXMLValidationLevel(xmlValidationLevel);
    return descriptorFile;
}
Also used : PermissionsDeploymentDescriptorFile(com.sun.enterprise.deployment.io.PermissionsDeploymentDescriptorFile) DasConfig(com.sun.enterprise.config.serverbeans.DasConfig)

Example 3 with PermissionsDeploymentDescriptorFile

use of com.sun.enterprise.deployment.io.PermissionsDeploymentDescriptorFile in project Payara by payara.

the class PermissionsXMLLoader method loadAppPermissionsFromPath.

// ### Private methods
private void loadAppPermissionsFromPath(File base) throws XMLStreamException, FileNotFoundException {
    File permissionsXml = new File(base.getAbsolutePath(), PERMISSIONS_XML);
    if (permissionsXml.exists()) {
        try (FileInputStream permissionsXmlStream = new FileInputStream(permissionsXml)) {
            // This one uses the Node approach
            PermissionsDeploymentDescriptorFile pddf = getPermissionsDeploymentDescriptorFile();
            PermissionsDescriptor permissionsDescriptor = (PermissionsDescriptor) pddf.read(permissionsXmlStream);
            declaredPermissionXml = permissionsDescriptor.getDeclaredPermissions();
        } catch (SAXParseException | IOException e) {
            throw new SecurityException(e);
        }
        if (logger.isLoggable(FINE)) {
            logger.fine("App declared permission = " + declaredPermissionXml);
        }
    }
}
Also used : PermissionsDescriptor(com.sun.enterprise.deployment.PermissionsDescriptor) PermissionsDeploymentDescriptorFile(com.sun.enterprise.deployment.io.PermissionsDeploymentDescriptorFile) SAXParseException(org.xml.sax.SAXParseException) IOException(java.io.IOException) PermissionsDeploymentDescriptorFile(com.sun.enterprise.deployment.io.PermissionsDeploymentDescriptorFile) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

PermissionsDeploymentDescriptorFile (com.sun.enterprise.deployment.io.PermissionsDeploymentDescriptorFile)3 DasConfig (com.sun.enterprise.config.serverbeans.DasConfig)2 PermissionsDescriptor (com.sun.enterprise.deployment.PermissionsDescriptor)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 SAXParseException (org.xml.sax.SAXParseException)2