diff --git a/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/internal/log/JavaUtilLoggerImpl.java b/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/internal/log/JavaUtilLoggerImpl.java index f77998c22b4..e3ecaaf76a6 100644 --- a/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/internal/log/JavaUtilLoggerImpl.java +++ b/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/internal/log/JavaUtilLoggerImpl.java @@ -16,9 +16,6 @@ import java.io.File; import java.io.IOException; -import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.text.SimpleDateFormat; import java.util.Date; import java.util.logging.FileHandler; @@ -63,6 +60,11 @@ private void addLogHandler() { } } + /** + * Set state directory + * + * @param sStateDir + */ public static void setStateDir(String sStateDir) { stateDir = sStateDir; } @@ -91,7 +93,8 @@ public JavaUtilLoggerImpl(String name) { /** * The constructor. * - * @param name + * @param name logger name + * @param verboseLevel set verbose level */ public JavaUtilLoggerImpl(String name, int verboseLevel) { this.logger = Logger.getLogger(name); @@ -205,13 +208,20 @@ private static Level toJavaUtilLevel(int chartLevel) { return Level.SEVERE; } + /** + * Init file handler for logging + * + * @param sLogFolder log file folder + * @param level log level + * @throws SecurityException security exception + * @throws IOException IO exception + */ public static void initFileHandler(String sLogFolder, final Level level) throws SecurityException, IOException { if (sLogFolder == null) { if (stateDir == null) { return; - } else { - sLogFolder = stateDir; } + sLogFolder = stateDir; } if (sLogFolder.length() > 0 && sLogFolder.lastIndexOf(File.separator) == sLogFolder.length() - 1) { @@ -222,21 +232,12 @@ public static void initFileHandler(String sLogFolder, final Level level) throws final String sDir = sLogFolder; try { - fileHandler = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public FileHandler run() throws Exception { - Level logLevel = level != null ? level : Level.FINEST; - - FileHandler fileHandler = new FileHandler(sDir + File.separator + sName + ".log", true); //$NON-NLS-1$ - fileHandler.setFormatter(new SimpleFormatter()); - fileHandler.setLevel(logLevel); - return fileHandler; - } + Level logLevel = level != null ? level : Level.FINEST; + fileHandler = new FileHandler(sDir + File.separator + sName + ".log", true); //$NON-NLS-1$ + fileHandler.setFormatter(new SimpleFormatter()); + fileHandler.setLevel(logLevel); - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + } catch (Exception typedException) { if (typedException instanceof SecurityException) { throw (SecurityException) typedException; } else if (typedException instanceof IOException) { diff --git a/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/internal/prefs/DefaultsManager.java b/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/internal/prefs/DefaultsManager.java index ef91d94c12c..6d4707b8f23 100644 --- a/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/internal/prefs/DefaultsManager.java +++ b/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/internal/prefs/DefaultsManager.java @@ -18,10 +18,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.util.prefs.BackingStoreException; import java.util.prefs.InvalidPreferencesFormatException; import java.util.prefs.Preferences; @@ -201,19 +197,11 @@ public void write() throws IOException, BackingStoreException { */ public void read() throws IOException, InvalidPreferencesFormatException { try { - pr = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public Preferences run() throws Exception { - try (FileInputStream fis = new FileInputStream(sLocation)) { - Preferences.importPreferences(fis); - return Preferences.userRoot(); - } - } - - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + try (FileInputStream fis = new FileInputStream(sLocation)) { + Preferences.importPreferences(fis); + pr = Preferences.userRoot(); + } + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } else if (typedException instanceof InvalidPreferencesFormatException) { @@ -228,14 +216,6 @@ public Preferences run() throws Exception { */ private boolean exists() { final File f = new File(sLocation); - - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Boolean run() { - return (f.exists() && f.isFile()); - } - - }); + return (f.exists() && f.isFile()); } } diff --git a/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/log/Logger.java b/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/log/Logger.java index 37fa367d0db..7966b9cede1 100644 --- a/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/log/Logger.java +++ b/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/log/Logger.java @@ -14,8 +14,6 @@ package org.eclipse.birt.chart.log; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.logging.Level; import java.util.logging.SimpleFormatter; import java.util.logging.StreamHandler; @@ -84,19 +82,13 @@ synchronized public static ILogger getLogger(String name) { private static StreamHandler getTracingHandler() { if (tracingHandler == null) { - tracingHandler = AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public StreamHandler run() { - StreamHandler handler = new StreamHandler(System.out, new SimpleFormatter()); - try { - tracingHandler.setLevel(Level.ALL); - } catch (SecurityException e) { - e.printStackTrace(); - } - return handler; - } - }); + StreamHandler handler = new StreamHandler(System.out, new SimpleFormatter()); + try { + tracingHandler.setLevel(Level.ALL); + } catch (SecurityException e) { + e.printStackTrace(); + } + tracingHandler = handler; } return tracingHandler; } diff --git a/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/model/impl/SerializerImpl.java b/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/model/impl/SerializerImpl.java index 04e743dd0e3..63df61b5393 100644 --- a/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/model/impl/SerializerImpl.java +++ b/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/model/impl/SerializerImpl.java @@ -22,10 +22,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -314,54 +310,47 @@ public Chart read(URI uri) throws IOException { public Chart readEmbedded(final URI uri) throws IOException { Chart chart = null; try { - chart = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public Chart run() throws Exception { - // Create and setup local ResourceSet - ResourceSet rsChart = new ResourceSetImpl(); - rsChart.getResourceFactoryRegistry().getExtensionToFactoryMap().put("chart", //$NON-NLS-1$ - new ModelResourceFactoryImpl()); - - // Create resources to represent the disk files to be used - // to store the - // models - Resource rChart = null; - - StringBuffer sb = null; - InputStream fis = null; - FileWriter writer = null; - try { - fis = new FileInputStream(uri.toFileString()); - sb = getChartStringFromStream(fis); - - File fTmp = File.createTempFile("_ChartResource", ".chart"); //$NON-NLS-1$ //$NON-NLS-2$ - writer = new FileWriter(fTmp); - writer.write(sb.toString()); - writer.flush(); - - URI uriEmbeddedModel = URI.createFileURI(fTmp.getAbsolutePath()); - rChart = rsChart.getResource(uriEmbeddedModel, true); - - rChart.load(Collections.EMPTY_MAP); - - // Delete the temporary file once the model is loaded. - if (fTmp.exists()) { - fTmp.delete(); - } - return (Chart) rChart.getContents().get(0); - } finally { - if (writer != null) { - writer.close(); - } - if (fis != null) { - fis.close(); - } - } + // Create and setup local ResourceSet + ResourceSet rsChart = new ResourceSetImpl(); + rsChart.getResourceFactoryRegistry().getExtensionToFactoryMap().put("chart", //$NON-NLS-1$ + new ModelResourceFactoryImpl()); + + // Create resources to represent the disk files to be used + // to store the + // models + Resource rChart = null; + + StringBuffer sb = null; + InputStream fis = null; + FileWriter writer = null; + try { + fis = new FileInputStream(uri.toFileString()); + sb = getChartStringFromStream(fis); + + File fTmp = File.createTempFile("_ChartResource", ".chart"); //$NON-NLS-1$ //$NON-NLS-2$ + writer = new FileWriter(fTmp); + writer.write(sb.toString()); + writer.flush(); + + URI uriEmbeddedModel = URI.createFileURI(fTmp.getAbsolutePath()); + rChart = rsChart.getResource(uriEmbeddedModel, true); + + rChart.load(Collections.EMPTY_MAP); + + // Delete the temporary file once the model is loaded. + if (fTmp.exists()) { + fTmp.delete(); + } + chart = (Chart) rChart.getContents().get(0); + } finally { + if (writer != null) { + writer.close(); } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + if (fis != null) { + fis.close(); + } + } + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } diff --git a/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/util/PluginSettings.java b/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/util/PluginSettings.java index ee68e50dd16..270f863bba5 100644 --- a/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/util/PluginSettings.java +++ b/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/util/PluginSettings.java @@ -17,8 +17,6 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -648,24 +646,19 @@ public IDataPointDefinition getDataPointDefinition(Class cSeries) throws Char * @return display name of series. */ public String getSeriesDisplayName(final String seriesClassName) { - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public String run() { - String sDisplayName = seriesClassName; - try { - Class seriesClass = Class.forName(seriesClassName); - Method createMethod = seriesClass.getDeclaredMethod("create", new Class[] {}); //$NON-NLS-1$ - Series newSeries = (Series) createMethod.invoke(seriesClass, new Object[] {}); - Method mDisplayName = seriesClass.getDeclaredMethod("getDisplayName", new Class[] {}); //$NON-NLS-1$ - Object oName = mDisplayName.invoke(newSeries, new Object[] {}); - sDisplayName = (String) oName; - } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - e.printStackTrace(); - } - return sDisplayName; - } - }); + String sDisplayName = seriesClassName; + try { + Class seriesClass = Class.forName(seriesClassName); + Method createMethod = seriesClass.getDeclaredMethod("create", new Class[] {}); //$NON-NLS-1$ + Series newSeries = (Series) createMethod.invoke(seriesClass, new Object[] {}); + Method mDisplayName = seriesClass.getDeclaredMethod("getDisplayName", new Class[] {}); //$NON-NLS-1$ + Object oName = mDisplayName.invoke(newSeries, new Object[] {}); + sDisplayName = (String) oName; + } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { + e.printStackTrace(); + } + return sDisplayName; } /** diff --git a/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/util/SecurityUtil.java b/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/util/SecurityUtil.java index 1adcf2eac81..99a994be4a9 100644 --- a/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/util/SecurityUtil.java +++ b/chart/org.eclipse.birt.chart.engine/src/org/eclipse/birt/chart/util/SecurityUtil.java @@ -38,10 +38,6 @@ import java.net.URL; import java.net.URLClassLoader; import java.net.URLEncoder; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.text.MessageFormat; import java.util.Hashtable; @@ -66,17 +62,11 @@ private SecurityUtil() { * * @param pattern * @param args - * @return + * @return format message */ public static String formatMessage(final String pattern, final Object... args) { String piTmp0; - piTmp0 = AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public String run() { - return MessageFormat.format(pattern, args); - } - }); + piTmp0 = MessageFormat.format(pattern, args); return piTmp0; } @@ -85,21 +75,14 @@ public String run() { * Instantiate a new FileInputStream with a file * * @param file - * @return + * @return Return the new file input stream * @throws FileNotFoundException */ public static FileInputStream newFileInputStream(final File file) throws FileNotFoundException { FileInputStream piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public FileInputStream run() throws FileNotFoundException { - return new FileInputStream(file); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = new FileInputStream(file); + } catch (Exception typedException) { if (typedException instanceof FileNotFoundException) { throw (FileNotFoundException) typedException; } @@ -112,21 +95,14 @@ public FileInputStream run() throws FileNotFoundException { * Instantiate a new FileInputStream * * @param filename - * @return + * @return Return the new file input stream * @throws FileNotFoundException */ public static FileInputStream newFileInputStream(final String filename) throws FileNotFoundException { FileInputStream piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public FileInputStream run() throws FileNotFoundException { - return new FileInputStream(filename); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = new FileInputStream(filename); + } catch (Exception typedException) { if (typedException instanceof FileNotFoundException) { throw (FileNotFoundException) typedException; } @@ -139,21 +115,14 @@ public FileInputStream run() throws FileNotFoundException { * Instantiate a new FileOutputStream * * @param filename - * @return + * @return Return the new file output stream * @throws FileNotFoundException */ public static FileOutputStream newFileOutputStream(final String filename) throws FileNotFoundException { FileOutputStream piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public FileOutputStream run() throws FileNotFoundException { - return new FileOutputStream(filename); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = new FileOutputStream(filename); + } catch (Exception typedException) { if (typedException instanceof FileNotFoundException) { throw (FileNotFoundException) typedException; } @@ -167,22 +136,15 @@ public FileOutputStream run() throws FileNotFoundException { * * @param in * @param charsetName - * @return + * @return Return the new input stream reader * @throws UnsupportedEncodingException */ public static InputStreamReader newInputStreamReader(final InputStream in, final String charsetName) throws UnsupportedEncodingException { InputStreamReader piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public InputStreamReader run() throws UnsupportedEncodingException { - return new InputStreamReader(in, charsetName); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = new InputStreamReader(in, charsetName); + } catch (Exception typedException) { if (typedException instanceof UnsupportedEncodingException) { throw (UnsupportedEncodingException) typedException; } @@ -195,21 +157,14 @@ public InputStreamReader run() throws UnsupportedEncodingException { * Instantiate a new FileReader with filename. * * @param filename - * @return + * @return Return the new file reader * @throws FileNotFoundException */ public static FileReader newFileReader(final String filename) throws FileNotFoundException { FileReader piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public FileReader run() throws FileNotFoundException { - return new FileReader(filename); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = new FileReader(filename); + } catch (Exception typedException) { if (typedException instanceof FileNotFoundException) { throw (FileNotFoundException) typedException; } @@ -222,21 +177,14 @@ public FileReader run() throws FileNotFoundException { * Instantiate a new FileReader with a file. * * @param file - * @return + * @return Return the new file reader * @throws FileNotFoundException */ public static FileReader newFileReader(final File file) throws FileNotFoundException { FileReader piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public FileReader run() throws FileNotFoundException { - return new FileReader(file); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = new FileReader(file); + } catch (Exception typedException) { if (typedException instanceof FileNotFoundException) { throw (FileNotFoundException) typedException; } @@ -249,21 +197,14 @@ public FileReader run() throws FileNotFoundException { * Instantiate a new FileWriter with filename * * @param filename - * @return + * @return Return a new file writer * @throws IOException */ public static FileWriter newFileWriter(final String filename) throws IOException { FileWriter piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public FileWriter run() throws IOException { - return new FileWriter(filename); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = new FileWriter(filename); + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } @@ -275,22 +216,15 @@ public FileWriter run() throws IOException { /** * Instantiate a new FileWriter with a file * - * @param filename - * @return + * @param file of the file writer + * @return Return the new file writer * @throws IOException */ public static FileWriter newFileWriter(final File file) throws IOException { FileWriter piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public FileWriter run() throws IOException { - return new FileWriter(file); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = new FileWriter(file); + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } @@ -300,25 +234,19 @@ public FileWriter run() throws IOException { } /** + * Instantiate a new OutputStreamWriter * * @param out * @param charsetName - * @return + * @return Return the new output stream writer * @throws UnsupportedEncodingException */ public static OutputStreamWriter newOutputStreamWriter(final OutputStream out, final String charsetName) throws UnsupportedEncodingException { OutputStreamWriter piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public OutputStreamWriter run() throws UnsupportedEncodingException { - return new OutputStreamWriter(out, charsetName); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = new OutputStreamWriter(out, charsetName); + } catch (Exception typedException) { if (typedException instanceof UnsupportedEncodingException) { throw (UnsupportedEncodingException) typedException; } @@ -331,22 +259,15 @@ public OutputStreamWriter run() throws UnsupportedEncodingException { * Read an object from an ObjectInputStream. * * @param ois - * @return + * @return Return an object from an object input stream * @throws IOException * @throws ClassNotFoundException */ public static Object readObject(final ObjectInputStream ois) throws IOException, ClassNotFoundException { Object piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public Object run() throws IOException, ClassNotFoundException { - return ois.readObject(); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = ois.readObject(); + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } @@ -362,21 +283,14 @@ public Object run() throws IOException, ClassNotFoundException { * Instantiate a new ObjectOutputStream * * @param out - * @return + * @return Return a new object from object output stream * @throws IOException */ public static ObjectOutputStream newObjectOutputStream(final OutputStream out) throws IOException { ObjectOutputStream piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public ObjectOutputStream run() throws IOException { - return new ObjectOutputStream(out); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = new ObjectOutputStream(out); + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } @@ -389,21 +303,14 @@ public ObjectOutputStream run() throws IOException { * Instantiate a new ObjectInputStream. * * @param is - * @return + * @return Return an object input stream * @throws IOException */ public static ObjectInputStream newObjectInputStream(final InputStream is) throws IOException { ObjectInputStream piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public ObjectInputStream run() throws IOException { - return new ObjectInputStream(is); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = new ObjectInputStream(is); + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } @@ -416,21 +323,14 @@ public ObjectInputStream run() throws IOException { * Instantiate a new ImageOutputStream. * * @param output - * @return + * @return Return the new image output stream * @throws IOException */ public static ImageOutputStream newImageOutputStream(final Object output) throws IOException { ImageOutputStream piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public ImageOutputStream run() throws IOException { - return ImageIO.createImageOutputStream(output); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = ImageIO.createImageOutputStream(output); + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } @@ -444,17 +344,11 @@ public ImageOutputStream run() throws IOException { * * @param * @param - * @return + * @return Return a Hashtable */ public static Hashtable newHashtable() { Hashtable piTmp0; - piTmp0 = AccessController.doPrivileged(new PrivilegedAction>() { - - @Override - public Hashtable run() { - return new Hashtable<>(); - } - }); + piTmp0 = new Hashtable<>(); return piTmp0; } @@ -463,17 +357,11 @@ public Hashtable run() { * Returns as ClassLoader of a class * * @param cls - * @return + * @return Return a class loader */ public static ClassLoader getClassLoader(final Class cls) { ClassLoader piTmp0; - piTmp0 = AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public ClassLoader run() { - return cls.getClassLoader(); - } - }); + piTmp0 = cls.getClassLoader(); return piTmp0; } @@ -483,17 +371,11 @@ public ClassLoader run() { * * @param urls * @param parent - * @return + * @return Return the URL class loader */ public static URLClassLoader newURLClassLoader(final URL[] urls, final ClassLoader parent) { URLClassLoader piTmp0; - piTmp0 = AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public URLClassLoader run() { - return new URLClassLoader(urls, parent);// $NON-SEC-2 - } - }); + piTmp0 = new URLClassLoader(urls, parent);// $NON-SEC-2 return piTmp0; } @@ -503,7 +385,7 @@ public URLClassLoader run() { * * @param * @param cls - * @return + * @return Return a new class instance * @throws InstantiationException * @throws IllegalAccessException */ @@ -514,22 +396,16 @@ public static T newClassInstance(Class cls) throws InstantiationException /** * Load a class. * + * @param loader * @param name - * @return + * @return Return the loaded class * @throws ClassNotFoundException */ public static Class loadClass(final ClassLoader loader, final String name) throws ClassNotFoundException { Class piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction>() { - - @Override - public Class run() throws ClassNotFoundException { - return loader.loadClass(name); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = loader.loadClass(name); + } catch (Exception typedException) { if (typedException instanceof ClassNotFoundException) { throw (ClassNotFoundException) typedException; } @@ -539,22 +415,17 @@ public Class run() throws ClassNotFoundException { } /** + * Get methods * - * @return + * @param cls class + * @return Return the methods * @throws SecurityException */ public static Method[] getMethods(final Class cls) throws SecurityException { Method[] piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public Method[] run() throws SecurityException { - return cls.getMethods(); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = cls.getMethods(); + } catch (Exception typedException) { if (typedException instanceof SecurityException) { throw (SecurityException) typedException; } @@ -569,7 +440,7 @@ public Method[] run() throws SecurityException { * @param method * @param caller * @param args - * @return + * @return Return the object * @throws IllegalAccessException * @throws IllegalArgumentException * @throws InvocationTargetException @@ -578,15 +449,8 @@ public static Object invokeMethod(final Method method, final Object caller, fina throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { Object piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public Object run() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - return method.invoke(caller, args); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = method.invoke(caller, args); + } catch (Exception typedException) { if (typedException instanceof IllegalAccessException) { throw (IllegalAccessException) typedException; } @@ -607,7 +471,7 @@ public Object run() throws IllegalAccessException, IllegalArgumentException, Inv * @param * @param cls * @param parameterTypes - * @return + * @return Return the constructor * @throws NoSuchMethodException * @throws SecurityException */ @@ -615,15 +479,8 @@ public static Constructor getConstructor(final Class cls, final Class< throws NoSuchMethodException, SecurityException { Constructor piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction>() { - - @Override - public Constructor run() throws NoSuchMethodException, SecurityException { - return cls.getConstructor(parameterTypes); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = cls.getConstructor(parameterTypes); + } catch (Exception typedException) { if (typedException instanceof NoSuchMethodException) { throw (NoSuchMethodException) typedException; } @@ -639,17 +496,11 @@ public Constructor run() throws NoSuchMethodException, SecurityException { * Retrieve a system property * * @param key - * @return + * @return Return the property keys */ public static String getSysProp(final String key) { String piTmp0; - piTmp0 = AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public String run() { - return System.getProperty(key); - } - }); + piTmp0 = System.getProperty(key); return piTmp0; } @@ -659,17 +510,11 @@ public String run() { * * @param key * @param value - * @return + * @return Return the set of system properties */ public static String setSysProp(final String key, final String value) { String piTmp0; - piTmp0 = AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public String run() { - return System.setProperty(key, value); - } - }); + piTmp0 = System.setProperty(key, value); return piTmp0; } @@ -680,36 +525,21 @@ public String run() { * @param status */ public static void sysExit(final int status) { - AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Object run() { - System.exit(status); - return null; - } - }); - + System.exit(status); } /** * Instantiate a new URL * * @param spec - * @return + * @return Return a new URL * @throws MalformedURLException */ public static URL newURL(final String spec) throws MalformedURLException { URL piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public URL run() throws MalformedURLException { - return new URL(spec); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = new URL(spec); + } catch (Exception typedException) { if (typedException instanceof MalformedURLException) { throw (MalformedURLException) typedException; } @@ -723,21 +553,14 @@ public URL run() throws MalformedURLException { * * @param runtime * @param command - * @return + * @return Return the process of the executed command * @throws IOException */ public static Process execRuntimeCommand(final Runtime runtime, final String command) throws IOException { Process piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public Process run() throws IOException { - return runtime.exec(command); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = runtime.exec(command); + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } @@ -749,38 +572,30 @@ public Process run() throws IOException { /** * Instantiate a new TransformerFactory. * - * @return + * @return Return a new transformer factory * @throws Exception */ public static TransformerFactory newTransformerFactory() throws Exception { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public TransformerFactory run() throws Exception { - try { - return TransformerFactory.newInstance(); - } catch (TransformerFactoryConfigurationError error) { - throw error.getException(); - } - } - }); + TransformerFactory piTmp0 = null; + + try { + piTmp0 = TransformerFactory.newInstance(); + } catch (TransformerFactoryConfigurationError error) { + throw error.getException(); + } + + return piTmp0; } /** * Instantiate a new DocumentBuilderFactory. * - * @return + * @return Return the new document builder factory */ public static DocumentBuilderFactory newDocumentBuilderFactory() { DocumentBuilderFactory piTmp0; - piTmp0 = AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public DocumentBuilderFactory run() { - return DocumentBuilderFactory.newInstance(); - } - }); + piTmp0 = DocumentBuilderFactory.newInstance(); return piTmp0; } @@ -788,20 +603,15 @@ public DocumentBuilderFactory run() { /** * Constructs a URL from an URI. * - * @return + * @param uri + * @return Return a new URL + * @throws MalformedURLException */ public static URL toURL(final URI uri) throws MalformedURLException { URL piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public URL run() throws MalformedURLException { - return uri.toURL(); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = uri.toURL(); + } catch (Exception typedException) { if (typedException instanceof MalformedURLException) { throw (MalformedURLException) typedException; } @@ -814,22 +624,15 @@ public URL run() throws MalformedURLException { * Instantiate a new File with uri. * * @param uri - * @return + * @return Return the file URI based * @throws NullPointerException * @throws IllegalArgumentException */ public static File newFile(final URI uri) throws NullPointerException, IllegalArgumentException { File piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public File run() throws NullPointerException, IllegalArgumentException { - return new File(uri); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = new File(uri); + } catch (Exception typedException) { if (typedException instanceof NullPointerException) { throw (NullPointerException) typedException; } else if (typedException instanceof IllegalArgumentException) { @@ -845,21 +648,14 @@ public File run() throws NullPointerException, IllegalArgumentException { * * @param s * @param enc - * @return + * @return Return the encoded URL * @throws UnsupportedEncodingException */ public static String urlEncode(final String s, final String enc) throws UnsupportedEncodingException { String piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public String run() throws UnsupportedEncodingException { - return URLEncoder.encode(s, enc); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = URLEncoder.encode(s, enc); + } catch (Exception typedException) { if (typedException instanceof UnsupportedEncodingException) { throw (UnsupportedEncodingException) typedException; } @@ -873,17 +669,11 @@ public String run() throws UnsupportedEncodingException { * * @param out * @param autoFlush - * @return + * @return Return the print writter */ public static PrintWriter newPrintWriter(final Writer out, final boolean autoFlush) { PrintWriter piTmp0; - piTmp0 = AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public PrintWriter run() { - return new PrintWriter(out, autoFlush); - } - }); + piTmp0 = new PrintWriter(out, autoFlush); return piTmp0; } @@ -892,21 +682,14 @@ public PrintWriter run() { * Instantiate a new ImageOutputStream. * * @param output - * @return + * @return Return the image output stream * @throws IOException */ public static ImageOutputStream createImageOutputStream(final Object output) throws IOException { ImageOutputStream piTmp0 = null; try { - piTmp0 = AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public ImageOutputStream run() throws IOException { - return ImageIO.createImageOutputStream(output); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + piTmp0 = ImageIO.createImageOutputStream(output); + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } @@ -923,13 +706,7 @@ public ImageOutputStream run() throws IOException { */ public static String getSystemEnv(final String name) { String piTmp0; - piTmp0 = AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public String run() { - return System.getenv(name); - } - }); + piTmp0 = System.getenv(name); return piTmp0; } diff --git a/chart/org.eclipse.birt.chart.reportitem/src/org/eclipse/birt/chart/reportitem/BIRTScriptClassLoader.java b/chart/org.eclipse.birt.chart.reportitem/src/org/eclipse/birt/chart/reportitem/BIRTScriptClassLoader.java index 62782c17b10..8ecd3d11088 100644 --- a/chart/org.eclipse.birt.chart.reportitem/src/org/eclipse/birt/chart/reportitem/BIRTScriptClassLoader.java +++ b/chart/org.eclipse.birt.chart.reportitem/src/org/eclipse/birt/chart/reportitem/BIRTScriptClassLoader.java @@ -18,8 +18,6 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.List; @@ -50,6 +48,11 @@ protected Class findClass(String name) throws ClassNotFoundException { private ClassLoader classLoader; + /** + * Constructor + * + * @param classLoader + */ public BIRTScriptClassLoader(ClassLoader classLoader) { this.classLoader = classLoader; } @@ -115,12 +118,10 @@ public Class loadClass(String className, ClassLoader parentLoader) throws Cla return c; } - private static Class getClassUsingCustomClassPath(final String className, final String classPathKey, + private static Class getClassUsingCustomClassPath(final String className, + final String classPathKey, final ClassLoader parentLoader) { - return AccessController.doPrivileged(new PrivilegedAction>() { - - @Override - public Class run() { + Class c = null; String classPath = System.getProperty(classPathKey); if (classPath == null || classPath.length() == 0 || className == null) { return null; @@ -133,7 +134,7 @@ public Class run() { String cpValue = classPathArray[i]; File file = new File(cpValue); try { - l.add(file.toURL()); + l.add(file.toURI().toURL()); } catch (MalformedURLException e) { e.printStackTrace(); } @@ -146,7 +147,7 @@ public Class run() { IReportEngine.class.getClassLoader()); ClassLoader cl = new URLClassLoader(urls, cmLoader); try { - return cl.loadClass(className); + c = cl.loadClass(className); // Note: If the class can // not even be loadded by this // loader either, null will be returned @@ -154,10 +155,7 @@ public Class run() { // Ignore } } - return null; - } - }); - + return c; } } diff --git a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/archive/compound/ArchiveFileV2.java b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/archive/compound/ArchiveFileV2.java index fe6feb2207a..21c8ab7f9b4 100644 --- a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/archive/compound/ArchiveFileV2.java +++ b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/archive/compound/ArchiveFileV2.java @@ -18,8 +18,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -602,13 +600,7 @@ private void ensureParentFolderCreated() { } int getDefaultBlockSize() { - String value = (String) AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Object run() { - return System.getProperty(PROPERTY_DEFAULT_BLOCK_SIZE); - } - }); + String value = System.getProperty(PROPERTY_DEFAULT_BLOCK_SIZE); if (value != null) { try { diff --git a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/Platform.java b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/Platform.java index 8c3ffb7dda0..f80546e436e 100644 --- a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/Platform.java +++ b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/Platform.java @@ -257,13 +257,7 @@ public static String getDebugOption(String name) { */ public static Object createFactoryObject(final String extensionId) { if (platform != null) { - return java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() { - - @Override - public Object run() { - return platform.createFactoryObject(extensionId); - } - }); + return platform.createFactoryObject(extensionId); } return null; } diff --git a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/PlatformConfig.java b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/PlatformConfig.java index ae44208dedc..a758795dfbb 100644 --- a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/PlatformConfig.java +++ b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/PlatformConfig.java @@ -14,8 +14,6 @@ package org.eclipse.birt.core.framework; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.HashMap; import java.util.Map; @@ -119,13 +117,7 @@ public void setTempDir(String tmpDir) { public String getTempDir() { String tempDir = (String) getProperty(TEMP_DIR); if (tempDir == null) { - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public String run() { - return System.getProperty("java.io.tmpdir"); - } - }); + return System.getProperty("java.io.tmpdir"); } return tempDir; } diff --git a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/PlatformFileContext.java b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/PlatformFileContext.java index f673aedcd22..373150d5b80 100644 --- a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/PlatformFileContext.java +++ b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/PlatformFileContext.java @@ -11,9 +11,6 @@ package org.eclipse.birt.core.framework; -import java.security.AccessController; -import java.security.PrivilegedAction; - /** * An platform context that is based on file operations. Since in web * environment WAR deployment, absolute file path is not available. In this @@ -61,16 +58,10 @@ public String[] getLaunchArguments() { } private String getSystemBirtHome() { - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public String run() { - String home = System.getProperty(IPlatformConfig.BIRT_HOME); - if (home == null || "".equals(home)) { - return null; - } - return home; - } - }); + String home = System.getProperty(IPlatformConfig.BIRT_HOME); + if (home == null || "".equals(home)) { + return null; + } + return home; } } diff --git a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/PlatformServletContext.java b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/PlatformServletContext.java index e3a5447c626..e12aac919b0 100644 --- a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/PlatformServletContext.java +++ b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/PlatformServletContext.java @@ -16,8 +16,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Iterator; import java.util.Set; import java.util.logging.Level; @@ -60,14 +58,7 @@ public String getPlatform() { if (platform == null) { synchronized (this) { if (platform == null) { - AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Object run() { - deploy(); - return null; - } - }); + deploy(); } } } diff --git a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/URLClassLoader.java b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/URLClassLoader.java index 8f3ea06f033..c0a9e1173ed 100644 --- a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/URLClassLoader.java +++ b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/URLClassLoader.java @@ -29,8 +29,6 @@ import java.security.AccessController; import java.security.CodeSigner; import java.security.CodeSource; -import java.security.PrivilegedAction; -import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Enumeration; import java.util.LinkedList; @@ -131,17 +129,13 @@ public URL[] getURLs() { @Override protected Class findClass(final String name) throws ClassNotFoundException { + Class piTemp0 = null; try { - return (Class) AccessController.doPrivileged(new PrivilegedExceptionAction>() { - - @Override - public Class run() throws ClassNotFoundException { - return findClass1(name); - } - }, acc); - } catch (java.security.PrivilegedActionException pae) { - throw (ClassNotFoundException) pae.getException(); + piTemp0 = findClass1(name); + } catch (ClassNotFoundException e) { + throw (ClassNotFoundException) e.getException(); } + return piTemp0; } protected Class findClass1(String name) throws ClassNotFoundException { @@ -190,13 +184,7 @@ protected void definePackage(String className, Resource resource) { @Override public URL findResource(final String name) { - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public URL run() { - return findResource1(name); - } - }, acc); + return findResource1(name); } protected URL findResource1(String name) { @@ -216,13 +204,7 @@ protected URL findResource1(String name) { @Override public Enumeration findResources(final String name) { - return AccessController.doPrivileged(new PrivilegedAction>() { - - @Override - public Enumeration run() { - return findResources1(name); - } - }, acc); + return findResources1(name); } protected Enumeration findResources1(String name) { diff --git a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/osgi/OSGILauncher.java b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/osgi/OSGILauncher.java index bcd521444db..65a333ca011 100644 --- a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/osgi/OSGILauncher.java +++ b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/framework/osgi/OSGILauncher.java @@ -70,14 +70,7 @@ public class OSGILauncher extends PlatformLauncher { @Override public void startup(final PlatformConfig config) throws FrameworkException { try { - java.security.AccessController.doPrivileged(new java.security.PrivilegedExceptionAction() { - - @Override - public Object run() throws Exception { - doStartup(config); - return null; - } - }); + doStartup(config); } catch (Exception ex) { if (ex instanceof FrameworkException) { throw (FrameworkException) ex; @@ -316,15 +309,7 @@ public ClassLoader getFrameworkContextClassLoader() { @Override public void shutdown() { - java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() { - - @Override - public Object run() { - doShutdown(); - return null; - } - }); - + doShutdown(); } private void doShutdown() { diff --git a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/internal/plugin/CorePlugin.java b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/internal/plugin/CorePlugin.java index 222bb292b83..3090a61715b 100644 --- a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/internal/plugin/CorePlugin.java +++ b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/internal/plugin/CorePlugin.java @@ -14,9 +14,6 @@ package org.eclipse.birt.core.internal.plugin; -import java.security.AccessController; -import java.security.PrivilegedAction; - import org.eclipse.birt.core.framework.Platform; import org.eclipse.birt.core.framework.eclipse.EclipsePlatform; import org.eclipse.birt.core.internal.function.impl.FunctionProviderImpl; @@ -33,13 +30,7 @@ public class CorePlugin extends BIRTPlugin { @Override public void start(BundleContext context) throws Exception { super.start(context); - ClassLoader contextClassLoader = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Object run() { - return Thread.currentThread().getContextClassLoader(); - } - }); + ClassLoader contextClassLoader = (ClassLoader) Thread.currentThread().getContextClassLoader(); Platform.setPlatform(new EclipsePlatform(context, contextClassLoader)); FunctionProvider.setFunctionProvider(new FunctionProviderImpl()); diff --git a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/script/functionservice/impl/FunctionProviderBaseImpl.java b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/script/functionservice/impl/FunctionProviderBaseImpl.java index 1b5d8d35f4a..939ad2db93f 100644 --- a/core/org.eclipse.birt.core/src/org/eclipse/birt/core/script/functionservice/impl/FunctionProviderBaseImpl.java +++ b/core/org.eclipse.birt.core/src/org/eclipse/birt/core/script/functionservice/impl/FunctionProviderBaseImpl.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright (c) 2018 Actuate Corporation. - * + * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * https://www.eclipse.org/legal/epl-2.0/. - * + * * SPDX-License-Identifier: EPL-2.0 - * + * *******************************************************************************/ package org.eclipse.birt.core.script.functionservice.impl; @@ -16,8 +16,6 @@ import java.io.InputStreamReader; import java.net.URL; import java.net.URLClassLoader; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -141,13 +139,7 @@ public void setApplicationClassLoader(final ClassLoader appLoader, Context conte try { appLoader.loadClass("org.mozilla.javascript.Context"); } catch (ClassNotFoundException e) { - loader = AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public ClassLoader run() { - return new RhinoClassLoaderDecoration(appLoader, FunctionProviderImpl.class.getClassLoader()); - } - }); + loader = new RhinoClassLoaderDecoration(appLoader, FunctionProviderImpl.class.getClassLoader()); } context.setApplicationClassLoader(loader); } @@ -155,13 +147,7 @@ public ClassLoader run() { private synchronized URLClassLoader createScriptClassLoader(List urls, ClassLoader parent) { final URL[] jarUrls = (URL[]) urls.toArray(new URL[] {}); final ClassLoader parentClassLoader = parent; - URLClassLoader scriptClassLoader = AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public URLClassLoader run() { - return new URLClassLoader(jarUrls, parentClassLoader); - } - }); + URLClassLoader scriptClassLoader = new URLClassLoader(jarUrls, parentClassLoader); return scriptClassLoader; } diff --git a/data/org.eclipse.birt.data.oda.pojo.ui/src/org/eclipse/birt/data/oda/pojo/ui/impl/dialogs/ColumnMappingWizardPage.java b/data/org.eclipse.birt.data.oda.pojo.ui/src/org/eclipse/birt/data/oda/pojo/ui/impl/dialogs/ColumnMappingWizardPage.java index 8765f2cea02..6aa3738f372 100644 --- a/data/org.eclipse.birt.data.oda.pojo.ui/src/org/eclipse/birt/data/oda/pojo/ui/impl/dialogs/ColumnMappingWizardPage.java +++ b/data/org.eclipse.birt.data.oda.pojo.ui/src/org/eclipse/birt/data/oda/pojo/ui/impl/dialogs/ColumnMappingWizardPage.java @@ -17,8 +17,6 @@ import java.lang.reflect.Member; import java.net.URL; import java.net.URLClassLoader; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -291,7 +289,7 @@ public void createPageCustomControl(Composite parent) { pageComposite.setLayout(new FillLayout()); SashForm sf = new SashForm(pageComposite, SWT.HORIZONTAL); - createLeftComposite(pageComposite, sf); + createLeftComposite(sf); createRightComposite(sf); @@ -445,7 +443,7 @@ public void selectionChanged(SelectionChangedEvent event) { } - private void createLeftComposite(Composite topComposite, SashForm sf) { + private void createLeftComposite(SashForm sf) { Composite left = new Composite(sf, SWT.NONE); left.setLayout(new GridLayout(2, false)); @@ -726,14 +724,9 @@ public void initClassStructure(DataSetDesign dataSet) throws Throwable { try { final URL[] urls = Utils.createURLParser(this.getHostResourceIdentifiers()).parse(pojoClassPath); - ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction() { - @Override - public ClassLoader run() { - return new URLClassLoader(urls, + ClassLoader cl = new URLClassLoader(urls, // so cl can also load classes in pojo driver plugin Activator.class.getClassLoader()); - } - }); Class c = cl.loadClass(pojoRootClass.trim()); classStructureTree.setContentProvider(new ClassTreeContentProvider(splits, cl)); classStructureTree.setLabelProvider(new ClassTreeLabelProvider()); diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/ClassSecurity.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/ClassSecurity.java index 736a0fdbb19..39a7499d349 100644 --- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/ClassSecurity.java +++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/ClassSecurity.java @@ -14,11 +14,6 @@ package org.eclipse.birt.data.engine.core.security; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; - /** * This class handles a series of privileged operation against class and * classloaders. @@ -35,13 +30,7 @@ public class ClassSecurity { public static ClassLoader getClassLoader(final Class clazz) { assert clazz != null; - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public ClassLoader run() { - return clazz.getClassLoader(); - } - }); + return clazz.getClassLoader(); } /** @@ -54,15 +43,8 @@ public ClassLoader run() { public static Class loadClass(final ClassLoader loader, final String className) throws ClassNotFoundException { try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public Class run() throws ClassNotFoundException { - return loader.loadClass(className); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + return loader.loadClass(className); + } catch (Exception typedException) { if (typedException instanceof ClassNotFoundException) { throw (ClassNotFoundException) typedException; } diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/FileSecurity.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/FileSecurity.java index 7650a63239f..3622a85b5f4 100644 --- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/FileSecurity.java +++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/FileSecurity.java @@ -21,39 +21,27 @@ import java.io.FileReader; import java.io.IOException; import java.io.RandomAccessFile; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import org.eclipse.birt.data.engine.core.DataException; /** * */ - public class FileSecurity { /** + * Create a new file * * @param file - * @return + * @return Return the status of file creation * @throws IOException */ public static boolean createNewFile(final File file) throws IOException { if (file == null) { return false; } - try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public Boolean run() throws IOException { - return file.createNewFile(); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + return file.createNewFile(); + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } @@ -62,51 +50,39 @@ public Boolean run() throws IOException { } /** + * Create a random access file * * @param path * @param type - * @return + * @return Return the created file * @throws FileNotFoundException * @throws DataException */ public static RandomAccessFile createRandomAccessFile(final String path, final String type) throws FileNotFoundException, DataException { try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public RandomAccessFile run() throws FileNotFoundException { - return new RandomAccessFile(path, type); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + return new RandomAccessFile(path, type); + } catch (Exception typedException) { if (typedException instanceof FileNotFoundException) { throw (FileNotFoundException) typedException; } - throw new DataException(e.getLocalizedMessage()); + throw new DataException(typedException.getLocalizedMessage()); } } /** + * Create a random access file * * @param file * @param type - * @return + * @return Return the created file * @throws FileNotFoundException */ public static RandomAccessFile createRandomAccessFile(final File file, final String type) throws FileNotFoundException { try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public RandomAccessFile run() throws FileNotFoundException { - return new RandomAccessFile(file, type); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + return new RandomAccessFile(file, type); + } catch (Exception typedException) { if (typedException instanceof FileNotFoundException) { throw (FileNotFoundException) typedException; } @@ -115,34 +91,29 @@ public RandomAccessFile run() throws FileNotFoundException { } /** + * Create a file reader * * @param file - * @return + * @return Return the file reader * @throws FileNotFoundException * @throws DataException */ public static FileReader createFileReader(final File file) throws FileNotFoundException, DataException { try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public FileReader run() throws FileNotFoundException { - return new FileReader(file); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + return new FileReader(file); + } catch (Exception typedException) { if (typedException instanceof FileNotFoundException) { throw (FileNotFoundException) typedException; } - throw new DataException(e.getLocalizedMessage()); + throw new DataException(typedException.getLocalizedMessage()); } } /** + * Create the file output stream * * @param file - * @return + * @return Return the file output stream * @throws FileNotFoundException * @throws DataException */ @@ -151,151 +122,115 @@ public static FileOutputStream createFileOutputStream(final File file) throws Fi } /** + * Create the file output stream * * @param file * @param append - * @return + * @return Return the file output stream * @throws FileNotFoundException * @throws DataException */ public static FileOutputStream createFileOutputStream(final File file, final boolean append) throws FileNotFoundException, DataException { try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public FileOutputStream run() throws FileNotFoundException { - return new FileOutputStream(file, append); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + return new FileOutputStream(file, append); + } catch (Exception typedException) { if (typedException instanceof FileNotFoundException) { throw (FileNotFoundException) typedException; } - throw new DataException(e.getMessage()); + throw new DataException(typedException.getMessage()); } } /** + * Create the file input stream * * @param file - * @return + * @return Return the file input stream * @throws FileNotFoundException * @throws DataException */ public static FileInputStream createFileInputStream(final File file) throws FileNotFoundException, DataException { try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public FileInputStream run() throws FileNotFoundException { return new FileInputStream(file); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + } catch (Exception typedException) { if (typedException instanceof FileNotFoundException) { throw (FileNotFoundException) typedException; } - throw new DataException(e.getMessage()); + throw new DataException(typedException.getMessage()); } } /** + * Check whether file exists * * @param file - * @return + * @return Return the check result */ public static boolean fileExist(final File file) { if (file == null) { return false; } - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Boolean run() { - return file.exists(); - } - }); + return file.exists(); } /** + * CHeck whether the file is an existing file * * @param file - * @return + * @return Return the check result */ public static boolean fileIsFile(final File file) { if (file == null) { return false; } - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Boolean run() { - return file.isFile(); - } - }); + return file.isFile(); } /** + * Create a list of files * * @param file - * @return + * @return Return a file array */ public static File[] fileListFiles(final File file) { if (file == null) { return new File[0]; } - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public File[] run() { - return file.listFiles(); - } - }); + return file.listFiles(); } /** + * CHeck if the file is a directory * * @param file - * @return + * @return Return the check result */ public static boolean fileIsDirectory(final File file) { if (file == null) { return false; } - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Boolean run() { - return file.isDirectory(); - } - }); + return file.isDirectory(); } /** + * Get the absolute file path * * @param file - * @return + * @return Return the absolute file path */ public static String fileGetAbsolutePath(final File file) { if (file == null) { return null; } - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public String run() { - return file.getAbsolutePath(); - } - }); + return file.getAbsolutePath(); } /** + * Get the canonical file path * * @param file - * @return + * @return Return the canonical file path * @throws IOException * @throws DataException */ @@ -304,42 +239,30 @@ public static String fileGetCanonicalPath(final File file) throws IOException, D return null; } try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public String run() throws IOException { - return file.getCanonicalPath(); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + return file.getCanonicalPath(); + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } - throw new DataException(e.getMessage()); - + throw new DataException(typedException.getMessage()); } } /** + * Delete file * * @param file - * @return + * @return Return the delete status */ public static boolean fileDelete(final File file) { if (file == null) { return true; } - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Boolean run() { - return file.delete(); - } - }); + return file.delete(); } /** + * Delete file and exit * * @param file */ @@ -347,38 +270,27 @@ public static void fileDeleteOnExit(final File file) { if (file == null) { return; } - AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Object run() { - file.deleteOnExit(); - return null; - } - }); + file.deleteOnExit(); } /** + * Create file directory * * @param file - * @return + * @return Return the directory creation status */ public static boolean fileMakeDirs(final File file) { if (file == null) { return false; } - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Boolean run() { - return file.mkdirs(); - } - }); + return file.mkdirs(); } /** + * Get canonical file * * @param file - * @return + * @return Return the canonical file * @throws IOException * @throws DataException */ @@ -387,20 +299,12 @@ public static File fileGetCanonicalFile(final File file) throws IOException, Dat return null; } try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public File run() throws IOException { - return file.getCanonicalFile(); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + return file.getCanonicalFile(); + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } - throw new DataException(e.getMessage()); - + throw new DataException(typedException.getMessage()); } } } diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/ObjectSecurity.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/ObjectSecurity.java index 102f5126f9e..5c52945bafe 100644 --- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/ObjectSecurity.java +++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/ObjectSecurity.java @@ -20,9 +20,6 @@ import java.io.ObjectOutputStream; import java.io.ObjectStreamClass; import java.io.OutputStream; -import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import org.eclipse.birt.data.engine.core.DataException; @@ -40,77 +37,67 @@ public class ObjectSecurity { */ public static ObjectInputStream createObjectInputStream(final InputStream is) throws IOException, DataException { try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public ObjectInputStream run() throws IOException { - return new ObjectInputStream(is); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + return new ObjectInputStream(is); + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } - throw new DataException(e.getMessage()); + throw new DataException(typedException.getMessage()); } } + /** + * Create object input stream + * + * @param is + * @param classLoader + * @return Return the object input stream + * @throws IOException + * @throws DataException + */ public static ObjectInputStream createObjectInputStream(final InputStream is, final ClassLoader classLoader) throws IOException, DataException { try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { + return new ObjectInputStream(is) { @Override - public ObjectInputStream run() throws IOException { - return new ObjectInputStream(is) { - - @Override - protected Class resolveClass(ObjectStreamClass desc) - throws IOException, ClassNotFoundException { - return Class.forName(desc.getName(), false, classLoader); - } - }; + protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { + return Class.forName(desc.getName(), false, classLoader); } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + }; + + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } - throw new DataException(e.getMessage()); + throw new DataException(typedException.getMessage()); } } /** + * Create object output stream * * @param os - * @return + * @return Return the object output stream * @throws IOException * @throws DataException */ public static ObjectOutputStream createObjectOutputStream(final OutputStream os) throws IOException, DataException { try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public ObjectOutputStream run() throws IOException { - return new ObjectOutputStream(os); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + return new ObjectOutputStream(os); + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } - throw new DataException(e.getMessage()); + throw new DataException(typedException.getMessage()); } } /** + * Read object * * @param is - * @return + * @return Return the read object * @throws IOException * @throws DataException * @throws ClassNotFoundException @@ -121,22 +108,15 @@ public static Object readObject(final ObjectInputStream is) if (is == null) { return null; } - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public Object run() throws IOException, ClassNotFoundException { - return is.readObject(); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + return is.readObject(); + } catch (Exception typedException) { if (typedException instanceof IOException) { throw (IOException) typedException; } else if (typedException instanceof ClassNotFoundException) { throw (ClassNotFoundException) typedException; } - throw new DataException(e.getMessage()); + throw new DataException(typedException.getMessage()); } } } diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/PropertySecurity.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/PropertySecurity.java index 1f80ae84848..2c04a91f2e2 100644 --- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/PropertySecurity.java +++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/PropertySecurity.java @@ -14,62 +14,51 @@ package org.eclipse.birt.data.engine.core.security; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.HashMap; import java.util.Hashtable; import java.util.Properties; +/** + * Property security class + * + * @since 3.3 + * + */ public class PropertySecurity { /** + * Create a HashMap * - * @return + * @return Return a new HashMap */ public static HashMap createHashMap() { - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public HashMap run() { - return new HashMap(); - } - }); + return new HashMap(); } /** + * Create a HashTable * - * @return + * @return Return a HashTable */ public static Hashtable createHashtable() { - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Hashtable run() { - return new Hashtable(); - } - }); + return new Hashtable(); } /** + * Create properties * - * @return + * @return Return properties */ public static Properties createProperties() { - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Properties run() { - return new Properties(); - } - }); + return new Properties(); } + /** + * Get system property + * + * @param key + * @return Return system property + */ public static String getSystemProperty(final String key) { - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public String run() { - return System.getProperty(key); - } - }); + return System.getProperty(key); } } diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/ThreadSecurity.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/ThreadSecurity.java index a49685cc4c9..365f4619562 100644 --- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/ThreadSecurity.java +++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/ThreadSecurity.java @@ -14,9 +14,6 @@ package org.eclipse.birt.data.engine.core.security; -import java.security.AccessController; -import java.security.PrivilegedAction; - /** * * @@ -26,15 +23,9 @@ public class ThreadSecurity { /** * * @param runnable - * @return + * @return Return a new thread */ public static Thread createThread(final Runnable runnable) { - return AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public Thread run() { - return new Thread(runnable); - } - }); + return new Thread(runnable); } } diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/URLSecurity.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/URLSecurity.java index 611dc95b519..a508a718c11 100644 --- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/URLSecurity.java +++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/core/security/URLSecurity.java @@ -16,9 +16,6 @@ import java.net.MalformedURLException; import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import org.eclipse.birt.data.engine.core.DataException; @@ -32,26 +29,19 @@ public class URLSecurity { * @param protocol * @param host * @param file - * @return + * @return Return the URL * @throws MalformedURLException * @throws DataException */ public static URL getURL(final String protocol, final String host, final String file) throws MalformedURLException, DataException { try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public URL run() throws MalformedURLException { - return new URL(protocol, host, file); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + return new URL(protocol, host, file); + } catch (Exception typedException) { if (typedException instanceof MalformedURLException) { throw (MalformedURLException) typedException; } - throw new DataException(e.getLocalizedMessage()); + throw new DataException(typedException.getLocalizedMessage()); } } @@ -59,25 +49,18 @@ public URL run() throws MalformedURLException { /** * * @param spec - * @return + * @return Return the URL * @throws MalformedURLException * @throws DataException */ public static URL getURL(final String spec) throws MalformedURLException, DataException { try { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - - @Override - public URL run() throws MalformedURLException { - return new URL(spec); - } - }); - } catch (PrivilegedActionException e) { - Exception typedException = e.getException(); + return new URL(spec); + } catch (Exception typedException) { if (typedException instanceof MalformedURLException) { throw (MalformedURLException) typedException; } - throw new DataException(e.getLocalizedMessage()); + throw new DataException(typedException.getLocalizedMessage()); } } diff --git a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/impl/PreparedQueryUtil.java b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/impl/PreparedQueryUtil.java index 3e5d3b9ef1e..41269dd94e9 100644 --- a/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/impl/PreparedQueryUtil.java +++ b/data/org.eclipse.birt.data/src/org/eclipse/birt/data/engine/impl/PreparedQueryUtil.java @@ -14,13 +14,10 @@ package org.eclipse.birt.data.engine.impl; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.sql.Timestamp; import java.text.MessageFormat; import java.text.SimpleDateFormat; @@ -508,14 +505,8 @@ private static IBaseDataSetDesign adaptOdaDataSetDesign(IBaseDataSetDesign dataS pscDataSet.setFormatPattern(formatPattern); adaptedDesign = pscDataSet; } else { - String message = (String) AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Object run() { - return MessageFormat.format(ResourceConstants.UNSUPPORTED_INCRE_CACHE_MODE, - new Object[] { mode }); - } - }); - + String message = MessageFormat.format(ResourceConstants.UNSUPPORTED_INCRE_CACHE_MODE, + new Object[] { mode }); throw new UnsupportedOperationException(message); } } diff --git a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/DataAdapterUtil.java b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/DataAdapterUtil.java index c927089f762..ed1792b62ec 100644 --- a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/DataAdapterUtil.java +++ b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/DataAdapterUtil.java @@ -15,8 +15,6 @@ package org.eclipse.birt.report.data.adapter.api; import java.io.File; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -539,12 +537,7 @@ public static Object getParamValueFromConfigFile(ScalarParameterHandle paramHand String reportConfigName = designFileName.substring(0, index + 1) + "rptconfig"; final File file = new File(reportConfigName); - if (AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Boolean run() { - return file.exists(); - } - })) { + if (file.exists()) { String paraName = paramHandle.getName(); ScalarParameterHandle parameterHandle = (ScalarParameterHandle) designModule.findParameter(paraName); paraName = paraName + "_" + parameterHandle.getID(); diff --git a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/script/ReportContextObject.java b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/script/ReportContextObject.java index 09481eb789f..919e68030df 100644 --- a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/script/ReportContextObject.java +++ b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/api/script/ReportContextObject.java @@ -16,8 +16,6 @@ import java.io.Serializable; import java.math.BigDecimal; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Date; import java.util.Locale; import java.util.Map; @@ -85,12 +83,7 @@ public Object getParameterDisplayText(String name) { * @return */ public Object getLocale() { - return AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Locale run() { - return Locale.getDefault(); - } - }); + return Locale.getDefault(); } /** diff --git a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/DataRequestSessionImpl.java b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/DataRequestSessionImpl.java index 500e0baafa2..2ac50824c23 100644 --- a/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/DataRequestSessionImpl.java +++ b/data/org.eclipse.birt.report.data.adapter/src/org/eclipse/birt/report/data/adapter/impl/DataRequestSessionImpl.java @@ -21,8 +21,6 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -1665,12 +1663,7 @@ protected static ResourceIdentifiers createResourceIdentifiers(final ModuleHandl identifiers.setDesignResourceBaseURI(handle.getSystemId().toURI()); } if (handle.getResourceFolder() != null) { - URI uri = AccessController.doPrivileged(new PrivilegedAction() { - @Override - public URI run() { - return new File(handle.getModule().getSession().getResourceFolder()).toURI(); - } - }); + URI uri = new File(handle.getModule().getSession().getResourceFolder()).toURI(); identifiers.setApplResourceBaseURI(uri); } diff --git a/data/org.eclipse.birt.report.engine.script.javascript/src/org/eclipse/birt/report/engine/javascript/JavascriptEngine.java b/data/org.eclipse.birt.report.engine.script.javascript/src/org/eclipse/birt/report/engine/javascript/JavascriptEngine.java index 534a1f032e7..5cb7b2bd903 100644 --- a/data/org.eclipse.birt.report.engine.script.javascript/src/org/eclipse/birt/report/engine/javascript/JavascriptEngine.java +++ b/data/org.eclipse.birt.report.engine.script.javascript/src/org/eclipse/birt/report/engine/javascript/JavascriptEngine.java @@ -14,8 +14,6 @@ package org.eclipse.birt.report.engine.javascript; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.HashMap; import java.util.Locale; import java.util.Map; @@ -202,13 +200,7 @@ public JavascriptEngineFactory getFactory() { @Override public CompiledJavascript compile(ScriptContext scriptContext, final String id, final int lineNumber, final String script) throws BirtException { - Script scriptObject = AccessController.doPrivileged(new PrivilegedAction