List of usage examples for java.security InvalidParameterException printStackTrace
public void printStackTrace()
From source file:com.gfw.press.encrypt.Encrypt.java
/** * ??AES SecretKey//from ww w . j ava 2 s . co m * * @param bits * ? * * @return SecretKey * */ public SecretKey getKey(int bits) { if (bits < 128) { return null; } try { keyGenerator.init(bits); return keyGenerator.generateKey(); } catch (InvalidParameterException ex) { log("?AES SecretKey"); ex.printStackTrace(); return null; } }
From source file:press.gfw.chat.Encrypt.java
/** * ??AES SecretKey/*from w ww .ja v a 2s . c o m*/ * * @param bits * ? * * @return SecretKey * */ public SecretKey getKey(int bits) { if (bits < 128) { return null; } try { keyGenerator.init(bits); return keyGenerator.generateKey(); } catch (InvalidParameterException ex) { log("?AES SecretKey"); ex.printStackTrace(); return null; } }
From source file:com.bluros.music.nowplaying.BaseNowplayingFragment.java
public void changeDigit(TimelyView tv, int start, int end) { try {/* ww w . j a v a2 s. c om*/ ObjectAnimator obja = tv.animate(start, end); obja.setDuration(400); obja.start(); } catch (InvalidParameterException e) { e.printStackTrace(); } }
From source file:org.easyxml.xml.Document.java
/** * /* w w w . j a va 2 s .c o m*/ * Set the DefaultContainer * * @param container * - The Element to be regarded as DefaultContainer. */ protected void setDefaultContainer(Element container) { try { if (container == null) { throw new InvalidParameterException("The container is not valid!"); } // Iterate through the DOM tree to make sure the container is a // descendant of this XmlDocument if (container != this) { Element parent = container; do { parent = parent.getParent(); if (parent == this) break; else if (parent == null) throw new InvalidParameterException("The root of the element must be this XmlDocument !"); } while (parent != null); this.defaultContainer = container; } } catch (InvalidParameterException e) { e.printStackTrace(); } }
From source file:org.easyxml.xml.Element.java
/** * /* w w w . j a va 2 s. co m*/ * Get the values of innerText/attribute/childElements/childAttributes * specified by 'path'. * * @param path * - The whole path of a Element or a Attribute. * * For example, "SOAP:Envelope>SOAP:Body>Child" denotes <Child> * element/elements under <SOAP:Body>. * * "SOAP:Envelope>SOAP:Body>Child<Attr" denotes the "Attr" * attribute of the above <Child> element/elements. * * @return When path * * 1) equals to "Value": then only the innerText of this element * would be returned. * * 2) equals to some existing attribute name: then only value of * that attribute would be returned. * * 3) is parsed as some elements, then their innerText would be * returned as an array. * * 4) is parsed as some attributes, then these attribute values * would be returned as an array. * * 5) Otherwise returns null. */ public String[] getValuesOf(String path) { String[] values = null; if (path == Value) { // When path is "Value", then only the innerText of this element // would be returned. values = new String[1]; values[0] = getValue(); return values; } else if (attributes != null && attributes.containsKey(path)) { // If the path denotes one existing attribute of this element, then // only value of that attribute would be returned. values = new String[1]; values[0] = getAttributeValue(path); return values; } try { String[] segments = parsePath(path); // Get the target elements or elements of the target attributes // first String elementPath = segments[0]; List<Element> elements = getElementsOf(elementPath); if (elements == null) return null; int size = elements.size(); values = new String[size]; if (segments.length == 1) { // The path identify Element, thus return their innerText as an // array for (int i = 0; i < size; i++) { values[i] = elements.get(i).getValue(); } } else { // Otherwise, the path denotes some attributes, then return the // attributes values as an array String attributeName = segments[1]; for (int i = 0; i < size; i++) { values[i] = elements.get(i).getAttributeValue(attributeName); } } } catch (InvalidParameterException ex) { // If there is anything unexpected, return null ex.printStackTrace(); return null; } return values; }
From source file:org.easyxml.xml.Element.java
/** * /*from www. j a v a 2 s.c om*/ * Set the values of innerText/attribute/childElements/childAttributes * specified by 'path'. * * This would facilitate creation of a layered DOM tree conveniently. * * For example, run setValuesOf("Child>GrandChild<Id", "1st", "2nd") of an * empty element would: * * 1) Create a new <Child> element; * * 2) Create TWO new <GrandChild> element under the newly created <Child> * element; * * 3) First <GrandChild> element would have "Id" attribute of "1st", and * second <GrandChild> of "2nd". * * If then call setValuesOf("Child>GrandChild<Id", "1", "2", "3"), no a new * <GrandChild> element would be created * * and the attribute values of these <GrandChild> elements would be set to * "1", "2" and "3" respectively. * * @param path * - The whole path of a Element or a Attribute. * * For example, "SOAP:Envelope>SOAP:Body>Child" denotes <Child> * element/elements under <SOAP:Body>. * * "SOAP:Envelope>SOAP:Body>Child<Attr" denotes the "Attr" * attribute of the above <Child> element/elements. * * @param values * - The values to be set when 'path': * * 1) equals to "Value": then set the new value of the innerText * of this element. * * 2) equals to some existing attribute name: then set the new * value of that attribute. * * 3) is parsed as some elements, then their innerText would be * set. * * 4) is parsed as some attributes, then these attribute values * would be set. * * @return 'true' if setting is successful, 'false' if failed. */ public Boolean setValuesOf(String path, String... values) { try { if (path == Value) { if (values.length != 1) throw new InvalidParameterException( "Only one String value is expected to set the value of this element"); // Change the innerText value of this element setValue(values[0]); return true; } else if (attributes != null && attributes.containsKey(path)) { if (values.length != 1) throw new InvalidParameterException( "Only one String value is expected to set the attribute value."); // Set the attribute value of this element setAttributeValue(path, values[0]); return true; } String[] segments = parsePath(path); String elementPath = segments[0]; // Try to treat the path as a key to its direct children elements // first List<Element> elements = getElementsOf(elementPath); Element newElement = null; if (elements == null) { // 'path' is not a key for its own direct children, thus split // it with '>' // For instance, "Child>GrandChild" would be split to {"Child", // "GrandChild"} then this element would: // 1) search "Child" as its direct children elements; // 2) if no <Child> element exists, create one; // 3) search "Child>GrandChild" as its direct children elements; // 4) if no exists, create new <GrandChild> as a new child of // <Child> element. String[] containers = elementPath.split(DefaultElementPathSign); String next = ""; Element last = this; for (int i = 0; i < containers.length; i++) { next += containers[i]; if (getElementsOf(next) == null) { newElement = new Element(containers[i], last); } last = getElementsOf(next).get(0); next += DefaultElementPathSign; } elements = getElementsOf(elementPath); } int size = values.length; if (size > elements.size()) { // In case the existing elements are less than values.length, // create new elements under the last container int lastChildMark = elementPath.lastIndexOf(DefaultElementPathSign); String lastContainerPath = lastChildMark == -1 ? "" : elementPath.substring(0, lastChildMark); String lastElementName = elementPath.substring(lastChildMark + 1); Element firstContainer = getElementsOf(lastContainerPath).get(0); for (int i = elements.size(); i < size; i++) { newElement = new Element(lastElementName, firstContainer); } elements = getElementsOf(elementPath); } if (segments.length == 1) { // The path identify Element, thus set their innerText for (int i = 0; i < size; i++) { elements.get(i).setValue(values[i]); } } else { // The path identify Attribute, thus set values of these // attribute accordingly String attributeName = segments[1]; for (int i = 0; i < size; i++) { elements.get(i).setAttributeValue(attributeName, values[i]); } } return true; } catch (InvalidParameterException ex) { ex.printStackTrace(); return false; } }
From source file:com.ifoer.expeditionphone.MainActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(Flags.FLAG8, Flags.FLAG8); contexts = this; this.loadSpecail = getIntent().getBooleanExtra("loadSpecail", false); FROMPATH = Constant.assestsPath;/*from w w w.ja v a2 s . c om*/ Locale locale = Locale.getDefault(); country = MainMenuActivity.country; if (country == null) { country = locale.getCountry(); } this.lanName = AndroidToLan.toLan(country); this.language = locale.getLanguage(); Constant.language = locale.toString(); if (this.loadSpecail) { setContentView(C0136R.layout.specia_function2); this.SpecialGridView = (GridView) findViewById(C0136R.id.main_WorkSpace); this.SpecialGridView.setHorizontalSpacing(15); this.SpecialGridView.setVerticalSpacing(15); this.SpecialGridView.setSelector(C0136R.color.transparent); this.SpecialGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE); this.mSpecilaBaseDiagAdapeter = createBaseDiagAdapter2(this.specialList); this.SpecialGridView.setAdapter(this.mSpecilaBaseDiagAdapeter); this.SpecialGridView.setOnItemClickListener(this); } else { setContentView(C0136R.layout.base_diagnose); LinearLayout lineLinear = (LinearLayout) findViewById(C0136R.id.diagnose_line2); this.mSlidePoinView = new SlidePointView(this); lineLinear.addView(this.mSlidePoinView); this.mSlidePoinView.postInvalidate(); this.mChinaCarGridView = new GridView(this); this.mAsiaCarGridView = new GridView(this); this.mEuroCarGridView = new GridView(this); this.mAmericaCarGridView = new GridView(this); this.mAmericaCarGridView.setHorizontalSpacing(15); this.mAmericaCarGridView.setVerticalSpacing(15); this.mAsiaCarGridView.setHorizontalSpacing(15); this.mAsiaCarGridView.setVerticalSpacing(15); this.mEuroCarGridView.setHorizontalSpacing(15); this.mEuroCarGridView.setVerticalSpacing(15); this.mAmericaCarGridView.setVerticalScrollBarEnabled(false); this.mAsiaCarGridView.setVerticalScrollBarEnabled(false); this.mEuroCarGridView.setVerticalScrollBarEnabled(false); this.mAsiaCarGridView.setSelector(C0136R.color.transparent); this.mEuroCarGridView.setSelector(C0136R.color.transparent); this.mAmericaCarGridView.setSelector(C0136R.color.transparent); LayoutParams linearParams = new LayoutParams(-2, -2); linearParams.width = C0136R.dimen.itemSize; linearParams.height = C0136R.dimen.itemSize; this.mChinaCarGridView.setLayoutParams(linearParams); this.mAsiaCarGridView.setLayoutParams(linearParams); this.mEuroCarGridView.setLayoutParams(linearParams); this.mAmericaCarGridView.setLayoutParams(linearParams); this.mChinaCarGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE); this.mAsiaCarGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE); this.mEuroCarGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE); this.mAmericaCarGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE); } MyApplication.getInstance().addActivity(this); createMainActivity(); MySharedPreferences.getSharedPref(this).edit().putString("CurrentPosition", Constant.language).commit(); MySharedPreferences.setString(contexts, MySharedPreferences.generateOperatingRecord, Contact.RELATION_ASK); if (MainMenuActivity.database != null) { database = MainMenuActivity.database; } else { database = DBDao.getInstance(this).getConnection(); } new Thread(new UpgradeRunnable(contexts)).start(); registerBoradcastReceiver(); try { dataDir = getPackageManager().getApplicationInfo(getPackageName(), 0).dataDir; } catch (NameNotFoundException e) { e.printStackTrace(); } try { serialPort = new SerialPortManager().getSerialPort(); } catch (InvalidParameterException e2) { e2.printStackTrace(); } catch (SecurityException e3) { e3.printStackTrace(); } catch (Exception e4) { e4.printStackTrace(); } if (MySharedPreferences.share == null) { MySharedPreferences.getSharedPref(this); } }
From source file:com.razerzone.store.sdk.engine.gamemaker.Plugin.java
public static String init(final String secretApiKey) { if (sEnableLogging) { Log.d(TAG, "init: secretApiKey=" + secretApiKey); }//from w ww . j av a 2s .co m final Activity activity = Plugin.getRelay().getCurrentActivity(); if (null == activity) { Log.d(TAG, "Current activity is null"); return sFalse; } else { Log.d(TAG, "Current activity is valid"); } final FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content); if (null == content) { Log.d(TAG, "Content is null"); return sFalse; } else { Runnable runnable = new Runnable() { public void run() { Log.d(TAG, "Disable screensaver"); content.setKeepScreenOn(true); Log.d(TAG, "Add inputView"); sInputView = new InputView(activity); Bundle developerInfo = null; try { developerInfo = StoreFacade.createInitBundle(secretApiKey); } catch (InvalidParameterException e) { Log.e(TAG, e.getMessage()); activity.finish(); return; } if (sEnableLogging) { Log.d(TAG, "developer_id=" + developerInfo.getString(StoreFacade.DEVELOPER_ID)); } if (sEnableLogging) { Log.d(TAG, "developer_public_key length=" + developerInfo.getByteArray(StoreFacade.DEVELOPER_PUBLIC_KEY).length); } sInitCompleteListener = new CancelIgnoringResponseListener<Bundle>() { @Override public void onSuccess(Bundle bundle) { if (sEnableLogging) { Log.d(TAG, "InitCompleteListener: onSuccess"); } JSONObject json = new JSONObject(); try { json.put("method", "onSuccessInit"); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); sInitialized = true; } @Override public void onFailure(int errorCode, String errorMessage, Bundle optionalData) { if (sEnableLogging) { Log.d(TAG, "InitCompleteListener: onFailure errorCode=" + errorCode + " errorMessage=" + errorMessage); } JSONObject json = new JSONObject(); try { json.put("method", "onFailureInit"); JSONObject data = new JSONObject(); data.put("errorCode", Integer.toString(errorCode)); data.put("errorMessage", errorMessage); json.put("data", data); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } }; sStoreFacade = StoreFacade.getInstance(); try { sStoreFacade.init(activity, developerInfo, sInitCompleteListener); } catch (Exception e) { e.printStackTrace(); } sRequestLoginListener = new ResponseListener<Void>() { @Override public void onSuccess(Void result) { if (sEnableLogging) { Log.d(TAG, "sRequestLoginListener: onSuccess"); } JSONObject json = new JSONObject(); try { json.put("method", "onSuccessRequestLogin"); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } @Override public void onFailure(int errorCode, String errorMessage, Bundle optionalData) { if (sEnableLogging) { Log.e(TAG, "sRequestLoginListener: onFailure errorCode=" + errorCode + " errorMessage=" + errorMessage); } JSONObject json = new JSONObject(); try { json.put("method", "onFailureRequestLogin"); JSONObject data = new JSONObject(); data.put("errorCode", Integer.toString(errorCode)); data.put("errorMessage", errorMessage); json.put("data", data); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } @Override public void onCancel() { if (sEnableLogging) { Log.d(TAG, "sRequestLoginListener: onCancel"); } JSONObject json = new JSONObject(); try { json.put("method", "onCancelRequestLogin"); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } }; sRequestGamerInfoListener = new ResponseListener<GamerInfo>() { @Override public void onSuccess(GamerInfo info) { if (null == info) { Log.e(TAG, "GamerInfo is null!"); return; } if (sEnableLogging) { Log.d(TAG, "sRequestGamerInfoListener: onSuccess uuid=" + info.getUuid() + " username=" + info.getUsername()); } JSONObject json = new JSONObject(); try { json.put("method", "onSuccessRequestGamerInfo"); JSONObject data = new JSONObject(); data.put("uuid", info.getUuid()); data.put("username", info.getUsername()); json.put("data", data); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } @Override public void onFailure(int errorCode, String errorMessage, Bundle optionalData) { if (sEnableLogging) { Log.e(TAG, "sRequestGamerInfoListener: onFailure errorCode=" + errorCode + " errorMessage=" + errorMessage); } JSONObject json = new JSONObject(); try { json.put("method", "onFailureRequestGamerInfo"); JSONObject data = new JSONObject(); data.put("errorCode", Integer.toString(errorCode)); data.put("errorMessage", errorMessage); json.put("data", data); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } @Override public void onCancel() { if (sEnableLogging) { Log.d(TAG, "sRequestGamerInfoListener: onCancel"); } JSONObject json = new JSONObject(); try { json.put("method", "onCancelRequestGamerInfo"); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } }; sRequestProductsListener = new ResponseListener<List<Product>>() { @Override public void onSuccess(final List<Product> products) { if (null == products) { Log.e(TAG, "Products are null!"); return; } if (sEnableLogging) { Log.i(TAG, "sRequestProductsListener: onSuccess"); } JSONObject json = new JSONObject(); try { json.put("method", "onSuccessRequestProducts"); JSONArray data = new JSONArray(); int index = 0; for (Product product : products) { JSONObject item = new JSONObject(); try { item.put("currencyCode", product.getCurrencyCode()); item.put("description", product.getDescription()); item.put("identifier", product.getIdentifier()); item.put("localPrice", product.getLocalPrice()); item.put("name", product.getName()); item.put("originalPrice", product.getOriginalPrice()); item.put("percentOff", product.getPercentOff()); item.put("developerName", product.getDeveloperName()); data.put(index, item); ++index; } catch (JSONException e2) { } } json.put("data", data); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } @Override public void onFailure(int errorCode, String errorMessage, Bundle optionalData) { if (sEnableLogging) { Log.e(TAG, "sRequestProductsListener: onFailure errorCode=" + errorCode + " errorMessage=" + errorMessage); } JSONObject json = new JSONObject(); try { json.put("method", "onFailureRequestProducts"); JSONObject data = new JSONObject(); data.put("errorCode", Integer.toString(errorCode)); data.put("errorMessage", errorMessage); json.put("data", data); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } @Override public void onCancel() { if (sEnableLogging) { Log.i(TAG, "sRequestProductsListener: onCancel"); } JSONObject json = new JSONObject(); try { json.put("method", "onCancelRequestProducts"); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } }; sRequestPurchaseListener = new ResponseListener<PurchaseResult>() { @Override public void onSuccess(PurchaseResult result) { if (null == result) { Log.e(TAG, "PurchaseResult is null!"); return; } if (sEnableLogging) { Log.i(TAG, "sRequestPurchaseListener: onSuccess"); } JSONObject json = new JSONObject(); try { json.put("method", "onSuccessRequestPurchase"); JSONObject data = new JSONObject(); data.put("identifier", result.getProductIdentifier()); data.put("ownerId", result.getOrderId()); json.put("data", data); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } @Override public void onFailure(int errorCode, String errorMessage, Bundle optionalData) { if (sEnableLogging) { Log.e(TAG, "sRequestPurchaseListener: onFailure errorCode=" + errorCode + " errorMessage=" + errorMessage); } JSONObject json = new JSONObject(); try { json.put("method", "onFailureRequestPurchase"); JSONObject data = new JSONObject(); data.put("errorCode", Integer.toString(errorCode)); data.put("errorMessage", errorMessage); json.put("data", data); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } @Override public void onCancel() { if (sEnableLogging) { Log.i(TAG, "sRequestPurchaseListener: onCancel"); } JSONObject json = new JSONObject(); try { json.put("method", "onCancelRequestPurchase"); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } }; sRequestReceiptsListener = new ResponseListener<Collection<Receipt>>() { @Override public void onSuccess(Collection<Receipt> receipts) { if (null == receipts) { Log.e(TAG, "Receipts are null!"); return; } if (sEnableLogging) { Log.i(TAG, "requestReceipts onSuccess: received " + receipts.size() + " receipts"); } JSONObject json = new JSONObject(); try { json.put("method", "onSuccessRequestReceipts"); JSONArray data = new JSONArray(); int index = 0; for (Receipt receipt : receipts) { JSONObject item = new JSONObject(); try { item.put("identifier", receipt.getIdentifier()); item.put("purchaseDate", receipt.getPurchaseDate()); item.put("gamer", receipt.getGamer()); item.put("uuid", receipt.getUuid()); item.put("localPrice", receipt.getLocalPrice()); item.put("currency", receipt.getCurrency()); item.put("generatedDate", receipt.getGeneratedDate()); data.put(index, item); ++index; } catch (JSONException e2) { } } json.put("data", data); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } @Override public void onFailure(int errorCode, String errorMessage, Bundle optionalData) { if (sEnableLogging) { Log.e(TAG, "requestReceipts onFailure: errorCode=" + errorCode + " errorMessage=" + errorMessage); } JSONObject json = new JSONObject(); try { json.put("method", "onFailureRequestReceipts"); JSONObject data = new JSONObject(); data.put("errorCode", Integer.toString(errorCode)); data.put("errorMessage", errorMessage); json.put("data", data); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } @Override public void onCancel() { if (sEnableLogging) { Log.i(TAG, "requestReceipts onCancel"); } JSONObject json = new JSONObject(); try { json.put("method", "onCancelRequestReceipts"); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } }; sShutdownListener = new CancelIgnoringResponseListener<Void>() { @Override public void onSuccess(Void aVoid) { if (sEnableLogging) { Log.i(TAG, "shutdown onSuccess"); } JSONObject json = new JSONObject(); try { json.put("method", "onSuccessShutdown"); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } @Override public void onFailure(int i, String s, Bundle bundle) { if (sEnableLogging) { Log.i(TAG, "shutdown onFailure"); } JSONObject json = new JSONObject(); try { json.put("method", "onFailureShutdown"); } catch (JSONException e1) { } String jsonData = json.toString(); sAsyncResults.add(jsonData); } }; Controller.init(activity); } }; activity.runOnUiThread(runnable); } return sTrue; }