use of org.jboss.weld.security.GetSystemPropertyAction in project core by weld.
the class Weld method isEnabled.
protected boolean isEnabled(String key, boolean defaultValue) {
Object value = properties.get(key);
if (value != null) {
return Boolean.TRUE.equals(value);
}
String system = AccessController.doPrivileged(new GetSystemPropertyAction(key));
if (system != null) {
return Boolean.valueOf(system);
}
return defaultValue;
}
use of org.jboss.weld.security.GetSystemPropertyAction in project core by weld.
the class ClassPathBeanArchiveScanner method scan.
@Override
public List<ScanResult> scan() {
String javaClassPath = AccessController.doPrivileged(new GetSystemPropertyAction(JAVA_CLASS_PATH_SYSTEM_PROPERTY));
if (javaClassPath == null) {
throw CommonLogger.LOG.cannotReadJavaClassPathSystemProperty();
}
ImmutableList.Builder<ScanResult> results = ImmutableList.builder();
Set<String> entries = ImmutableSet.of(javaClassPath.split(Pattern.quote(File.pathSeparator)));
logger.debugv("Scanning class path entries: {0}", entries);
for (String entry : entries) {
if (entry == null || entry.isEmpty()) {
continue;
}
File entryFile = new File(entry);
if (!entryFile.canRead()) {
throw CommonLogger.LOG.cannotReadClassPathEntry(entryFile);
}
try {
if (entryFile.isDirectory()) {
scanDirectory(entryFile, results);
} else {
scanJarFile(entryFile, results);
}
} catch (IOException e) {
throw CommonLogger.LOG.cannotScanClassPathEntry(entryFile, e);
}
}
return results.build();
}
use of org.jboss.weld.security.GetSystemPropertyAction in project core by weld.
the class Reports method generateValidationReport.
static void generateValidationReport(Probe probe, Exception exception, Environment environment, BeanManagerImpl manager) {
HtmlTag html = HtmlTag.html();
HtmlTag head = HtmlTag.head().appendTo(html);
head.add(HtmlTag.title(TITLE));
head.add(HtmlTag.style().add(SafeString.of(IOUtils.getResourceAsString("/report.css"))));
HtmlTag body = HtmlTag.body().appendTo(html);
body.add(HtmlTag.h1(TITLE));
HtmlTag meta = HtmlTag.stripedTable().appendTo(body);
meta.add(HtmlTag.tr().add(HtmlTag.td().add(HtmlTag.strong("Generated at:")), HtmlTag.td(LocalDateTime.now().toString())));
meta.add(HtmlTag.tr().add(HtmlTag.td().add(HtmlTag.strong("Weld Version:")), HtmlTag.td(Formats.getSimpleVersion())));
meta.add(HtmlTag.tr().add(HtmlTag.td().add(HtmlTag.strong("Weld Environment:")), HtmlTag.td(environment.toString())));
meta.add(HtmlTag.tr().add(HtmlTag.td().add(HtmlTag.strong("Java Version:")), HtmlTag.td(AccessController.doPrivileged(new GetSystemPropertyAction("java.version")))));
meta.add(HtmlTag.tr().add(HtmlTag.td().add(HtmlTag.strong("Java Vendor:")), HtmlTag.td(AccessController.doPrivileged(new GetSystemPropertyAction("java.vendor")))));
meta.add(HtmlTag.tr().add(HtmlTag.td().add(HtmlTag.strong("Operating System:")), HtmlTag.td(AccessController.doPrivileged(new GetSystemPropertyAction("os.name")))));
HtmlTag contents = HtmlTag.ol().appendTo(body);
contents.add(HtmlTag.li().add(HtmlTag.a("#" + EXCEPTION).add(TITLE_EXCEPTION)));
contents.add(HtmlTag.li().add(HtmlTag.a("#" + BDAS).add(TITLE_BDAS)));
contents.add(HtmlTag.li().add(HtmlTag.a("#" + DEPS).add(TITLE_DEPS)));
contents.add(HtmlTag.li().add(HtmlTag.a("#" + BEANS).add(TITLE_BEANS)));
contents.add(HtmlTag.li().add(HtmlTag.a("#" + CONFIG).add(TITLE_CONFIG)));
body.add(HtmlTag.aname(EXCEPTION));
body.add(HtmlTag.h2(TITLE_EXCEPTION));
body.add(HtmlTag.p(exception.getMessage()).attr(HtmlTag.STYLE, "font-size: large;color: red;font-weight:bold;"));
body.add(HtmlTag.h(3, "Exception Stack:"));
final StringWriter stackWriter = new StringWriter();
exception.printStackTrace(new PrintWriter(stackWriter));
body.add(HtmlTag.div(EXCEPTION).add(HtmlTag.pre(stackWriter.toString())));
Map<BeanDeploymentArchive, BeanManagerImpl> beanDeploymentArchivesMap = Container.instance(manager).beanDeploymentArchives();
List<BeanDeploymentArchive> bdas = new ArrayList<BeanDeploymentArchive>(beanDeploymentArchivesMap.keySet());
Collections.sort(bdas, probe.getBdaComparator());
addBeanArchives(body, bdas);
addInvalidDependencies(probe, body);
addBeans(probe, body, bdas);
addConfiguration(body, manager);
String export = manager.getServices().get(WeldConfiguration.class).getStringProperty(ConfigurationKey.PROBE_EXPORT_DATA_AFTER_DEPLOYMENT);
File exportPath;
if (!export.isEmpty()) {
exportPath = new File(export);
} else {
exportPath = new File(System.getProperty("user.dir"));
}
if (!exportPath.canWrite()) {
ProbeLogger.LOG.invalidExportPath(exportPath);
return;
}
try {
File exportFile = new File(exportPath, VALIDATION_REPORT_FILE_NAME);
Files.write(exportFile.toPath(), html.toString().getBytes(Charset.forName("UTF-8")));
ProbeLogger.LOG.validationReportExported("file://" + exportFile.getAbsolutePath());
} catch (IOException e) {
ProbeLogger.LOG.unableToExportData(exportPath, e.getCause() != null ? e.getCause() : e);
ProbeLogger.LOG.catchingTrace(e);
}
}
Aggregations