Refine search
private static List<String> getRemoteWords(String location) { SpecialPermission.check(); return AccessController.doPrivileged((PrivilegedAction<List<String>>) () -> { return getRemoteWordsUnprivileged(location); }); }
private static void setCurrentThreadName(final String name) { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new SpecialPermission()); } AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { Thread.currentThread().setName(name); return null; } }); }
ExtMonitor() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new SpecialPermission()); } }
sm.checkPermission(new SpecialPermission()); AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { final List<Path> filesWithWrongPermissions = AccessController.doPrivileged(new PrivilegedAction<List<Path>>() { @Override public List<Path> run() { final List<String> files = AccessController.doPrivileged(new PrivilegedAction<List<String>>() { @Override public List<String> run() {
public void run() { SpecialPermission.check(); AccessController.doPrivileged((PrivilegedAction<Void>) () -> { this.runUnprivileged(); return null; }); }
private static void setCurrentThreadName(final String name) { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new SpecialPermission()); } AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { Thread.currentThread().setName(name); return null; } }); }
@Override public void run() { SpecialPermission.check(); AccessController.doPrivileged((PrivilegedAction<Void>) () -> { runUnprivileged(); return null; }); }
private SslContext buildSSLContext0(final SslContextBuilder sslContextBuilder) throws SSLException { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new SpecialPermission()); } SslContext sslContext = null; try { sslContext = AccessController.doPrivileged(new PrivilegedExceptionAction<SslContext>() { @Override public SslContext run() throws Exception { return sslContextBuilder.build(); } }); } catch (final PrivilegedActionException e) { throw (SSLException) e.getCause(); } return sslContext; }
private void initConfig(String path, boolean printErr) { SpecialPermission.check(); AccessController.doPrivileged((PrivilegedAction<Void>) () -> { try (BufferedReader br = IOUtil.getReader(PathToStream.stream(path), "utf-8")) { String temp; int index; while ((temp = br.readLine()) != null) { if (StringUtil.isBlank(temp) || temp.trim().charAt(0) == '#' || !temp.contains("=")) { continue; } index = temp.indexOf('='); MyStaticValue.ENV.put(temp.substring(0, index).trim(), temp.substring(index + 1).trim()); } } catch (Exception e) { if (printErr) { LOG.error("{} load err: {}", path, e); } else { LOG.warn("{} load err", path); } } return null; }); }
/** * We build the list of Nodes from Kubernetes API * Information can be cached using `plugins.refresh_interval` property if needed. * Setting `plugins.refresh_interval` to `-1` will cause infinite caching. * Setting `plugins.refresh_interval` to `0` will disable caching (default). */ @Override public List<DiscoveryNode> buildDynamicNodes() { final List<DiscoveryNode> result = new ArrayList<>(); // ES permission you should check before doPrivileged() blocks SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new SpecialPermission()); } AccessController.doPrivileged(new PrivilegedAction<Void>() { @Override public Void run() { result.addAll(readNodes()); return null; } }); return result; }
@Override public String execute() { final StringWriter writer = new StringWriter(); try { // crazy reflection here SpecialPermission.check(); AccessController.doPrivileged((PrivilegedAction<Void>) () -> { template.execute(writer, params); return null; }); } catch (Exception e) { logger.error((Supplier<?>) () -> new ParameterizedMessage("Error running {}", template), e); throw new GeneralScriptException("Error running " + template, e); } return writer.toString(); } }
@Inject public GroovyScriptEngineService(Settings settings) { super(settings); // Creates the classloader here in order to isolate Groovy-land code final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new SpecialPermission()); } this.loader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { @Override public ClassLoader run() { // snapshot our context (which has permissions for classes), since the script has none final AccessControlContext context = AccessController.getContext(); return new ClassLoader(getClass().getClassLoader()) { @Override protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { if (sm != null) { try { context.checkPermission(new ClassPermission(name)); } catch (SecurityException e) { throw new ClassNotFoundException(name, e); } } return super.loadClass(name, resolve); } }; } }); }
@Override public String execute() { final StringWriter writer = new StringWriter(); try { // crazy reflection here SpecialPermission.check(); AccessController.doPrivileged((PrivilegedAction<Void>) () -> { template.execute(writer, params); return null; }); } catch (Exception e) { logger.error((Supplier<?>) () -> new ParameterizedMessage("Error running {}", template), e); throw new GeneralScriptException("Error running " + template, e); } return writer.toString(); } }
protected OnLoadListener(final File outputFile, final ActionListener<Void> listener) { this.outputFile = outputFile; this.listener = listener; if (isExcel2007) { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new SpecialPermission()); } workbook = AccessController .doPrivileged((PrivilegedAction<Workbook>) () -> new SXSSFWorkbook(-1)); sheet = AccessController .doPrivileged((PrivilegedAction<Sheet>) () -> workbook.createSheet()); } else { workbook = new HSSFWorkbook(); sheet = workbook.createSheet(); } }
SpecialPermission.check(); final Loader loader = AccessController.doPrivileged(new PrivilegedAction<Loader>() { @Override public Loader run() { return AccessController.doPrivileged(new PrivilegedAction<Constructor<?>>() { @Override public Constructor<?> run() {
sm.checkPermission(new SpecialPermission()); String dnString = AccessController.doPrivileged(new PrivilegedAction<String>() { @Override public String run() {
private void initDic() { SpecialPermission.check(); for (String k : MyStaticValue.ENV.keySet().toArray(new String[0])) { if (k.startsWith(DicLibrary.DEFAULT)) { DicLibrary.keys().removeIf(k::equals); AccessController.doPrivileged((PrivilegedAction<Void>) () -> { DicLibrary.get(k); return null; } else if (k.startsWith(StopLibrary.DEFAULT)) { StopLibrary.keys().removeIf(k::equals); AccessController.doPrivileged((PrivilegedAction<Void>) () -> { StopLibrary.get(k); return null; } else if (k.startsWith(SynonymsLibrary.DEFAULT)) { SynonymsLibrary.keys().removeIf(k::equals); AccessController.doPrivileged((PrivilegedAction<Void>) () -> { SynonymsLibrary.get(k); return null;
@Override public Object compile(final String scriptSource, Map<String, String> params) { // Create the script class name final String className = MessageDigests.toHexString(MessageDigests.sha1().digest(scriptSource.getBytes(StandardCharsets.UTF_8))); final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new SpecialPermission()); } return AccessController.doPrivileged(new PrivilegedAction<Object>() { public Class<?> run() { try { GroovyCodeSource codeSource = new GroovyCodeSource(scriptSource, className, BootstrapInfo.UNTRUSTED_CODEBASE); codeSource.setCachable(false); CompilerConfiguration configuration = new CompilerConfiguration() .addCompilationCustomizers(new ImportCustomizer().addStarImports("org.joda.time").addStaticStars("java.lang.Math")) .addCompilationCustomizers(new GroovyBigDecimalTransformer(CompilePhase.CONVERSION)); // always enable invokeDynamic, not the crazy softreference-based stuff configuration.getOptimizationOptions().put(GROOVY_INDY_SETTING_NAME, true); GroovyClassLoader groovyClassLoader = new GroovyClassLoader(loader, configuration); return groovyClassLoader.parseClass(codeSource); } catch (Throwable e) { if (logger.isTraceEnabled()) { logger.trace("Exception compiling Groovy script:", e); } throw new ScriptException("Error compiling script " + className, e); } } }); }
SpecialPermission.check(); Expression expr = AccessController.doPrivileged(new PrivilegedAction<Expression>() { @Override public Expression run() {
this.configPath = null; AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { sm.checkPermission(new SpecialPermission()); AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { sm.checkPermission(new SpecialPermission()); AccessController.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() {