List of usage examples for java.lang SecurityException printStackTrace
public void printStackTrace()
From source file:com.projity.util.ClassUtils.java
public static java.lang.reflect.Field staticFieldFromFullName(String nameAndField) { int lastDot = nameAndField.lastIndexOf("."); String className = nameAndField.substring(0, lastDot); String fieldName = nameAndField.substring(lastDot + 1); try {//from w w w. j a v a 2 s . c o m return ClassUtils.forName(className).getDeclaredField(fieldName); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:com.projity.util.ClassUtils.java
public static Method staticMethodFromFullName(String nameAndField, Class[] args) { int lastDot = nameAndField.lastIndexOf("."); String className = nameAndField.substring(0, lastDot); String methodName = nameAndField.substring(lastDot + 1); try {/*from ww w. j a va 2 s . c om*/ return ClassUtils.forName(className).getDeclaredMethod(methodName, args); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:Main.java
/** * Try to get the exif orientation of the passed image uri * * @param context/*from www. j av a2 s . c o m*/ * @param uri * @return */ public static int getExifOrientation(Context context, Uri uri) { final String scheme = uri.getScheme(); ContentProviderClient provider = null; if (scheme == null || ContentResolver.SCHEME_FILE.equals(scheme)) { return getExifOrientation(uri.getPath()); } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { try { provider = context.getContentResolver().acquireContentProviderClient(uri); } catch (SecurityException e) { return 0; } if (provider != null) { Cursor result; try { result = provider.query(uri, new String[] { MediaStore.Images.ImageColumns.ORIENTATION, MediaStore.Images.ImageColumns.DATA }, null, null, null); } catch (Exception e) { e.printStackTrace(); return 0; } if (result == null) { return 0; } int orientationColumnIndex = result.getColumnIndex(MediaStore.Images.ImageColumns.ORIENTATION); int dataColumnIndex = result.getColumnIndex(MediaStore.Images.ImageColumns.DATA); try { if (result.getCount() > 0) { result.moveToFirst(); int rotation = 0; if (orientationColumnIndex > -1) { rotation = result.getInt(orientationColumnIndex); } if (dataColumnIndex > -1) { String path = result.getString(dataColumnIndex); rotation |= getExifOrientation(path); } return rotation; } } finally { result.close(); } } } return 0; }
From source file:Main.java
/** * Try to get the exif orientation of the passed image uri * /*from w ww . j a v a 2 s. c o m*/ * @param context * @param uri * @return */ public static int getExifOrientation(Context context, Uri uri) { final String scheme = uri.getScheme(); ContentProviderClient provider = null; if (scheme == null || ContentResolver.SCHEME_FILE.equals(scheme)) { return getExifOrientation(uri.getPath()); } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { try { provider = context.getContentResolver().acquireContentProviderClient(uri); } catch (SecurityException e) { return 0; } if (provider != null) { Cursor result; try { result = provider.query(uri, new String[] { Images.ImageColumns.ORIENTATION, Images.ImageColumns.DATA }, null, null, null); } catch (Exception e) { e.printStackTrace(); return 0; } if (result == null) { return 0; } int orientationColumnIndex = result.getColumnIndex(Images.ImageColumns.ORIENTATION); int dataColumnIndex = result.getColumnIndex(Images.ImageColumns.DATA); try { if (result.getCount() > 0) { result.moveToFirst(); int rotation = 0; if (orientationColumnIndex > -1) { rotation = result.getInt(orientationColumnIndex); } if (dataColumnIndex > -1) { String path = result.getString(dataColumnIndex); rotation |= getExifOrientation(path); } return rotation; } } finally { result.close(); } } } return 0; }
From source file:edu.mit.csail.sdg.alloy4.Terminal.java
/** Copy the required files from the JAR into a temporary directory. */ private static void copyFromJAR() { // Compute the appropriate platform String os = System.getProperty("os.name").toLowerCase(Locale.US).replace(' ', '-'); if (os.startsWith("mac-")) os = "mac"; else if (os.startsWith("windows-")) os = "windows"; String arch = System.getProperty("os.arch").toLowerCase(Locale.US).replace(' ', '-'); if (arch.equals("powerpc")) arch = "ppc-" + os; else/*from ww w . ja v a 2 s . c o m*/ arch = arch.replaceAll("\\Ai[3456]86\\z", "x86") + "-" + os; if (os.equals("mac")) arch = "x86-mac"; // our pre-compiled binaries are all universal binaries // Find out the appropriate Alloy directory final String platformBinary = alloyHome() + fs + "binary"; // Write a few test files try { (new File(platformBinary)).mkdirs(); Util.writeAll(platformBinary + fs + "tmp.cnf", "p cnf 3 1\n1 0\n"); } catch (Err er) { // The error will be caught later by the "berkmin" or "spear" test } // Copy the platform-dependent binaries Util.copy(true, false, platformBinary, arch + "/libminisat.so", arch + "/libminisatx1.so", arch + "/libminisat.jnilib", arch + "/libminisatprover.so", arch + "/libminisatproverx1.so", arch + "/libminisatprover.jnilib", arch + "/libzchaff.so", arch + "/libzchaffx1.so", arch + "/libzchaff.jnilib", arch + "/berkmin", arch + "/spear"); Util.copy(false, false, platformBinary, arch + "/minisat.dll", arch + "/minisatprover.dll", arch + "/zchaff.dll", arch + "/berkmin.exe", arch + "/spear.exe"); // Copy the model files Util.copy(false, true, alloyHome(), "models/book/appendixA/addressBook1.als", "models/book/appendixA/addressBook2.als", "models/book/appendixA/barbers.als", "models/book/appendixA/closure.als", "models/book/appendixA/distribution.als", "models/book/appendixA/phones.als", "models/book/appendixA/prison.als", "models/book/appendixA/properties.als", "models/book/appendixA/ring.als", "models/book/appendixA/spanning.als", "models/book/appendixA/tree.als", "models/book/appendixA/tube.als", "models/book/appendixA/undirected.als", "models/book/appendixE/hotel.thm", "models/book/appendixE/p300-hotel.als", "models/book/appendixE/p303-hotel.als", "models/book/appendixE/p306-hotel.als", "models/book/chapter2/addressBook1a.als", "models/book/chapter2/addressBook1b.als", "models/book/chapter2/addressBook1c.als", "models/book/chapter2/addressBook1d.als", "models/book/chapter2/addressBook1e.als", "models/book/chapter2/addressBook1f.als", "models/book/chapter2/addressBook1g.als", "models/book/chapter2/addressBook1h.als", "models/book/chapter2/addressBook2a.als", "models/book/chapter2/addressBook2b.als", "models/book/chapter2/addressBook2c.als", "models/book/chapter2/addressBook2d.als", "models/book/chapter2/addressBook2e.als", "models/book/chapter2/addressBook3a.als", "models/book/chapter2/addressBook3b.als", "models/book/chapter2/addressBook3c.als", "models/book/chapter2/addressBook3d.als", "models/book/chapter2/theme.thm", "models/book/chapter4/filesystem.als", "models/book/chapter4/grandpa1.als", "models/book/chapter4/grandpa2.als", "models/book/chapter4/grandpa3.als", "models/book/chapter4/lights.als", "models/book/chapter5/addressBook.als", "models/book/chapter5/lists.als", "models/book/chapter5/sets1.als", "models/book/chapter5/sets2.als", "models/book/chapter6/hotel.thm", "models/book/chapter6/hotel1.als", "models/book/chapter6/hotel2.als", "models/book/chapter6/hotel3.als", "models/book/chapter6/hotel4.als", "models/book/chapter6/mediaAssets.als", "models/book/chapter6/memory/abstractMemory.als", "models/book/chapter6/memory/cacheMemory.als", "models/book/chapter6/memory/checkCache.als", "models/book/chapter6/memory/checkFixedSize.als", "models/book/chapter6/memory/fixedSizeMemory.als", "models/book/chapter6/memory/fixedSizeMemory_H.als", "models/book/chapter6/ringElection.thm", "models/book/chapter6/ringElection1.als", "models/book/chapter6/ringElection2.als", "models/examples/algorithms/dijkstra.als", "models/examples/algorithms/dijkstra.thm", "models/examples/algorithms/messaging.als", "models/examples/algorithms/messaging.thm", "models/examples/algorithms/opt_spantree.als", "models/examples/algorithms/opt_spantree.thm", "models/examples/algorithms/peterson.als", "models/examples/algorithms/ringlead.als", "models/examples/algorithms/ringlead.thm", "models/examples/algorithms/s_ringlead.als", "models/examples/algorithms/stable_mutex_ring.als", "models/examples/algorithms/stable_mutex_ring.thm", "models/examples/algorithms/stable_orient_ring.als", "models/examples/algorithms/stable_orient_ring.thm", "models/examples/algorithms/stable_ringlead.als", "models/examples/algorithms/stable_ringlead.thm", "models/examples/case_studies/INSLabel.als", "models/examples/case_studies/chord.als", "models/examples/case_studies/chord2.als", "models/examples/case_studies/chordbugmodel.als", "models/examples/case_studies/com.als", "models/examples/case_studies/firewire.als", "models/examples/case_studies/firewire.thm", "models/examples/case_studies/ins.als", "models/examples/case_studies/iolus.als", "models/examples/case_studies/sync.als", "models/examples/case_studies/syncimpl.als", "models/examples/puzzles/farmer.als", "models/examples/puzzles/farmer.thm", "models/examples/puzzles/handshake.als", "models/examples/puzzles/handshake.thm", "models/examples/puzzles/hanoi.als", "models/examples/puzzles/hanoi.thm", "models/examples/systems/file_system.als", "models/examples/systems/file_system.thm", "models/examples/systems/javatypes_soundness.als", "models/examples/systems/lists.als", "models/examples/systems/lists.thm", "models/examples/systems/marksweepgc.als", "models/examples/systems/views.als", "models/examples/toys/birthday.als", "models/examples/toys/birthday.thm", "models/examples/toys/ceilingsAndFloors.als", "models/examples/toys/ceilingsAndFloors.thm", "models/examples/toys/genealogy.als", "models/examples/toys/genealogy.thm", "models/examples/toys/grandpa.als", "models/examples/toys/grandpa.thm", "models/examples/toys/javatypes.als", "models/examples/toys/life.als", "models/examples/toys/life.thm", "models/examples/toys/numbering.als", "models/examples/toys/railway.als", "models/examples/toys/railway.thm", "models/examples/toys/trivial.als", "models/examples/tutorial/farmer.als", "models/util/boolean.als", "models/util/graph.als", "models/util/integer.als", "models/util/natural.als", "models/util/ordering.als", "models/util/relation.als", "models/util/seqrel.als", "models/util/sequence.als", "models/util/sequniv.als", "models/util/ternary.als", "models/util/time.als"); // Record the locations System.setProperty("alloy.theme0", alloyHome() + fs + "models"); System.setProperty("alloy.home", alloyHome()); try { // It doesn't work to set the env variable after java is started but this hack makes it work see // http://blog.cedarsoft.com/2010/11/setting-java-library-path-programmatically/ System.setProperty("java.library.path", platformBinary); Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths"); fieldSysPath.setAccessible(true); fieldSysPath.set(null, null); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.agiso.core.i18n.util.I18nUtils.java
public static String getCode(Enum<?> e) { try {/*from w ww. j a v a 2 s . c o m*/ return getCode(e.getClass().getField(e.name())); } catch (SecurityException ex) { // TODO Auto-generated catch block ex.printStackTrace(); } catch (NoSuchFieldException ex) { // TODO Auto-generated catch block ex.printStackTrace(); } return e.getDeclaringClass().getName() + CODE_SEPARATOR + e.name(); }
From source file:com.clican.pluto.common.util.BeanUtils.java
@SuppressWarnings("unchecked") public static <K> Object getPropertyByMthodName(Object obj, String[] propertyNameList) { if (null == propertyNameList || propertyNameList.length < 1) { return (K) obj; }/*w w w . ja v a 2 s.c om*/ try { K result = null; String propertyName = propertyNameList[0]; Method method = obj.getClass().getMethod(StringUtils.getGetMethodName(propertyName), new Class<?>[] {}); if (propertyNameList.length > 1) { Object newObj = method.invoke(obj, new Object[] {}); String[] newPropertyNameList = new String[propertyNameList.length - 1]; System.arraycopy(propertyNameList, 1, newPropertyNameList, 0, propertyNameList.length - 1); return getPropertyByMthodName(newObj, newPropertyNameList); } else { result = (K) method.invoke(obj, new Object[] {}); } return result; } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:com.github.diogochbittencourt.googleplaydownloader.downloader.impl.AndroidHttpClient.java
/** * Create a new HttpClient with reasonable defaults (which you can update). * * @param userAgent to report in your HTTP requests * @param context to use for caching SSL sessions (may be null for no caching) * @return AndroidHttpClient for you to use for all your requests. *//*from w w w .j av a 2 s. co m*/ public static AndroidHttpClient newInstance(String userAgent, Context context) { HttpParams params = new BasicHttpParams(); // Turn off stale checking. Our connections break all the time anyway, // and it's not worth it to pay the penalty of checking every time. HttpConnectionParams.setStaleCheckingEnabled(params, false); HttpConnectionParams.setConnectionTimeout(params, SOCKET_OPERATION_TIMEOUT); HttpConnectionParams.setSoTimeout(params, SOCKET_OPERATION_TIMEOUT); HttpConnectionParams.setSocketBufferSize(params, 8192); // Don't handle redirects -- return them to the caller. Our code // often wants to re-POST after a redirect, which we must do ourselves. HttpClientParams.setRedirecting(params, false); Object sessionCache = null; // Use a session cache for SSL sockets -- Froyo only if (null != context && null != sSslSessionCacheClass) { Constructor<?> ct; try { ct = sSslSessionCacheClass.getConstructor(Context.class); sessionCache = ct.newInstance(context); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // Set the specified user agent and register standard protocols. HttpProtocolParams.setUserAgent(params, userAgent); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); SocketFactory sslCertificateSocketFactory = null; if (null != sessionCache) { Method getHttpSocketFactoryMethod; try { getHttpSocketFactoryMethod = SSLCertificateSocketFactory.class .getDeclaredMethod("getHttpSocketFactory", Integer.TYPE, sSslSessionCacheClass); sslCertificateSocketFactory = (SocketFactory) getHttpSocketFactoryMethod.invoke(null, SOCKET_OPERATION_TIMEOUT, sessionCache); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (null == sslCertificateSocketFactory) { sslCertificateSocketFactory = SSLSocketFactory.getSocketFactory(); } schemeRegistry.register(new Scheme("https", sslCertificateSocketFactory, 443)); ClientConnectionManager manager = new ThreadSafeClientConnManager(params, schemeRegistry); // We use a factory method to modify superclass initialization // parameters without the funny call-a-static-method dance. return new AndroidHttpClient(manager, params); }
From source file:bammerbom.ultimatecore.bukkit.resources.utils.BossbarUtil.java
public static Field getField(Class<?> cl, String field_name) { try {/*from w ww .j av a2s . c om*/ return cl.getDeclaredField(field_name); } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } return null; }
From source file:bammerbom.ultimatecore.bukkit.resources.utils.BossbarUtil.java
public static void sendPacket(Player p, Object packet) { try {/*ww w . j a v a 2s . c o m*/ Object nmsPlayer = getHandle(p); Field con_field = nmsPlayer.getClass().getField("playerConnection"); Object con = con_field.get(nmsPlayer); Method packet_method = getMethod(con.getClass(), "sendPacket"); packet_method.invoke(con, new Object[] { packet }); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } }