Author: norman
Date: Wed Sep 30 13:33:52 2009
New Revision: 820267
URL: http://svn.apache.org/viewvc?rev=820267&view=rev
Log:
Complete STARTTLS for pop3... wh00t (JAMES-924)
Modified:
james/server/trunk/phoenix-deployment/src/conf/james-config.xml
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/StlsCmdHandler.java
Modified: james/server/trunk/phoenix-deployment/src/conf/james-config.xml
URL:
http://svn.apache.org/viewvc/james/server/trunk/phoenix-deployment/src/conf/james-config.xml?rev=820267&r1=820266&r2=820267&view=diff
==============================================================================
--- james/server/trunk/phoenix-deployment/src/conf/james-config.xml (original)
+++ james/server/trunk/phoenix-deployment/src/conf/james-config.xml Wed Sep 30
13:33:52 2009
@@ -923,6 +923,19 @@
For example, Uncomment this if you want to use
BouncyCastle JCE (http://www.bouncycastle.org)
<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
-->
+
+ <!-- Set enable to true to support STARTTLS.
+ To use this you need to copy sunjce_provider.jar to /path/james/lib
directory.
+ -->
+ <startTLS enable="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore
/path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>yoursecret</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </startTLS>
+
<handler>
<!-- This is the name used by the server to identify itself in the
POP3 -->
<!-- protocol. If autodetect is TRUE, the server will discover its
-->
@@ -973,14 +986,13 @@
<!-- Set enable to true to support STARTTLS.
To use this you need to copy sunjce_provider.jar to /path/james/lib
directory.
-->
-
<startTLS enable="false">
<!-- To create a new keystore execute:
keytool -genkey -alias james -keyalg RSA -keystore
/path/to/james/conf/keystore
-->
<keystore>file://conf/keystore</keystore>
- <secret></secret>
+ <secret>yoursecret</secret>
<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
</startTLS>
Modified:
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/StlsCmdHandler.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/StlsCmdHandler.java?rev=820267&r1=820266&r2=820267&view=diff
==============================================================================
---
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/StlsCmdHandler.java
(original)
+++
james/server/trunk/pop3server-function/src/main/java/org/apache/james/pop3server/StlsCmdHandler.java
Wed Sep 30 13:33:52 2009
@@ -17,52 +17,61 @@
* under the License. *
****************************************************************/
-
package org.apache.james.pop3server;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Handler which offer STARTTLS implementation for POP3. STARTTLS is started
+ * with the STSL command
+ *
+ *
+ */
public class StlsCmdHandler implements CommandHandler, CapaCapability {
- private final static String COMMAND_NAME = "STLS";
+ public final static String COMMAND_NAME = "STLS";
- /**
- * @see
org.apache.james.pop3server.CommandHandler#onCommand(org.apache.james.pop3server.POP3Session)
- */
- public void onCommand(POP3Session session) {
- // check if starttls is supported, the state is the right one
and it was not started before
- if (session.isStartTLSSupported() && session.getHandlerState()
== POP3Handler.TRANSACTION && session.isTLSStarted() == false) {
- session.writeResponse(POP3Handler.OK_RESPONSE+ " Begin
TLS negotiation");
- try {
- session.startTLS();
- } catch (IOException e) {
- session.getLogger().info("Error while trying to
secure connection",e);
- session.endSession();
- }
- } else {
- session.writeResponse(POP3Handler.ERR_RESPONSE);
- }
- }
+ /**
+ * @see
org.apache.james.pop3server.CommandHandler#onCommand(org.apache.james.pop3server.POP3Session)
+ */
+ public void onCommand(POP3Session session) {
+ // check if starttls is supported, the state is the right one and it
was
+ // not started before
+ if (session.isStartTLSSupported() && session.getHandlerState() ==
POP3Handler.AUTHENTICATION_READY
+ && session.isTLSStarted() == false) {
+ session.writeResponse(POP3Handler.OK_RESPONSE + " Begin TLS
negotiation");
+ try {
+ session.startTLS();
+ } catch (IOException e) {
+ session.getLogger().info("Error while trying to secure
connection", e);
+
+ // disconnect
+ session.endSession();
+ }
+ } else {
+ session.writeResponse(POP3Handler.ERR_RESPONSE);
+ }
+ }
/**
* @see org.apache.james.pop3server.CommandHandler#getCommands()
*/
- public List<String> getCommands() {
- List<String> commands = new ArrayList<String>();
- commands.add(COMMAND_NAME);
- return commands;
- }
-
- /**
+ public List<String> getCommands() {
+ List<String> commands = new ArrayList<String>();
+ commands.add(COMMAND_NAME);
+ return commands;
+ }
+
+ /**
* @see
org.apache.james.pop3server.CapaCapability#getImplementedCapabilities(org.apache.james.pop3server.POP3Session)
*/
- public List<String> getImplementedCapabilities(POP3Session session) {
- List<String> caps = new ArrayList<String>();
- if (session.isStartTLSSupported() && session.getHandlerState()
== POP3Handler.AUTHENTICATION_READY) {
- caps.add(COMMAND_NAME);
- return caps;
- }
- return caps;
- }
+ public List<String> getImplementedCapabilities(POP3Session session) {
+ List<String> caps = new ArrayList<String>();
+ if (session.isStartTLSSupported() && session.getHandlerState() ==
POP3Handler.AUTHENTICATION_READY) {
+ caps.add(COMMAND_NAME);
+ return caps;
+ }
+ return caps;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]