List of usage examples for java.security AccessControlException printStackTrace
public void printStackTrace()
From source file:Main.java
public static void main(String[] argv) throws Exception { String secretObj = "secret"; Guard guard = new PropertyPermission("java.home", "read"); GuardedObject gobj = new GuardedObject(secretObj, guard); try {/*from ww w . j ava2 s . c om*/ Object o = gobj.getObject(); } catch (AccessControlException e) { e.printStackTrace(); } }
From source file:net.sf.xmm.moviemanager.MovieManager.java
public static void main(String args[]) { boolean sandbox = SysUtil.isRestrictedSandbox(); // Uses this to check if the app is running in a sandbox with limited privileges try {//from w ww . j a v a 2s .com /* Disable HTTPClient logging output */ System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); //$NON-NLS-1$ //$NON-NLS-2$ } catch (java.security.AccessControlException s) { s.printStackTrace(); sandbox = true; } if (!sandbox) { // Disables logging for cobra html renderer java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.OFF); File log4jConfigFile = FileUtil.getFile("config/log4j.properties"); //$NON-NLS-1$ if (log4jConfigFile.isFile()) { PropertyConfigurator.configure(log4jConfigFile.getAbsolutePath()); } else { BasicConfigurator.configure(); } } else BasicConfigurator.configure(); log = Logger.getRootLogger(); // Places the Log file in the user directory (the program location) RollingFileAppender appndr = (RollingFileAppender) log.getAppender("FileAppender"); String logFile = null; try { if (SysUtil.isMac() || SysUtil.isWindowsVista() || SysUtil.isWindows7()) logFile = new File(SysUtil.getConfigDir(), "Log.txt").getAbsolutePath(); } catch (Exception e1) { e1.printStackTrace(); } finally { if (logFile == null) logFile = new File(SysUtil.getUserDir(), "Log.txt").getAbsolutePath(); } if (appndr != null && appndr.getFile() == null) { appndr.setFile(logFile); appndr.activateOptions(); } /* Writes the date. */ log.debug("================================================================================"); //$NON-NLS-1$ log.debug("Log Start: " + new Date(System.currentTimeMillis())); //$NON-NLS-1$ log.debug("MeD's Movie Manager v" + config.sysSettings.getVersion()); //$NON-NLS-1$ log.debug("MovieManager release:" + MovieManager.getConfig().sysSettings.getRelease() + " - " + "IMDb Lib release:" + IMDbLib.getRelease() + " (" + IMDbLib.getVersion() + ")"); log.debug(SysUtil.getSystemInfo(SysUtil.getLineSeparator())); //$NON-NLS-1$ /* Loads the config */ if (!sandbox) config.loadConfig(); // Calls the plugin startup method MovieManagerStartupHandler startupHandler = MovieManager.getConfig().getStartupHandler(); if (startupHandler != null) { startupHandler.startUp(); } if (!sandbox) { if (SysUtil.isAtLeastJRE6()) { SysUtil.includeJarFilesInClasspath("lib/LookAndFeels/1.6"); } SysUtil.includeJarFilesInClasspath("lib/LookAndFeels"); SysUtil.includeJarFilesInClasspath("lib/drivers"); /* Must be called before the GUI is created */ if (SysUtil.isMac()) { SysUtil.includeJarFilesInClasspath("lib/mac"); lookAndFeelManager.setupOSXLaF(); } } movieManager = new MovieManager(); movieManager.sandbox = sandbox; // Loads the HTML templates templateHandler.loadHTMLTemplates(); EventQueue.invokeLater(new Runnable() { public final void run() { try { /* Installs the Look&Feels */ lookAndFeelManager.instalLAFs(); if (!MovieManager.isApplet()) lookAndFeelManager.setLookAndFeel(); log.debug("Look & Feels installed."); log.debug("Creating MovieManager Dialog"); movieManager.createDialog(); /* Starts the MovieManager. */ MovieManager.getDialog().setUp(); log.debug("MovieManager Dialog - setup."); MovieManager.getDialog().showDialog(); /* SetUp the Application Menu for OSX */ if (SysUtil.isMac()) { LookAndFeelManager.macOSXRegistration(MovieManager.getDialog()); } // Calls the plugin startup method MovieManagerLoginHandler loginHandler = MovieManager.getConfig().getLoginHandler(); if (loginHandler != null) { loginHandler.loginStartUp(); } log.debug("Loading Database...."); /* Loads the database. */ databaseHandler.loadDatabase(true); log.debug("Database loaded."); AppUpdater.handleVersionUpdate(); } catch (Exception e) { log.error("Exception occured while intializing MeD's Movie Manager", e); } } }); }
From source file:com.paulwithers.bp106.DemoUtils.java
public static String convertObjectToString(final Object o) { String retVal_ = ""; try {/*from www . j a v a 2s . co m*/ retVal_ = AccessController.doPrivileged(new PrivilegedExceptionAction<String>() { public String run() throws Exception { return ReflectionToStringBuilder.toString(o); } }); } catch (AccessControlException e) { e.printStackTrace(); } catch (PrivilegedActionException e) { e.printStackTrace(); } return retVal_; }
From source file:com.paulwithers.bp106.DemoUtils.java
public static String convertObjectToString(final Object o, final ToStringStyle style) { String retVal_ = ""; try {//from w w w . ja v a 2 s . c om retVal_ = AccessController.doPrivileged(new PrivilegedExceptionAction<String>() { public String run() throws Exception { return ReflectionToStringBuilder.toString(o, style); } }); } catch (AccessControlException e) { e.printStackTrace(); } catch (PrivilegedActionException e) { e.printStackTrace(); } return retVal_; }
From source file:net.sf.xmm.moviemanager.http.IMDBTest.java
@Before public void setUp() throws Exception { if (setup)/*from www.j ava 2s. co m*/ return; setup = true; BasicConfigurator.configure(); try { /* Disable HTTPClient logging output */ System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); //$NON-NLS-1$ //$NON-NLS-2$ } catch (java.security.AccessControlException s) { s.printStackTrace(); } }
From source file:com.sshtools.appframework.ui.SshToolsApplication.java
@SuppressWarnings("serial") private void loadMRU() { try {//from www. jav a 2 s .co m if (System.getSecurityManager() != null) { AccessController.checkPermission(new FilePermission("<<ALL FILES>>", "write")); } File a = getApplicationPreferencesDirectory(); if (a == null) { throw new AccessControlException("Application preferences directory not specified."); } InputStream in = null; MRUList mru = new MRUList(); try { File f = new File(a, getApplicationName() + ".mru"); if (f.exists()) { in = new FileInputStream(f); mru.reload(in); } } catch (Exception e) { e.printStackTrace(); } finally { IOUtil.closeStream(in); } mruModel = new MRUListModel() { @Override public void add(File f) { super.add(f); saveMRU(SshToolsApplication.this); } @Override public void setMRUList(MRUList mru) { super.setMRUList(mru); } }; mruModel.setMRUList(mru); } catch (AccessControlException ace) { ace.printStackTrace(); } }
From source file:com.sshtools.sshterm.SshTermSessionPanel.java
/** * * * @param application//from ww w . ja va2s. c om * * @throws SshToolsApplicationException */ public void init(SshToolsApplication application) throws SshToolsApplicationException { super.init(application); // Additional connection tabs additionalTabs = new SshToolsConnectionTab[] { new SshTermTerminalTab() }; // Printing page format try { if (System.getSecurityManager() != null) { AccessController.checkPermission(new RuntimePermission("queuePrintJob")); } try { PrinterJob job = PrinterJob.getPrinterJob(); if (job == null) { throw new IOException("Could not get print page format."); } pageFormat = job.defaultPage(); if (PreferencesStore.preferenceExists(PREF_PAGE_FORMAT_ORIENTATION)) { pageFormat.setOrientation( PreferencesStore.getInt(PREF_PAGE_FORMAT_ORIENTATION, PageFormat.LANDSCAPE)); Paper paper = new Paper(); paper.setImageableArea(PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_X, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_Y, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_W, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_H, 0)); paper.setSize(PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_W, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_H, 0)); pageFormat.setPaper(paper); } } catch (Exception e) { showExceptionMessage("Error", e.getMessage()); } } catch (AccessControlException ace) { ace.printStackTrace(); } enableEvents(VDU_EVENTS); // Set up the actions initActions(); // Create the status bar statusBar = new StatusBar(); dataListener = new DataNotificationListener(statusBar); // Create our terminal emulation object try { emulation = createEmulation(); } catch (IOException ioe) { throw new SshToolsApplicationException(ioe); } emulation.addTerminalListener(this); // Set a scrollbar for the terminal - doesn't seem to be as simple as this scrollBar = new JScrollBar(JScrollBar.VERTICAL); emulation.setBufferSize(1000); // Create our swing terminal and add it to the main frame terminal = new TerminalPanel(emulation) { public void processEvent(AWTEvent evt) { /** We can't add a MouseWheelListener because it was not available in 1.3, so direct processing of events is necessary */ if (evt instanceof MouseEvent && evt.getID() == 507) { try { Method m = evt.getClass().getMethod("getWheelRotation", new Class[] {}); SshTermSessionPanel.this.scrollBar.setValue(SshTermSessionPanel.this.scrollBar.getValue() + (SshTermSessionPanel.this.scrollBar.getUnitIncrement() * ((Integer) m.invoke(evt, new Object[] {})).intValue() * PreferencesStore.getInt(PREF_MOUSE_WHEEL_INCREMENT, 1))); } catch (Throwable t) { } } else { super.processEvent(evt); } } public void copyNotify() { copyAction.actionPerformed(null); } }; terminal.requestFocus(); terminal.setScrollbar(scrollBar); terminal.addMouseMotionListener(this); //terminal.addMouseWheelListener(this); // Center panel with terminal and scrollbar JPanel center = new JPanel(new BorderLayout()); center.setBackground(Color.red); center.add(terminal, BorderLayout.CENTER); center.add(scrollBar, BorderLayout.EAST); // Show the context menu on mouse button 3 (right click) terminal.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) > 0) { getContextMenu().setLabel(getApplication().getApplicationName()); getContextMenu().show(terminal, evt.getX(), evt.getY()); } else if ((evt.getModifiers() & MouseEvent.BUTTON2_MASK) > 0) { pasteAction.actionPerformed(null); } } }); // // JPanel top = new JPanel(new BorderLayout()); // top.add(getJMenuBar(), BorderLayout.NORTH); // top.add(north, BorderLayout.SOUTH); setLayout(new BorderLayout()); add(center, BorderLayout.CENTER); // add(top, BorderLayout.NORTH); // Make sure that the swing terminal has focus terminal.requestFocus(); }
From source file:com.sshtools.sshvnc.SshVNCPanel.java
private void initActions() { // Create the action menu groups registerActionMenu(new SshToolsApplicationPanel.ActionMenu("File", "File", 'f', 0)); registerActionMenu(new SshToolsApplicationPanel.ActionMenu("Edit", "Edit", 'e', 10)); registerActionMenu(new SshToolsApplicationPanel.ActionMenu("View", "View", 'v', 20)); vncTab = new VNCTab( /*vnc*/); newAction = new NewAction() { public void actionPerformed(ActionEvent evt) { SshToolsConnectionProfile newProfile = newConnectionProfile(null); if (newProfile != null) { connect(newProfile, true); }// w w w . java 2 s.c om else { log.info("New connection cancelled"); } } }; registerAction(newAction); closeAction = new CloseAction() { public void actionPerformed(ActionEvent evt) { closing = true; // Close on a thread to avoid blocking the event queue Thread thread = new Thread() { public void run() { closeConnection(true); } }; thread.start(); } }; registerAction(closeAction); refreshAction = new RefreshAction() { public void actionPerformed(ActionEvent evt) { refresh(); } }; registerAction(refreshAction); ctrlAltDelAction = new CtrlAltDelAction() { public void actionPerformed(ActionEvent evt) { try { vnc.sendCtrlAltDel(); } catch (IOException ioe) { closeConnection(true); showErrorMessage(SshVNCPanel.this, "Error", ioe); } } }; registerAction(ctrlAltDelAction); clipboardAction = new ClipboardAction() { public void actionPerformed(ActionEvent evt) { vnc.setClipboardVisible(!vnc.isClipboardVisible()); } }; registerAction(clipboardAction); if (getApplication().getMRUModel() != null) { registerAction( mruAction = new MRUActionImpl(getApplication().getMRUModel())); } connectionPropertiesAction = new ConnectionPropertiesAction() { public void actionPerformed(ActionEvent evt) { editConnection(getCurrentConnectionProfile()); } }; registerAction(connectionPropertiesAction); // Only allow opening of files if allowed by the security manager try { if (System.getSecurityManager() != null) { AccessController.checkPermission( new FilePermission("<<ALL FILES>>", "read")); } openAction = new OpenAction() { public void actionPerformed(ActionEvent evt) { open(); } }; registerAction(openAction); } catch (AccessControlException ace) { ace.printStackTrace(); } // Only allow saving of files if allowed by the security manager try { if (System.getSecurityManager() != null) { AccessController.checkPermission( new FilePermission("<<ALL FILES>>", "write")); } saveAction = new SaveAction() { public void actionPerformed(ActionEvent evt) { saveConnection(false, getCurrentConnectionFile(), getCurrentConnectionProfile()); } }; registerAction(saveAction); saveAsAction = new SaveAsAction() { public void actionPerformed(ActionEvent evt) { saveConnection(true, getCurrentConnectionFile(), getCurrentConnectionProfile()); } }; registerAction(saveAsAction); recordAction = new RecordAction() { public void actionPerformed(ActionEvent evt) { startRecording(); } }; registerAction(recordAction); stopAction = new StopAction() { public void actionPerformed(ActionEvent evt) { stopRecording(); } }; registerAction(stopAction); } catch (AccessControlException ace) { ace.printStackTrace(); } // Only allow editing of connection file if read / write is allowed try { if (System.getSecurityManager() != null) { AccessController.checkPermission( new FilePermission("<<ALL FILES>>", "write")); } if (System.getSecurityManager() != null) { AccessController.checkPermission( new FilePermission("<<ALL FILES>>", "read")); } editAction = new EditAction() { public void actionPerformed(ActionEvent evt) { editConnection(); } }; registerAction(editAction); } catch (AccessControlException ace) { ace.printStackTrace(); } java.util.List providers = SessionProviderFactory.getInstance().getSessionProviders(); SessionProvider provider; SessionProviderAction action; for (Iterator it = providers.iterator(); it.hasNext();) { provider = (SessionProvider) it.next(); action = new SessionProviderAction(provider); sessionActions.put(action.getActionCommand(), action); action.addActionListener(this); registerAction(action); } }
From source file:com.sshtools.powervnc.PowerVNCPanel.java
private void initActions() { // Create the action menu groups System.out.println("initActions"); registerActionMenu(new SshToolsApplicationPanel.ActionMenu("File", "File", 'f', 0)); registerActionMenu(new SshToolsApplicationPanel.ActionMenu("Edit", "Edit", 'e', 10)); registerActionMenu(new SshToolsApplicationPanel.ActionMenu("View", "View", 'v', 20)); vncTab = new VNCTab( /*vnc*/); desktopAction = new DesktopAction() { public void actionPerformed(ActionEvent evt) { try { authenticationComplete(false); } catch (SshException e) { // TODO Auto-generated catch block e.printStackTrace();/*from w w w .j a va 2 s.co m*/ } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } /* newProfile = newConnectionProfile(null); if (newProfile != null) { connect(newProfile, true); } else { log.info("New connection cancelled"); } */ } }; registerAction(desktopAction); closeAction = new CloseAction() { public void actionPerformed(ActionEvent evt) { closing = true; // Close on a thread to avoid blocking the event queue Thread thread = new Thread() { public void run() { closeConnection(true); } }; thread.start(); } }; registerAction(closeAction); filemanagerAction = new FileManagerAction() { public void actionPerformed(ActionEvent evt) { new JFtp(ssh); // refresh(); } }; registerAction(filemanagerAction); ctrlAltDelAction = new CtrlAltDelAction() { public void actionPerformed(ActionEvent evt) { try { vnc.sendCtrlAltDel(); } catch (IOException ioe) { closeConnection(true); showErrorMessage(PowerVNCPanel.this, "Error", ioe); } } }; registerAction(ctrlAltDelAction); clipboardAction = new ClipboardAction() { public void actionPerformed(ActionEvent evt) { vnc.setClipboardVisible(!vnc.isClipboardVisible()); } }; registerAction(clipboardAction); if (getApplication().getMRUModel() != null) { registerAction( mruAction = new MRUActionImpl(getApplication().getMRUModel())); } connectionPropertiesAction = new ConnectionPropertiesAction() { public void actionPerformed(ActionEvent evt) { editConnection(getCurrentConnectionProfile()); } }; registerAction(connectionPropertiesAction); // Only allow opening of files if allowed by the security manager try { if (System.getSecurityManager() != null) { AccessController.checkPermission( new FilePermission("<<ALL FILES>>", "read")); } openAction = new OpenAction() { public void actionPerformed(ActionEvent evt) { open(); } }; registerAction(openAction); } catch (AccessControlException ace) { ace.printStackTrace(); } // Only allow saving of files if allowed by the security manager try { if (System.getSecurityManager() != null) { AccessController.checkPermission( new FilePermission("<<ALL FILES>>", "write")); } saveAction = new SaveAction() { public void actionPerformed(ActionEvent evt) { saveConnection(false, getCurrentConnectionFile(), getCurrentConnectionProfile()); } }; registerAction(saveAction); saveAsAction = new SaveAsAction() { public void actionPerformed(ActionEvent evt) { saveConnection(true, getCurrentConnectionFile(), getCurrentConnectionProfile()); } }; registerAction(saveAsAction); recordAction = new RecordAction() { public void actionPerformed(ActionEvent evt) { startRecording(); } }; registerAction(recordAction); stopAction = new StopAction() { public void actionPerformed(ActionEvent evt) { stopRecording(); } }; registerAction(stopAction); } catch (AccessControlException ace) { ace.printStackTrace(); } // Only allow editing of connection file if read / write is allowed try { if (System.getSecurityManager() != null) { AccessController.checkPermission( new FilePermission("<<ALL FILES>>", "write")); } if (System.getSecurityManager() != null) { AccessController.checkPermission( new FilePermission("<<ALL FILES>>", "read")); } editAction = new EditAction() { public void actionPerformed(ActionEvent evt) { editConnection(); } }; registerAction(editAction); } catch (AccessControlException ace) { ace.printStackTrace(); } java.util.List providers = SessionProviderFactory.getInstance().getSessionProviders(); SessionProvider provider; SessionProviderAction action; for (Iterator it = providers.iterator(); it.hasNext();) { provider = (SessionProvider) it.next(); action = new SessionProviderAction(provider); sessionActions.put(action.getActionCommand(), action); action.addActionListener(this); registerAction(action); } }
From source file:com.sshtools.sshterm.SshTerminalPanel.java
public void init(SshToolsApplication application) throws SshToolsApplicationException { super.init(application); boolean kerb_support = false; if (PreferencesStore.get(PREF_KRB5_MYPROXY_USE, "NONE").indexOf("true") >= 0) kerb_support = true;//from w w w . j a v a2s. c om // Additional connection tabs if (kerb_support == true) { additionalTabs = new SshToolsConnectionTab[] { new SshTermCommandTab(), new SshTermTerminalTab(), new GSIAuthTab(), new XForwardingTab(), new SshToolsConnectionKerberosTab() }; SshTerminalPanel.PREF_KRB5_MYPROXY_ENABLED = true; } else { additionalTabs = new SshToolsConnectionTab[] { new SshTermCommandTab(), new SshTermTerminalTab(), new GSIAuthTab(), new XForwardingTab() }; SshTerminalPanel.PREF_KRB5_MYPROXY_ENABLED = false; } // //portForwardingPane = new PortForwardingPane(); // Printing page format try { if (System.getSecurityManager() != null) { AccessController.checkPermission(new RuntimePermission("queuePrintJob")); } try { PrinterJob job = PrinterJob.getPrinterJob(); if (job == null) { throw new IOException("Could not get print page format."); } pageFormat = job.defaultPage(); if (PreferencesStore.preferenceExists(PREF_PAGE_FORMAT_ORIENTATION)) { pageFormat.setOrientation( PreferencesStore.getInt(PREF_PAGE_FORMAT_ORIENTATION, PageFormat.LANDSCAPE)); Paper paper = new Paper(); paper.setImageableArea(PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_X, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_Y, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_W, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_H, 0)); paper.setSize(PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_W, 0), PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_H, 0)); pageFormat.setPaper(paper); } } catch (Exception e) { showExceptionMessage("Error", e.getMessage()); } } catch (AccessControlException ace) { ace.printStackTrace(); } enableEvents(VDU_EVENTS); // Set up the actions initActions(); // Create the status bar statusBar = new StatusBar(); dataListener = new DataNotificationListener(statusBar); // Create our terminal emulation object try { emulation = createEmulation(); } catch (IOException ioe) { throw new SshToolsApplicationException(ioe); } emulation.addTerminalListener(this); // Set a scrollbar for the terminal - doesn't seem to be as simple as this scrollBar = new JScrollBar(JScrollBar.VERTICAL); emulation.setBufferSize(1000); // Create our swing terminal and add it to the main frame terminal = new TerminalPanel(emulation) { public void processEvent(AWTEvent evt) { /** We can't add a MouseWheelListener because it was not available in 1.3, so direct processing of events is necessary */ if (evt instanceof MouseEvent && evt.getID() == 507) { try { Method m = evt.getClass().getMethod("getWheelRotation", new Class[] {}); SshTerminalPanel.this.scrollBar.setValue(SshTerminalPanel.this.scrollBar.getValue() + (SshTerminalPanel.this.scrollBar.getUnitIncrement() * ((Integer) m.invoke(evt, new Object[] {})).intValue() * PreferencesStore.getInt(PREF_MOUSE_WHEEL_INCREMENT, 1))); } catch (Throwable t) { // In theory, this should never happen } } else { super.processEvent(evt); } } public void copyNotify() { copyAction.actionPerformed(null); } }; terminal.requestFocus(); terminal.setScrollbar(scrollBar); terminal.addMouseMotionListener(this); //terminal.addMouseWheelListener(this); // Center panel with terminal and scrollbar JPanel center = new JPanel(new BorderLayout()); center.setBackground(Color.red); center.add(terminal, BorderLayout.CENTER); center.add(scrollBar, BorderLayout.EAST); // Show the context menu on mouse button 3 (right click) terminal.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) > 0) { getContextMenu() .setLabel((getCurrentConnectionFile() == null) ? getApplication().getApplicationName() : getCurrentConnectionFile().getName()); getContextMenu().show(terminal, evt.getX(), evt.getY()); } else if ((evt.getModifiers() & MouseEvent.BUTTON2_MASK) > 0) { pasteAction.actionPerformed(null); } } }); // // JPanel top = new JPanel(new BorderLayout()); // top.add(getJMenuBar(), BorderLayout.NORTH); // top.add(north, BorderLayout.SOUTH); setLayout(new BorderLayout()); add(center, BorderLayout.CENTER); // add(top, BorderLayout.NORTH); // Make sure that the swing terminal has focus terminal.requestFocus(); }