You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2009/10/12 16:10:16 UTC
svn commit: r824345 [3/3] - in /james/server/trunk: ./ avalon-socket-library/
avalon-socket-library/src/main/java/org/apache/james/socket/
avalon-socket-library/src/main/java/org/apache/james/socket/configuration/
imapserver-function/src/main/java/org/...
Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CRLFTerminatedReader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CRLFTerminatedReader.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CRLFTerminatedReader.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CRLFTerminatedReader.java Mon Oct 12 14:10:11 2009
@@ -0,0 +1,186 @@
+/****************************************************************
+ * 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.socket.shared;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.io.IOException;
+
+/**
+ * A Reader for use with SMTP or other protocols in which lines
+ * must end with CRLF. Extends Reader and overrides its
+ * readLine() method. The Reader readLine() method cannot
+ * serve for SMTP because it ends lines with either CR or LF alone.
+ */
+public class CRLFTerminatedReader extends Reader {
+
+ @SuppressWarnings("serial")
+ public class TerminationException extends IOException {
+ private int where;
+ public TerminationException(int where) {
+ super();
+ this.where = where;
+ }
+
+ public TerminationException(String s, int where) {
+ super(s);
+ this.where = where;
+ }
+
+ public int position() {
+ return where;
+ }
+ }
+
+ @SuppressWarnings("serial")
+ public class LineLengthExceededException extends IOException {
+ public LineLengthExceededException(String s) {
+ super(s);
+ }
+ }
+
+ InputStream in;
+
+ public CRLFTerminatedReader(InputStream in) {
+ this.in = in;
+ }
+
+ /**
+ * Constructs this CRLFTerminatedReader.
+ * @param in an InputStream
+ * @param enc the String name of a supported charset.
+ * "ASCII" is common here.
+ * @throws UnsupportedEncodingException if the named charset
+ * is not supported
+ */
+ public CRLFTerminatedReader(InputStream in, String enc) throws UnsupportedEncodingException {
+ this(in);
+ }
+
+ private StringBuilder lineBuffer = new StringBuilder();
+ private final int
+ EOF = -1,
+ CR = 13,
+ LF = 10;
+
+ private int tainted = -1;
+
+ /**
+ * Read a line of text which is terminated by CRLF. The concluding
+ * CRLF characters are not returned with the String, but if either CR
+ * or LF appears in the text in any other sequence it is returned
+ * in the String like any other character. Some characters at the
+ * end of the stream may be lost if they are in a "line" not
+ * terminated by CRLF.
+ *
+ * @return either a String containing the contents of a
+ * line which must end with CRLF, or null if the end of the
+ * stream has been reached, possibly discarding some characters
+ * in a line not terminated with CRLF.
+ * @throws IOException if an I/O error occurs.
+ */
+ public String readLine() throws IOException{
+
+ //start with the buffer empty
+ lineBuffer.delete(0, lineBuffer.length());
+
+ /* This boolean tells which state we are in,
+ * depending upon whether or not we got a CR
+ * in the preceding read().
+ */
+ boolean cr_just_received = false;
+
+ // Until we add support for specifying a maximum line lenth as
+ // a Service Extension, limit lines to 2K, which is twice what
+ // RFC 2821 4.5.3.1 requires.
+ while (lineBuffer.length() <= 2048) {
+ int inChar = read();
+
+ if (!cr_just_received){
+ //the most common case, somewhere before the end of a line
+ switch (inChar){
+ case CR : cr_just_received = true;
+ break;
+ case EOF : return null; // premature EOF -- discards data(?)
+ case LF : //the normal ending of a line
+ if (tainted == -1) tainted = lineBuffer.length();
+ // intentional fall-through
+ default : lineBuffer.append((char)inChar);
+ }
+ }else{
+ // CR has been received, we may be at end of line
+ switch (inChar){
+ case LF : // LF without a preceding CR
+ if (tainted != -1) {
+ int pos = tainted;
+ tainted = -1;
+ throw new TerminationException("\"bare\" CR or LF in data stream", pos);
+ }
+ return lineBuffer.toString();
+ case EOF : return null; // premature EOF -- discards data(?)
+ case CR : //we got two (or more) CRs in a row
+ if (tainted == -1) tainted = lineBuffer.length();
+ lineBuffer.append((char)CR);
+ break;
+ default : //we got some other character following a CR
+ if (tainted == -1) tainted = lineBuffer.length();
+ lineBuffer.append((char)CR);
+ lineBuffer.append((char)inChar);
+ cr_just_received = false;
+ }
+ }
+ }//while
+ throw new LineLengthExceededException("Exceeded maximum line length");
+ }//method readLine()
+
+ /**
+ * @see java.io.Reader#read()
+ */
+ public int read() throws IOException {
+ return in.read();
+ }
+
+ /**
+ * @see java.io.Reader#ready()
+ */
+ public boolean ready() throws IOException {
+ return in.available() > 0;
+ }
+
+ /**
+ * @see java.io.Reader#read(char[], int, int)
+ */
+ public int read(char cbuf[], int off, int len) throws IOException {
+ byte [] temp = new byte[len];
+ int result = in.read(temp, 0, len);
+ for (int i=0;i<result;i++) cbuf[i] = (char) temp[i];
+ return result;
+ }
+
+ /**
+ * @see java.io.Reader#close()
+ */
+ public void close() throws IOException {
+ in.close();
+ }
+}
Propchange: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CRLFTerminatedReader.java
------------------------------------------------------------------------------
cvs2svn:cvs-rev = 1.1.2.2
Propchange: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CRLFTerminatedReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CRLFTerminatedReader.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CRLFTerminatedReader.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CommonCommandHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CommonCommandHandler.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CommonCommandHandler.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CommonCommandHandler.java Mon Oct 12 14:10:11 2009
@@ -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.socket.shared;
+
+import java.util.Collection;
+
+public interface CommonCommandHandler {
+
+ /**
+ * Return a Collection of implemented commands
+ *
+ * @return Collection which contains implemented commands
+ */
+ Collection<String> getImplCommands();
+}
Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ExtensibleHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ExtensibleHandler.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ExtensibleHandler.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ExtensibleHandler.java Mon Oct 12 14:10:11 2009
@@ -0,0 +1,48 @@
+/****************************************************************
+ * 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.socket.shared;
+
+import java.util.List;
+
+import org.apache.james.socket.WiringException;
+
+
+/**
+ * Handlers extends this interface to be notified of available
+ * extensions of the given type.
+ */
+public interface ExtensibleHandler {
+
+ /**
+ * Return a List of interfaces of plugins that will
+ * extend this.
+ */
+ List<Class<?>> getMarkerInterfaces();
+
+ /**
+ * Method called during initialization after all the handlers have been declared
+ * in the handlerchain.
+ *
+ * @param interfaceName
+ * @param extension a list of objects implementing the marker interface
+ */
+ void wireExtensions(Class interfaceName, List extension) throws WiringException;
+
+}
Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/HandlersPackage.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/HandlersPackage.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/HandlersPackage.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/HandlersPackage.java Mon Oct 12 14:10:11 2009
@@ -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.socket.shared;
+
+import java.util.List;
+
+/**
+ * Provides a mean to bundle a set of handlers (defined by their classnames) within
+ * a single object.
+ * This is used for the default set of CoreCommands.
+ */
+public interface HandlersPackage {
+
+ /**
+ * Return a List which contains a set of CommandHandlers
+ *
+ * @return Map
+ */
+ List<String> getHandlers();
+
+}
Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/LogEnabled.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/LogEnabled.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/LogEnabled.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/LogEnabled.java Mon Oct 12 14:10:11 2009
@@ -0,0 +1,37 @@
+/****************************************************************
+ * 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.socket.shared;
+
+import org.apache.commons.logging.Log;
+
+/**
+ * Indicates that a services requires general logging.
+ * Note that this log should only be used for general service operations.
+ * A context sensitive log should be preferred where that is available
+ * within the context of a call.
+ */
+public interface LogEnabled {
+
+ /**
+ * Sets the service log.
+ * @param log not null
+ */
+ public void setLog(Log log);
+}
Propchange: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/LogEnabled.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/LogEnabledSession.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/LogEnabledSession.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/LogEnabledSession.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/LogEnabledSession.java Mon Oct 12 14:10:11 2009
@@ -0,0 +1,30 @@
+/****************************************************************
+ * 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.socket.shared;
+
+import org.apache.commons.logging.Log;
+
+public interface LogEnabledSession {
+ /**
+ * Gets the context sensitive log for this session.
+ * @return log, not null
+ */
+ public Log getLogger();
+}
Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ProtocolContext.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ProtocolContext.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ProtocolContext.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ProtocolContext.java Mon Oct 12 14:10:11 2009
@@ -0,0 +1,116 @@
+/****************************************************************
+ * 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.socket.shared;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import org.apache.commons.logging.Log;
+import org.apache.james.socket.Watchdog;
+
+/**
+ * This is the helper interface provided to ProtocolHandlers to let them
+ * communicate with the outside world.
+ */
+public interface ProtocolContext {
+
+ /**
+ * Writes a response to the client and flush it.
+ * @param responseString the response string
+ */
+ public void writeLoggedFlushedResponse(String responseString);
+
+ /**
+ * Writes a response to the client without flushing.
+ * @param responseString the response string
+ */
+ public void writeLoggedResponse(String responseString);
+
+ /**
+ * The watchdog is used to deal with timeouts.
+ * @return the watchdog instance
+ */
+ public Watchdog getWatchdog();
+
+ /**
+ * getter for the remote hostname
+ * @return remote hostname
+ */
+ public String getRemoteHost();
+
+ /**
+ * getter for the remote ip
+ * @return remote ip
+ */
+ public String getRemoteIP();
+
+ /**
+ * Returns a CRLF terminated line reader
+ * @return line reader
+ */
+ public CRLFTerminatedReader getInputReader();
+
+ /**
+ * Returns the raw input stream
+ * @return the raw inputstream
+ */
+ public InputStream getInputStream();
+
+ /**
+ * Returns the raw outputstream
+ * @return outputstream
+ */
+ public OutputStream getOutputStream();
+
+ /**
+ * Returns the printwriter.
+ * @return the output printwriter
+ */
+ public PrintWriter getOutputWriter();
+
+ /**
+ * Is the socket disconnected?
+ * @return true if the connection has disconnected,
+ * false otherwise
+ */
+ public boolean isDisconnected();
+
+ /**
+ * Gets a context sensitive logger.
+ * @return not null
+ */
+ public Log getLogger();
+
+ /**
+ * Secure the current socket using tls/ssl
+ * @throws IOException
+ */
+ public void secure() throws IOException;
+
+ /**
+ * Return if the current socket is using tls/ssl
+ *
+ * @return isSecure
+ */
+ public boolean isSecure();
+}
\ No newline at end of file
Propchange: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ProtocolContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ProtocolContext.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ProtocolHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ProtocolHandler.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ProtocolHandler.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ProtocolHandler.java Mon Oct 12 14:10:11 2009
@@ -0,0 +1,50 @@
+/****************************************************************
+ * 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.socket.shared;
+
+import java.io.IOException;
+
+/**
+ * Handles protocol interactions.
+ */
+public interface ProtocolHandler {
+
+ /**
+ * Handle the protocol
+ * @param context not null
+ *
+ * @throws IOException get thrown if an IO error is detected
+ */
+ public abstract void handleProtocol(ProtocolContext context) throws IOException;
+
+ /**
+ * Resets the handler data to a basic state.
+ */
+ public abstract void resetHandler();
+
+ /**
+ * Called when a fatal failure occurs during processing.
+ * Provides a last ditch chance to send a message to the client.
+ * @param e exception
+ * @param context not null
+ */
+ public abstract void fatalFailure(RuntimeException e, ProtocolContext context);
+
+}
\ No newline at end of file
Propchange: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ProtocolHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/ProtocolHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/SwitchableInputStream.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/SwitchableInputStream.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/SwitchableInputStream.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/SwitchableInputStream.java Mon Oct 12 14:10:11 2009
@@ -0,0 +1,44 @@
+/****************************************************************
+ * 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.socket.shared;
+
+import java.io.FilterInputStream;
+import java.io.InputStream;
+
+/**
+ * InputStream which allows to replace the wrapped InputStream
+ *
+ *
+ */
+public class SwitchableInputStream extends FilterInputStream {
+
+ protected SwitchableInputStream(InputStream in) {
+ super(in);
+ }
+
+ /**
+ * Set the wrapped InputStream
+ *
+ * @param in
+ */
+ public void setWrappedInputStream(InputStream in) {
+ this.in = in;
+ }
+}
Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/SwitchableOutputStream.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/SwitchableOutputStream.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/SwitchableOutputStream.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/SwitchableOutputStream.java Mon Oct 12 14:10:11 2009
@@ -0,0 +1,75 @@
+/****************************************************************
+ * 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.socket.shared;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * OutputStream which allows to replace the wrapped InputStream
+ *
+ * NOTE: This extends OutputStream because SSLSocket was not be able to complete the SSL
+ * negoation when using this class to wrap the socket.getOutputStream() while extending FilterOutputStream.
+ * No clue why...
+ *
+ *
+ */
+public class SwitchableOutputStream extends OutputStream {
+ private OutputStream out;
+
+ public SwitchableOutputStream(OutputStream out) {
+ this.out = out;
+ }
+
+ /**
+ * Set the wrapped OutputStream
+ *
+ * @param in
+ */
+ public void setWrappedOutputStream(OutputStream out) {
+ this.out = out;
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ out.write(b);
+ }
+
+ @Override
+ public void close() throws IOException {
+ out.close();
+ }
+
+ @Override
+ public void flush() throws IOException {
+ out.flush();
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException {
+ out.write(b, off, len);
+ }
+
+ @Override
+ public void write(byte[] b) throws IOException {
+ out.write(b);
+ }
+
+}
Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/TLSSupportedSession.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/TLSSupportedSession.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/TLSSupportedSession.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/TLSSupportedSession.java Mon Oct 12 14:10:11 2009
@@ -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.socket.shared;
+
+import java.io.IOException;
+
+/**
+ * Session which supports TLS
+ *
+ *
+ */
+public interface TLSSupportedSession extends LogEnabledSession{
+ /**
+ * Returns the user name associated with this interaction.
+ *
+ * @return the user name
+ */
+ String getUser();
+
+ /**
+ * Sets the user name associated with this interaction.
+ *
+ * @param user the user name
+ */
+ void setUser(String user);
+
+
+ /**
+ * Returns host name of the client
+ *
+ * @return hostname of the client
+ */
+ String getRemoteHost();
+
+ /**
+ * Returns host ip address of the client
+ *
+ * @return host ip address of the client
+ */
+ String getRemoteIPAddress();
+ /**
+ * Return true if StartTLS is supported by the configuration
+ *
+ * @return supported
+ */
+ boolean isStartTLSSupported();
+
+ /**
+ * Return true if the starttls was started
+ *
+ * @return true
+ */
+ boolean isTLSStarted();
+
+ /**
+ * Starttls
+ *
+ * @throws IOException
+ */
+ void startTLS() throws IOException;
+
+}
Modified: james/server/trunk/stage/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/stage/pom.xml?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/stage/pom.xml (original)
+++ james/server/trunk/stage/pom.xml Mon Oct 12 14:10:11 2009
@@ -47,6 +47,10 @@
<dependencies>
<dependency>
<groupId>org.apache.james</groupId>
+ <artifactId>james-server-socket-shared-library</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
<artifactId>apache-mailet</artifactId>
</dependency>
<dependency>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org