List of usage examples for java.security NoSuchAlgorithmException getMessage
public String getMessage()
From source file:com.rockagen.gnext.service.spring.AuthUserServImpl.java
@Override public void add(AuthUser pojo) { if (pojo != null) { try {//w w w . j ava 2 s .com String salt = Crypto.getHexSalt(); String cipher = Crypto.sha1WithSalt(pojo.getPassWord(), salt); pojo.setSalt(salt); pojo.setPassWord(cipher); super.add(pojo); } catch (NoSuchAlgorithmException e) { log.error("{}", e.getMessage(), e); } catch (NoSuchProviderException e) { log.error("{}", e.getMessage(), e); } } }
From source file:securitytools.veracode.VeracodeAsyncClient.java
/** * Constructs a new asynchronous VeracodeClient using the specified * configuration./*www .j av a 2s . co m*/ * * @param credentials Credentials used to access Veracode services. * @param clientConfiguration Client configuration for options such as proxy * settings, user-agent header, and network timeouts. */ public VeracodeAsyncClient(VeracodeCredentials credentials, ClientConfiguration clientConfiguration) { this.clientConfiguration = clientConfiguration; CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(new AuthScope(TARGET), credentials); AuthCache authCache = new BasicAuthCache(); authCache.put(TARGET, new BasicScheme()); context = HttpClientContext.create(); context.setCredentialsProvider(credentialsProvider); context.setAuthCache(authCache); try { client = HttpClientFactory.buildAsync(clientConfiguration); } catch (NoSuchAlgorithmException nsae) { throw new VeracodeClientException(nsae.getMessage(), nsae); } }
From source file:org.xlcloud.encryption.AESEncryptionService.java
/** {@inheritDoc} */ public String encrypt(String message) throws EncryptionException { try {// ww w . j a v a 2 s . c o m Cipher cipher = Cipher.getInstance(ENCRYPTION_ALGORITHM); cipher.init(Cipher.ENCRYPT_MODE, buildEncryptionKey()); byte[] encrypted = cipher.doFinal(message.getBytes(ENCODING)); return Base64.encodeBase64String(encrypted); } catch (NoSuchAlgorithmException e) { LOG.error(e.getMessage()); throw new EncryptionException(e.getMessage(), e); } catch (NoSuchPaddingException e) { LOG.error(e.getMessage()); throw new EncryptionException(e.getMessage(), e); } catch (InvalidKeyException e) { LOG.error(e.getMessage()); throw new EncryptionException(e.getMessage(), e); } catch (UnsupportedEncodingException e) { LOG.error(e.getMessage()); throw new EncryptionException(e.getMessage(), e); } catch (IllegalBlockSizeException e) { LOG.error(e.getMessage()); throw new EncryptionException(e.getMessage(), e); } catch (BadPaddingException e) { LOG.error(e.getMessage()); throw new EncryptionException(e.getMessage(), e); } }
From source file:io.apiman.gateway.vertx.api.AuthenticatingRouteMatcher.java
private boolean basicAuth(HttpServerRequest request, String encodedAuth) { byte[] authBytes = Base64.decodeBase64(encodedAuth); String decodedString = new String(authBytes); String[] splitAuth = StringUtils.split(StringUtils.trim(decodedString), ":"); //$NON-NLS-1$ if (splitAuth.length != 2) return false; if (fileBasicAuthData.containsKey(splitAuth[0])) { String storedHash = new String(Base64.decodeBase64(fileBasicAuthData.get(splitAuth[0]))); MessageDigest digest;//w ww. j a v a 2s . co m try { digest = MessageDigest.getInstance("SHA-256"); //$NON-NLS-1$ digest.update(splitAuth[1].getBytes()); String receivedHash = new String(digest.digest()); if (storedHash.equals(receivedHash)) { return true; } } catch (NoSuchAlgorithmException e) { logger.error(e.getMessage(), e.getCause()); } } request.response().headers().add("WWW-Authenticate", "Basic realm=\"" + config.getRealm() + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return false; }
From source file:org.alfresco.repo.security.authentication.MD4PasswordEncoderImpl.java
private byte[] md4(String input) { try {//from ww w .ja v a 2 s. co m MessageDigest digester = MessageDigest.getInstance("MD4"); return digester.digest(input.getBytes("UnicodeLittleUnmarked")); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e.getMessage(), e); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:de.betterform.connector.http.ssl.KeyStoreSSLContext.java
private SSLContext createSSLContext() { try {// www.j a va 2 s . c om TrustManager[] trustmanagers = null; KeyManager[] keyManagers = null; if (getKeyStoreURL() != null) { BetterFORMKeyStoreManager bfkm = new BetterFORMKeyStoreManager(); bfkm.addCustomX509KeyManager(getKeyStoreURL(), getKeyStorePasswd()); keyManagers = new KeyManager[] { bfkm }; BetterFORMTrustManager trustManagers = new BetterFORMTrustManager(); trustManagers.addCustomX509TrustManager(getKeyStoreURL(), getKeyStorePasswd()); trustmanagers = trustManagers.getTrustManagers(); } SSLContext sslcontext = SSLContext.getInstance("SSL"); sslcontext.init(keyManagers, trustmanagers, null); return sslcontext; } catch (NoSuchAlgorithmException e) { LOGGER.error(e.getMessage(), e); throw new AuthSSLInitializationError("Unsupported algorithm exception: " + e.getMessage()); } catch (KeyStoreException e) { LOGGER.error(e.getMessage(), e); throw new AuthSSLInitializationError("Keystore exception: " + e.getMessage()); } catch (GeneralSecurityException e) { LOGGER.error(e.getMessage(), e); throw new AuthSSLInitializationError("Key management exception: " + e.getMessage()); } catch (IOException e) { LOGGER.error(e.getMessage(), e); throw new AuthSSLInitializationError("I/O error reading keystore/truststore file: " + e.getMessage()); } }
From source file:com.cubusmail.server.mail.security.MailPasswordEncryptor.java
/** * /*from ww w . j a va 2s.c o m*/ */ public void init() { try { this.keyPair = KeyPairGenerator.getInstance(this.algorithm).generateKeyPair(); } catch (NoSuchAlgorithmException e) { log.error(e.getMessage(), e); throw new IllegalStateException(e.getMessage(), e); } }
From source file:com.premiumminds.billy.portugal.services.certification.CertificationManager.java
public CertificationManager() { this.privateKey = null; this.publicKey = null; this.autoVerifyHash = false; try {//from w w w . j a va 2 s . c o m this.signature = Signature.getInstance("SHA1withRSA"); } catch (NoSuchAlgorithmException e) { CertificationManager.log.error(e.getMessage(), e); } }
From source file:com.lucidworks.security.authentication.util.Signer.java
/** * Returns then signature of a string./*from w w w.jav a 2 s. c o m*/ * * @param str string to sign. * * @return the signature for the string. */ protected String computeSignature(String str) { try { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(str.getBytes()); md.update(secret); byte[] digest = md.digest(); return new Base64(0).encodeToString(digest); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("It should not happen, " + ex.getMessage(), ex); } }
From source file:com.cloudera.alfredo.util.Signer.java
/** * Returns then signature of a string./*from w w w. j av a 2 s .c om*/ * * @param str string to sign. * @return the signature for the string. */ protected String computeSignature(String str) { try { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(str.getBytes()); md.update(secret); byte[] digest = md.digest(); Base64 base64 = new Base64(0); return base64.encodeToString(digest); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("It should not happen, " + ex.getMessage(), ex); } }