You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by "von Janowsky, Simon" <vo...@consist.de> on 2009/10/14 09:39:21 UTC

Bug in Geronimo JavaMail

  Hello,
we found a bug in the geronimo javamail, and couldn't find
a issue for this in jira.

When a url ist set to receive email the username ist extracted correctly
using UrlName class,
but when querying  the imap server the system defined username is used
instead.

This is because the username in the connect Method in Service.java
overrides
the
username from the url. See this code excerpt from
javax.mail.Service.class
in geronimo-javamail_1.4_spec-1.6.jar 

<code class="Service.java method="connect(String host, int port, String
user, String password)">

       if (user == null) {
            // first choice is from the url, if we have
            if (url != null) {
                user = url.getUsername();
                // make sure we get the password from the url, if we
can.
                if (password == null) {
                    password = url.getPassword();
                }
                // user still null?  We have several levels of
properties to try yet
                if (user == null) {
                	if (protocol != null) {
                		user = session.getProperty("mail." +
protocol + ".user");
                	}
                }
            }

            // this may still be null...get the global mail property
            if (user == null) {
                user = session.getProperty("mail.user");
            }

            // finally, we try getting the system defined user name
		// HERE THE USER IS ALWAYS OVERWRITTEN
		// HERE THE USER IS ALWAYS OVERWRITTEN
		// HERE THE USER IS ALWAYS OVERWRITTEN
            try {
                user = System.getProperty("user.name");
            } catch (SecurityException e) {
                // we ignore this, and just us a null username.
            }
        }

</code>


With kind regards,
Simon von Janowsky


Re: Bug in Geronimo JavaMail

Posted by Rick McGuire <ri...@gmail.com>.
This sounds like a new issue.  Please open a Jira against this.

Rick

von Janowsky, Simon wrote:
>   Hello,
> we found a bug in the geronimo javamail, and couldn't find
> a issue for this in jira.
>
> When a url ist set to receive email the username ist extracted correctly
> using UrlName class,
> but when querying  the imap server the system defined username is used
> instead.
>
> This is because the username in the connect Method in Service.java
> overrides
> the
> username from the url. See this code excerpt from
> javax.mail.Service.class
> in geronimo-javamail_1.4_spec-1.6.jar 
>
> <code class="Service.java method="connect(String host, int port, String
> user, String password)">
>
>        if (user == null) {
>             // first choice is from the url, if we have
>             if (url != null) {
>                 user = url.getUsername();
>                 // make sure we get the password from the url, if we
> can.
>                 if (password == null) {
>                     password = url.getPassword();
>                 }
>                 // user still null?  We have several levels of
> properties to try yet
>                 if (user == null) {
>                 	if (protocol != null) {
>                 		user = session.getProperty("mail." +
> protocol + ".user");
>                 	}
>                 }
>             }
>
>             // this may still be null...get the global mail property
>             if (user == null) {
>                 user = session.getProperty("mail.user");
>             }
>
>             // finally, we try getting the system defined user name
> 		// HERE THE USER IS ALWAYS OVERWRITTEN
> 		// HERE THE USER IS ALWAYS OVERWRITTEN
> 		// HERE THE USER IS ALWAYS OVERWRITTEN
>             try {
>                 user = System.getProperty("user.name");
>             } catch (SecurityException e) {
>                 // we ignore this, and just us a null username.
>             }
>         }
>
> </code>
>
>
> With kind regards,
> Simon von Janowsky
>
>
>