/** * Encrypt the data. * @param key The key. * @param bytes The data * @return byte[] The encrypted data * @throws HttpException If {@link Cipher.doFinal(byte[])} fails */ private byte[] encrypt(byte[] key, byte[] bytes) throws AuthenticationException { Cipher ecipher = getCipher(key); try { byte[] enc = ecipher.doFinal(bytes); return enc; } catch (IllegalBlockSizeException e) { throw new AuthenticationException("Invalid block size for DES encryption.", e); } catch (BadPaddingException e) { throw new AuthenticationException("Data not padded correctly for DES encryption.", e); } }
private void authenticate(final HttpMethod method) { try { if (this.conn.isProxied() && !this.conn.isSecure()) { authenticateProxy(method); } authenticateHost(method); } catch (AuthenticationException e) { LOG.error(e.getMessage(), e); } }
/** * Return the cipher for the specified key. * @param key The key. * @return Cipher The cipher. * @throws AuthenticationException If the cipher cannot be retrieved. */ private Cipher getCipher(byte[] key) throws AuthenticationException { try { final Cipher ecipher = Cipher.getInstance("DES/ECB/NoPadding"); key = setupKey(key); ecipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "DES")); return ecipher; } catch (NoSuchAlgorithmException e) { throw new AuthenticationException("DES encryption is not available.", e); } catch (InvalidKeyException e) { throw new AuthenticationException("Invalid key for DES encryption.", e); } catch (NoSuchPaddingException e) { throw new AuthenticationException( "NoPadding option for DES is not available.", e); } }
authenticateProxy(this.connectMethod); } catch (AuthenticationException e) { LOG.error(e.getMessage(), e);
throw new AuthenticationException( "Unsupported qop in HTTP Digest authentication"); md5Helper = MessageDigest.getInstance(digAlg); } catch (Exception e) { throw new AuthenticationException( "Unsupported algorithm in HTTP Digest authentication: " + digAlg);
private void authenticate(final HttpMethod method) { try { if (this.conn.isProxied() && !this.conn.isSecure()) { authenticateProxy(method); } authenticateHost(method); } catch (AuthenticationException e) { LOG.error(e.getMessage(), e); } }
throw new AuthenticationException(id + " authorization challenge expected, but not found");
private void authenticate(final HttpMethod method) { try { if (this.conn.isProxied() && !this.conn.isSecure()) { authenticateProxy(method); } authenticateHost(method); } catch (AuthenticationException e) { LOG.error(e.getMessage(), e); } }
/** Read a byte from a position within the message buffer */ protected byte readByte(final int position) throws AuthenticationException { if (messageContents.length < position + 1) { throw new AuthenticationException("NTLM: Message too short"); } return messageContents[position]; }
private void authenticate(final HttpMethod method) { try { if (this.conn.isProxied() && !this.conn.isSecure()) { authenticateProxy(method); } authenticateHost(method); } catch (AuthenticationException e) { LOG.error(e.getMessage(), e); } }
/** * Find the character set based on the flags. * @param flags is the flags. * @return the character set. */ private static Charset getCharset(final int flags) throws AuthenticationException { if ((flags & FLAG_REQUEST_UNICODE_ENCODING) == 0) { return DEFAULT_CHARSET; } else { if (UNICODE_LITTLE_UNMARKED == null) { throw new AuthenticationException( "Unicode not supported" ); } return UNICODE_LITTLE_UNMARKED; } }
private void authenticate(final HttpMethod method) { try { if (this.conn.isProxied() && !this.conn.isSecure()) { authenticateProxy(method); } authenticateHost(method); } catch (AuthenticationException e) { LOG.error(e.getMessage(), e); } }
/** Read a bunch of bytes from a position in the message buffer */ protected void readBytes(final byte[] buffer, final int position) throws AuthenticationException { if (messageContents.length < position + buffer.length) { throw new AuthenticationException("NTLM: Message too short"); } System.arraycopy(messageContents, position, buffer, 0, buffer.length); }
private void authenticate(final HttpMethod method) { try { if (this.conn.isProxied() && !this.conn.isSecure()) { authenticateProxy(method); } authenticateHost(method); } catch (AuthenticationException e) { LOG.error(e.getMessage(), e); } }
private String generateNonce() throws AuthenticationException { try { SecureRandom sr = SecureRandom.getInstance("SHA1PRNG"); byte[] temp = new byte[NONCE_LENGTH]; sr.nextBytes(temp); String n = new String(Hex.encodeHex(temp)); return n; } catch (Exception e) { throw new AuthenticationException(e.getMessage(), e); } }
throw new ReviewboardException(e.getMessage(), e); } finally { loginRequest.releaseConnection();
private String generateNonce() throws AuthenticationException { try { SecureRandom sr = SecureRandom.getInstance("SHA1PRNG"); byte[] temp = new byte[NONCE_LENGTH]; sr.nextBytes(temp); String n = new String(Hex.encodeHex(temp)); return n; } catch (Exception e) { throw new AuthenticationException(e.getMessage(), e); } }
authenticateProxy(this.connectMethod); } catch (AuthenticationException e) { LOG.error(e.getMessage(), e);
/** Calculates RC4 */ static byte[] RC4(final byte[] value, final byte[] key) throws AuthenticationException { try { final Cipher rc4 = Cipher.getInstance("RC4"); rc4.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "RC4")); return rc4.doFinal(value); } catch (final Exception e) { throw new AuthenticationException(e.getMessage(), e); } }
authenticateProxy(this.connectMethod); } catch (AuthenticationException e) { LOG.error(e.getMessage(), e);