Author: norman
Date: Sun Jun 4 02:15:10 2006
New Revision: 411542
URL: http://svn.apache.org/viewvc?rev=411542&view=rev
Log:
Add mailattribute for networks which a allowed to relay and add the matcher for
this. See JAMES-263
Added:
james/server/trunk/src/java/org/apache/james/transport/matchers/SMTPIsAuthNetwork.java
Modified:
james/server/trunk/src/java/org/apache/james/smtpserver/DataCmdHandler.java
Modified:
james/server/trunk/src/java/org/apache/james/smtpserver/DataCmdHandler.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/DataCmdHandler.java?rev=411542&r1=411541&r2=411542&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/smtpserver/DataCmdHandler.java
(original)
+++ james/server/trunk/src/java/org/apache/james/smtpserver/DataCmdHandler.java
Sun Jun 4 02:15:10 2006
@@ -66,6 +66,11 @@
private final static String SMTP_AUTH_USER_ATTRIBUTE_NAME =
"org.apache.james.SMTPAuthUser";
/**
+ * The mail attribute which get set if the client is allowed to relay
+ */
+ private final static String SMTP_AUTH_NETWORK_NAME =
"org.apache.james.SMTPIsAuthNetwork";
+
+ /**
* The character array that indicates termination of an SMTP connection
*/
private final static char[] SMTPTerminator = { '\r', '\n', '.', '\r', '\n'
};
@@ -277,6 +282,11 @@
if (session.getUser() != null) {
mail.setAttribute(SMTP_AUTH_USER_ATTRIBUTE_NAME,
session.getUser());
}
+
+ if (session.isRelayingAllowed()) {
+ mail.setAttribute(SMTP_AUTH_NETWORK_NAME,"true");
+ }
+
session.setMail(mail);
} finally {
if (recipientCollection != null) {
Added:
james/server/trunk/src/java/org/apache/james/transport/matchers/SMTPIsAuthNetwork.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/transport/matchers/SMTPIsAuthNetwork.java?rev=411542&view=auto
==============================================================================
---
james/server/trunk/src/java/org/apache/james/transport/matchers/SMTPIsAuthNetwork.java
(added)
+++
james/server/trunk/src/java/org/apache/james/transport/matchers/SMTPIsAuthNetwork.java
Sun Jun 4 02:15:10 2006
@@ -0,0 +1,50 @@
+/***********************************************************************
+ * Copyright (c) 2006 The Apache Software Foundation. *
+ * All rights reserved. *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.transport.matchers;
+
+import org.apache.mailet.GenericMatcher;
+import org.apache.mailet.Mail;
+
+import java.util.Collection;
+
+/**
+ * <P>
+ * Matches mails that are sent by an client which is allowed to relay.
+ * </P>
+ *
+ * <PRE><CODE> <mailet match="SMTPIsAuthNetwork"
+ * class="<any-class>"> </CODE></PRE>
+ *
+ */
+public class SMTPIsAuthNetwork extends GenericMatcher {
+
+ /**
+ * The mail attribute which is set if the client is allowed to relay
+ */
+ private final static String SMTP_AUTH_NETWORK_NAME =
"org.apache.james.SMTPIsAuthNetwork";
+
+ public Collection match(Mail mail) {
+ String relayingAllowed = (String) mail
+ .getAttribute(SMTP_AUTH_NETWORK_NAME);
+ if (relayingAllowed != null && relayingAllowed.equals("true")) {
+ return mail.getRecipients();
+ } else {
+ return null;
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]