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);
}
}
}
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);
}
}
}
Aggregations