Examples of InternetHeaders


Examples of javax.mail.internet.InternetHeaders

          ByteArrayOutputStream os = new ByteArrayOutputStream();
          Writer writer = new OutputStreamWriter(MimeUtility.encode(os, "quoted-printable"),
              EncodingUtils.UTF8);
          writer.write(s);
          writer.close();
          InternetHeaders headers = new InternetHeaders();
          headers.setHeader("Content-Type", layout.getContentType() + "; charset=UTF-8");
          headers.setHeader("Content-Transfer-Encoding", "quoted-printable");
          part = new MimeBodyPart(headers, os.toByteArray());
        } catch (Exception ex) {
          StringBuilder contentBuilder = new StringBuilder(s);
          for (int i = 0; i < contentBuilder.length(); i++) {
            if (contentBuilder.charAt(i) >= 0x80) {
View Full Code Here

Examples of javax.mail.internet.InternetHeaders

        }
    }

    public InternetHeaders getInternetHeadersUID(int uid, String user)
        throws AccessControlException, AuthorizationException {
        InternetHeaders response = null;
        if (sequence.contains(new Integer(uid))) {
            BufferedInputStream inMsg = null;
            try {
                inMsg = new BufferedInputStream( new FileInputStream(path + File.separator + uid + MESSAGE_EXTENSION));
                response = new InternetHeaders(inMsg);
                inMsg.close();
            } catch(Exception e) {
                getLogger().error("Error reading headers of message from disc: " + e);
                e.printStackTrace();
                throw new
View Full Code Here

Examples of javax.mail.internet.InternetHeaders

     */
    public String getUniqueID() {
        FileInputStream fin = null;
        try {
            fin = new FileInputStream(articleFile);
            InternetHeaders headers = new InternetHeaders(fin);
            String[] idheader = headers.getHeader("Message-Id");
            return ( idheader.length > 0 ) ? idheader[0] : null;
        } catch(Exception ex) {
            throw new NNTPException(ex);
        } finally {
            IOUtil.shutdownStream(fin);
View Full Code Here

Examples of javax.mail.internet.InternetHeaders

     * @see org.apache.james.nntpserver.repository.NNTPArticle#writeOverview(PrintWriter)
     */
    public void writeOverview(PrintWriter prt) {
        try {
            FileInputStream fin = new FileInputStream(articleFile);
            InternetHeaders hdr = new InternetHeaders(fin);
            fin.close();
            String subject = hdr.getHeader("Subject",null);
            String author = hdr.getHeader("From",null);
            String date = hdr.getHeader("Date",null);
            String msgId = hdr.getHeader("Message-Id",null);
            String references = hdr.getHeader("References",null);
            long byteCount = articleFile.length();
            // TODO: Address the line count issue.
            long lineCount = -1;
            StringBuffer line=new StringBuffer(256)
                .append(getArticleNumber())      .append("\t")
View Full Code Here

Examples of javax.mail.internet.InternetHeaders

     * @see org.apache.james.nntpserver.repository.NNTPArticle#getHeader(String)
     */
    public String getHeader(String header) {
        try {
            FileInputStream fin = new FileInputStream(articleFile);
            InternetHeaders hdr = new InternetHeaders(fin);
            fin.close();
            return hdr.getHeader(header,null);
        } catch(Exception ex) {
            throw new NNTPException(ex);
        }
    }
View Full Code Here

Examples of javax.mail.internet.InternetHeaders

            //  and write to this outputstream

            //First handle the headers
            InputStream in = source.getInputStream();
            try {
                InternetHeaders headers = new InternetHeaders(in);
                PrintWriter pos = new InternetPrintWriter(new BufferedWriter(new OutputStreamWriter(headerOs), 512), true);
                for (Enumeration e = headers.getNonMatchingHeaderLines(ignoreList); e.hasMoreElements(); ) {
                    String header = (String)e.nextElement();
                    pos.println(header);
                }
                pos.println();
                pos.flush();
View Full Code Here

Examples of javax.mail.internet.InternetHeaders

      for( int i=0; i<certs.length; i++ ) {
        final String filename = "cert" + name + '-' + i + ".der";
        if (log.isDebugEnabled()) {
          log.debug("Returning certificate with issuerDN '"+CertTools.getIssuerDN(certs[i])+"' and subjectDN '"+CertTools.getSubjectDN(certs[i])+"'. Filename="+filename);
        }
        final InternetHeaders headers = new InternetHeaders();
        headers.addHeader("Content-type", "application/pkix-cert");
        headers.addHeader("Content-disposition", "attachment; filename="+filename);
        mp.addBodyPart(new MimeBodyPart(headers,certs[i].getEncoded()));
      }
      if (log.isTraceEnabled()) {
        log.trace("content type: "+mp.getContentType());       
      }
View Full Code Here

Examples of javax.mail.internet.InternetHeaders

                throw new IOException("Couldn't find MIME boundary: " + new String(boundary));
            }

            try {
                // TODO: Do we need to copy these headers somewhere?
                new InternetHeaders(stream);
            } catch (MessagingException e) {
                throw new RuntimeException(e);
            }

            body = new DelegatingInputStream(new MimeBodyPartInputStream(stream, boundary));
View Full Code Here

Examples of javax.mail.internet.InternetHeaders

            return null;
        }
        stream.unread(v);


        InternetHeaders headers;
        try {
            headers = new InternetHeaders(stream);
        } catch (MessagingException e) {
            // TODO create custom IOException
            throw new RuntimeException(e);
        }

        String id = headers.getHeader("Content-ID", null);
        if (id != null && id.startsWith("<")) {
            id = id.substring(1, id.length() - 1);
        } else {
            //no Content-ID, set cxf default ID
            id = "Content-ID: <root.message@cxf.apache.org";
View Full Code Here

Examples of javax.mail.internet.InternetHeaders

            if (!readTillFirstBoundary(stream, boundary)) {
                throw new IOException("Couldn't find MIME boundary: " + boundaryString);
            }

            try {
                InternetHeaders ih = new InternetHeaders(stream);
                message.put(InternetHeaders.class.getName(), ih);
                String val = ih.getHeader("Content-Type", "; ");
                if (!StringUtils.isEmpty(val)) {
                    String cs = HttpHeaderHelper.findCharset(val);
                    if (!StringUtils.isEmpty(cs)) {
                        message.put(Message.ENCODING, HttpHeaderHelper.mapCharset(cs));
                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.