geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r594520 [1/10] - in /geronimo/javamail/trunk/geronimo-javamail_1.4: ./ geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/ geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/handl...
Date Tue, 13 Nov 2007 12:57:53 GMT
Author: rickmcguire
Date: Tue Nov 13 04:57:39 2007
New Revision: 594520

URL: http://svn.apache.org/viewvc?rev=594520&view=rev
Log:
GERONIMO-3600 Add imap and imaps protocol support to the Geronimo javamail providers.


Added:
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/AuthenticatorFactory.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/SASLAuthenticator.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/ACL.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPAttachedMessage.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPFolder.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPMessage.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPMimeBodyPart.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPMultipartDataSource.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPNamespaceFolder.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPRootFolder.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPSSLStore.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPStore.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/Rights.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPACLResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPBody.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPBodySection.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPBodyStructure.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPCapabilityResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPCommand.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPConnection.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPConnectionPool.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPContinuationResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPDateFormat.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPEnvelope.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPFetchBodyPart.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPFetchDataItem.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPFetchResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPFlags.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPFlagsResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPInternalDate.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPInternetHeader.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPListResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPListRightsResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPMailboxResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPMailboxStatus.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPMessageSize.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPMessageText.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPMyRightsResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPNamespace.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPNamespaceResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPOkResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPPermanentFlagsResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPQuotaResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPQuotaRootResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPResponseBuffer.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPResponseStream.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPResponseTokenizer.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPSearchDateFormat.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPSearchResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPServerStatusResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPSizeResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPStatusResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPTaggedResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPUid.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPUntaggedResponse.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/connection/IMAPUntaggedResponseHandler.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/CommandFailedException.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/ConnectionException.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/InvalidCommandException.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/MailConnection.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/ProtocolProperties.java
  (with props)
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/util/ResponseFormatException.java
  (with props)
Modified:
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/handlers/AbstractTextHandler.java
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/transport/nntp/NNTPTransport.java
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransport.java
    geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/resources/META-INF/javamail.default.providers
    geronimo/javamail/trunk/geronimo-javamail_1.4/pom.xml

