List of usage examples for java.lang SecurityException printStackTrace
public void printStackTrace()
From source file:com.yelinaung.programmerexcuses.HomeActivity.java
public static boolean isOnline(Context c) { NetworkInfo netInfo = null;/*from w w w. j a v a 2 s .com*/ try { ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); netInfo = cm.getActiveNetworkInfo(); } catch (SecurityException e) { e.printStackTrace(); } return netInfo != null && netInfo.isConnectedOrConnecting(); }
From source file:com.sustainalytics.crawlerfilter.PDFtoTextBatch.java
/** * Method to initiate logger/*from w w w . jav a 2s . c o m*/ * @param file is a File object. The log file will be placed in this file's folder */ public static void initiateLogger(File file) { FileHandler fileHandler; try { // This block configure the logger with handler and formatter fileHandler = new FileHandler(file.getAbsolutePath() + "/" + "log.txt", true); logger.addHandler(fileHandler); SimpleFormatter formatter = new SimpleFormatter(); fileHandler.setFormatter(formatter); } catch (SecurityException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.taobao.tddl.common.config.impl.DefaultConfigDataHandlerFactory.java
@SuppressWarnings("unchecked") private static void createConstuctFromClassName() { ClassLoader currentCL = getBaseClassLoader(); handlerClassObj = loadClass(handlerClassName, currentCL); if (null == handlerClassObj) { throw new IllegalArgumentException("can not get handler class:" + handlerClassName); }/*from w w w. j a v a 2 s . c om*/ try { handlerConstructor = handlerClassObj.getConstructor(); } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } }
From source file:org.saiku.plugin.PentahoConnectionRetriever.java
public static Map<String, ISaikuConnection> getConnections() { Map<String, ISaikuConnection> connections = new HashMap<String, ISaikuConnection>(); final IPluginManager pluginManager = (IPluginManager) PentahoSystem.get(IPluginManager.class, PentahoSessionHolder.getSession()); final PluginClassLoader pluginClassloader = (PluginClassLoader) pluginManager .getClassLoader(PluginConfig.PLUGIN_NAME); String dataSources = makeDataSourcesUrl(); RepositoryContentFinder contentFinder = makeContentFinder(dataSources); CatalogLocator ci = makeCatalogLocator(); MondrianProperties.instance().DataSourceResolverClass .setString("org.saiku.plugin.PentahoDataSourceResolver"); SolutionReposHelper.setSolutionRepositoryThreadVariable( PentahoSystem.get(ISolutionRepository.class, PentahoSessionHolder.getSession())); MondrianServer server = MondrianServer.createWithRepository(contentFinder, ci); boolean done = false; Integer nr = 0;//from w w w.j a va2 s . c o m OlapConnection last = null; OlapConnection con; try { con = server.getConnection(null, null, null); if (con != null && con != last) { connections.put(nr.toString(), new SaikuReadyOlapConnection(nr.toString(), con)); nr++; } else { done = true; } } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return connections; }
From source file:es.eucm.eadventure.editor.plugin.vignette.ProxySetup.java
private static void init() { proxyConfig = null;//from w w w.ja v a 2 s . c o m log = Logger.getLogger("es.eucm.eadventure.tracking.prv.service.ProxyConfig"); handler = null; try { handler = new FileHandler("proxy.log"); log.addHandler(handler); } catch (SecurityException e) { handler = null; e.printStackTrace(); } catch (IOException e) { handler = null; e.printStackTrace(); } //Log log = LogFactory.getLog( "es.eucm.eadventure.tracking.prv.service.ProxyConfig" ); log("Setting prop java.net.useSystemProxies=true"); System.setProperty("java.net.useSystemProxies", "true"); Proxy proxy = getProxy(); if (proxy != null) { InetSocketAddress addr = (InetSocketAddress) proxy.address(); if (addr == null) { log("No proxy detected"); System.out.println("NO PROXY"); } else { String host = addr.getHostName(); int port = addr.getPort(); proxyConfig = new ProxyConfig(); proxyConfig.setHostName(host); proxyConfig.setPort("" + port); proxyConfig.setProtocol("http"); log("Proxy detected: host=" + host + " port=" + port); System.setProperty("java.net.useSystemProxies", "false"); System.setProperty("http.proxyHost", host); System.setProperty("http.proxyPort", "" + port); log("Setting up system proxy host & port"); } } System.setProperty("java.net.useSystemProxies", "false"); log("Setting prop java.net.useSystemProxies=false"); init = true; }
From source file:com.beetle.framework.util.OtherUtil.java
/** * ?//from w w w .j a v a 2s . co m * * @param filename * @return 0-????0 */ public static long getFileLastModified(String filename) { long l = 0; File f = new File(filename); if (f.exists()) { try { l = f.lastModified(); } catch (SecurityException se) { l = 0; se.printStackTrace(); } } return l; }
From source file:com.phonegap.DirectoryManager.java
/** * Delete file./* ww w . ja va 2 s . c o m*/ * * @param fileName The name of the file to delete * @return T=deleted, F=not deleted */ protected static boolean deleteFile(String fileName) { boolean status; SecurityManager checker = new SecurityManager(); // Make sure SD card exists if ((testSaveLocationExists()) && (!fileName.equals(""))) { File path = Environment.getExternalStorageDirectory(); File newPath = constructFilePaths(path.toString(), fileName); checker.checkDelete(newPath.toString()); // If file to delete is really a file if (newPath.isFile()) { try { Log.i("DirectoryManager deleteFile", fileName); newPath.delete(); status = true; } catch (SecurityException se) { se.printStackTrace(); status = false; } } // If not a file, then error else { status = false; } } // If no SD card else { status = false; } return status; }
From source file:com.shrj.util.ReflectionUtils.java
public static Class getClassGenricType(final Class clazz, final int index) { try {// w w w.j a v a 2s . c o m Field f = clazz.getDeclaredField("typeList"); Type t = f.getGenericType(); if (t instanceof ParameterizedType) { Type[] params = ((ParameterizedType) t).getActualTypeArguments(); if (index >= params.length || index < 0) { return Object.class; } // System.out.println(params[index]); return null; } } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } return Object.class; }
From source file:com.jb.statistics.common.utils.ReflectionUtils.java
public static Class getClassGenricType(final Class clazz, final int index) { try {//from w w w . java2 s . c om Field f = clazz.getDeclaredField("typeList"); Type t = f.getGenericType(); if (t instanceof ParameterizedType) { Type[] params = ((ParameterizedType) t).getActualTypeArguments(); if (index >= params.length || index < 0) { return Object.class; } // System.out.println(params[index]); return null; } } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } return Object.class; }
From source file:com.cws.esolutions.security.listeners.SecurityServiceInitializer.java
/** * Initializes the security service in a standalone mode - used for applications outside of a container or when * run as a standalone jar.//from ww w.j ava2s.c o m * * @param configFile - The security configuration file to utilize * @param logConfig - The logging configuration file to utilize * @param startConnections - Configure, load and start repository connections * @throws SecurityServiceException @{link com.cws.esolutions.security.exception.SecurityServiceException} * if an exception occurs during initialization */ public static void initializeService(final String configFile, final String logConfig, final boolean startConnections) throws SecurityServiceException { URL xmlURL = null; JAXBContext context = null; Unmarshaller marshaller = null; SecurityConfigurationData configData = null; final ClassLoader classLoader = SecurityServiceInitializer.class.getClassLoader(); final String serviceConfig = (StringUtils.isBlank(configFile)) ? System.getProperty("configFileFile") : configFile; final String loggingConfig = (StringUtils.isBlank(logConfig)) ? System.getProperty("secLogConfig") : logConfig; try { try { DOMConfigurator.configure(Loader.getResource(loggingConfig)); } catch (NullPointerException npx) { try { DOMConfigurator.configure(FileUtils.getFile(loggingConfig).toURI().toURL()); } catch (NullPointerException npx1) { System.err.println("Unable to load logging configuration. No logging enabled!"); System.err.println(""); npx1.printStackTrace(); } } xmlURL = classLoader.getResource(serviceConfig); if (xmlURL == null) { // try loading from the filesystem xmlURL = FileUtils.getFile(serviceConfig).toURI().toURL(); } context = JAXBContext.newInstance(SecurityConfigurationData.class); marshaller = context.createUnmarshaller(); configData = (SecurityConfigurationData) marshaller.unmarshal(xmlURL); SecurityServiceInitializer.svcBean.setConfigData(configData); if (startConnections) { DAOInitializer.configureAndCreateAuthConnection( new FileInputStream(FileUtils.getFile(configData.getSecurityConfig().getAuthConfig())), false, SecurityServiceInitializer.svcBean); Map<String, DataSource> dsMap = SecurityServiceInitializer.svcBean.getDataSources(); if (DEBUG) { DEBUGGER.debug("dsMap: {}", dsMap); } if (configData.getResourceConfig() != null) { if (dsMap == null) { dsMap = new HashMap<String, DataSource>(); } for (DataSourceManager mgr : configData.getResourceConfig().getDsManager()) { if (!(dsMap.containsKey(mgr.getDsName()))) { StringBuilder sBuilder = new StringBuilder() .append("connectTimeout=" + mgr.getConnectTimeout() + ";") .append("socketTimeout=" + mgr.getConnectTimeout() + ";") .append("autoReconnect=" + mgr.getAutoReconnect() + ";") .append("zeroDateTimeBehavior=convertToNull"); if (DEBUG) { DEBUGGER.debug("StringBuilder: {}", sBuilder); } BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(mgr.getDriver()); dataSource.setUrl(mgr.getDataSource()); dataSource.setUsername(mgr.getDsUser()); dataSource.setConnectionProperties(sBuilder.toString()); dataSource.setPassword(PasswordUtils.decryptText(mgr.getDsPass(), mgr.getDsSalt(), configData.getSecurityConfig().getSecretAlgorithm(), configData.getSecurityConfig().getIterations(), configData.getSecurityConfig().getKeyBits(), configData.getSecurityConfig().getEncryptionAlgorithm(), configData.getSecurityConfig().getEncryptionInstance(), configData.getSystemConfig().getEncoding())); if (DEBUG) { DEBUGGER.debug("BasicDataSource: {}", dataSource); } dsMap.put(mgr.getDsName(), dataSource); } } if (DEBUG) { DEBUGGER.debug("dsMap: {}", dsMap); } SecurityServiceInitializer.svcBean.setDataSources(dsMap); } } } catch (JAXBException jx) { jx.printStackTrace(); throw new SecurityServiceException(jx.getMessage(), jx); } catch (FileNotFoundException fnfx) { fnfx.printStackTrace(); throw new SecurityServiceException(fnfx.getMessage(), fnfx); } catch (MalformedURLException mux) { mux.printStackTrace(); throw new SecurityServiceException(mux.getMessage(), mux); } catch (SecurityException sx) { sx.printStackTrace(); throw new SecurityServiceException(sx.getMessage(), sx); } }