@Override public void write(byte b[]) throws IOException { write(b, 0, b.length); }
public void writeTo(OutputStream os) throws IOException { // the message should not change between the constructor and this call try { if (buf != null) os.write(buf, 0, msgSize); else { os = new CRLFOutputStream(os); msg.writeTo(os); } } catch (MessagingException mex) { // exceptions here are bad, "should" never happen throw new IOException("MessagingException while appending message: " + mex); } } }
/** * Ensure we're at the beginning of a line. * Write CRLF if not. * * @exception IOException if the write fails */ public void ensureAtBOL() throws IOException { if (!atBOL) super.writeln(); } }
public byte[] canonicalize(byte[] inputBytes) throws XWSSecurityException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); CRLFOutputStream crlfOutStream = new CRLFOutputStream(bout); try { crlfOutStream.write(inputBytes); } catch (IOException e) { log.log(Level.SEVERE, "WSS1002.error.canonicalizing.textplain", new Object[] {e.getMessage()}); throw new XWSSecurityException(e); } return bout.toByteArray(); }
if(outputStream == null){ bout = new ByteArrayOutputStream(); crlfOutStream = new CRLFOutputStream(bout); }else{ crlfOutStream = new CRLFOutputStream(outputStream); crlfOutStream.write(data,0,len); len = input.read(data); } catch (IOException e) {
public void write(byte b[]) throws IOException { write(b, 0, b.length); }
/** * Ensure we're at the beginning of a line. * Write CRLF if not. * * @exception IOException if the write fails */ public void ensureAtBOL() throws IOException { if (!atBOL) super.writeln(); } }
@Override public void writeTo(OutputStream os) throws IOException { // the message should not change between the constructor and this call try { if (buf != null) os.write(buf, 0, msgSize); else { os = new CRLFOutputStream(os); msg.writeTo(os); } } catch (MessagingException mex) { // exceptions here are bad, "should" never happen throw new IOException("MessagingException while appending message: " + mex); } } }
public void write(byte b[], int off, int len) throws IOException { int lastc = (lastb == -1) ? '\n' : lastb; int start = off; len += off; for (int i = off; i < len; i++) { if ((lastc == '\n' || lastc == '\r') && b[i] == '.') { super.write(b, start, i - start); out.write('.'); start = i; } lastc = b[i]; } if ((len - start) > 0) super.write(b, start, len - start); }
public MessageLiteral(Message msg, int maxsize) throws MessagingException, IOException { this.msg = msg; // compute the size here so exceptions can be returned immediately LengthCounter lc = new LengthCounter(maxsize); OutputStream os = new CRLFOutputStream(lc); msg.writeTo(os); os.flush(); msgSize = lc.getSize(); buf = lc.getBytes(); }
@Override public void write(int b) throws IOException { // if that last character was a newline, and the current // character is ".", we always write out an extra ".". if ((lastb == '\n' || lastb == '\r' || lastb == -1) && b == '.') { out.write('.'); } super.write(b); }
public MessageLiteral(Message msg, int maxsize) throws MessagingException, IOException { this.msg = msg; // compute the size here so exceptions can be returned immediately LengthCounter lc = new LengthCounter(maxsize); OutputStream os = new CRLFOutputStream(lc); msg.writeTo(os); os.flush(); msgSize = lc.getSize(); buf = lc.getBytes(); }
public void write(int b) throws IOException { // if that last character was a newline, and the current // character is ".", we always write out an extra ".". if ((lastb == '\n' || lastb == '\r' || lastb == -1) && b == '.') { out.write('.'); } super.write(b); }
public void write(byte b[], int off, int len) throws IOException { int start = off; len += off; for (int i = start; i < len ; i++) { if (b[i] == '\r') { out.write(b, start, i - start); writeln(); start = i + 1; } else if (b[i] == '\n') { if (lastb != '\r') { out.write(b, start, i - start); writeln(); } start = i + 1; } lastb = b[i]; } if ((len - start) > 0) { out.write(b, start, len - start); atBOL = false; } }
public void writeTo(OutputStream os) throws IOException { // the message should not change between the constructor and this call try { if (buf != null) os.write(buf, 0, msgSize); else { os = new CRLFOutputStream(os); msg.writeTo(os); } } catch (MessagingException mex) { // exceptions here are bad, "should" never happen throw new IOException("MessagingException while appending message: " + mex); } } }
@Override public void write(byte b[], int off, int len) throws IOException { int lastc = (lastb == -1) ? '\n' : lastb; int start = off; len += off; for (int i = off; i < len; i++) { if ((lastc == '\n' || lastc == '\r') && b[i] == '.') { super.write(b, start, i - start); out.write('.'); start = i; } lastc = b[i]; } if ((len - start) > 0) super.write(b, start, len - start); }
@Override public void write(byte b[], int off, int len) throws IOException { int start = off; len += off; for (int i = start; i < len ; i++) { if (b[i] == '\r') { out.write(b, start, i - start); writeln(); start = i + 1; } else if (b[i] == '\n') { if (lastb != '\r') { out.write(b, start, i - start); writeln(); } start = i + 1; } lastb = b[i]; } if ((len - start) > 0) { out.write(b, start, len - start); atBOL = false; } }
/** * Create a canonicalized version of a given mime message * * @param mimeMessage * the message to canonicalize * @return a mime message in the canonical form * @throws IOException * @throws MessagingException */ protected MimeMessage canonicalizeMessage(MimeMessage mimeMessage) throws IOException, MessagingException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); CRLFOutputStream crlfOutputStream = new CRLFOutputStream(byteArrayOutputStream); mimeMessage.writeTo(crlfOutputStream); return new MimeMessage((Session)null, new ByteArrayInputStream(byteArrayOutputStream.toByteArray())); }