List of usage examples for java.lang SecurityException printStackTrace
public void printStackTrace()
From source file:com.xse.optstack.persconftool.base.persistence.PersConfExport.java
private boolean persistGroup(final File resourceFolder, final EApplicationGroup group) { final boolean persistStatus = true; final File groupFolder = new File( resourceFolder.getAbsolutePath() + File.separator + group.getType().getLiteral().toLowerCase()); try {//from w w w . j a v a 2 s. c o m groupFolder.mkdir(); } catch (final SecurityException e) { Logger.error(Activator.PLUGIN_ID, "Not allowed to create group folder: " + groupFolder.getAbsolutePath(), e); return false; } final Set<String> appNames = new HashSet<>(); // ################ Installation Rules final Gson installRulesJson = PersConfExport.createGsonBuilder().create(); final JsonObject installRulesObj = new JsonObject(); for (final EApplication eApplication : group.getApplications()) { if (eApplication.getInstallRule() != null) { installRulesObj.add(eApplication.getName(), new JsonPrimitive( PersConfDefinitions.INSTALL_RULE_PREFIX + eApplication.getInstallRule().getLiteral())); } } try (final FileWriter fileWriter = new FileWriter(new File( groupFolder.getAbsolutePath() + File.separator + PersConfDefinitions.INSTALL_RULES_FILE))) { fileWriter.write(installRulesJson.toJson(installRulesObj)); } catch (final IOException e) { Logger.error(Activator.PLUGIN_ID, "Error writing install rules configuration file!", e); } // ################ Ownership Configuration final Gson ownershipConfigurationJson = PersConfExport.createGsonBuilder().create(); final JsonObject ownershipConfigurationObj = new JsonObject(); for (final EApplication eApplication : group.getApplications()) { final JsonObject appElement = new JsonObject(); boolean saveApplication = false; if (eApplication.getUserName() == null || eApplication.getUserName().equals("")) appElement.add(PersConfDefinitions.USERNAME_KEY_NAME, new JsonPrimitive("")); else { appElement.add(PersConfDefinitions.USERNAME_KEY_NAME, new JsonPrimitive(eApplication.getUserName())); saveApplication = true; } if (eApplication.getGroupName() == null || eApplication.getGroupName().equals("")) appElement.add(PersConfDefinitions.GROUPNAME_KEY_NAME, new JsonPrimitive("")); else { appElement.add(PersConfDefinitions.GROUPNAME_KEY_NAME, new JsonPrimitive(eApplication.getGroupName())); saveApplication = true; } if (eApplication.getUserId() == null) appElement.add(PersConfDefinitions.USERID_KEY_NAME, new JsonPrimitive("")); else { appElement.add(PersConfDefinitions.USERID_KEY_NAME, new JsonPrimitive(String.valueOf(eApplication.getUserId()))); saveApplication = true; } if (eApplication.getGroupId() == null) appElement.add(PersConfDefinitions.GROUPID_KEY_NAME, new JsonPrimitive("")); else { appElement.add(PersConfDefinitions.GROUPID_KEY_NAME, new JsonPrimitive(String.valueOf(eApplication.getGroupId()))); saveApplication = true; } if (saveApplication) ownershipConfigurationObj.add(eApplication.getName(), appElement); } try (final FileWriter fileWriter = new FileWriter(new File(groupFolder.getAbsolutePath() + File.separator + PersConfDefinitions.OWNERSHIP_CONFIGURATION_FILE))) { fileWriter.write(ownershipConfigurationJson.toJson(ownershipConfigurationObj)); } catch (final IOException e) { Logger.error(Activator.PLUGIN_ID, "Error writing ownership configuration file!", e); } for (final EApplication eApplication : group.getApplications()) { final File applicationFolder = new File(groupFolder + File.separator + eApplication.getName()); applicationFolder.mkdir(); this.exportCHeader(eApplication); // ################ Resource Configuration final GsonBuilder resourceConfigJsonBuilder = PersConfExport.createGsonBuilder(); resourceConfigJsonBuilder.registerTypeAdapter(EApplicationImpl.class, new ResouceConfigurationApplicationTypeAdapter()); resourceConfigJsonBuilder.registerTypeAdapter(EConfigurationImpl.class, new ResourceConfigurationConfigurationTypeAdapter()); resourceConfigJsonBuilder.registerTypeAdapter(EPolicy.class, new ResouceConfigurationTypeAdapter()); resourceConfigJsonBuilder.registerTypeAdapter(EStorage.class, new ResouceConfigurationTypeAdapter()); resourceConfigJsonBuilder.registerTypeAdapter(EDefaultDataType.class, new ResouceConfigurationTypeAdapter()); resourceConfigJsonBuilder.setExclusionStrategies(new ExclusionStrategy() { @Override public boolean shouldSkipField(final FieldAttributes fieldAttributes) { return false; } @Override public boolean shouldSkipClass(final Class<?> clazz) { return clazz.isAssignableFrom(EDefaultData.class); } }); final Gson gson = resourceConfigJsonBuilder.create(); try (final FileWriter fileWriter = new FileWriter(new File(applicationFolder.getAbsolutePath() + File.separator + PersConfDefinitions.RESOURCE_CONFIGURATION_FILE))) { fileWriter.write(gson.toJson(eApplication)); } catch (final IOException e) { Logger.error(Activator.PLUGIN_ID, "Error writing resource configuration file!", e); } // ################ Install Exceptions final Gson installExceptionsGson = PersConfExport.createGsonBuilder().create(); final JsonObject installExceptionsObj = new JsonObject(); for (final EResource resource : eApplication.getResources()) { if (resource.getInstallException() != null) { installExceptionsObj.add(resource.getName(), new JsonPrimitive(PersConfDefinitions.INSTALL_EXCEPTION_PREFIX + resource.getInstallException().getLiteral())); } } try (final FileWriter fileWriter = new FileWriter(new File(applicationFolder.getAbsolutePath() + File.separator + PersConfDefinitions.INSTALL_EXCEPTIONS_FILE))) { fileWriter.write(installExceptionsGson.toJson(installExceptionsObj)); } catch (final IOException e) { Logger.error(Activator.PLUGIN_ID, "Error writing install exceptions configuration file!", e); } final File fileFolder = new File(applicationFolder + File.separator + PersConfDefinitions.FILE_FOLDER); fileFolder.mkdir(); final File configDefaultFileFolder = new File( fileFolder + File.separator + PersConfDefinitions.CONFIGURABLE_DEFAULT_DATA_FOLDER); configDefaultFileFolder.mkdir(); final File defaultFileFolder = new File( fileFolder + File.separator + PersConfDefinitions.DEFAULT_DATA_FOLDER); defaultFileFolder.mkdir(); // ################ Default Data final File keyFolder = new File(applicationFolder + File.separator + PersConfDefinitions.KEY_FOLDER); keyFolder.mkdir(); // ################ Factory Default // boolean hasDefaultKeyData = false; // for (final EResource eResource : eApplication.getResources()) { // if (DefaultDataApplicationTypeAdapter.hasDefaultDataValue(eResource.getConfiguration().getFactoryDefault())) { // hasDefaultKeyData = true; // break; // } // } PersConfExport.copyDefaultDataFiles(defaultFileFolder, eApplication, EConfiguration::getFactoryDefault); final File factoryDefaultsFile = new File( keyFolder.getAbsolutePath() + File.separator + PersConfDefinitions.FACTORY_DEFAULTS_FILE); final GsonBuilder factoryDefaultGsonBuilder = PersConfExport.createGsonBuilder(); factoryDefaultGsonBuilder.registerTypeAdapter(EApplicationImpl.class, new DefaultDataApplicationTypeAdapter(true)); factoryDefaultGsonBuilder.registerTypeAdapter(EDefaultDataImpl.class, new DefaultDataTypeAdapter()); final Gson factoryDefaultGson = factoryDefaultGsonBuilder.create(); try (final FileWriter fileWriter = new FileWriter(factoryDefaultsFile)) { fileWriter.write(factoryDefaultGson.toJson(eApplication)); } catch (final IOException e) { e.printStackTrace(); } // ################ Configurable Default // hasDefaultKeyData = false; // for (final EResource eResource : eApplication.getResources()) { // if (DefaultDataApplicationTypeAdapter.hasDefaultDataValue(eResource.getConfiguration().getConfigDefault())) { // hasDefaultKeyData = true; // break; // } // } PersConfExport.copyDefaultDataFiles(configDefaultFileFolder, eApplication, EConfiguration::getConfigDefault); final File configDefaultsFile = new File( keyFolder.getAbsolutePath() + File.separator + PersConfDefinitions.CONFIGURABLE_DEFAULTS_FILE); final GsonBuilder configurableDefaultGsonBuilder = PersConfExport.createGsonBuilder(); configurableDefaultGsonBuilder.registerTypeAdapter(EApplicationImpl.class, new DefaultDataApplicationTypeAdapter(false)); configurableDefaultGsonBuilder.registerTypeAdapter(EDefaultDataImpl.class, new DefaultDataTypeAdapter()); final Gson configurableDefaultGson = configurableDefaultGsonBuilder.create(); try (final FileWriter fileWriter = new FileWriter(configDefaultsFile)) { fileWriter.write(configurableDefaultGson.toJson(eApplication)); } catch (final IOException e) { e.printStackTrace(); } appNames.add(eApplication.getName()); } final File[] groupFiles = groupFolder.listFiles((FileFilter) DirectoryFileFilter.INSTANCE); // remove all application folders not part of the current configuration anymore if (groupFiles != null) { for (final File appFolder : groupFiles) { if (!appNames.contains(appFolder.getName())) { try { FileUtils.deleteDirectory(appFolder); } catch (final IOException e) { Logger.error(Activator.PLUGIN_ID, "Unable to delete removed application directory: " + appFolder.getName(), e); } } } } return persistStatus; }
From source file:com.android.vending.billing.InAppBillingService.LACK.listAppsFragment.java
public void connectToLicensing() { mServiceConnL = new ServiceConnection() { public void onServiceConnected(ComponentName paramAnonymousComponentName, IBinder paramAnonymousIBinder) { System.out.println("Licensing service try to connect."); if (listAppsFragment.this.mServiceL == null) { listAppsFragment.this.mServiceL = ILicensingService.Stub.asInterface(paramAnonymousIBinder); }/* w w w.j av a2s . c o m*/ try { listAppsFragment.this.mServiceL.checkLicense(new Random().nextLong(), listAppsFragment.getInstance().getPackageName(), new ILicenseResultListener.Stub() { public void verifyLicense(int paramAnonymous2Int, String paramAnonymous2String1, String paramAnonymous2String2) throws RemoteException { System.out.println(paramAnonymous2Int); listAppsFragment.this.responseCode = paramAnonymous2Int; listAppsFragment.removeDialogLP(11); switch (paramAnonymous2Int) { case 1: case 2: default: listAppsFragment.handler.post(new Runnable() { public void run() { listAppsFragment.this.showMessage(Utils.getText(2131165549), Utils.getText(2131165547)); } }); } for (;;) { System.out.println("" + paramAnonymous2String1); System.out.println(paramAnonymous2String2); listAppsFragment.this.cleanupService(); return; listAppsFragment.handler.post(new Runnable() { public void run() { listAppsFragment.this.showMessage(Utils.getText(2131165549), Utils.getText(2131165548)); } }); continue; if ((paramAnonymous2String1 != null) && (paramAnonymous2String2 != null) && (Utils.checkCoreJarPatch11()) && (Utils.checkCoreJarPatch12())) { listAppsFragment.handler.post(new Runnable() { public void run() { listAppsFragment.this.showMessage(Utils.getText(2131165549), Utils.getText(2131165550)); } }); } else { listAppsFragment.handler.post(new Runnable() { public void run() { listAppsFragment.this.showMessage(Utils.getText(2131165549), Utils.getText(2131165547)); } }); } } } }); return; } catch (RemoteException paramAnonymousComponentName) { paramAnonymousComponentName.printStackTrace(); } } public void onServiceDisconnected(ComponentName paramAnonymousComponentName) { System.out.println("Licensing service disconnected."); listAppsFragment.this.mServiceL = null; listAppsFragment.removeDialogLP(11); } }; if (this.mServiceL == null) { boolean bool1; label311: do { try { Intent localIntent = new Intent(new String( Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U="))); localIntent.setPackage("com.android.vending"); localIntent.putExtra("xexe", "lp"); boolean bool4 = false; bool1 = false; boolean bool3 = false; boolean bool2 = bool4; try { if (getPkgMng().queryIntentServices(localIntent, 0).isEmpty()) { continue; } bool2 = bool4; Iterator localIterator = getPkgMng().queryIntentServices(localIntent, 0).iterator(); bool1 = bool3; Object localObject; cleanupService(); } catch (Exception localException1) { try { for (;;) { if (!localIterator.hasNext()) { break label311; } localObject = (ResolveInfo) localIterator.next(); if ((((ResolveInfo) localObject).serviceInfo.packageName == null) || (!((ResolveInfo) localObject).serviceInfo.packageName .equals("com.android.vending"))) { break; } localObject = new ComponentName(((ResolveInfo) localObject).serviceInfo.packageName, ((ResolveInfo) localObject).serviceInfo.name); localIntent = new Intent(); bool2 = bool1; localIntent.setComponent((ComponentName) localObject); bool2 = bool1; localIntent.putExtra("xexe", "lp"); bool2 = bool1; handler.post(new Runnable() { public void run() { listAppsFragment.removeDialogLP(11); listAppsFragment.showDialogLP(11); listAppsFragment.progress2.setCancelable(true); listAppsFragment.progress2.setMessage(Utils.getText(2131165747)); } }); bool2 = bool1; bool1 = getInstance().bindService(localIntent, mServiceConnL, 1); } } catch (Exception localException2) { for (;;) { } } localException1 = localException1; bool1 = bool2; localException1.printStackTrace(); removeDialogLP(11); } removeDialogLP(11); return; } catch (SecurityException localSecurityException) { localSecurityException.printStackTrace(); cleanupService(); return; } catch (Base64DecoderException localBase64DecoderException) { localBase64DecoderException.printStackTrace(); cleanupService(); return; } } while (!bool1); } }