Added: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/AuthenticatorFactory.java
URL: http://svn.apache.org/viewvc/geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/AuthenticatorFactory.java?rev=594520&view=auto
==============================================================================
--- geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/AuthenticatorFactory.java
(added)
+++ geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/AuthenticatorFactory.java
Tue Nov 13 04:57:39 2007
@@ -0,0 +1,88 @@
+/**
+ * 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.geronimo.javamail.authentication;
+
+import java.lang.reflect.Constructor;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.geronimo.javamail.util.ProtocolProperties; 
+
+public class AuthenticatorFactory {
+    // the list of authentication mechanisms we have direct support for.  Others come from

+    // SASL, if it's available. 
+    
+    public static final String AUTHENTICATION_PLAIN = "PLAIN";
+    public static final String AUTHENTICATION_LOGIN = "LOGIN";
+    public static final String AUTHENTICATION_CRAMMD5 = "CRAM-MD5";
+    public static final String AUTHENTICATION_DIGESTMD5 = "DIGEST-MD5";
+     
+    static public ClientAuthenticator getAuthenticator(ProtocolProperties props, List mechanisms,
String host, String username, String password, String authId, String realm)
+    {
+        // if the authorization id isn't given, then this is the same as the logged in user
name. 
+        if (authId == null) {
+            authId = username; 
+        }
+        
+        // if SASL is enabled, try getting a SASL authenticator first 
+        if (props.getBooleanProperty("sasl.enable", false)) {
+            // we need to convert the mechanisms map into an array of strings for SASL. 
+            String [] mechs = (String [])mechanisms.toArray(new String[mechanisms.size()]);

+            
+            try {
+                // need to try to load this using reflection since it has references to 
+                // the SASL API.  That's only available with 1.5 or later. 
+                Class authenticatorClass = Class.forName("org.apache.geronimo.javamal.authentication.SASLAuthenticator");

+                Constructor c = authenticatorClass.getConstructor(new Class[] {
+                    (new String[0]).getClass(), 
+                    Properties.class, 
+                    String.class, 
+                    String.class, 
+                    String.class, 
+                    String.class, 
+                    String.class, 
+                    String.class
+                }); 
+                
+                Object[] args = { mechs, props.getProperties(), props.getProtocol(), host,
realm, authId, username, password };
+                
+                return (ClientAuthenticator)c.newInstance(args); 
+            } catch (Throwable e) {
+                // Any exception is likely because we're running on 1.4 and can't use the
Sasl API.  
+                // just ignore and use our fallback implementations. 
+            }
+        }
+
+        // now go through the progression of mechanisms we support, from the
+        // most secure to the least secure.
+
+        if (mechanisms.contains(AUTHENTICATION_DIGESTMD5)) {
+            return new DigestMD5Authenticator(host, username, password, realm);
+        } else if (mechanisms.contains(AUTHENTICATION_CRAMMD5)) {
+            return new CramMD5Authenticator(username, password);
+        } else if (mechanisms.contains(AUTHENTICATION_LOGIN)) {
+            return new LoginAuthenticator(username, password);
+        } else if (mechanisms.contains(AUTHENTICATION_PLAIN)) {
+            return new PlainAuthenticator(username, password);
+        } else {
+            // can't find a mechanism we support in common
+            return null;
+        }
+    }
+}
+     

Propchange: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/AuthenticatorFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/AuthenticatorFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/AuthenticatorFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/SASLAuthenticator.java
URL: http://svn.apache.org/viewvc/geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/SASLAuthenticator.java?rev=594520&view=auto
==============================================================================
--- geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/SASLAuthenticator.java
(added)
+++ geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/SASLAuthenticator.java
Tue Nov 13 04:57:39 2007
@@ -0,0 +1,174 @@
+/*
+ * 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.geronimo.javamail.authentication;
+
+import java.io.UnsupportedEncodingException ;
+import java.util.Map;        
+import java.util.Properties; 
+
+import javax.mail.MessagingException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.sasl.Sasl; 
+import javax.security.sasl.SaslClient; 
+import javax.security.sasl.SaslException; 
+import javax.security.sasl.RealmCallback; 
+import javax.security.sasl.RealmChoiceCallback; 
+
+public class SASLAuthenticator implements ClientAuthenticator, CallbackHandler {
+    // The realm we're authenticating within 
+    protected String realm; 
+    // the user we're authenticating
+    protected String username;
+    // the user's password (the "shared secret")
+    protected String password;
+    // the authenticator we're proxying 
+    protected SaslClient authenticator; 
+
+    protected boolean complete = false;
+
+    /**
+     * Main constructor.
+     * 
+     * @param username
+     *            The login user name.
+     * @param password
+     *            The login password.
+     */
+    public SASLAuthenticator(String[] mechanisms, Properties properties, String protocol,
String host, String realm, 
+            String authorizationID, String username, String password) throws MessagingException
{
+        this.realm = realm; 
+        this.username = username;
+        this.password = password;
+        try {
+            authenticator = Sasl.createSaslClient(mechanisms, authorizationID, protocol,
host, (Map)properties, 
+                this); 
+        } catch (SaslException e) {
+        } 
+    }
+    
+    
+    /**
+     * Respond to the hasInitialResponse query. We defer this to the Sasl client.  
+     * 
+     * @return The SaslClient response to the same query. 
+     */
+    public boolean hasInitialResponse() {
+        return authenticator.hasInitialResponse(); 
+    }
+
+    /**
+     * Indicate whether the challenge/response process is complete.
+     * 
+     * @return True if the last challenge has been processed, false otherwise.
+     */
+    public boolean isComplete() {
+        return authenticator.hasInitialResponse(); 
+    }
+
+    /**
+     * Retrieve the authenticator mechanism name.
+     * 
+     * @return Always returns the string "PLAIN"
+     */
+    public String getMechanismName() {
+        // the authenticator selects this for us. 
+        return authenticator.getMechanismName(); 
+    }
+
+    /**
+     * Evaluate a login challenge, returning the a result string that
+     * should satisfy the clallenge.  This is forwarded to the 
+     * SaslClient, which will use the CallBackHandler to retrieve the 
+     * information it needs for the given protocol. 
+     * 
+     * @param challenge
+     *            The decoded challenge data, as byte array.
+     * 
+     * @return A formatted challege response, as an array of bytes.
+     * @exception MessagingException
+     */
+    public byte[] evaluateChallenge(byte[] challenge) throws MessagingException {
+        // for an initial response challenge, there's no challenge date.  The SASL 
+        // client still expects a byte array argument. 
+        if (challenge == null) {
+            challenge = new byte[0];
+        }
+        
+        try {
+            return authenticator.evaluateChallenge(challenge);
+        } catch (SaslException e) {
+            // got an error, fail this
+            throw new MessagingException("Error performing SASL validation", e);
+        }
+    }
+    
+    public void handle(Callback[] callBacks) {
+        for (int i = 0; i < callBacks.length; i++) {
+            Callback callBack = callBacks[i]; 
+            // requesting the user name 
+            if (callBack instanceof NameCallback) {
+                ((NameCallback)callBack).setName(username); 
+            }
+            // need the password 
+            else if (callBack instanceof PasswordCallback) {
+                ((PasswordCallback)callBack).setPassword(password.toCharArray()); 
+            }
+            // direct request for the realm information 
+            else if (callBack instanceof RealmCallback) {
+                RealmCallback realmCallback = (RealmCallback)callBack; 
+                // we might not have a realm, so use the default from the 
+                // callback item 
+                if (realm == null) {
+                    realmCallback.setText(realmCallback.getDefaultText()); 
+                }
+                else { 
+                    realmCallback.setText(realm); 
+                }
+            }
+            // asked to select the realm information from a list 
+            else if (callBack instanceof RealmChoiceCallback) {
+                RealmChoiceCallback realmCallback = (RealmChoiceCallback)callBack; 
+                // if we don't have a realm, just tell it to use the default 
+                if (realm == null) {
+                    realmCallback.setSelectedIndex(realmCallback.getDefaultChoice()); 
+                }
+                else {
+                    // locate our configured one in the list 
+                    String[] choices = realmCallback.getChoices(); 
+
+                    for (int j = 0; j < choices.length; j++) {
+                        // set the index to any match and get out of here. 
+                        if (choices[j].equals(realm)) {
+                            realmCallback.setSelectedIndex(j); 
+                            break; 
+                        }
+                    }
+                    // NB:  If there was no match, we don't set anything.  
+                    // this should cause an authentication failure. 
+                }
+            }
+        }
+    }
+}
+

