List of usage examples for java.security NoSuchAlgorithmException NoSuchAlgorithmException
public NoSuchAlgorithmException(Throwable cause)
From source file:au.edu.monash.merc.capture.util.httpclient.ssl.EasyX509TrustManager.java
/** * Constructor for EasyX509TrustManager. *//*from ww w . j ava 2 s.c o m*/ public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException { super(); TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); factory.init(keystore); TrustManager[] trustmanagers = factory.getTrustManagers(); if (trustmanagers.length == 0) { throw new NoSuchAlgorithmException("no trust manager found"); } this.standardTrustManager = (X509TrustManager) trustmanagers[0]; }
From source file:com.sun.socialsite.util.LeniantX509TrustManager.java
/** * Constructor for LeniantX509TrustManager. *///from w w w. ja v a 2 s.com public LeniantX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException { super(); TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); factory.init(keystore); TrustManager[] trustmanagers = factory.getTrustManagers(); if (trustmanagers.length == 0) { throw new NoSuchAlgorithmException("no trust manager found"); } this.standardTrustManager = (X509TrustManager) trustmanagers[0]; }
From source file:be.fedict.hsm.model.SignatureServiceBean.java
@Override public byte[] sign(String digestMethodAlgorithm, byte[] digestValue, String keyAlias) throws NoSuchAlgorithmException { LOG.debug("digest method algorithm: " + digestMethodAlgorithm); LOG.debug("key alias: " + keyAlias); Principal callerPrincipal = this.sessionContext.getCallerPrincipal(); LOG.debug("caller principal: " + callerPrincipal.getName()); LOG.debug(/* w ww . j av a 2s .c o m*/ "caller in role application: " + this.sessionContext.isCallerInRole(ApplicationRoles.APPLICATION)); long appId = Long.parseLong(callerPrincipal.getName()); ApplicationKeyEntity applicationKeyEntity = this.entityManager.find(ApplicationKeyEntity.class, new ApplicationKeyId(appId, keyAlias)); if (null == applicationKeyEntity) { throw new NoSuchAlgorithmException("unknown key alias: " + keyAlias); } String keyStoreAlias = applicationKeyEntity.getKeyStoreKeyAlias(); long keyStoreId = applicationKeyEntity.getKeyStore().getId(); String digestAlgo = digestMethodToDigestAlgo.get(digestMethodAlgorithm); if (null == digestAlgo) { throw new IllegalArgumentException("unsupported digest method algo: " + digestMethodAlgorithm); } byte[] signatureValue; try { signatureValue = this.keyStoreSingletonBean.sign(keyStoreId, keyStoreAlias, digestAlgo, digestValue); } catch (Exception e) { LOG.error("signature error: " + e.getMessage()); return null; } AuditEntity auditEntity = new AuditEntity(applicationKeyEntity.getApplication().getName(), keyAlias, applicationKeyEntity.getKeyStore().getName(), keyStoreAlias, new String(Hex.encodeHex(digestValue))); this.entityManager.persist(auditEntity); return signatureValue; }
From source file:be.fedict.commons.eid.jca.BeIDSignature.java
BeIDSignature(final String signatureAlgorithm) throws NoSuchAlgorithmException { LOG.debug("constructor: " + signatureAlgorithm); this.signatureAlgorithm = signatureAlgorithm; if (false == digestAlgos.containsKey(signatureAlgorithm)) { LOG.error("no such algo: " + signatureAlgorithm); throw new NoSuchAlgorithmException(signatureAlgorithm); }//from w w w.j av a 2 s. c o m final String digestAlgo = digestAlgos.get(signatureAlgorithm); if (null != digestAlgo) { this.messageDigest = MessageDigest.getInstance(digestAlgo); this.precomputedDigestOutputStream = null; } else { LOG.debug("NONE message digest"); this.messageDigest = null; this.precomputedDigestOutputStream = new ByteArrayOutputStream(); } }
From source file:com.microsoft.tfs.core.config.httpclient.internal.DefaultX509TrustManager.java
public DefaultX509TrustManager(final KeyStore keyStore) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException { final TrustManagerFactory factory = TrustManagerFactory .getInstance(TrustManagerFactory.getDefaultAlgorithm()); factory.init(keyStore);/*from w w w . j a v a2s. c om*/ final TrustManager[] trustManagers = factory.getTrustManagers(); if (trustManagers.length == 0) { throw new NoSuchAlgorithmException("No trust manager found"); //$NON-NLS-1$ } if (!(trustManagers[0] instanceof X509TrustManager)) { throw new NoSuchAlgorithmException("No X509 trust manager found"); //$NON-NLS-1$ } standardTrustManager = (X509TrustManager) trustManagers[0]; }
From source file:com.microsoft.azure.keyvault.cryptography.RsaKey.java
@Override public ListenableFuture<byte[]> decryptAsync(final byte[] ciphertext, final byte[] iv, final byte[] authenticationData, final byte[] authenticationTag, final String algorithm) throws NoSuchAlgorithmException { if (ciphertext == null) { throw new IllegalArgumentException("ciphertext"); }//from ww w .ja va2s . c om // Interpret the requested algorithm if (Strings.isNullOrWhiteSpace(algorithm)) { throw new IllegalArgumentException("algorithm"); } Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithm); if (baseAlgorithm == null || !(baseAlgorithm instanceof AsymmetricEncryptionAlgorithm)) { throw new NoSuchAlgorithmException(algorithm); } AsymmetricEncryptionAlgorithm algo = (AsymmetricEncryptionAlgorithm) baseAlgorithm; ICryptoTransform transform; ListenableFuture<byte[]> result; try { transform = algo.CreateDecryptor(_keyPair, _provider); result = Futures.immediateFuture(transform.doFinal(ciphertext)); } catch (Exception e) { result = Futures.immediateFailedFuture(e); } return result; }
From source file:com.intel.chimera.codec.OpensslCipher.java
private static Transform tokenizeTransformation(String transformation) throws NoSuchAlgorithmException { if (transformation == null) { throw new NoSuchAlgorithmException("No transformation given."); }//from ww w . j a va 2 s. c o m /* * Array containing the components of a Cipher transformation: * * index 0: algorithm (e.g., AES) * index 1: mode (e.g., CTR) * index 2: padding (e.g., NoPadding) */ String[] parts = new String[3]; int count = 0; StringTokenizer parser = new StringTokenizer(transformation, "/"); while (parser.hasMoreTokens() && count < 3) { parts[count++] = parser.nextToken().trim(); } if (count != 3 || parser.hasMoreTokens()) { throw new NoSuchAlgorithmException("Invalid transformation format: " + transformation); } return new Transform(parts[0], parts[1], parts[2]); }
From source file:com.archivas.clienttools.arcutils.utils.net.GetCertsX509TrustManager.java
public GetCertsX509TrustManager(HCAPProfile profile, final SSLCertificateCallback sslExceptionCallback) throws NoSuchAlgorithmException, NoSuchProviderException, KeyStoreException { super();// w ww . j a v a 2 s . co m this.profile = profile; this.hostname = profile.getHostname(); // getHostname returns the hostname provided in the // profile wizard synchronized (LOCK) { this.sslExceptionCallback = sslExceptionCallback; LOG.log(Level.FINER, "Entering GetCertsX509TrustManager(Keystore, callback)"); initStandardTrustManager(null); initPersistedTrustManager(); initMemoryTrustManager(); if (standardTrustManager == null && persistedTrustManager == null && memoryTrustManager == null) { throw new NoSuchAlgorithmException("no trust manager found"); } } }
From source file:com.intel.chimera.cipher.Openssl.java
private static Transform tokenizeTransformation(String transformation) throws NoSuchAlgorithmException { if (transformation == null) { throw new NoSuchAlgorithmException("No transformation given."); }//from w w w .j av a2s . c o m /* * Array containing the components of a Cipher transformation: * * index 0: algorithm (e.g., AES) * index 1: mode (e.g., CTR) * index 2: padding (e.g., NoPadding) */ String[] parts = new String[3]; int count = 0; StringTokenizer parser = new StringTokenizer(transformation, "/"); while (parser.hasMoreTokens() && count < 3) { parts[count++] = parser.nextToken().trim(); } if (count != 3 || parser.hasMoreTokens()) { throw new NoSuchAlgorithmException("Invalid transformation format: " + transformation); } return new Transform(parts[0], parts[1], parts[2]); }
From source file:com.microsoft.azure.keyvault.cryptography.RsaKey.java
@Override public ListenableFuture<Triple<byte[], byte[], String>> encryptAsync(final byte[] plaintext, final byte[] iv, final byte[] authenticationData, final String algorithm) throws NoSuchAlgorithmException { if (plaintext == null) { throw new IllegalArgumentException("plaintext"); }//w ww . j a v a 2s . c om // Interpret the requested algorithm String algorithmName = (Strings.isNullOrWhiteSpace(algorithm) ? getDefaultEncryptionAlgorithm() : algorithm); Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithmName); if (baseAlgorithm == null || !(baseAlgorithm instanceof AsymmetricEncryptionAlgorithm)) { throw new NoSuchAlgorithmException(algorithmName); } AsymmetricEncryptionAlgorithm algo = (AsymmetricEncryptionAlgorithm) baseAlgorithm; ICryptoTransform transform; ListenableFuture<Triple<byte[], byte[], String>> result; try { transform = algo.CreateEncryptor(_keyPair, _provider); result = Futures.immediateFuture(Triple.of(transform.doFinal(plaintext), (byte[]) null, algorithmName)); } catch (Exception e) { result = Futures.immediateFailedFuture(e); } return result; }