1 2 Previous Next 20 Replies Latest reply on Jul 9, 2005 3:35 PM by mikezzz

    Working on JBMAIL-10

    jeff87

      Hi all,

      So I've been looking at http://jira.jboss.com/jira/browse/JBMAIL-10 and found the code in SMTPProtocolInstance.

       if ((authUser != null && !authUser.equals(senderAddress.getUser()))
       || (!dg.isInGroup(senderAddress.getDomain()))) {
       writer.println(
       "503 Incorrect Authentication for Specified Email Address");
       writer.flush();
       return false;
       }
      


      When the From field is in my domain, it seems to allow anything; which I guess is bad. When it's outside my domain I do see the 503 message. So should there be some type of alias list in jboss-service.xml associated with each user listing e-mail addresses they can use in the from field? Maybe something like:
      <user>
       <id>userid</id>
       <password>pwd</password>
       <aliases>
       <alias>mail-admin@locadomain</alias>
       <alias>administrator@localdomain</alias>
       </aliases>
      </user>
      


      Thanks,
      Jeff

        • 1. Re: Working on JBMAIL-10

          I think this should be an (optional & configurable) extension to the user repository. There will need to be a version that stores this information in the database (via hibernate). One that is configured via jboss-service.xml will suffice for testing only.

          If this alias extension is not configured, but verify address is true then perhaps allowing only @ should be the appropriate behaviour.

          Mike.

          • 2. Re: Working on JBMAIL-10
            acoliver

            I've been trying to say basically about the same thing, but the site upgrade has hosed me for the last week or so. The Alias thing is a cool "feature" but verify-identiy only needs to assure that user@foo.com - matches the "user" that authenticated and that foo.com matches a domain in the local domain-list.

            • 3. Re: Working on JBMAIL-10
              jeff87

              OK, I think this might be working. If the recipient e-mail address is in the local domain, it never gets to that part of the code for verify-identity. There are comments that mail going to the local domain does not need authentication.

               // mail to any domain in our local group should be accepted --- that's
               // the free
               // and open world of smtp, where anybody can email anybody. but mail
               // submitted by an
               // unauthenticated user to an unknown domain should get denied.
               String toDomain = rcptAddr.getDomain();
               if (dg.isInGroup(toDomain)) {
               return true; // normal open and free smtp world
               } else if (getState("USER") == null) {
               return false; // no access for unauthenticated users to unknown
               // domains
               }
              


              So if I authenticate as "test" and try to send to an address outside the local domain; then an e-mail address like jboss@localhost or test@external.com will get the error like it should. Should it make that check regardless of the recipient's domain if verify-identity is true?

              Thanks,
              Jeff

              • 4. Re: Working on JBMAIL-10
                jeff87

                OK, I think I may finally have it. So here is what I tried:

                Authenticated as ?test?.

                Set from address to test@email.com

                I was refused sending to jboss@localhost.localdomain and jboss@jboss.org

                Then set the from address to jboss@localhost.localdomain.

                I was refused sending to jboss@localhost.localdomain and jboss@jboss.org

                Then set the from address to test@localhost.localdomain

                I was able to send to both jboss@localhost.localdomain and jboss@jboss.org


                So if this how it should behave, how do I submit the code? Just attach the file to an e-mail to Andy?

                Thanks everyone,
                Jeff

                • 5. Re: Working on JBMAIL-10

                  Sounds good. Attach the patch to the task in JIRA.

                  Cheers,
                  Mike.

                  • 6. Re: Working on JBMAIL-10
                    acoliver

                    One more twist. If "localhost" and "localhost.localdomain" and "localdomain" are ALL in the local domain list then I should be able to set any of "test@localhost" or "test@localhost.localdomain" or "test@localdomain" as the from address. Does that make sense?

                    -Andy

                    • 7. Re: Working on JBMAIL-10
                      jeff87

                      OK, I'll try that when I can get jbmail working again. I upgraded to 4.0.2 like mentioned in another post and I seem to be having some hibernate problems. When it deploys I see this message:

                      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
                      ObjectName: jboss.mail:service=Hibernate
                       State: NOTYETINSTALLED
                       Depends On Me:
                       jboss.mail:name=PagedStore,type=MailServices
                      


                      Then when I start up thunderbird and try to retrieve mail, I get this error:

                      23:30:53,591 INFO [HnMailboxManager] Getting mailbox for user: test
                      23:30:53,591 WARN [HnMailboxManager] Session is null
                      23:30:53,591 ERROR [CmdPASS] Error getting MailboxMBean: org.jboss.mail.MailException: org.hibernate.HibernateException: javax.naming.NameNotFoundException: jbossmail.HibernateSessionFactory not bound
                      org.jboss.mail.MailException: org.hibernate.HibernateException: javax.naming.NameNotFoundException: jbossmail.HibernateSessionFactory not bound
                       at org.jboss.mail.mailbox.hn.HnMailboxManager.org$jboss$mail$mailbox$hn$HnMailboxManager$getMailbox$aop(HnMailboxManager.java:66)
                       at org.jboss.mail.mailbox.hn.HnMailboxManager_getMailbox_7855421929627787669_OptimizedMethodInvocation.invokeNext(HnMailboxManager_getMailbox_7855421929627787669_OptimizedMethodInvocation.java)
                       at org.jboss.aspects.tx.TxSupport.invokeInOurTx(TxSupport.java:141)
                       at org.jboss.aspects.tx.TxSupport$Required.serverInvoke(TxSupport.java:438)
                       at org.jboss.aspects.tx.TxInterceptor.internalInvoke(TxInterceptor.java:112)
                       at org.jboss.aspects.tx.TxInterceptor.invoke(TxInterceptor.java:60)
                       at org.jboss.mail.mailbox.hn.HnMailboxManager_getMailbox_7855421929627787669_OptimizedMethodInvocation.invokeNext(HnMailboxManager_getMailbox_7855421929627787669_OptimizedMethodInvocation.java)
                       at org.jboss.mail.mailbox.hn.HnMailboxManager.getMailbox(HnMailboxManager.java)
                       at org.jboss.mail.pop3.handlers.CmdPASS.handleRequest(CmdPASS.java:85)
                       at org.jboss.mail.pop3.POP3ProtocolInstance.handleRequest(POP3ProtocolInstance.java:177)
                       at org.jboss.mail.ConnectionHandler.runSocket(ConnectionHandler.java:165)
                       at org.jboss.mail.ConnectionHandler.run(ConnectionHandler.java:71)
                       at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
                       at java.lang.Thread.run(Thread.java:534)
                      Caused by: org.hibernate.HibernateException: javax.naming.NameNotFoundException: jbossmail.HibernateSessionFactory not bound
                       at org.jboss.mail.util.HibernateUtil.getSession(HibernateUtil.java:62)
                       at org.jboss.mail.mailbox.hn.HnMailboxManager.org$jboss$mail$mailbox$hn$HnMailboxManager$getMailbox$aop(HnMailboxManager.java:47)
                       ... 13 more
                      Caused by: javax.naming.NameNotFoundException: jbossmail.HibernateSessionFactory not bound
                       at org.jnp.server.NamingServer.getBinding(NamingServer.java:491)
                       at org.jnp.server.NamingServer.getBinding(NamingServer.java:499)
                       at org.jnp.server.NamingServer.getObject(NamingServer.java:505)
                       at org.jnp.server.NamingServer.lookup(NamingServer.java:278)
                       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
                       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
                       at javax.naming.InitialContext.lookup(InitialContext.java:347)
                       at org.jboss.mail.util.HibernateUtil.getSession(HibernateUtil.java:57)
                       ... 14 more
                      


                      • 8. Re: Working on JBMAIL-10

                        Did you refresh JBoss from CVS. Only with the latest in HEAD will JBoss Mail work with 4.0.2 (my bad, I should have made that clearer in my post).

                        There are a couple of outstanding issues with moving to hibernate 3 (e.g. XDoclet needs upgrading), that I will have fixed and checked in tomorrow. If you haven't refereshed your CVS snapshot, stick with 4.0.1 until you finish the patch.

                        Cheers,
                        Mike.

                        • 9. Re: Working on JBMAIL-10
                          jeff87

                          I do have the latest. I've tried 4.0.2 and the instructions in the post about running in 4.0.1 (the new ant task and all that stuff). In both instances I get the message

                          --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
                          ObjectName: jboss.mail:service=Hibernate
                           State: NOTYETINSTALLED
                           Depends On Me:
                           jboss.mail:name=PagedStore,type=MailServices
                          


                          I still have java 1.4.2, should I upgrade to 1.5 as well? What types of things would keep the MBean from installing?

                          Thanks,
                          Jeff

                          • 10. Re: Working on JBMAIL-10

                            Can you find and post the first exception thrown during application start up/deployment?

                            How are you deploying JBMail to JBoss server? If you are using the 'dev-deploy' task, try the 'deploy' task. Make sure that you have deployed to the default configuration. Also can you check that you have the hibernate3 deployer installed? Also check that the common-collections jar file has been copied into the deployer directory.

                            I run on both JDK 1.4.2 and 1.5, so that shouldn't be a problem.

                            Essentially the jndi name 'jbossmail.HibernateSessionFactory' is not being bound. Which means the mail.har is not deploying properly. That would suggest some problem with the hibernate deployer.

                            Can you confirm that the version of XDoclet in the jboss-mail/xdoclet-lib directory is 1.2.3?

                            • 11. Re: Working on JBMAIL-10
                              jeff87

                              I was using dev-deploy actually and getting the error below. I tried the deploy task and that deployed just fine. Thanks for the help.

                              Jeff

                              19:30:53,025 INFO [EARDeployer] Started J2EE application: file:/C:/java/jboss-4.0.2/server/default/deploy/mail.ear/
                              19:30:53,025 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
                              
                              --- MBeans waiting for other MBeans ---
                              ObjectName: jboss.mail:name=PagedStore,type=MailServices
                               State: CONFIGURED
                               I Depend On:
                               jboss.mail:service=Hibernate
                               Depends On Me:
                               jboss.mail:name=MailBodyManager,type=MailServices
                              
                              ObjectName: jboss.mail:name=MailBodyManager,type=MailServices
                               State: CONFIGURED
                               I Depend On:
                               jboss.mail:name=PagedStore,type=MailServices
                               Depends On Me:
                               jboss.mail:name=MailboxManager,type=MailServices
                               jboss.mail:name=SMTPProtocol,type=MailServices
                              
                              ObjectName: jboss.mail:name=MailboxManager,type=MailServices
                               State: CONFIGURED
                               I Depend On:
                               jboss.mail:name=MailBodyManager,type=MailServices
                               Depends On Me:
                               jboss.mail:name=POP3Protocol,type=MailServices
                              
                              ObjectName: jboss.mail:name=SMTPProtocol,type=MailServices
                               State: CONFIGURED
                               I Depend On:
                               jboss.mail:name=UserRepository,type=MailServices,uimanageable=true
                               jboss.mail:group=Local,name=DomainGroup,type=MailServices
                               jboss.mail:name=MailBodyManager,type=MailServices
                               jboss.mail:name=MailListenerChain,type=MailServices
                               Depends On Me:
                               jboss.mail:name=SMTP,type=MailServices
                              
                              ObjectName: jboss.mail:name=SMTP,type=MailServices
                               State: CONFIGURED
                               I Depend On:
                               jboss.mail:name=SMTPProtocol,type=MailServices
                              
                              ObjectName: jboss.mail:name=POP3Protocol,type=MailServices
                               State: CONFIGURED
                               I Depend On:
                               jboss.mail:name=MailListener,type=MailServices
                               jboss.mail:name=MailboxManager,type=MailServices
                               jboss.mail:name=UserRepository,type=MailServices,uimanageable=true
                               Depends On Me:
                               jboss.mail:name=POP3SSL,type=MailServices
                               jboss.mail:name=POP3,type=MailServices
                              
                              ObjectName: jboss.mail:name=POP3SSL,type=MailServices
                               State: CONFIGURED
                               I Depend On:
                               jboss.mail:name=POP3Protocol,type=MailServices
                              
                              ObjectName: jboss.mail:name=POP3,type=MailServices
                               State: CONFIGURED
                               I Depend On:
                               jboss.mail:name=POP3Protocol,type=MailServices
                              
                              --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
                              ObjectName: jboss.mail:service=Hibernate
                               State: NOTYETINSTALLED
                               Depends On Me:
                               jboss.mail:name=PagedStore,type=MailServices
                              


                              • 12. Re: Working on JBMAIL-10
                                jeff87

                                OK, so to finally answer Andy's question:


                                One more twist. If "localhost" and "localhost.localdomain" and "localdomain" are ALL in the local domain list then I should be able to set any of "test@localhost" or "test@localhost.localdomain" or "test@localdomain" as the from address. Does that make sense?

                                -Andy


                                So I had these domains listed in my jboss-service.xml file:
                                localhost
                                localhost.com
                                localhost.localdomain
                                localhost.localdomain.com
                                localdomain.com

                                I was able to set the from address domain to each of those and send successfully. So I think the patch I uploaded might be ready for review. I think it's fixed. So being optimistic and assuming I fixed it, what's next?

                                Jeff

                                • 13. Re: Working on JBMAIL-10

                                  Hi Jeff,

                                  Thank you for the patch. I have taken a quick look at it. Unfortunately you appear to have reformatted most of the file. I.e. either you are using 8 spaces for tabs or have replaces the spaces with actual tab characters. Would it be possible to do the fix without making changes to the formatting of the file? It is not possible for me to see the functional changes made.

                                  Cheers,
                                  Mike.

                                  • 14. Re: Working on JBMAIL-10
                                    jeff87

                                    I'll try. My actual changes were rather small. I just moved the If block that involved verify-identity upwards in the code before the check to see the domain of where the e-mail was being sent and I changed the If statement itself (&& to an || if I remember correctly). I had reformatted it because the indentation seemed to be all over the place, or at least it was for me when I opened it in Eclipse. If there's a standard tab/space configuration you guys use in Eclipse, let me know and I'll be happy to adjust my Eclipse settings accordingly. I don't know if I can get a new patch to you tonight, probably Friday or Saturday.

                                    Jeff

                                    1 2 Previous Next