List of usage examples for java.awt AWTPermission AWTPermission
public AWTPermission(String name)
From source file:Main.java
public static void main(String args[]) throws Exception { AWTPermission ap = new AWTPermission("accessClipboard"); AccessController.checkPermission(ap); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { SecurityManager sm = System.getSecurityManager(); if (sm != null) { FilePermission fp = new FilePermission("c:\\autoexec.bat", "read"); sm.checkPermission(fp);/*from ww w . j a va 2s. c om*/ } if (sm != null) { AWTPermission ap = new AWTPermission("accessClipboard"); sm.checkPermission(ap); } System.out.println("Has AWTPermission to access AWT Clipboard"); }
From source file:com.sshtools.sshterm.SshTermSessionPanel.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)); registerActionMenu(new SshToolsApplicationPanel.ActionMenu("Help", "Help", 'h', 90)); actions = new Vector(); connectionPropertiesAction = new ConnectionPropertiesActionImpl(); registerAction(connectionPropertiesAction); // newAction = new NewAction(); // registerAction(newAction); // Only allow opening of files if allowed by the security manager try {//ww w. j a va 2s .c om if (System.getSecurityManager() != null) { AccessController.checkPermission(new FilePermission("<<ALL FILES>>", "read")); } //openAction = new OpenAction(); // registerAction(openAction); playAction = new PlayAction(); registerAction(playAction); } catch (AccessControlException ace) { log.warn("File reading actions are not available"); } // 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(); // registerAction(saveAction); // saveAsAction = new SaveAsAction(); // registerAction(saveAsAction); recordAction = new RecordAction(); registerAction(recordAction); stopAction = new StopAction(); registerAction(stopAction); } catch (AccessControlException ace) { log.warn("File write actions are not available"); } // 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 EditActionImpl(); // registerAction(editAction); } catch (AccessControlException ace) { log.warn("Read / write actions are not available"); } // Checking if printing is allowed if (pageFormat != null) { try { if (System.getSecurityManager() != null) { AccessController.checkPermission(new RuntimePermission("queuePrintJob")); } printAction = new PrintActionImpl(); registerAction(printAction); printPreviewAction = new PrintPreviewActionImpl(); registerAction(printPreviewAction); } catch (AccessControlException ace) { log.warn("Print actions are not available"); } } // Always allow refreshing of terminal refreshAction = new RefreshActionImpl(); registerAction(refreshAction); // Always allow closing of connect closeAction = new CloseAction(); registerAction(closeAction); // Copy / Paste try { if (System.getSecurityManager() != null) { AccessController.checkPermission(new AWTPermission("accessClipboard")); } copyAction = new CopyActionImpl(); registerAction(copyAction); pasteAction = new PasteActionImpl(); registerAction(pasteAction); } catch (AccessControlException ace) { } // Theres no point in having the keygen action if we can't write to local file try { if (System.getSecurityManager() != null) { AccessController.checkPermission(new FilePermission("<<ALL FILES>>", "write")); } // keygenAction = new KeygenAction(); // registerAction(keygenAction); } catch (AccessControlException ace) { log.warn("Keygen actions is not available"); } // Clear action clearAction = new ClearActionImpl(); registerAction(clearAction); // Remove stuff we dont want deregisterAction(getAction("Options")); setActionVisible("New Window", false); setActionVisible("About", false); }
From source file:com.sshtools.sshterm.SshTerminalPanel.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)); registerActionMenu(new SshToolsApplicationPanel.ActionMenu("Proxy", "Proxy", 'p', 80)); registerActionMenu(new SshToolsApplicationPanel.ActionMenu("Help", "Help", 'h', 90)); actions = new Vector(); // MRU/* w ww. j av a 2 s . c o m*/ if (getApplication().getMRUModel() != null) { registerAction(mruAction = new MRUActionImpl(getApplication().getMRUModel())); } // connectionPropertiesAction = new ConnectionPropertiesActionImpl(); registerAction(connectionPropertiesAction); newAction = new NewAction(); registerAction(newAction); // 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(); registerAction(openAction); playAction = new PlayAction(); registerAction(playAction); } catch (AccessControlException ace) { log.warn("File reading actions are not available"); } // 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(); registerAction(saveAction); saveAsAction = new SaveAsAction(); registerAction(saveAsAction); recordAction = new RecordAction(); registerAction(recordAction); stopAction = new StopAction(); registerAction(stopAction); } catch (AccessControlException ace) { log.warn("File write actions are not available"); } // 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 EditActionImpl(); registerAction(editAction); } catch (AccessControlException ace) { log.warn("Read / write actions are not available"); } // Checking if printing is allowed if (pageFormat != null) { try { if (System.getSecurityManager() != null) { AccessController.checkPermission(new RuntimePermission("queuePrintJob")); } printAction = new PrintActionImpl(); registerAction(printAction); printPreviewAction = new PrintPreviewActionImpl(); registerAction(printPreviewAction); } catch (AccessControlException ace) { log.warn("Print actions are not available"); } } // Always allow refreshing of terminal refreshAction = new RefreshActionImpl(); registerAction(refreshAction); // Always allow closing of connect closeAction = new CloseAction(); registerAction(closeAction); // Copy / Paste try { if (System.getSecurityManager() != null) { AccessController.checkPermission(new AWTPermission("accessClipboard")); } copyAction = new CopyActionImpl(); registerAction(copyAction); pasteAction = new PasteActionImpl(); registerAction(pasteAction); } catch (AccessControlException ace) { } // Theres no point in having the keygen action if we can't write to local file try { if (System.getSecurityManager() != null) { AccessController.checkPermission(new FilePermission("<<ALL FILES>>", "write")); } keygenAction = new KeygenAction(); registerAction(keygenAction); } catch (AccessControlException ace) { log.warn("Keygen actions is not available"); } // Clear action clearAction = new ClearActionImpl(); registerAction(clearAction); // GSI options proxyInfoAction = new ProxyInfoAction(); registerAction(proxyInfoAction); proxyDestroyAction = new ProxyDestroyAction(); registerAction(proxyDestroyAction); // Secure Tunneling /*try { SessionProvider provider = SessionProviderFactory.getInstance().getProvider("tunneling"); if(provider!=null) { tunnelingAction = (StandardAction)new SessionProviderAction( provider); registerAction(tunnelingAction); } } catch (Throwable t) { log.info( "Secure Tunneling not available on CLASSPATH"); } // ShiFT action try { SessionProvider provider = SessionProviderFactory.getInstance().getProvider("shift"); if(provider!=null) { shiftAction = (StandardAction)new SessionProviderAction( provider); registerAction(shiftAction); } } catch (Throwable t) { log.info( "ShiFT not available on CLASSPATH"); }*/ 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); registerAction(action); } }