List of usage examples for java.lang SecurityException getMessage
public String getMessage()
From source file:org.apache.nifi.processors.hadoop.AbstractHadoopProcessor.java
public static final Validator createMultipleFilesExistValidator() { return new Validator() { @Override//from ww w. j ava2 s.c om public ValidationResult validate(String subject, String input, ValidationContext context) { final String[] files = input.split(","); for (String filename : files) { try { final File file = new File(filename.trim()); final boolean valid = file.exists() && file.isFile(); if (!valid) { final String message = "File " + file + " does not exist or is not a file"; return new ValidationResult.Builder().subject(subject).input(input).valid(false) .explanation(message).build(); } } catch (SecurityException e) { final String message = "Unable to access " + filename + " due to " + e.getMessage(); return new ValidationResult.Builder().subject(subject).input(input).valid(false) .explanation(message).build(); } } return new ValidationResult.Builder().subject(subject).input(input).valid(true).build(); } }; }
From source file:BrowserLauncher.java
/** * Called by a static initializer to load any classes, fields, and methods required at runtime * to locate the user's web browser./*from w w w .ja v a2s . c o m*/ * @return <code>true</code> if all intialization succeeded * <code>false</code> if any portion of the initialization failed */ private static boolean loadClasses() { switch (jvm) { case MRJ_2_0: try { Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget"); Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils"); Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent"); Class aeClass = Class.forName("com.apple.MacOS.ae"); aeDescClass = Class.forName("com.apple.MacOS.AEDesc"); aeTargetConstructor = aeTargetClass.getDeclaredConstructor(new Class[] { int.class }); appleEventConstructor = appleEventClass.getDeclaredConstructor( new Class[] { int.class, int.class, aeTargetClass, int.class, int.class }); aeDescConstructor = aeDescClass.getDeclaredConstructor(new Class[] { String.class }); makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", new Class[] { String.class }); putParameter = appleEventClass.getDeclaredMethod("putParameter", new Class[] { int.class, aeDescClass }); sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", new Class[] {}); Field keyDirectObjectField = aeClass.getDeclaredField("keyDirectObject"); keyDirectObject = (Integer) keyDirectObjectField.get(null); Field autoGenerateReturnIDField = appleEventClass.getDeclaredField("kAutoGenerateReturnID"); kAutoGenerateReturnID = (Integer) autoGenerateReturnIDField.get(null); Field anyTransactionIDField = appleEventClass.getDeclaredField("kAnyTransactionID"); kAnyTransactionID = (Integer) anyTransactionIDField.get(null); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (NoSuchFieldException nsfe) { errorMessage = nsfe.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_2_1: try { mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType"); Field systemFolderField = mrjFileUtilsClass.getDeclaredField("kSystemFolderType"); kSystemFolderType = systemFolderField.get(null); findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", new Class[] { mrjOSTypeClass }); getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", new Class[] { File.class }); getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", new Class[] { File.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchFieldException nsfe) { errorMessage = nsfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (SecurityException se) { errorMessage = se.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_3_0: try { Class linker = Class.forName("com.apple.mrj.jdirect.Linker"); Constructor constructor = linker.getConstructor(new Class[] { Class.class }); linkage = constructor.newInstance(new Object[] { BrowserLauncher.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (InvocationTargetException ite) { errorMessage = ite.getMessage(); return false; } catch (InstantiationException ie) { errorMessage = ie.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_3_1: try { mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", new Class[] { String.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } break; default: break; } return true; }
From source file:org.kuali.rice.core.framework.persistence.jpa.metadata.MetadataManager.java
/** * Retrieves the primary key as an object for the given Object (which is assumed to be a JPA entity). If the entity has a single field * primary key, the value of that field is returned. If a composite key is needed, it will be constructed and populated with the correct * values. If a problem occurs, a null will be returned * /*from w ww . j ava2 s. c o m*/ * @param object the object to get a primary key value from * @return a primary key value */ public static Object getEntityPrimaryKeyObject(Object object) { final EntityDescriptor descriptor = getEntityDescriptor(object.getClass()); final Class idClass = descriptor.getIdClass(); if (idClass != null) { try { Object pkObject = idClass.newInstance(); for (FieldDescriptor fieldDescriptor : descriptor.getPrimaryKeys()) { Field field = getField(object.getClass(), fieldDescriptor.getName()); field.setAccessible(true); final Object value = field.get(object); if (value != null) { final Field fieldToSet = getField(pkObject.getClass(), fieldDescriptor.getName()); fieldToSet.setAccessible(true); fieldToSet.set(pkObject, value); } } return pkObject; } catch (SecurityException se) { LOG.error(se.getMessage(), se); } catch (InstantiationException ie) { LOG.error(ie.getMessage(), ie); } catch (IllegalAccessException iae) { LOG.error(iae.getMessage(), iae); } catch (NoSuchFieldException nsfe) { LOG.error(nsfe.getMessage(), nsfe); } } else { for (FieldDescriptor fieldDescriptor : descriptor.getPrimaryKeys()) { try { Field field = getField(object.getClass(), fieldDescriptor.getName()); field.setAccessible(true); return field.get(object); // there's only one value, let's kick out } catch (Exception e) { LOG.error(e.getMessage(), e); } } } return null; }
From source file:org.kuali.rice.core.framework.persistence.jpa.metadata.MetadataManager.java
/** * Retrieves the primary key as an object for the given Object (which is assumed to be a JPA entity), filling it with values from the extension. * If the entity has a single field primary key, the value of that field from the extension is returned. If a composite key is needed, it will be * constructed (based on the id class for the extension object) and populated with the correct values from the extension. If a problem occurs, * a null will be returned.//from w w w .j a v a 2 s.c om * * @param owner the object to get values from * @param extension the object to build a key for * @return a primary key value */ public static Object getPersistableBusinessObjectPrimaryKeyObjectWithValuesForExtension(Object owner, Object extension) { final EntityDescriptor descriptor = getEntityDescriptor(extension.getClass()); final Class idClass = descriptor.getIdClass(); if (idClass != null) { try { Object pkObject = idClass.newInstance(); for (FieldDescriptor fieldDescriptor : descriptor.getPrimaryKeys()) { Field field = getField(owner.getClass(), fieldDescriptor.getName()); field.setAccessible(true); final Object value = field.get(owner); if (value != null) { final Field fieldToSet = getField(pkObject.getClass(), fieldDescriptor.getName()); fieldToSet.setAccessible(true); fieldToSet.set(pkObject, value); } } return pkObject; } catch (SecurityException se) { LOG.error(se.getMessage(), se); } catch (InstantiationException ie) { LOG.error(ie.getMessage(), ie); } catch (IllegalAccessException iae) { LOG.error(iae.getMessage(), iae); } catch (NoSuchFieldException nsfe) { LOG.error(nsfe.getMessage(), nsfe); } } else { for (FieldDescriptor fieldDescriptor : descriptor.getPrimaryKeys()) { try { Field field = getField(owner.getClass(), fieldDescriptor.getName()); field.setAccessible(true); final Object value = field.get(owner); return value; // there's only one value, let's kick out } catch (Exception e) { LOG.error(e.getMessage(), e); } } } return null; }
From source file:com.piusvelte.taplock.server.TapLockServer.java
private static void initialize() { (new File(APP_PATH)).mkdir(); if (OS == OS_WIN) Security.addProvider(new BouncyCastleProvider()); System.out.println("APP_PATH: " + APP_PATH); try {//from ww w .jav a 2 s .c om sLogFileHandler = new FileHandler(sLog); } catch (SecurityException e) { writeLog("sLogFileHandler init: " + e.getMessage()); } catch (IOException e) { writeLog("sLogFileHandler init: " + e.getMessage()); } File propertiesFile = new File(sProperties); if (!propertiesFile.exists()) { try { propertiesFile.createNewFile(); } catch (IOException e) { writeLog("propertiesFile.createNewFile: " + e.getMessage()); } } Properties prop = new Properties(); try { prop.load(new FileInputStream(sProperties)); if (prop.isEmpty()) { prop.setProperty(sPassphraseKey, sPassphrase); prop.setProperty(sDisplaySystemTrayKey, Boolean.toString(sDisplaySystemTray)); prop.setProperty(sDebuggingKey, Boolean.toString(sDebugging)); prop.store(new FileOutputStream(sProperties), null); } else { if (prop.containsKey(sPassphraseKey)) sPassphrase = prop.getProperty(sPassphraseKey); else prop.setProperty(sPassphraseKey, sPassphrase); if (prop.containsKey(sDisplaySystemTrayKey)) sDisplaySystemTray = Boolean.parseBoolean(prop.getProperty(sDisplaySystemTrayKey)); else prop.setProperty(sDisplaySystemTrayKey, Boolean.toString(sDisplaySystemTray)); if (prop.containsKey(sDebuggingKey)) sDebugging = Boolean.parseBoolean(prop.getProperty(sDebuggingKey)); else prop.setProperty(sDebuggingKey, Boolean.toString(sDebugging)); } } catch (FileNotFoundException e) { writeLog("prop load: " + e.getMessage()); } catch (IOException e) { writeLog("prop load: " + e.getMessage()); } if (sLogFileHandler != null) { sLogger = Logger.getLogger("TapLock"); sLogger.setUseParentHandlers(false); sLogger.addHandler(sLogFileHandler); SimpleFormatter sf = new SimpleFormatter(); sLogFileHandler.setFormatter(sf); writeLog("service starting"); } if (sDisplaySystemTray && SystemTray.isSupported()) { final SystemTray systemTray = SystemTray.getSystemTray(); Image trayIconImg = Toolkit.getDefaultToolkit() .getImage(TapLockServer.class.getResource("/systemtrayicon.png")); final TrayIcon trayIcon = new TrayIcon(trayIconImg, "Tap Lock"); trayIcon.setImageAutoSize(true); PopupMenu popupMenu = new PopupMenu(); MenuItem aboutItem = new MenuItem("About"); CheckboxMenuItem toggleSystemTrayIcon = new CheckboxMenuItem("Display Icon in System Tray"); toggleSystemTrayIcon.setState(sDisplaySystemTray); CheckboxMenuItem toggleDebugging = new CheckboxMenuItem("Debugging"); toggleDebugging.setState(sDebugging); MenuItem shutdownItem = new MenuItem("Shutdown Tap Lock Server"); popupMenu.add(aboutItem); popupMenu.add(toggleSystemTrayIcon); if (OS == OS_WIN) { MenuItem setPasswordItem = new MenuItem("Set password"); popupMenu.add(setPasswordItem); setPasswordItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JPanel panel = new JPanel(); JLabel label = new JLabel("Enter your Windows account password:"); JPasswordField passField = new JPasswordField(32); panel.add(label); panel.add(passField); String[] options = new String[] { "OK", "Cancel" }; int option = JOptionPane.showOptionDialog(null, panel, "Tap Lock", JOptionPane.NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]); if (option == 0) { String password = encryptString(new String(passField.getPassword())); if (password != null) { Properties prop = new Properties(); try { prop.load(new FileInputStream(sProperties)); prop.setProperty(sPasswordKey, password); prop.store(new FileOutputStream(sProperties), null); } catch (FileNotFoundException e1) { writeLog("prop load: " + e1.getMessage()); } catch (IOException e1) { writeLog("prop load: " + e1.getMessage()); } } } } }); } popupMenu.add(toggleDebugging); popupMenu.add(shutdownItem); trayIcon.setPopupMenu(popupMenu); try { systemTray.add(trayIcon); } catch (AWTException e) { writeLog("systemTray.add: " + e.getMessage()); } aboutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String newline = System.getProperty("line.separator"); newline += newline; JOptionPane.showMessageDialog(null, "Tap Lock" + newline + "Copyright (c) 2012 Bryan Emmanuel" + newline + "This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version." + newline + "This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details." + newline + "You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>." + newline + "Bryan Emmanuel piusvelte@gmail.com"); } }); toggleSystemTrayIcon.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { setTrayIconDisplay(e.getStateChange() == ItemEvent.SELECTED); if (!sDisplaySystemTray) systemTray.remove(trayIcon); } }); toggleDebugging.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { setDebugging(e.getStateChange() == ItemEvent.SELECTED); } }); shutdownItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { shutdown(); } }); } synchronized (sConnectionThreadLock) { (sConnectionThread = new ConnectionThread()).start(); } }
From source file:net.sf.joost.trax.TrAXHelper.java
/** * Helpermethod for getting an InputSource from a StreamSource. * @param source <code>Source</code> * @return An <code>InputSource</code> object or null * @throws TransformerConfigurationException *///from w w w. java 2 s. co m protected static InputSource getInputSourceForStreamSources(Source source, ErrorListener errorListener) throws TransformerConfigurationException { if (DEBUG) log.debug("getting an InputSource from a StreamSource"); InputSource input = null; String systemId = source.getSystemId(); if (systemId == null) { systemId = ""; } try { if (source instanceof StreamSource) { if (DEBUG) log.debug("Source is a StreamSource"); StreamSource stream = (StreamSource) source; InputStream istream = stream.getInputStream(); Reader reader = stream.getReader(); // Create InputSource from Reader or InputStream in Source if (istream != null) { input = new InputSource(istream); } else { if (reader != null) { input = new InputSource(reader); } else { input = new InputSource(systemId); } } } else { //Source type is not supported if (errorListener != null) { try { errorListener .fatalError(new TransformerConfigurationException("Source is not a StreamSource")); return null; } catch (TransformerException e2) { if (DEBUG) log.debug("Source is not a StreamSource"); throw new TransformerConfigurationException("Source is not a StreamSource"); } } if (DEBUG) log.debug("Source is not a StreamSource"); throw new TransformerConfigurationException("Source is not a StreamSource"); } //setting systemId input.setSystemId(systemId); // } catch (NullPointerException nE) { // //catching NullPointerException // if(errorListener != null) { // try { // errorListener.fatalError( // new TransformerConfigurationException(nE)); // return null; // } catch( TransformerException e2) { // log.debug(nE); // throw new TransformerConfigurationException(nE.getMessage()); // } // } // log.debug(nE); // throw new TransformerConfigurationException(nE.getMessage()); } catch (SecurityException sE) { //catching SecurityException if (errorListener != null) { try { errorListener.fatalError(new TransformerConfigurationException(sE)); return null; } catch (TransformerException e2) { if (DEBUG) log.debug(sE); throw new TransformerConfigurationException(sE.getMessage()); } } if (DEBUG) log.debug(sE); throw new TransformerConfigurationException(sE.getMessage()); } return (input); }
From source file:Browser.java
/** * Called by a static initializer to load any classes, fields, and methods * required at runtime to locate the user's web browser. * @return <code>true</code> if all intialization succeeded * <code>false</code> if any portion of the initialization failed *//*from www . ja va 2 s . co m*/ private static boolean loadClasses() { switch (jvm) { case MRJ_2_0: try { Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget"); Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils"); Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent"); Class aeClass = Class.forName("com.apple.MacOS.ae"); aeDescClass = Class.forName("com.apple.MacOS.AEDesc"); aeTargetConstructor = aeTargetClass.getDeclaredConstructor(new Class[] { int.class }); appleEventConstructor = appleEventClass.getDeclaredConstructor( new Class[] { int.class, int.class, aeTargetClass, int.class, int.class }); aeDescConstructor = aeDescClass.getDeclaredConstructor(new Class[] { String.class }); makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", new Class[] { String.class }); putParameter = appleEventClass.getDeclaredMethod("putParameter", new Class[] { int.class, aeDescClass }); sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", new Class[] {}); Field keyDirectObjectField = aeClass.getDeclaredField("keyDirectObject"); keyDirectObject = (Integer) keyDirectObjectField.get(null); Field autoGenerateReturnIDField = appleEventClass.getDeclaredField("kAutoGenerateReturnID"); kAutoGenerateReturnID = (Integer) autoGenerateReturnIDField.get(null); Field anyTransactionIDField = appleEventClass.getDeclaredField("kAnyTransactionID"); kAnyTransactionID = (Integer) anyTransactionIDField.get(null); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (NoSuchFieldException nsfe) { errorMessage = nsfe.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_2_1: try { mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType"); Field systemFolderField = mrjFileUtilsClass.getDeclaredField("kSystemFolderType"); kSystemFolderType = systemFolderField.get(null); findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", new Class[] { mrjOSTypeClass }); getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", new Class[] { File.class }); getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", new Class[] { File.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchFieldException nsfe) { errorMessage = nsfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (SecurityException se) { errorMessage = se.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_3_0: try { Class linker = Class.forName("com.apple.mrj.jdirect.Linker"); Constructor constructor = linker.getConstructor(new Class[] { Class.class }); linkage = constructor.newInstance(new Object[] { Browser.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (InvocationTargetException ite) { errorMessage = ite.getMessage(); return false; } catch (InstantiationException ie) { errorMessage = ie.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_3_1: try { mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", new Class[] { String.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } break; default: break; } return true; }
From source file:fxts.stations.util.BrowserLauncher.java
/** * Called by a static initializer to load any classes, fields, and methods required at runtime * to locate the user's web browser.//from ww w . j a v a2 s . c om * * @return <code>true</code> if all intialization succeeded * <code>false</code> if any portion of the initialization failed */ private static boolean loadClasses() { switch (jvm) { case MRJ_2_0: try { Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget"); Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils"); Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent"); Class aeClass = Class.forName("com.apple.MacOS.ae"); aeDescClass = Class.forName("com.apple.MacOS.AEDesc"); aeTargetConstructor = aeTargetClass.getDeclaredConstructor(new Class[] { int.class }); appleEventConstructor = appleEventClass.getDeclaredConstructor( new Class[] { int.class, int.class, aeTargetClass, int.class, int.class }); aeDescConstructor = aeDescClass.getDeclaredConstructor(new Class[] { String.class }); makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", new Class[] { String.class }); putParameter = appleEventClass.getDeclaredMethod("putParameter", new Class[] { int.class, aeDescClass }); sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", new Class[] {}); Field keyDirectObjectField = aeClass.getDeclaredField("keyDirectObject"); keyDirectObject = (Integer) keyDirectObjectField.get(null); Field autoGenerateReturnIDField = appleEventClass.getDeclaredField("kAutoGenerateReturnID"); kAutoGenerateReturnID = (Integer) autoGenerateReturnIDField.get(null); Field anyTransactionIDField = appleEventClass.getDeclaredField("kAnyTransactionID"); kAnyTransactionID = (Integer) anyTransactionIDField.get(null); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (NoSuchFieldException nsfe) { errorMessage = nsfe.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_2_1: try { mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType"); Field systemFolderField = mrjFileUtilsClass.getDeclaredField("kSystemFolderType"); kSystemFolderType = systemFolderField.get(null); findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", new Class[] { mrjOSTypeClass }); getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", new Class[] { File.class }); getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", new Class[] { File.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchFieldException nsfe) { errorMessage = nsfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (SecurityException se) { errorMessage = se.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_3_0: try { Class linker = Class.forName("com.apple.mrj.jdirect.Linker"); Constructor constructor = linker.getConstructor(new Class[] { Class.class }); linkage = constructor.newInstance(new Object[] { BrowserLauncher.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } catch (InvocationTargetException ite) { errorMessage = ite.getMessage(); return false; } catch (InstantiationException ie) { errorMessage = ie.getMessage(); return false; } catch (IllegalAccessException iae) { errorMessage = iae.getMessage(); return false; } break; case MRJ_3_1: try { mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", new Class[] { String.class }); } catch (ClassNotFoundException cnfe) { errorMessage = cnfe.getMessage(); return false; } catch (NoSuchMethodException nsme) { errorMessage = nsme.getMessage(); return false; } break; default: break; } return true; }
From source file:org.apache.manifoldcf.agents.output.filesystem.FileOutputConnector.java
protected static void handleSecurityException(SecurityException e) throws ManifoldCFException, ServiceInterruption { Logging.agents.error("FileSystem: SecurityException: " + e.getMessage(), e); throw new ManifoldCFException(e.getMessage(), e); }
From source file:org.lmn.fc.common.datatranslators.DataExporter.java
/*********************************************************************************************** * exportInstrumentXML().// w ww .j a v a 2 s.c om * Saves the current Instrument XML at the specified location. * * @param filename * @param timestamp * @param instrument * @param log * @param clock * * @return boolean */ public static boolean exportInstrumentXML(final String filename, final boolean timestamp, final Instrument instrument, final Vector<Vector> log, final ObservatoryClockInterface clock) { final String SOURCE = "DataExporter.exportInstrumentXML()"; boolean boolSuccess; boolSuccess = false; if ((filename != null) && (!EMPTY_STRING.equals(filename)) && (instrument != null) && (log != null) && (clock != null)) { try { final File file; final OutputStream outputStream; file = new File(FileUtilities.buildFullFilename(filename, timestamp, DataFormat.XML)); FileUtilities.overwriteFile(file); outputStream = new FileOutputStream(file); instrument.save(outputStream, getXmlOptions()); boolSuccess = true; // Tidy up outputStream.flush(); outputStream.close(); SimpleEventLogUIComponent.logEvent(log, EventStatus.INFO, METADATA_TARGET_XML + METADATA_ACTION_EXPORT + METADATA_FILENAME + file.getAbsolutePath() + TERMINATOR, SOURCE, clock); } catch (SecurityException exception) { SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL, METADATA_TARGET_XML + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_ACCESS_DENIED + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR, SOURCE, clock); } catch (FileNotFoundException exception) { SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL, METADATA_TARGET_XML + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_FILE_NOT_FOUND + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR, SOURCE, clock); } catch (IOException exception) { SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL, METADATA_TARGET_XML + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_FILE_SAVE + TERMINATOR + SPACE + METADATA_EXCEPTION + exception.getMessage() + TERMINATOR, SOURCE, clock); } } else { SimpleEventLogUIComponent.logEvent(log, EventStatus.FATAL, METADATA_TARGET_XML + METADATA_ACTION_EXPORT + METADATA_RESULT + ERROR_XML + TERMINATOR, SOURCE, clock); } return (boolSuccess); }