Author: norman
Date: Wed Jan 18 08:59:52 2012
New Revision: 1232791
URL: http://svn.apache.org/viewvc?rev=1232791&view=rev
Log:
Fix broken StartTls handling. See PROTOCOLS-89
Added:
james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/POP3StartTlsResponseTest.java
(with props)
james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/SMTPStartTlsResponseTest.java
(with props)
Modified:
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3StartTlsResponse.java
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3StreamResponse.java
james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPStartTLSResponse.java
Modified:
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3StartTlsResponse.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3StartTlsResponse.java?rev=1232791&r1=1232790&r2=1232791&view=diff
==============================================================================
---
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3StartTlsResponse.java
(original)
+++
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3StartTlsResponse.java
Wed Jan 18 08:59:52 2012
@@ -19,6 +19,9 @@
package org.apache.james.protocols.pop3;
+import java.util.List;
+
+import org.apache.james.protocols.api.Response;
import org.apache.james.protocols.api.StartTlsResponse;
/**
@@ -36,4 +39,26 @@ public class POP3StartTlsResponse extend
super(code);
}
+ /**
+ * Return an immutable {@link StartTlsResponse}.
+ */
+ @Override
+ public Response immutable() {
+ // We need to override this and return a StartTlsResponse. See
ROTOCOLS-89
+ return new StartTlsResponse() {
+
+ public boolean isEndSession() {
+ return POP3StartTlsResponse.this.isEndSession();
+ }
+
+ public String getRetCode() {
+ return POP3StartTlsResponse.this.getRetCode();
+ }
+
+ public List<CharSequence> getLines() {
+ return POP3StartTlsResponse.this.getLines();
+ }
+ };
+ }
+
}
Modified:
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3StreamResponse.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3StreamResponse.java?rev=1232791&r1=1232790&r2=1232791&view=diff
==============================================================================
---
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3StreamResponse.java
(original)
+++
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3StreamResponse.java
Wed Jan 18 08:59:52 2012
@@ -23,6 +23,7 @@ import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.SequenceInputStream;
+import org.apache.james.protocols.api.Response;
import org.apache.james.protocols.api.StreamResponse;
/**
@@ -45,4 +46,13 @@ public class POP3StreamResponse extends
public InputStream getStream() {
return new SequenceInputStream(stream, new
ByteArrayInputStream(".\r\n".getBytes()));
}
+
+ /**
+ * Throws {@link UnsupportedOperationException}
+ */
+ @Override
+ public Response immutable() {
+ throw new UnsupportedOperationException("POP3StreamResponse can only
be used once, so its not supported to reuse it");
+ }
+
}
Added:
james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/POP3StartTlsResponseTest.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/POP3StartTlsResponseTest.java?rev=1232791&view=auto
==============================================================================
---
james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/POP3StartTlsResponseTest.java
(added)
+++
james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/POP3StartTlsResponseTest.java
Wed Jan 18 08:59:52 2012
@@ -0,0 +1,39 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.protocols.pop3;
+
+import org.apache.james.protocols.api.StartTlsResponse;
+import org.junit.Test;
+
+import static junit.framework.Assert.*;
+
+public class POP3StartTlsResponseTest {
+
+
+ /**
+ * Test for PROTOCOLS-89
+ */
+ @Test
+ public void testImmutable() {
+ POP3StartTlsResponse response = new
POP3StartTlsResponse(POP3Response.OK_RESPONSE);
+ assertTrue(response instanceof StartTlsResponse);
+ assertTrue(response.immutable() instanceof StartTlsResponse);
+ }
+}
Propchange:
james/protocols/trunk/pop3/src/test/java/org/apache/james/protocols/pop3/POP3StartTlsResponseTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPStartTLSResponse.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPStartTLSResponse.java?rev=1232791&r1=1232790&r2=1232791&view=diff
==============================================================================
---
james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPStartTLSResponse.java
(original)
+++
james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPStartTLSResponse.java
Wed Jan 18 08:59:52 2012
@@ -19,6 +19,9 @@
package org.apache.james.protocols.smtp;
+import java.util.List;
+
+import org.apache.james.protocols.api.Response;
import org.apache.james.protocols.api.StartTlsResponse;
@@ -37,4 +40,26 @@ public class SMTPStartTLSResponse extend
super(rawLine);
}
+ /**
+ * Returns an immutable {@link StartTlsResponse}
+ */
+ @Override
+ public Response immutable() {
+ // We need to override this and return a StartTlsResponse. See
ROTOCOLS-89
+ return new StartTlsResponse() {
+
+ public boolean isEndSession() {
+ return SMTPStartTLSResponse.this.isEndSession();
+ }
+
+ public String getRetCode() {
+ return SMTPStartTLSResponse.this.getRetCode();
+ }
+
+ public List<CharSequence> getLines() {
+ return SMTPStartTLSResponse.this.getLines();
+ }
+ };
+ }
+
}
Added:
james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/SMTPStartTlsResponseTest.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/SMTPStartTlsResponseTest.java?rev=1232791&view=auto
==============================================================================
---
james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/SMTPStartTlsResponseTest.java
(added)
+++
james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/SMTPStartTlsResponseTest.java
Wed Jan 18 08:59:52 2012
@@ -0,0 +1,38 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.protocols.smtp;
+
+import org.apache.james.protocols.api.StartTlsResponse;
+import org.junit.Test;
+
+import static junit.framework.Assert.*;
+
+public class SMTPStartTlsResponseTest {
+
+ /**
+ * Test for PROTOCOLS-89
+ */
+ @Test
+ public void testImmutable() {
+ SMTPStartTLSResponse response = new SMTPStartTLSResponse("554",
"Reject");
+ assertTrue(response instanceof StartTlsResponse);
+ assertTrue(response.immutable() instanceof StartTlsResponse);
+ }
+}
Propchange:
james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/SMTPStartTlsResponseTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]