• PUDN用户
    了解作者
  • Java
    开发工具
  • 5.7MB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 7
    下载次数
  • 2009-11-23 19:02
    上传日期
在网上下载的网上jsp邮件系统,用不明白,传上来大家研究研究
webmail.rar
内容介绍
/* CVS ID: $Id: WebMailSession.java,v 1.14 2001/03/26 17:08:11 wastl Exp $ */ package net.wastl.webmail.server; import java.net.*; import java.io.*; import java.util.*; import java.text.*; import javax.mail.*; import javax.mail.event.*; import javax.mail.internet.*; import net.wastl.webmail.misc.*; import net.wastl.webmail.xml.*; // No longer used: //import net.wastl.webmail.ui.html.JavaScriptFilter; //import net.wastl.webmail.ui.html.HTMLifier; import net.wastl.webmail.ui.html.Fancyfier; import net.wastl.webmail.server.http.HTTPRequestHeader; import net.wastl.webmail.exceptions.*; // Modified by exce, start import org.bulbul.webmail.util.TranscodeUtil; // Modified by exce, end import org.w3c.tidy.Tidy; import org.w3c.dom.*; /* * WebMailSession.java * * Created: Thu Feb 4 12:59:30 1999 * * Copyright (C) 1999-2001 Sebastian Schaffert * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * A user session for WebMail. * Contains the state of the actual user (loads it from disk). * Has a unique session-ID. * * * @author Sebastian Schaffert * @version $Revision: 1.14 $ */ /* 9/24/2000 devink - updated for challenge/response auth */ public class WebMailSession implements HTTPSession { /** When has the session been last accessed? */ private long last_access; /** The session-ID for this session */ private String session_code; /** Parent WebMailServer */ private WebMailServer parent; /** State of the current users configuration */ private XMLUserData user; private XMLUserModel model; /** Connections to Mailboxes */ private Hashtable connections; /** Connections to hosts */ private Hashtable stores; /** javax.mail Mailsession */ private Session mailsession; private InetAddress remote; /* Files attached to messages will be stored here. We will have to take care of possible memory problems! */ private Hashtable mime_parts_decoded; private boolean sent; private String remote_agent; private String remote_accepts; private int attachments_size=0; private String last_login; /** Save the login password. It will be used for the second try password if * opening a folder fails. */ private String login_password; private Object sess=null; private Hashtable folders; protected Vector need_expunge_folders; protected boolean is_logged_out=false; public WebMailSession(WebMailServer parent,Object parm,HTTPRequestHeader h) throws UserDataException, InvalidPasswordException { try { Class srvltreq=Class.forName("javax.servlet.http.HttpServletRequest"); if(srvltreq.isInstance(parm)) { javax.servlet.http.HttpServletRequest req=(javax.servlet.http.HttpServletRequest)parm; this.sess=req.getSession(false); session_code=((javax.servlet.http.HttpSession)sess).getId(); try { remote=InetAddress.getByName(req.getRemoteHost()); } catch(UnknownHostException e) { try { remote=InetAddress.getByName(req.getRemoteAddr()); } catch(Exception ex) { try { remote=InetAddress.getByName("localhost"); } catch(Exception ex2) {} } } } else { throw new Exception("Servlet class found but not running as servlet"); } } catch(Throwable t) { this.remote=(InetAddress)parm; session_code=Helper.calcSessionCode(remote,h); } doInit(parent,h); } /** * This method does the actual initialisation * * devink 7/15/2000 - added TwoPassAuthenticationException * - updated call to getUserData(), to use my new one. * devink 9/24/2000 - reverted back to old getUserData call */ protected void doInit(WebMailServer parent, HTTPRequestHeader h) throws UserDataException, InvalidPasswordException { setLastAccess(); this.parent=parent; remote_agent=h.getHeader("User-Agent").replace('\n',' '); remote_accepts=h.getHeader("Accept").replace('\n',' '); parent.getStorage().log(Storage.LOG_INFO,"WebMail: New Session ("+session_code+")"); user=WebMailServer.getStorage().getUserData(h.getContent("login"),h.getContent("vdom"),h.getContent("password"),true); last_login=user.getLastLogin(); user.login(); login_password=h.getContent("password"); model=parent.getStorage().createXMLUserModel(user); connections=new Hashtable(); stores=new Hashtable(); folders=new Hashtable(); mailsession=Session.getDefaultInstance(System.getProperties(),null); /* If the user logs in for the first time we want all folders subscribed */ if(user.getLoginCount().equals("1")) { Enumeration enum=user.mailHosts(); while(enum.hasMoreElements()) { String id=(String)enum.nextElement(); if(user.getMailHost(id).getName().equals("Default")) { try { setSubscribedAll(id,true); } catch(MessagingException ex) { ex.printStackTrace(); } break; } } } setEnv(); } public XMLUserModel getUserModel() { return model; } public Document getModel() { return model.getRoot(); } /** * Calculate session-ID for a session. * * @param a Adress of the remote host * @param h Requestheader of the remote user agent * @returns Session-ID */ public String calcCode(InetAddress a, HTTPRequestHeader h) { if(sess==null) { return Helper.calcSessionCode(a,h); } else { try { Class srvltreq=Class.forName("javax.servlet.http.HttpSession"); if(srvltreq.isInstance(sess)) { return ((javax.servlet.http.HttpSession)sess).getId(); } else { return "error"; } } catch(Throwable t) { return "error"; } } } /** * Login to this session. * Establishes connections to a user�s Mailhosts * * @param h RequestHeader with content from Login-POST operation. * @deprecated Use login() instead, no need for parameters and exception handling */ public void login(HTTPRequestHeader h) throws InvalidPasswordException { //user.login(h.getContent("password")); login(); } /** * Login this session. * * Updates access time, sets initial environment and connects all configured mailboxes. */ public void login() { setLastAccess(); setEnv(); connectAll(); } /** * Return a locale-specific string resource */ public String getStringResource(String key) { return parent.getStorage().getStringResource(key,user.getPreferredLocale()); } /** * Create a Message List. * Fetches a list of headers in folder foldername for part list_part. * The messagelist will be stored in the "MESSAGES" environment. * * @param foldername folder for which a message list should be built * @param list_part part of list to display (1 = last xx messages, 2 = total-2*xx - total-xx messages) */ public void createMessageList(String folderhash,int list_part) throws NoSuchFolderException { long time_start=System.currentTimeMillis(); TimeZone tz=TimeZone.getDefault(); DateFormat
评论
    相关推荐
    • WebMail.rar
      Jsp做的网络邮件管理系统系统中采用了反射技术,使用Jsp+Servlet实现
    • Madirish Webmail-开源
      Madirish Webmail是基于PHP的电子邮件代理(带有通讯簿和日历),主要用于通过Web访问POP3帐户。 该系统使用MySQL和PHP,并且虽然是为Linux开发的,但可能会在其他平台上运行。 地址簿
    • modoboa-webmail:Modoboa的网络邮件
      通过运行以下命令在系统范围内或虚拟环境中安装此扩展程序: $ pip install modoboa-webmail 编辑您的modoboa实例的settings.py文件,并在MODOBOA_APPS变量中添加modoboa_webmail ,如下所示: MODOBOA_APPS = ( ...
    • 邮件系统javamail
      基于javamail实现的邮件发送接收的系统javamail
    • @Focusexe 邮件系统
      中国网络技术联盟对国内外领先的大容量电子邮件系统进行了深入的分析、评测,同时对国内Internet服务提供商及E-mail用户进行了客观的调查研究,在此基础上自主研制开发了适合用户需求的大容量电子邮件系统 @FocusExe...
    • 网鸽邮件系统 v4.8.1
      · 邮件服务器和WEBMAIL均采用C语言编写,从而将系统的整体性能发挥到极至。 · 系统的安装和配置非常简单,整个过程仅需2分钟即可完成。 · 纯绿色软件,没有访问和修改注册表,没有更改系统目录下的共享库,且支持反...
    • ice webmail
      Java发送邮件 ice webmail邮件系统
    • 网鸽邮件系统 v6.0.zip
      网鸽邮件系统是一套快速、稳定、...· 邮件服务器和WEBMAIL均采用C语言编写(完全摈弃ASP、JAVA等脚本语言),从而将系统的整体性能发挥到极至。 · 网鸽邮件系统经过长时间的锤炼和完善,目前的最新版本为FI3.12版。
    • AfterLogic Webmail 6.3.4
      号称支持POP3和IMAP的Webmail从7.0版之后实际上就不支持POP3了,对于需要将收到的邮件保存到数据库的系统开发人员,只能寻找Webmail在7.0之前的版本进行参考。这个6.3.4版能够支持POP3,把邮件从服务器下载并保存到...
    • 在线邮箱管理系统WebMail
      有一般邮件系统邮件收发、文件夹管理功能 可以实现邮件的在线收发功能(可以选择html格式),支持多附件发送 利用TreeNode进行菜单管理 关于功能完善方面请自行调测增加 DB_51aspx中为MS SqlServer数据库文件,...