Author: norman
Date: Fri Nov 18 09:41:36 2011
New Revision: 1203552
URL: http://svn.apache.org/viewvc?rev=1203552&view=rev
Log:
Start to move pop3 code from server to protocols. See PROTOCOLS-2
Added:
james/protocols/trunk/pop3/.classpath
james/protocols/trunk/pop3/.project
james/protocols/trunk/pop3/src/
james/protocols/trunk/pop3/src/main/
james/protocols/trunk/pop3/src/main/java/
james/protocols/trunk/pop3/src/main/java/org/
james/protocols/trunk/pop3/src/main/java/org/apache/
james/protocols/trunk/pop3/src/main/java/org/apache/james/
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/Mailbox.java
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3HandlerConfiguration.java
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Protocol.java
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Request.java
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Response.java
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Session.java
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3SessionImpl.java
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3StreamResponse.java
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/ReadByteFilterInputStream.java
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/StartTlsPop3Response.java
Added: james/protocols/trunk/pop3/.classpath
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/.classpath?rev=1203552&view=auto
==============================================================================
--- james/protocols/trunk/pop3/.classpath (added)
+++ james/protocols/trunk/pop3/.classpath Fri Nov 18 09:41:36 2011
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: james/protocols/trunk/pop3/.project
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/.project?rev=1203552&view=auto
==============================================================================
--- james/protocols/trunk/pop3/.project (added)
+++ james/protocols/trunk/pop3/.project Fri Nov 18 09:41:36 2011
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>protocols-pop3</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
Added:
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/Mailbox.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/Mailbox.java?rev=1203552&view=auto
==============================================================================
---
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/Mailbox.java
(added)
+++
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/Mailbox.java
Fri Nov 18 09:41:36 2011
@@ -0,0 +1,24 @@
+/****************************************************************
+ * 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;
+
+public interface Mailbox {
+
+}
Added:
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3HandlerConfiguration.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3HandlerConfiguration.java?rev=1203552&view=auto
==============================================================================
---
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3HandlerConfiguration.java
(added)
+++
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3HandlerConfiguration.java
Fri Nov 18 09:41:36 2011
@@ -0,0 +1,41 @@
+/****************************************************************
+ * 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;
+
+/**
+ * Provides a number of server-wide constant values to the POP3Handlers
+ */
+public interface POP3HandlerConfiguration {
+
+ /**
+ * Returns the service wide hello name
+ *
+ * @return the hello name
+ */
+ String getHelloName();
+
+ /**
+ * Return if starttls is supported by the POP3Server
+ *
+ * @return startTLSSupported
+ */
+ boolean isStartTLSSupported();
+
+}
Added:
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Protocol.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Protocol.java?rev=1203552&view=auto
==============================================================================
---
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Protocol.java
(added)
+++
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Protocol.java
Fri Nov 18 09:41:36 2011
@@ -0,0 +1,55 @@
+/****************************************************************
+ * 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.Protocol;
+import org.apache.james.protocols.api.ProtocolSession;
+import org.apache.james.protocols.api.ProtocolTransport;
+import org.apache.james.protocols.api.handler.ProtocolHandlerChain;
+import org.slf4j.Logger;
+
+public class POP3Protocol implements Protocol{
+
+ private ProtocolHandlerChain chain;
+ private POP3HandlerConfiguration config;
+ private Logger logger;
+
+ public POP3Protocol(ProtocolHandlerChain chain, POP3HandlerConfiguration
config, Logger logger) {
+ this.chain = chain;
+ this.config = config;
+ this.logger = logger;
+ }
+ @Override
+ public ProtocolHandlerChain getProtocolChain() {
+ return chain;
+ }
+
+
+ @Override
+ public ProtocolSession newSession(ProtocolTransport transport) {
+ return new POP3SessionImpl(logger, transport, config);
+ }
+
+ @Override
+ public boolean isStartTLSSupported() {
+ return config.isStartTLSSupported();
+ }
+
+}
Added:
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Request.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Request.java?rev=1203552&view=auto
==============================================================================
---
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Request.java
(added)
+++
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Request.java
Fri Nov 18 09:41:36 2011
@@ -0,0 +1,32 @@
+/****************************************************************
+ * 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.BaseRequest;
+
+/**
+ * POP3Request object
+ */
+public class POP3Request extends BaseRequest {
+
+ public POP3Request(final String command, final String argument) {
+ super(command, argument);
+ }
+}
Added:
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Response.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Response.java?rev=1203552&view=auto
==============================================================================
---
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Response.java
(added)
+++
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Response.java
Fri Nov 18 09:41:36 2011
@@ -0,0 +1,80 @@
+/****************************************************************
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.apache.james.protocols.api.AbstractResponse;
+
+/**
+ * Contains an POP3 result
+ */
+public class POP3Response extends AbstractResponse {
+
+ // POP3 response prefixes
+ /** OK response. Requested content will follow */
+ public final static String OK_RESPONSE = "+OK";
+
+ /**
+ * Error response. Requested content will not be provided. This prefix is
+ * followed by a more detailed error message.
+ */
+ public final static String ERR_RESPONSE = "-ERR";
+
+ /**
+ * Construct a new POP3Response. The given code and description can not be
+ * null, if null an IllegalArgumentException get thrown
+ *
+ * @param code
+ * the returnCode
+ * @param description
+ * the description
+ */
+ public POP3Response(String code, CharSequence description) {
+ super(code, description);
+ }
+
+ public POP3Response(String code) {
+ this(code, null);
+ }
+
+ protected POP3Response() {
+ }
+
+
+ /**
+ * Return a List of all responseLines stored in this POP3Response
+ *
+ * @return all responseLines
+ */
+ public List<CharSequence> getLines() {
+ List<CharSequence> responseList = new ArrayList<CharSequence>();
+ for (int i = 0; i < lines.size(); i++) {
+ if (i == 0) {
+ responseList.add(getRetCode() + " " +lines.get(i));
+ } else {
+ responseList.add(lines.get(i));
+ }
+ }
+ return responseList;
+ }
+
+}
Added:
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Session.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Session.java?rev=1203552&view=auto
==============================================================================
---
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Session.java
(added)
+++
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Session.java
Fri Nov 18 09:41:36 2011
@@ -0,0 +1,81 @@
+/****************************************************************
+ * 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.ProtocolSession;
+
+/**
+ * All the handlers access this interface to communicate with POP3Handler
object
+ */
+
+public interface POP3Session extends ProtocolSession {
+
+ final static String UID_LIST = "UID_LIST";
+ final static String DELETED_UID_LIST = "DELETED_UID_LIST";
+ final static String MAILBOX_SESSION = "MAILBOX_SESSION";
+
+ // Authentication states for the POP3 interaction
+ /** Waiting for user id */
+ final static int AUTHENTICATION_READY = 0;
+ /** User id provided, waiting for password */
+ final static int AUTHENTICATION_USERSET = 1;
+ /**
+ * A valid user id/password combination has been provided. In this state
the
+ * client can access the mailbox of the specified user.
+ */
+ final static int TRANSACTION = 2;
+
+ /**
+ * Returns POP3Handler service wide configuration
+ *
+ * @return POP3HandlerConfigurationData
+ */
+ POP3HandlerConfiguration getConfigurationData();
+
+ /**
+ * Returns the current handler state
+ *
+ * @return handler state
+ */
+ int getHandlerState();
+
+ /**
+ * Sets the new handler state
+ *
+ * @param handlerState
+ * state
+ */
+ void setHandlerState(int handlerState);
+
+ /**
+ * Returns the mail list contained in the mailbox
+ *
+ * @return mailbox content
+ */
+ Mailbox getUserMailbox();
+
+ /**
+ * Sets a new mailbox content
+ *
+ * @param mailbox
+ * mailbox
+ */
+ void setUserMailbox(Mailbox mailbox);
+}
Added:
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3SessionImpl.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3SessionImpl.java?rev=1203552&view=auto
==============================================================================
---
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3SessionImpl.java
(added)
+++
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3SessionImpl.java
Fri Nov 18 09:41:36 2011
@@ -0,0 +1,100 @@
+/****************************************************************
+ * 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.AbstractSession;
+import org.apache.james.protocols.api.ProtocolTransport;
+import org.apache.james.protocols.api.Response;
+import org.slf4j.Logger;
+
+/**
+ * {@link POP3Session} implementation which use Netty
+ */
+public class POP3SessionImpl extends AbstractSession implements POP3Session {
+ private POP3HandlerConfiguration configData;
+
+ private int handlerState;
+
+ private Mailbox mailbox;
+
+
+ public POP3SessionImpl(Logger logger, ProtocolTransport transport,
POP3HandlerConfiguration configData) {
+ super(logger, transport);
+ this.configData = configData;
+ }
+
+ /**
+ * @see org.apache.james.protocols.pop3.POP3Session#getConfigurationData()
+ */
+ public POP3HandlerConfiguration getConfigurationData() {
+ return configData;
+ }
+
+ /**
+ * @see org.apache.james.protocols.pop3.POP3Session#getHandlerState()
+ */
+ public int getHandlerState() {
+ return handlerState;
+ }
+
+ /**
+ * @see org.apache.james.protocols.pop3.POP3Session#setHandlerState(int)
+ */
+ public void setHandlerState(int handlerState) {
+ this.handlerState = handlerState;
+ }
+
+ /**
+ * @see org.apache.james.protocols.api.ProtocolSession#resetState()
+ */
+ public void resetState() {
+ getState().clear();
+
+ setHandlerState(AUTHENTICATION_READY);
+ }
+
+ /**
+ * @see org.apache.james.protocols.pop3.POP3Session#getUserMailbox()
+ */
+ public Mailbox getUserMailbox() {
+ return mailbox;
+ }
+
+ /**
+ * @see
+ * org.apache.james.protocols.pop3.POP3Session#setUserMailbox(Mailbox)
+ */
+ public void setUserMailbox(Mailbox mailbox) {
+ this.mailbox = mailbox;
+ }
+
+ @Override
+ public Response newLineTooLongResponse() {
+ return null;
+ }
+
+ @Override
+ public Response newFatalErrorResponse() {
+ return null;
+ }
+
+
+
+
+}
Added:
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=1203552&view=auto
==============================================================================
---
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3StreamResponse.java
(added)
+++
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3StreamResponse.java
Fri Nov 18 09:41:36 2011
@@ -0,0 +1,40 @@
+/****************************************************************
+ * 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 java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.SequenceInputStream;
+
+import org.apache.james.protocols.api.StreamResponse;
+
+public class POP3StreamResponse extends POP3Response implements StreamResponse
{
+
+ private InputStream stream;
+
+ public POP3StreamResponse(String code, CharSequence description,
InputStream stream) {
+ super(code, description);
+ this.stream = stream;
+ }
+
+ public InputStream getStream() {
+ return new SequenceInputStream(stream, new
ByteArrayInputStream(".\r\n".getBytes()));
+ }
+}
Added:
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/ReadByteFilterInputStream.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/ReadByteFilterInputStream.java?rev=1203552&view=auto
==============================================================================
---
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/ReadByteFilterInputStream.java
(added)
+++
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/ReadByteFilterInputStream.java
Fri Nov 18 09:41:36 2011
@@ -0,0 +1,61 @@
+/****************************************************************
+ * 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 java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * {@link FilterInputStream} which delagates every {@link #read(byte[])} and
{@link #read(byte[], int, int)} to the {@link #read()} method
+ *
+ *
+ */
+public class ReadByteFilterInputStream extends FilterInputStream {
+
+ protected ReadByteFilterInputStream(InputStream in) {
+ super(in);
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ int i;
+ for (i = 0; i < len; i++) {
+ int a = read();
+ if (i == 0 && a == -1) {
+ return -1;
+ } else {
+ if (a == -1) {
+ break;
+ } else {
+ b[off++] = (byte) a;
+ }
+ }
+ }
+ return i;
+
+ }
+
+ @Override
+ public int read(byte[] b) throws IOException {
+ return read(b, 0, b.length);
+ }
+
+}
Added:
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/StartTlsPop3Response.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/StartTlsPop3Response.java?rev=1203552&view=auto
==============================================================================
---
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/StartTlsPop3Response.java
(added)
+++
james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/StartTlsPop3Response.java
Fri Nov 18 09:41:36 2011
@@ -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;
+
+/**
+ * Special sub-type of {@link POP3Response} which will trigger the start of
TLS after the response was written to the client
+ *
+ *
+ */
+public class StartTlsPop3Response extends POP3Response implements
StartTlsResponse{
+
+ public StartTlsPop3Response(String code, CharSequence description) {
+ super(code, description);
+ }
+
+ public StartTlsPop3Response(String code) {
+ super(code);
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]