/** * Encodes the specified <code>byte</code> to this output stream. * * @param c the <code>byte</code>. * @exception IOException if an I/O error occurs. */ public synchronized void write(int c) throws IOException { buffer[bufsize++] = (byte)c; if (bufsize == 3) { // Encoding unit = 3 bytes encode(); bufsize = 0; } }
/** * Encode the data stored in <code>buffer</code>. * Uses <code>outbuf</code> to store the encoded * data before writing. * * @exception IOException if an I/O error occurs. */ private void encode() throws IOException { int osize = encodedSize(bufsize); out.write(encode(buffer, 0, bufsize, outbuf), 0, osize); // increment count count += osize; // If writing out this encoded unit caused overflow, // start a new line. if (count >= bytesPerLine) { if (!noCRLF) out.write(newline); count = 0; } }
/** * Base64 encode a byte array. No line breaks are inserted. * This method is suitable for short strings, such as those * in the IMAP AUTHENTICATE protocol, but not to encode the * entire content of a MIME part. * * @param inbuf the byte array * @return the encoded byte array */ public static byte[] encode(byte[] inbuf) { if (inbuf.length == 0) return inbuf; return encode(inbuf, 0, inbuf.length, null); }
/** * Encode the data stored in <code>buffer</code>. * Uses <code>outbuf</code> to store the encoded * data before writing. * * @exception IOException if an I/O error occurs. */ private void encode() throws IOException { int osize = encodedSize(bufsize); out.write(encode(buffer, 0, bufsize, outbuf), 0, osize); // increment count count += osize; // If writing out this encoded unit caused overflow, // start a new line. if (count >= bytesPerLine) { if (!noCRLF) out.write(newline); count = 0; } }
/** * Base64 encode a byte array. No line breaks are inserted. * This method is suitable for short strings, such as those * in the IMAP AUTHENTICATE protocol, but not to encode the * entire content of a MIME part. * * @param inbuf the byte array * @return the encoded byte array */ public static byte[] encode(byte[] inbuf) { if (inbuf.length == 0) return inbuf; return encode(inbuf, 0, inbuf.length, null); }
/** * Encodes the specified <code>byte</code> to this output stream. * * @param c the <code>byte</code>. * @exception IOException if an I/O error occurs. */ @Override public synchronized void write(int c) throws IOException { buffer[bufsize++] = (byte)c; if (bufsize == 3) { // Encoding unit = 3 bytes encode(); bufsize = 0; } }
/** * Flushes this output stream and forces any buffered output bytes * to be encoded out to the stream. * * @exception IOException if an I/O error occurs. */ public synchronized void flush() throws IOException { if (bufsize > 0) { // If there's unencoded characters in the buffer .. encode(); // .. encode them bufsize = 0; } out.flush(); }
/** * Flushes this output stream and forces any buffered output bytes * to be encoded out to the stream. * * @exception IOException if an I/O error occurs. */ @Override public synchronized void flush() throws IOException { if (bufsize > 0) { // If there's unencoded characters in the buffer .. encode(); // .. encode them bufsize = 0; } out.flush(); }
@Override String getInitialResponse(String host, String authzid, String user, String passwd) throws MessagingException, IOException { String resp = "user=" + user + "\001auth=Bearer " + passwd + "\001\001"; byte[] b = BASE64EncoderStream.encode( resp.getBytes(StandardCharsets.UTF_8)); return ASCIIUtility.toString(b); }
@Override void doAuth(String host, String authzid, String user, String passwd) throws MessagingException, IOException { // send username resp = simpleCommand(BASE64EncoderStream.encode( user.getBytes(StandardCharsets.UTF_8))); if (resp == 334) { // send passwd resp = simpleCommand(BASE64EncoderStream.encode( passwd.getBytes(StandardCharsets.UTF_8))); } } }
void doAuth(String host, String authzid, String user, String passwd) throws MessagingException, IOException { // send username resp = simpleCommand( BASE64EncoderStream.encode(ASCIIUtility.getBytes(user))); if (resp == 334) { // send passwd resp = simpleCommand( BASE64EncoderStream.encode(ASCIIUtility.getBytes(passwd))); } } }
String getInitialResponse(String host, String authzid, String user, String passwd) throws MessagingException, IOException { String resp = "user=" + user + "\001auth=Bearer " + passwd + "\001\001"; byte[] b = BASE64EncoderStream.encode(ASCIIUtility.getBytes(resp)); return ASCIIUtility.toString(b); }
getBytes(StandardCharsets.UTF_8); String proxyHeaderValue = new String( BASE64EncoderStream.encode(upbytes), StandardCharsets.US_ASCII); requestBuilder.append("Proxy-Authorization: Basic ").
public String generateType1Msg(int flags) { // XXX - should set "flags" in generated message int dlen = ntdomain.length(); type1[16]= (byte) (dlen % 256); type1[17]= (byte) (dlen / 256); type1[18] = type1[16]; type1[19] = type1[17]; if (dlen == 0) type1[13] &= ~0x10; int hlen = hostname.length(); type1[24]= (byte) (hlen % 256); type1[25]= (byte) (hlen / 256); type1[26] = type1[24]; type1[27] = type1[25]; copybytes(type1, 32, hostname, "iso-8859-1"); copybytes(type1, hlen+32, ntdomain, "iso-8859-1"); type1[20] = (byte) ((hlen+32) % 256); type1[21] = (byte) ((hlen+32) / 256); byte[] msg = new byte[32 + hlen + dlen]; System.arraycopy(type1, 0, msg, 0, 32 + hlen + dlen); if (logger.isLoggable(Level.FINE)) logger.fine("type 1 message: " + toHex(msg)); String result = null; try { result = new String(BASE64EncoderStream.encode(msg), "iso-8859-1"); } catch (UnsupportedEncodingException e) { assert false; } return result; }
public String generateType1Msg(int flags) { // XXX - should set "flags" in generated message int dlen = ntdomain.length(); type1[16]= (byte) (dlen % 256); type1[17]= (byte) (dlen / 256); type1[18] = type1[16]; type1[19] = type1[17]; if (dlen == 0) type1[13] &= ~0x10; int hlen = hostname.length(); type1[24]= (byte) (hlen % 256); type1[25]= (byte) (hlen / 256); type1[26] = type1[24]; type1[27] = type1[25]; copybytes(type1, 32, hostname, "iso-8859-1"); copybytes(type1, hlen+32, ntdomain, "iso-8859-1"); type1[20] = (byte) ((hlen+32) % 256); type1[21] = (byte) ((hlen+32) / 256); byte[] msg = new byte[32 + hlen + dlen]; System.arraycopy(type1, 0, msg, 0, 32 + hlen + dlen); if (logger.isLoggable(Level.FINE)) logger.fine("type 1 message: " + toHex(msg)); String result = null; try { result = new String(BASE64EncoderStream.encode(msg), "iso-8859-1"); } catch (UnsupportedEncodingException e) { assert false; } return result; }
result = new String(BASE64EncoderStream.encode(msg), "iso-8859-1"); } catch (UnsupportedEncodingException e) { assert false;
result = new String(BASE64EncoderStream.encode(msg), "iso-8859-1"); } catch (UnsupportedEncodingException e) { assert false;