Search in sources :

Example 1 with PermissionsDescriptor

use of com.sun.enterprise.deployment.PermissionsDescriptor 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 PermissionsDescriptor

use of com.sun.enterprise.deployment.PermissionsDescriptor 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

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