Propchange: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/SASLAuthenticator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/SASLAuthenticator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/authentication/SASLAuthenticator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/handlers/AbstractTextHandler.java
URL: http://svn.apache.org/viewvc/geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/handlers/AbstractTextHandler.java?rev=594520&r1=594519&r2=594520&view=diff
==============================================================================
--- geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/handlers/AbstractTextHandler.java
(original)
+++ geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/handlers/AbstractTextHandler.java
Tue Nov 13 04:57:39 2007
@@ -19,10 +19,12 @@
 import java.awt.datatransfer.DataFlavor;
 import java.awt.datatransfer.UnsupportedFlavorException;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Reader;
+
 import javax.activation.DataContentHandler;
 import javax.activation.DataSource;
 
@@ -45,12 +47,12 @@
     }
 
     public Object getContent(DataSource ds) throws IOException {
-        // todo handle encoding
-        Reader reader = new InputStreamReader(ds.getInputStream());
+        InputStream is = ds.getInputStream(); 
+        Reader reader = new InputStreamReader(is);
         StringBuffer result = new StringBuffer(1024);
         char[] buffer = new char[32768];
         int count;
-        while ((count = reader.read(buffer)) != -1) {
+        while ((count = reader.read(buffer)) > 0) {
             result.append(buffer, 0, count);
         }
         return result.toString();

Added: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/ACL.java
URL: http://svn.apache.org/viewvc/geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/ACL.java?rev=594520&view=auto
==============================================================================
--- geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/ACL.java
(added)
+++ geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/ACL.java
Tue Nov 13 04:57:39 2007
@@ -0,0 +1,146 @@
+/**
+ * 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.geronimo.javamail.store.imap;
+
+/**
+ * A named access control list for IMAP resources.  
+ */
+public class ACL implements Cloneable {
+    /**
+     * The name of the resource this ACL applies to.
+     */
+    private String name; 
+    /**
+     * The rights associated with this resource.
+     */
+    private Rights rights;
+    
+    /**
+     * Create an ACL for a resource.  The ACL will have an empty Rights set.
+     * 
+     * @param name   The name of the resource.
+     */
+    public ACL(String name) {
+        this.name = name; 
+        this.rights = new Rights(); 
+    }
+    
+    /**
+     * Create a named ACL instance with an initial Rights set.
+     * 
+     * @param name   The name of the resouce this ACL applies to.
+     * @param rights The Rights associated with this resource.
+     */
+    public ACL(String name, Rights rights) {
+        this.name = name; 
+        this.rights = rights;  
+    }
+    
+    /**
+     * Get the ACL name.
+     * 
+     * @return The string name of the ACL.
+     */
+    public String getName() {
+        return name; 
+    }
+    
+    /**
+     * Get the Rights associated with this ACL.
+     * 
+     * @return The Rights set supported for this resource.
+     */
+    public Rights getRights() {
+        return rights; 
+    }
+    
+    /**
+     * Set a new set of Rights for this ACL instance.
+     * 
+     * @param rights The new Rights set.
+     */
+    public void setRights(Rights rights) {
+        this.rights = rights;         
+    }
+    
+    
+    
+    /**
+     * Creates and returns a copy of this object.  The precise meaning
+     * of "copy" may depend on the class of the object. The general
+     * intent is that, for any object <tt>x</tt>, the expression:
+     * <blockquote>
+     * <pre>
+     * x.clone() != x</pre></blockquote>
+     * will be true, and that the expression:
+     * <blockquote>
+     * <pre>
+     * x.clone().getClass() == x.getClass()</pre></blockquote>
+     * will be <tt>true</tt>, but these are not absolute requirements.
+     * While it is typically the case that:
+     * <blockquote>
+     * <pre>
+     * x.clone().equals(x)</pre></blockquote>
+     * will be <tt>true</tt>, this is not an absolute requirement.
+     * <p>
+     * By convention, the returned object should be obtained by calling
+     * <tt>super.clone</tt>.  If a class and all of its superclasses (except
+     * <tt>Object</tt>) obey this convention, it will be the case that
+     * <tt>x.clone().getClass() == x.getClass()</tt>.
+     * <p>
+     * By convention, the object returned by this method should be independent
+     * of this object (which is being cloned).  To achieve this independence,
+     * it may be necessary to modify one or more fields of the object returned
+     * by <tt>super.clone</tt> before returning it.  Typically, this means
+     * copying any mutable objects that comprise the internal "deep structure"
+     * of the object being cloned and replacing the references to these
+     * objects with references to the copies.  If a class contains only
+     * primitive fields or references to immutable objects, then it is usually
+     * the case that no fields in the object returned by <tt>super.clone</tt>
+     * need to be modified.
+     * <p>
+     * The method <tt>clone</tt> for class <tt>Object</tt> performs
a
+     * specific cloning operation. First, if the class of this object does
+     * not implement the interface <tt>Cloneable</tt>, then a
+     * <tt>CloneNotSupportedException</tt> is thrown. Note that all arrays
+     * are considered to implement the interface <tt>Cloneable</tt>.
+     * Otherwise, this method creates a new instance of the class of this
+     * object and initializes all its fields with exactly the contents of
+     * the corresponding fields of this object, as if by assignment; the
+     * contents of the fields are not themselves cloned. Thus, this method
+     * performs a "shallow copy" of this object, not a "deep copy" operation.
+     * <p>
+     * The class <tt>Object</tt> does not itself implement the interface
+     * <tt>Cloneable</tt>, so calling the <tt>clone</tt> method on
an object
+     * whose class is <tt>Object</tt> will result in throwing an
+     * exception at run time.
+     * 
+     * @return a clone of this instance.
+     * @exception CloneNotSupportedException
+     *                   if the object's class does not
+     *                   support the <code>Cloneable</code> interface. Subclasses
+     *                   that override the <code>clone</code> method can also
+     *                   throw this exception to indicate that an instance cannot
+     *                   be cloned.
+     * @see java.lang.Cloneable
+     */
+    protected Object clone() throws CloneNotSupportedException {
+        return new ACL(name, new Rights(rights)); 
+    }
+}

Propchange: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/ACL.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/ACL.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/ACL.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPAttachedMessage.java
URL: http://svn.apache.org/viewvc/geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPAttachedMessage.java?rev=594520&view=auto
==============================================================================
--- geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPAttachedMessage.java
(added)
+++ geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPAttachedMessage.java
Tue Nov 13 04:57:39 2007
@@ -0,0 +1,125 @@
+/**
+ * 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.geronimo.javamail.store.imap;
+
+import javax.activation.DataHandler;
+
+import javax.mail.Flags;
+import javax.mail.MessagingException;
+import javax.mail.MethodNotSupportedException;
+
+import org.apache.geronimo.javamail.store.imap.connection.IMAPEnvelope;
+import org.apache.geronimo.javamail.store.imap.connection.IMAPBodyStructure;
+
+/**
+ * A nested message attachement inside of another 
+ * IMAP message.  This is a less-functional version 
+ * of the top-level message.
+ */
+public class IMAPAttachedMessage extends IMAPMessage {
+    // the parent enclosing message.
+    protected IMAPMessage parent;
+
+    /**
+     * Constructor for an attached message part.
+     * 
+     * @param parent   The parent message (outer-most message).
+     * @param section  The section identifier for this embedded part
+     *                 in IMAP section format.  This will identify
+     *                 the part hierarchy used to locate this part within
+     *                 the message.
+     * @param envelope The Envelope that describes this part.
+     * @param bodyStructure
+     *                 The Body structure element that describes this part.
+     */
+    public IMAPAttachedMessage(IMAPMessage parent, String section, IMAPEnvelope envelope,
IMAPBodyStructure bodyStructure) {
+        super((IMAPFolder)parent.getFolder(), parent.store, parent.getMessageNumber(), parent.sequenceNumber);
+        this.parent = parent;
+        // sets the subset we're looking for 
+        this.section = section;
+        // the envelope and body structure are loaded from the server by the parent 
+        this.envelope = envelope;
+        this.bodyStructure = bodyStructure;
+    }
+
+    /**
+     * Check if this message is still valid.  This is 
+     * delegated to the outer-most message.
+     * 
+     * @exception MessagingException
+     */
+    protected void checkValidity() throws MessagingException {
+        parent.checkValidity();
+    }
+
+    /**
+     * Check if the outer-most message has been expunged.
+     * 
+     * @return true if the message has been expunged.
+     */
+    public boolean isExpunged() {
+        return parent.isExpunged();
+    }
+
+    /**
+     * Get the size of this message part.
+     * 
+     * @return The estimate size of this message part, in bytes.
+     */
+    public int getSize() {
+        return bodyStructure.bodySize;
+    }
+
+    
+    /**
+     * Return a copy the flags associated with this message.
+     *
+     * @return a copy of the flags for this message
+     * @throws MessagingException if there was a problem accessing the Store
+     */
+    public Flags getFlags() throws MessagingException {
+        return parent.getFlags(); 
+    }
+
+
+    /**
+     * Check whether the supplied flag is set.
+     * The default implementation checks the flags returned by {@link #getFlags()}.
+     *
+     * @param flag the flags to check for
+     * @return true if the flags is set
+     * @throws MessagingException if there was a problem accessing the Store
+     */
+    public boolean isSet(Flags.Flag flag) throws MessagingException {
+        // load the flags, if needed 
+        return parent.isSet(flag); 
+    }
+
+    /**
+     * Set or clear a flag value.
+     *
+     * @param flags  The set of flags to effect.
+     * @param set    The value to set the flag to (true or false).
+     *
+     * @exception MessagingException
+     */
+    public void setFlags(Flags flag, boolean set) throws MessagingException {
+        throw new MethodNotSupportedException("Flags cannot be set on message attachements");

+    }
+}
+

Propchange: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPAttachedMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPAttachedMessage.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/javamail/trunk/geronimo-javamail_1.4/geronimo-javamail_1.4_provider/src/main/java/org/apache/geronimo/javamail/store/imap/IMAPAttachedMessage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message