/** * Extracts the server nonce out of the given message type 2. * * @param message the String containing the base64 encoded message. * @return an array of 8 bytes that the server sent to be used when * hashing the password. */ public byte[] parseType2Message(String message) { // Decode the message first. byte[] msg = Base64.decodeBase64(EncodingUtil.getBytes(message, DEFAULT_CHARSET)); byte[] nonce = new byte[8]; // The nonce is the 8 bytes starting from the byte in position 24. for (int i = 0; i < 8; i++) { nonce[i] = msg[i + 24]; } return nonce; }
/** * Gets the content in bytes. Bytes are lazily created to allow the charset to be changed * after the part is created. * * @return the content in bytes */ private byte[] getContent() { if (content == null) { content = EncodingUtil.getBytes(value, getCharSet()); } return content; }
/** * @deprecated Use {@link #print(String, String)} * * Writes the specified String (as bytes) to the output stream. * * @param data the string to be written * @throws IllegalStateException if the connection is not open * @throws IOException if an I/O problem occurs */ public void print(String data) throws IOException, IllegalStateException { LOG.trace("enter HttpConnection.print(String)"); write(EncodingUtil.getBytes(data, "ISO-8859-1")); }
/** * Writes the specified String (as bytes) to the output stream. * * @param data the string to be written * @param charset the charset to use for writing the data * @throws IllegalStateException if the connection is not open * @throws IOException if an I/O problem occurs * * @since 3.0 */ public void print(String data, String charset) throws IOException, IllegalStateException { LOG.trace("enter HttpConnection.print(String)"); write(EncodingUtil.getBytes(data, charset)); }
/** * @deprecated Use {@link #printLine(String, String)} * * Writes the specified String (as bytes), followed by * <tt>"\r\n".getBytes()</tt> to the output stream. * * @param data the data to be written * @throws IllegalStateException if the connection is not open * @throws IOException if an I/O problem occurs */ public void printLine(String data) throws IOException, IllegalStateException { LOG.trace("enter HttpConnection.printLine(String)"); writeLine(EncodingUtil.getBytes(data, "ISO-8859-1")); }
/** * Writes the specified String (as bytes), followed by * <tt>"\r\n".getBytes()</tt> to the output stream. * * @param data the data to be written * @param charset the charset to use for writing the data * @throws IllegalStateException if the connection is not open * @throws IOException if an I/O problem occurs * * @since 3.0 */ public void printLine(String data, String charset) throws IOException, IllegalStateException { LOG.trace("enter HttpConnection.printLine(String)"); writeLine(EncodingUtil.getBytes(data, charset)); }
/** * Returns a basic <tt>Authorization</tt> header value for the given * {@link UsernamePasswordCredentials} and charset. * * @param credentials The credentials to encode. * @param charset The charset to use for encoding the credentials * * @return a basic authorization string * * @since 3.0 */ public static String authenticate(UsernamePasswordCredentials credentials, String charset) { LOG.trace("enter BasicScheme.authenticate(UsernamePasswordCredentials, String)"); if (credentials == null) { throw new IllegalArgumentException("Credentials may not be null"); } if (charset == null || charset.length() == 0) { throw new IllegalArgumentException("charset may not be null or empty"); } StringBuffer buffer = new StringBuffer(); buffer.append(credentials.getUserName()); buffer.append(":"); buffer.append(credentials.getPassword()); return "Basic " + EncodingUtil.getAsciiString( Base64.encodeBase64(EncodingUtil.getBytes(buffer.toString(), charset))); }
/** * Escape and encode a given string with allowed characters not to be * escaped and a given charset. * * @param unescaped a string * @param allowed allowed characters not to be escaped * @param charset the charset * @return the escaped string */ public static String encode(String unescaped, BitSet allowed, String charset) throws URIException { byte[] rawdata = URLCodec.encodeUrl(allowed, EncodingUtil.getBytes(unescaped, charset)); return EncodingUtil.getAsciiString(rawdata); }
throw new IllegalArgumentException("Allowed bitset may not be null"); byte[] rawdata = URLCodec.encodeUrl(allowed, EncodingUtil.getBytes(original, charset)); return EncodingUtil.getAsciiString(rawdata).toCharArray();
String tmp2=encode(md5Helper.digest(EncodingUtil.getBytes(a1, charset))); StringBuffer tmp3 = new StringBuffer(tmp2.length() + nonce.length() + cnonce.length() + 2); tmp3.append(tmp2); LOG.warn("Unhandled algorithm " + algorithm + " requested"); String md5a1 = encode(md5Helper.digest(EncodingUtil.getBytes(a1, charset)));
byte[] passw = EncodingUtil.getBytes(password.toUpperCase(), credentialCharset); byte[] lmPw1 = new byte[7]; byte[] lmPw2 = new byte[7];
host = host.toUpperCase(); user = user.toUpperCase(); byte[] domainBytes = EncodingUtil.getBytes(domain, DEFAULT_CHARSET); byte[] hostBytes = EncodingUtil.getBytes(host, DEFAULT_CHARSET); byte[] userBytes = EncodingUtil.getBytes(user, credentialCharset); int domainLen = domainBytes.length; int hostLen = hostBytes.length; + userLen + hostLen; prepareResponse(finalLength); byte[] ntlmssp = EncodingUtil.getBytes("NTLMSSP", DEFAULT_CHARSET); addBytes(ntlmssp); addByte((byte) 0);
/** * Gets the content in bytes. Bytes are lazily created to allow the charset to be changed * after the part is created. * * @return the content in bytes */ private byte[] getContent() { if (content == null) { content = EncodingUtil.getBytes(value, getCharSet()); } return content; }
private byte[] getContent() { if (this.content == null) { this.content = EncodingUtil.getBytes(this.value, this.getCharSet()); } return this.content; }
/** * Gets the content in bytes. Bytes are lazily created to allow the charset to be changed * after the part is created. * * @return the content in bytes */ private byte[] getContent() { if (content == null) { content = EncodingUtil.getBytes(value, getCharSet()); } return content; }
/** * Gets the content in bytes. Bytes are lazily created to allow the charset to be changed * after the part is created. * * @return the content in bytes */ private byte[] getContent() { if (content == null) { content = EncodingUtil.getBytes(value, getCharSet()); } return content; }
/** * Gets the content in bytes. Bytes are lazily created to allow the charset to be changed * after the part is created. * * @return the content in bytes */ private byte[] getContent() { if (content == null) { content = EncodingUtil.getBytes(value, getCharSet()); } return content; }
/** * @deprecated Use {@link #print(String, String)} * * Writes the specified String (as bytes) to the output stream. * * @param data the string to be written * @throws IllegalStateException if the connection is not open * @throws IOException if an I/O problem occurs */ public void print(String data) throws IOException, IllegalStateException { LOG.trace("enter HttpConnection.print(String)"); write(EncodingUtil.getBytes(data, "ISO-8859-1")); }
/** * @deprecated Use {@link #print(String, String)} * * Writes the specified String (as bytes) to the output stream. * * @param data the string to be written * @throws IllegalStateException if the connection is not open * @throws IOException if an I/O problem occurs */ public void print(String data) throws IOException, IllegalStateException { LOG.trace("enter HttpConnection.print(String)"); write(EncodingUtil.getBytes(data, "ISO-8859-1")); }