List of usage examples for java.lang SecurityException toString
public String toString()
From source file:org.opendatakit.services.utilities.Base64Wrapper.java
public String encodeToString(byte[] ba) { Class<?>[] argClassList = new Class[] { byte[].class, int.class }; try {/*from w w w . j ava 2 s . c o m*/ Method m = base64.getDeclaredMethod("encode", argClassList); Object[] argList = new Object[] { ba, FLAGS }; Object o = m.invoke(null, argList); byte[] outArray = (byte[]) o; String s = new String(outArray, CharEncoding.UTF_8); return s; } catch (SecurityException e) { e.printStackTrace(); throw new IllegalArgumentException(e.toString()); } catch (NoSuchMethodException e) { WebLogger.getLogger(appName).printStackTrace(e); throw new IllegalArgumentException(e.toString()); } catch (IllegalAccessException e) { WebLogger.getLogger(appName).printStackTrace(e); throw new IllegalArgumentException(e.toString()); } catch (InvocationTargetException e) { WebLogger.getLogger(appName).printStackTrace(e); throw new IllegalArgumentException(e.toString()); } catch (UnsupportedEncodingException e) { WebLogger.getLogger(appName).printStackTrace(e); throw new IllegalArgumentException(e.toString()); } }
From source file:org.xwalk.runtime.extension.api.contacts.Contacts.java
private void handleClear() { Cursor c = null;//ww w . j a v a2 s . c o m try { c = mResolver.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); while (c.moveToNext()) { String key = c.getString(c.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)); Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, key); mResolver.delete(uri, null, null); } } catch (SecurityException e) { Log.e(TAG, "handleClear - failed to query: " + e.toString()); } finally { if (c != null) c.close(); } }
From source file:org.opendatakit.services.utilities.Base64Wrapper.java
public byte[] decode(String base64String) { Class<?>[] argClassList = new Class[] { String.class, int.class }; Object o;//from www .ja v a2 s . co m try { Method m = base64.getDeclaredMethod("decode", argClassList); Object[] argList = new Object[] { base64String, FLAGS }; o = m.invoke(null, argList); } catch (SecurityException e) { WebLogger.getLogger(appName).printStackTrace(e); throw new IllegalArgumentException(e.toString()); } catch (NoSuchMethodException e) { WebLogger.getLogger(appName).printStackTrace(e); throw new IllegalArgumentException(e.toString()); } catch (IllegalAccessException e) { WebLogger.getLogger(appName).printStackTrace(e); throw new IllegalArgumentException(e.toString()); } catch (InvocationTargetException e) { WebLogger.getLogger(appName).printStackTrace(e); throw new IllegalArgumentException(e.toString()); } return (byte[]) o; }
From source file:edu.teco.context.ui.FileChooserDialogFragment.java
private void loadFileList() { try {//from w w w .j a va 2s .co m mPath.mkdirs(); } catch (SecurityException e) { if (FrameworkContext.ERROR) Log.e(TAG, "unable to write on the sd card " + e.toString()); } if (mPath.exists()) { FilenameFilter filter = new FilenameFilter() { public boolean accept(File dir, String filename) { File sel = new File(dir, filename); return filename.contains(mFileType) || sel.isDirectory(); } }; mFileList = mPath.list(filter); } else { mFileList = new String[0]; } }
From source file:org.omegat.util.StaticUtils.java
/** * Returns the location of the configuration directory, depending on the * user's platform. Also creates the configuration directory, if necessary. * If any problems occur while the location of the configuration directory * is being determined, an empty string will be returned, resulting in the * current working directory being used. * * <ul><li>Windows XP: <Documents and Settings>\<User name>\Application Data\OmegaT * <li>Windows Vista: User\<User name>\AppData\Roaming * <li>Linux: ~/.omegat /* w ww . j a v a 2s .com*/ * <li>Solaris/SunOS: ~/.omegat * <li>FreeBSD: ~/.omegat * <li>Mac OS X: ~/Library/Preferences/OmegaT * <li>Other: User home directory * </ul> * * @return The full path of the directory containing the OmegaT * configuration files, including trailing path separator. */ public static String getConfigDir() { // if the configuration directory has already been determined, return it if (m_configDir != null) { return m_configDir; } String cd = RuntimePreferences.getConfigDir(); if (cd != null) { // use the forced specified directory m_configDir = new File(cd).getAbsolutePath() + File.separator; return m_configDir; } OsType os = Platform.getOsType(); // name of operating system String home; // user home directory // get os and user home properties try { // get the user's home directory home = System.getProperty("user.home"); } catch (SecurityException e) { // access to the os/user home properties is restricted, // the location of the config dir cannot be determined, // set the config dir to the current working dir m_configDir = new File(".").getAbsolutePath() + File.separator; // log the exception, only do this after the config dir // has been set to the current working dir, otherwise // the log method will probably fail Log.logErrorRB("SU_USERHOME_PROP_ACCESS_ERROR"); Log.log(e.toString()); return m_configDir; } // if os or user home is null or empty, we cannot reliably determine // the config dir, so we use the current working dir (= empty string) if (os == null || StringUtil.isEmpty(home)) { // set the config dir to the current working dir m_configDir = new File(".").getAbsolutePath() + File.separator; return m_configDir; } // check for Windows versions if (os == OsType.WIN32 || os == OsType.WIN64) { String appData = null; // We do not use %APPDATA% // Trying first Vista/7, because "Application Data" exists also as virtual folder, // so we would not be able to differentiate with 2000/XP otherwise File appDataFile = new File(home, "AppData\\Roaming"); if (appDataFile.exists()) { appData = appDataFile.getAbsolutePath(); } else { // Trying to locate "Application Data" for 2000 and XP // C:\Documents and Settings\<User>\Application Data appDataFile = new File(home, "Application Data"); if (appDataFile.exists()) { appData = appDataFile.getAbsolutePath(); } } if (!StringUtil.isEmpty(appData)) { // if a valid application data dir has been found, // append an OmegaT subdir to it m_configDir = appData + WINDOWS_CONFIG_DIR; } else { // otherwise set the config dir to the user's home directory, // usually // C:\Documents and Settings\<User>\OmegaT m_configDir = home + WINDOWS_CONFIG_DIR; } } // Check for UNIX varieties // Solaris is generally detected as SunOS else if (os == OsType.LINUX32 || os == OsType.LINUX64 || os == OsType.OTHER) { // set the config dir to the user's home dir + "/.omegat/", so it's // hidden m_configDir = home + UNIX_CONFIG_DIR; } // check for Mac OS X else if (Platform.isMacOSX()) { // set the config dir to the user's home dir + // "/Library/Preferences/OmegaT/" m_configDir = home + OSX_CONFIG_DIR; } // other OSes / default else { // use the user's home directory by default m_configDir = home + File.separator; } // create the path to the configuration dir, if necessary if (!m_configDir.isEmpty()) { try { // check if the dir exists File dir = new File(m_configDir); if (!dir.exists()) { // create the dir boolean created = dir.mkdirs(); // if the dir could not be created, // set the config dir to the current working dir if (!created) { Log.logErrorRB("SU_CONFIG_DIR_CREATE_ERROR"); m_configDir = new File(".").getAbsolutePath() + File.separator; } } } catch (SecurityException e) { // the system doesn't want us to write where we want to write // reset the config dir to the current working dir m_configDir = new File(".").getAbsolutePath() + File.separator; // log the exception, but only after the config dir has been // reset Log.logErrorRB("SU_CONFIG_DIR_CREATE_ERROR"); Log.log(e.toString()); } } // we should have a correct, existing config dir now return m_configDir; }
From source file:org.xwalk.runtime.extension.api.contacts.ContactEventListener.java
private HashSet<String> getAllContactIDs() { Cursor c = null;//ww w . j a v a2 s . c o m try { c = mResolver.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); HashSet<String> contactIDs = new HashSet<String>(); while (c.moveToNext()) { String contactID = c.getString(c.getColumnIndex(ContactsContract.Contacts._ID)); contactIDs.add(contactID); } return contactIDs; } catch (SecurityException e) { Log.e(TAG, "getAllContactIDs: " + e.toString()); return null; } finally { if (c != null) c.close(); } }
From source file:org.xwalk.runtime.extension.api.contacts.ContactEventListener.java
private void readAllRawContactInfo() { Cursor c = null;/* w ww . j a v a 2s .co m*/ try { c = mResolver.query(RawContacts.CONTENT_URI, null, null, null, null); mRawID2ContactIDMaps = new HashMap<String, String>(); mRawID2VersionMaps = new HashMap<String, String>(); while (c.moveToNext()) { String contactID = c.getString(c.getColumnIndex(RawContacts.CONTACT_ID)); String rawContactID = c.getString(c.getColumnIndex(RawContacts._ID)); String version = c.getString(c.getColumnIndex(RawContacts.VERSION)); mRawID2ContactIDMaps.put(rawContactID, contactID); mRawID2VersionMaps.put(rawContactID, version); } } catch (SecurityException e) { Log.e(TAG, "readAllRawContactInfo: " + e.toString()); } finally { if (c != null) c.close(); } }
From source file:org.xwalk.runtime.extension.api.contacts.ContactEventListener.java
private HashSet<String> compareAllRawContactInfo(HashSet<String> commonSet) { HashSet<String> contactIDs = null; HashMap<String, String> compareMaps = null; Cursor c = null;//from w w w. ja v a 2 s . com try { c = mResolver.query(RawContacts.CONTENT_URI, null, null, null, null); contactIDs = new HashSet<String>(); compareMaps = new HashMap<String, String>(); while (c.moveToNext()) { String rawContactID = c.getString(c.getColumnIndex(RawContacts._ID)); String version = c.getString(c.getColumnIndex(RawContacts.VERSION)); compareMaps.put(rawContactID, version); } } catch (SecurityException e) { Log.e(TAG, "compareAllRawContactInfo: " + e.toString()); return null; } finally { if (c != null) c.close(); } Iterator<String> iterator = compareMaps.keySet().iterator(); while (iterator.hasNext()) { String rawContactID = iterator.next(); String newVersion = compareMaps.get(rawContactID); String oldVersion = mRawID2VersionMaps.get(rawContactID); if (oldVersion == null || !newVersion.equals(oldVersion)) { String contactID = mRawID2ContactIDMaps.get(rawContactID); if (contactID != null && commonSet.contains(contactID)) { contactIDs.add(contactID); } } } return contactIDs; }
From source file:TcpClient.java
/** Default constructor. */ public TcpServer() { this.payload = new TcpPayload(); initServerSocket();// w w w . j a v a2 s . com try { while (true) { // listen for and accept a client connection to serverSocket Socket sock = this.serverSocket.accept(); OutputStream oStream = sock.getOutputStream(); ObjectOutputStream ooStream = new ObjectOutputStream(oStream); ooStream.writeObject(this.payload); // send serilized payload ooStream.close(); Thread.sleep(1000); } } catch (SecurityException se) { System.err.println("Unable to get host address due to security."); System.err.println(se.toString()); System.exit(1); } catch (IOException ioe) { System.err.println("Unable to read data from an open socket."); System.err.println(ioe.toString()); System.exit(1); } catch (InterruptedException ie) { } // Thread sleep interrupted finally { try { this.serverSocket.close(); } catch (IOException ioe) { System.err.println("Unable to close an open socket."); System.err.println(ioe.toString()); System.exit(1); } } }
From source file:org.xwalk.runtime.extension.api.contacts.ContactFinder.java
private Set<String> getContactIds(FindOption findOption) { Set<String> ids = null; Cursor c = null;//w ww . j a v a2 s. c o m try { c = mUtils.mResolver.query(Data.CONTENT_URI, null, findOption.mWhere, findOption.mWhereArgs, findOption.mSortOrder); ids = new HashSet<String>(); while (c.moveToNext()) { ids.add(String.valueOf(c.getLong(c.getColumnIndex(Data.CONTACT_ID)))); } return ids; } catch (SecurityException e) { Log.e(TAG, "getContactIds: " + e.toString()); return null; } finally { if (c != null) c.close(); } }