List of usage examples for java.security NoSuchAlgorithmException printStackTrace
public void printStackTrace()
From source file:com.lewischooman.utils.Digester.java
@Override @SuppressWarnings("CallToPrintStackTrace") public byte[] digest(String toDigest) { MessageDigest mDigest;// ww w. j ava 2s . co m byte[] inBytes, outBytes = null; if (toDigest == null) { return null; } try { mDigest = MessageDigest.getInstance(this.algorithm); mDigest.reset(); inBytes = toDigest.getBytes(this.charset); mDigest.update(inBytes); outBytes = mDigest.digest(); } catch (NoSuchAlgorithmException ex) { ex.printStackTrace(); } return outBytes; }
From source file:org.opendatakit.briefcase.util.EncryptionInformation.java
public EncryptionInformation(String base64EncryptedSymmetricKey, String instanceId, PrivateKey rsaPrivateKey) throws CryptoException { try {/* w ww . j a va 2 s . c o m*/ // construct the base64-encoded RSA-encrypted symmetric key Cipher pkCipher; pkCipher = Cipher.getInstance(FileSystemUtils.ASYMMETRIC_ALGORITHM); // write AES key pkCipher.init(Cipher.DECRYPT_MODE, rsaPrivateKey); byte[] encryptedSymmetricKey = Base64.decodeBase64(base64EncryptedSymmetricKey); byte[] decryptedKey = pkCipher.doFinal(encryptedSymmetricKey); cipherFactory = new CipherFactory(instanceId, decryptedKey); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); throw new CryptoException("Error decrypting base64EncryptedKey Cause: " + e.toString()); } catch (NoSuchPaddingException e) { e.printStackTrace(); throw new CryptoException("Error decrypting base64EncryptedKey Cause: " + e.toString()); } catch (InvalidKeyException e) { e.printStackTrace(); throw new CryptoException("Error decrypting base64EncryptedKey Cause: " + e.toString()); } catch (IllegalBlockSizeException e) { e.printStackTrace(); throw new CryptoException("Error decrypting base64EncryptedKey Cause: " + e.toString()); } catch (BadPaddingException e) { e.printStackTrace(); throw new CryptoException("Error decrypting base64EncryptedKey Cause: " + e.toString()); } }
From source file:com.ibm.mobilefirstplatform.clientsdk.android.security.mca.internal.security.DefaultJSONSignerTests.java
public KeyPair generateRandomKeyPair() { KeyPair keyPair = null;//from w ww. ja v a2s. co m try { KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); kpg.initialize(512); keyPair = kpg.genKeyPair(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return keyPair; }
From source file:org.infoscoop.dao.model.Account.java
public void setPasswordPlainText(String plainTextPassword) { try {/* w ww . ja v a2 s. c om*/ MessageDigest digest = MessageDigest.getInstance("SHA"); this.password = new String( Base64.encodeBase64(digest.digest(plainTextPassword.getBytes("iso-8859-1")))); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
From source file:com.sisfin.util.CryptService.java
/** * Inicializa o session bean com o algoritmo de codificao definido no * arquivo de configurao dos beans.//from w ww . j a va2s .c om */ @PostConstruct public void init() { try { md = MessageDigest.getInstance(messageDigestAlgorithm); } catch (NoSuchAlgorithmException e) { // TODO: arrumar isso e.printStackTrace(); } }
From source file:org.ksoap2.transport.ServiceConnectionSE.java
public ServiceConnectionSE(String url) throws IOException { // //from www . j a v a 2s .com try { SSLContext sContext = SSLContext.getInstance("SSL"); sContext.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sContext.getSocketFactory()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (KeyManagementException e) { e.printStackTrace(); } connection = (HttpsURLConnection) new URL(url).openConnection(); ((HttpsURLConnection) connection).setHostnameVerifier(new AllowAllHostnameVerifier()); connection.setUseCaches(false); connection.setDoOutput(true); connection.setDoInput(true); }
From source file:com.abcseo.comments.dao.RepositoryMemHashImpl.java
public RepositoryMemHashImpl() { try {//from ww w . ja v a2 s. co m md = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:it.scsoft.tiuuid.TitaniumUUIDModule.java
@Kroll.method public String uuidForDevice() { // Serial/*from www . j a v a 2 s . c o m*/ String serial = android.os.Build.SERIAL; // IMEI String imei = ""; if (ContextCompat.checkSelfPermission(TiApplication.getInstance().getApplicationContext(), Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) { TelephonyManager telephonyManager = (TelephonyManager) TiApplication.getInstance() .getSystemService(Context.TELEPHONY_SERVICE); imei = telephonyManager.getDeviceId(); } // AndroidID String androidID = Secure.getString(TiApplication.getInstance().getContentResolver(), Secure.ANDROID_ID); // uuid String uuid = serial + imei + androidID; // MD5 hash via http://stackoverflow.com/questions/3934331/how-to-hash-a-string-in-android String hash = ""; MessageDigest digest; try { digest = MessageDigest.getInstance("MD5"); digest.update(uuid.getBytes(Charset.forName("US-ASCII")), 0, uuid.length()); byte[] magnitude = digest.digest(); BigInteger bi = new BigInteger(1, magnitude); hash = String.format("%0" + (magnitude.length << 1) + "x", bi); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return hash; }
From source file:eu.europa.esig.dss.cookbook.sources.JavaKeyStoreTool.java
public JavaKeyStoreTool(final String ksUrlLocation, final String ksPassword) { InputStream ksStream = null;//from w w w . jav a 2s . c om try { final URL ksLocation = new URL(ksUrlLocation); ks = KeyStore.getInstance(KeyStore.getDefaultType()); ksStream = ksLocation.openStream(); ks.load(ksStream, (ksPassword == null) ? null : ksPassword.toCharArray()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (CertificateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (KeyStoreException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(ksStream); } }
From source file:com.persistent.cloudninja.service.impl.ManageUsersServiceImpl.java
/** * This method returns the SHA-1 encoded HexPassword * /*from w w w .j a v a 2 s . co m*/ * @param password * the plain text password * @return hexpassword The SHA-1 encoded Hex password. */ private String getSHA1hexPassword(String password) { String hexPassword = ""; if (password != null && password.trim().length() > 0) { try { MessageDigest sha1Digest = MessageDigest.getInstance("SHA-1"); sha1Digest.update(password.trim().getBytes()); hexPassword = new String(Hex.encodeHex(sha1Digest.digest())).toUpperCase(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } } return hexPassword; }